On Mon, 13 Apr 2015, Mathieu Desnoyers wrote:

> [ Andrew, can you take this for the 4.1 merge window ? ]

You probably mean 4.2, right?

This fails the basic test for exposure in linux-next, adds syscalls
without the explicit ack of any x86 maintainer and exposes a user
space ABI with a magic undocumented flags argument.

> This patch only adds the system call to x86.

So the changes to 
 
>  include/uapi/asm-generic/unistd.h |    4 +-

are just cosmetic, right?

> +/* System call membarrier "flags" argument. */
> +enum {
> +     /*
> +      * Query whether the rest of the specified flags are supported,
> +      * without performing synchronization.
> +      */

Docbook has support for enums.

> +     MEMBARRIER_QUERY = (1 << 31),
> +};

Why is this an anonymous enum?

> +#ifdef CONFIG_SMP

So documentation is SMP only, right?

> +/*

Docbook comments start with "/**"

> + * sys_membarrier - issue memory barrier on all running threads
> + * @flags: MEMBARRIER_QUERY:
> + *             Query whether the rest of the specified flags are supported,
> + *             without performing synchronization.

      @flags:   Explain what this is for, not what a particular implemented
                value is used for. The values should be proper documented
                in the enum

Why is this an int and not a named enum?

Why is this named flags and not given a descriptive name? If I
understand your changelog correctly you want to implement other
synchronization modes than the current synchronize_sched. So mode
might be a proper name.

Why is MEMBARRIER_QUERY not a proper operation mode and simply returns
the supported modes instead of doing it backwards and asking whether
a specific value is supported?

> + * On uniprocessor systems, this system call simply returns 0 after
> + * validating the arguments, so user-space knows it is implemented.

And the exact point of knowing this is?

> + */
> +SYSCALL_DEFINE1(membarrier, int, flags)
> +{
> +     int retval;
> +
> +     retval = membarrier_validate_flags(flags);
> +     if (retval)
> +             goto end;
> +     if (unlikely(flags & MEMBARRIER_QUERY) || num_online_cpus() == 1)
> +             goto end;

So why not doing the obvious?

enum modes {
     QUERY     = 0,
     FULL_SYNC = 1 <<  0,
};

#define IMPLEMENTED_MODES       (FULL_SYNC)

        switch (mode) {
        case FULL_SYNC:
                synchronize_sched_on_smp();
                return 0;
        case QUERY:
                return IMPLEMENTED_MODES;
        }
        return -EINVAL;

And later on you do

 enum modes {
     QUERY       = 0,
     FULL_SYNC   = 1 <<  0,
+    MAGIC_SYNC  = 1 <<  1,
 };

-#define IMPLEMENTED_MODES      (FULL_SYNC)
+#define IMPLEMENTED_MODES      (FULL_SYNC | MAGIC_SYNC)

All you need to make sure is that any mode is a power of 2.

Hmm?

Thanks,

        tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to