Re: [RFC PATCH] sys_membarrier(): system/process-wide memory barrier (x86) (v12)

From: Peter Zijlstra
Date: Mon Mar 16 2015 - 13:25:11 EST


On Mon, Mar 16, 2015 at 03:43:56PM +0000, Mathieu Desnoyers wrote:
> > > +enum {
> > > + /*
> > > + * Private flag set: only synchronize across a single process. If this
> > > + * flag is not set, it means "shared": synchronize across multiple
> > > + * processes. The shared mode is useful for shared memory mappings
> > > + * across processes.
> > > + */
> > > + MEMBARRIER_PRIVATE_FLAG = (1 << 0),
> > > +
> > > + /*
> > > + * Expedited flag set: adds some overhead, fast execution (few
> > > + * microseconds). If this flag is not set, it means "delayed": low
> > > + * overhead, but slow execution (few milliseconds).
> > > + */
> > > + MEMBARRIER_EXPEDITED_FLAG = (1 << 1),
> >
> >
> > I suppose this is an unprivileged syscall; so what do we do about:
> >
> > for (;;)
> > sys_membar(EXPEDITED);
> >
> > Which would spray the entire system with IPIs at break neck speed.
>
> Currently, combining EXPEDITED with non-PRIVATE returns -EINVAL.

Ah, tl;dr that bit. This patch really had _too_ much verbiage.

> Therefore, if someone cares about issuing barriers on the entire
> system, the only option is to use non-EXPEDITED, which rely on
> synchronize_rcu().
>
> The only way to invoke expedited barriers in a loop is:
>
> for (;;)
> sys_membarrier(MEMBARRIER_EXPEDITED | MEMBARRIER_PRIVATE);
>
> Which will only send IPIs to the CPU running threads from the same
> process.

That is indeed less of a problem.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/