mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Josh Triplett <josh@joshtriplett.org>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Nicholas Miell <nmiell@comcast.net>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@redhat.com>,
	Alan Cox <gnomes@lxorguk.ukuu.org.uk>,
	Lai Jiangshan <laijs@cn.fujitsu.com>,
	Stephen Hemminger <stephen@networkplumber.org>,
	Peter Zijlstra <peterz@infradead.org>,
	David Howells <dhowells@redhat.com>
Subject: Re: [PATCH v14 for 4.1] sys_membarrier(): system-wide memory barrier (x86)
Date: Tue, 14 Apr 2015 21:35:57 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.11.1504142132100.3845@nanos> (raw)
In-Reply-To: <191985313.30287.1429039372434.JavaMail.zimbra@efficios.com>

On Tue, 14 Apr 2015, Mathieu Desnoyers wrote:
> Thinking about it a bit more, one reason for doing the QUERY along
> with the exact set of flags queried allow us to do more than just
> returning which flags are supported: it allows us to tell userspace
> whether the combination of flags used is valid or not.
> 
> For instance, if we add a MEMBARRIER_PRIVATE flag in a future release
> to issue memory barriers only to other threads from the same process,
> and we add a MEMBARRIER_EXPEDITED which uses IPIs to issue those
> barriers, we could very well have a situation where using
> 
>   EXPEDITED | PRIVATE  would be valid (only sending IPIs to CPUs
>   running threads from the same process)
> 
> but
> 
>   EXPEDITED alone would be invalid (-EINVAL), until we figure out
>   how to expedite memory barriers to all processors without impacting
>   other processes, if at all possible.
> 
> Using QUERY with an empty set of flags could however return the set of
> flags supported, which could be a nice feature. Anyway, I think
> the "0" flag should be the basic always correct configuration that
> is always supported, otherwise we'd have -ENOSYS. Therefore, querying
> whether the empty set of flags is supported has little value, other
> than checking for -ENOSYS.
> 
> So considering the above, the typical use of this query method from
> library initialization would be:
> 
> int supported_flags = sys_membarrier(MEMBARRIER_QUERY);
> 
> ... check for -ENOSYS ....
> ... check whether the flags we need are supported ...
> 
> if (sys_membarrier(MEMBARRIER_QUERY | flag1 | flag2))
>   goto error;
> 
> then we are guaranteed that using sys_membarrier(flag1 | flag2)
> will always succeed within the application, without needing to
> handle errors every time it is used. This property is useful
> to implement a synchronize_rcu() that returns "void" and simplify
> error handling within the application.

So how many of these "flags" are you planning to implement and how
many valid combinations are going to exist?

I doubt it's more than a dozen. So I prefer explicit operation modes
for the valid ones rather than having a random pile of "flags".

Thanks,

	tglx



  reply	other threads:[~2015-04-14 19:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-13 19:10 Mathieu Desnoyers
2015-04-13 21:49 ` Thomas Gleixner
2015-04-13 22:45   ` Thomas Gleixner
2015-04-14 19:02   ` Mathieu Desnoyers
2015-04-14 19:22     ` Mathieu Desnoyers
2015-04-14 19:35       ` Thomas Gleixner [this message]
2015-04-14 20:17         ` Mathieu Desnoyers
2015-04-14 21:05           ` Thomas Gleixner
2015-04-14 19:31     ` Thomas Gleixner
  -- strict thread matches above, loose matches on Subject: below --
2015-03-25 19:03 Mathieu Desnoyers
2015-03-27  9:21 ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.11.1504142132100.3845@nanos \
    --to=tglx@linutronix.de \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=josh@joshtriplett.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@redhat.com \
    --cc=nmiell@comcast.net \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=stephen@networkplumber.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®