On Wed, 11 Mar 2026 18:03:25 +0900
Masami Hiramatsu (Google) <[email protected]> wrote:

> > +   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 ? ")," : ", ");

Hmm, I created the above *before* creating the __futex_cmds. But yes, that
makes sense. Thanks for the suggestion.


> 
> 
> > +
> > +   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)
> 

Oops, I think this was a cut-and-paste error :-p

-- Steve

Reply via email to