On Tue, 10 Mar 2026 16:09:55 -0400
Steven Rostedt <[email protected]> wrote:
> +#ifdef CONFIG_FTRACE_SYSCALLS
> +static const char * __futex_cmds[] =
> +{
> + "FUTEX_WAIT", "FUTEX_WAKE", "FUTEX_FD", "FUTEX_REQUEUE",
> + "FUTEX_CMP_REQUEUE", "FUTEX_WAKE_OP", "FUTEX_LOCK_PI",
> + "FUTEX_UNLOCK_PI", "FUTEX_TRYLOCK_PI", "FUTEX_WAIT_BITSET",
> + "FUTEX_WAKE_BITSET", "FUTEX_WAIT_REQUEUE_PI", "FUTEX_CMP_REQUEUE_PI",
> + "FUTEX_LOCK_PI2",
> +};
> +
[...]
> @@ -437,6 +464,69 @@ sys_enter_openat_print_fmt(struct syscall_metadata
> *entry, char *buf, int len)
> return pos;
> }
>
> +static int __init
> +sys_enter_futex_print_fmt(struct syscall_metadata *entry, char *buf, int len)
> +{
> + int pos = 0;
> +
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "\"uaddr: 0x%%lx (0x%%lx) cmd=%%s%%s%%s");
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + " val: 0x%%x timeout/val2: 0x%%llx");
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + " uaddr2: 0x%%lx val3: 0x%%x\", ");
> +
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + " REC->uaddr,");
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + " REC->__value,");
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + " __print_symbolic(REC->op & 0x%x, ", FUTEX_CMD_MASK);
> +
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_WAIT\"}, ", FUTEX_WAIT);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_WAKE\"}, ", FUTEX_WAKE);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_FD\"}, ", FUTEX_FD);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_REQUEUE\"}, ", FUTEX_REQUEUE);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_CMP_REQUEUE\"}, ", FUTEX_CMP_REQUEUE);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_WAKE_OP\"}, ", FUTEX_WAKE_OP);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_LOCK_PI\"}, ", FUTEX_LOCK_PI);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_UNLOCK_PI\"}, ", FUTEX_UNLOCK_PI);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_TRYLOCK_PI\"}, ", FUTEX_TRYLOCK_PI);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_WAIT_BITSET\"}, ", FUTEX_WAIT_BITSET);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_WAKE_BITSET\"}, ", FUTEX_WAKE_BITSET);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_WAIT_REQUEUE_PI\"}, ",
> FUTEX_WAIT_REQUEUE_PI);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_CMP_REQUEUE_PI\"}, ",
> FUTEX_CMP_REQUEUE_PI);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + "{%d, \"FUTEX_LOCK_PI2\"}),", FUTEX_LOCK_PI2);
Hmm can we share __futex_cmds[] with kernel/futex/syscalls.c?
Then these could be
for (i = 0; i <= FUTEX_LOCK_PI2; i++)
pos += snprintf(buf + pos, LEN_OR_ZERO,
"{%d, \"%s\"}%s", i, __futex_cmds[i],
i == FUTEX_LOCK_PI2 ? ")," : ", ");
> +
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + " (REC->op & %d) ? \"|FUTEX_PRIVATE_FLAG\" : \"\",",
> + FUTEX_PRIVATE_FLAG);
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + " (REC->op & %d) ? \"|FUTEX_CLOCK_REALTIME\" : \"\",",
> + FUTEX_CLOCK_REALTIME);
> +
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + " REC->val, REC->utime,");
> +
> + pos += snprintf(buf + pos, LEN_OR_ZERO,
> + " REC->uaddr, REC->val3");
> + return pos;
> +}
> +
> static int __init
> __set_enter_print_fmt(struct syscall_metadata *entry, char *buf, int len)
> {
[...]
> @@ -689,6 +799,48 @@ static int syscall_copy_user_array(char *buf, const char
> __user *ptr,
> return 0;
> }
>
> +static int
> +syscall_get_futex(unsigned long *args, char **buffer, int *size, int
> buf_size)
> +{
> + struct syscall_user_buffer *sbuf;
> + const char __user *ptr;
> + char *buf;
> +
> + /* buf_size of zero means user doesn't want user space read */
> + if (!buf_size)
> + return -1;
> +
> + /* If the syscall_buffer is NULL, tracing is being shutdown */
> + sbuf = READ_ONCE(syscall_buffer);
> + if (!sbuf)
> + return -1;
> +
> + ptr = (char __user *)args[0];
> +
> + *buffer = trace_user_fault_read(&sbuf->buf, ptr, 4, NULL, NULL);
> + if (!*buffer)
> + return -1;
> +
> + /* Add room for the value */
> + *size += 4;
> +
> + buf = *buffer;
As kernel test bot says, this does nothing. (*buffer is already assigned)
> +
> + return 0;
> +}
Thanks,
--
Masami Hiramatsu (Google) <[email protected]>