From: Ingo Molnar <mingo@elte.hu>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Nick Piggin <npiggin@suse.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Steven Rostedt <rostedt@goodmis.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Nicholas Miell <nmiell@comcast.net>,
laijs@cn.fujitsu.com, dipankar@in.ibm.com,
akpm@linux-foundation.org, josh@joshtriplett.org,
dvhltc@us.ibm.com, niv@us.ibm.com, tglx@linutronix.de,
peterz@infradead.org, Valdis.Kletnieks@vt.edu,
dhowells@redhat.com, linux-kernel@vger.kernel.org,
Chris Friesen <cfriesen@nortel.com>,
Fr??d??ric Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH -tip] introduce sys_membarrier(): process-wide memory barrier (v9)
Date: Tue, 16 Mar 2010 14:56:17 +0100 [thread overview]
Message-ID: <20100316135617.GC575@elte.hu> (raw)
In-Reply-To: <20100316133534.GB22578@Krystal>
* Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
> * Ingo Molnar (mingo@elte.hu) wrote:
> >
> > * Nick Piggin <npiggin@suse.de> wrote:
> >
> > > On Tue, Mar 16, 2010 at 08:36:35AM +0100, Ingo Molnar wrote:
> > > >
> > > > * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
> > > >
> > > > > Unless this question is answered, Ingo's SA_RUNNING signal proposal, as
> > > > > appealing as it may look at a first glance, falls into the
> > > > > "fundamentally broken" category. [...]
> > > >
> > > > How is it different from your syscall? I.e. which lines of code make the
> > > > difference? We could certainly apply the (trivial) barrier change to
> > > > context_switch().
> > >
> > > I think it is just easy for userspace to misuse or think it does something
> > > that it doesn't (because of races).
> >
> > That wasnt my question though. The question i asked Mathieu was to show how
> > SA_RUNNING is "fundamentally broken" for librcu use while sys_membarrier() is
> > not?
> >
> > This is really what he claims above. (i preserved the quote)
> >
> > It must be a misunderstanding either on my side or on his side. (Once that is
> > cleared we can discuss further usecases for SA_RUNNING.)
>
> Well, it's not broken for sys_membarrier() specifically if we add the proper
> memory barriers to the scheduler, but it's broken when we try to use it for
> anything else. [...]
That's quite an important distinction to an unqualified "fundamentally
broken", right?
> [...] What makes it broken is that it requires that the scheduler switch
> guarantee to have the same side-effect on a running thread than execution on
> the per-running-thread signal handler.
>
> What's different with the sys_membarrier system call is that it does not try
> to make generic something that should probably stay case-specific due to its
> close coupling with the scheduler.
Yeah, that's a fair point.
Without another realistic usecase SA_RUNNING would just essentially be a
SA_BARRIER special-case. (IMO even in that case signal handling speedups
driven via this usecase would still be tempting though.)
But note that some other usecase is possible as well:
In theory we could inject signals at context-switch time (if that signal is
not pending yet) - signals are fairly atomic [with a preallocated pool] and
the 'wakeup' property of signals is not needed as the to-be-running task is
obviously up to execution. (so there's no deadlock. It doesnt have to run with
the rq lock taken in any case - it can run from sched_tail() i suspect.)
So all this could be done via the ret-to-user framework that KVM uses at
essentially no extra scheduler overhead. I think :-) It would be a bit like
SIGALRM for timers.
Plus another performance optimization would be useful as well: signals could
be turned on/off without having to enter the kernel. This could be done via a
in-user-memory enable/disable-signals flag/mask associated with each task. (it
would pin a page of memory.)
The question is, do we want to enable user-space to trigger a signal upon
context-switches?
It probably cannot be a queued one, as preemption from the signal handler
itself would be rather yucky. As long as concurrency control is involved,
user-space only wants a callback for the _first_ reschedule - subsequent
reschedules dont need to trigger a signal, until the signal handler has
finished.
Ingo
next prev parent reply other threads:[~2010-03-16 13:57 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-25 23:23 [PATCH -tip] introduce sys_membarrier(): process-wide memory barrier (v9) Mathieu Desnoyers
2010-03-01 14:25 ` Mathieu Desnoyers
2010-03-02 17:52 ` Josh Triplett
2010-03-02 23:07 ` Mathieu Desnoyers
2010-03-03 1:53 ` Josh Triplett
2010-03-04 12:23 ` Ingo Molnar
2010-03-04 15:52 ` Mathieu Desnoyers
2010-03-04 16:03 ` Mathieu Desnoyers
2010-03-04 16:34 ` Linus Torvalds
2010-03-04 16:50 ` Paul E. McKenney
2010-03-04 17:56 ` Mathieu Desnoyers
2010-03-15 20:53 ` Mathieu Desnoyers
2010-03-16 7:36 ` Ingo Molnar
2010-03-16 7:57 ` Nick Piggin
2010-03-16 13:05 ` Mathieu Desnoyers
2010-03-16 13:13 ` Ingo Molnar
2010-03-16 13:35 ` Mathieu Desnoyers
2010-03-16 13:56 ` Ingo Molnar [this message]
2010-03-16 14:16 ` Mathieu Desnoyers
2010-03-04 20:23 ` Ingo Molnar
2010-03-06 19:43 ` Linus Torvalds
2010-03-09 6:59 ` Nick Piggin
2010-03-10 4:16 ` Mathieu Desnoyers
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=20100316135617.GC575@elte.hu \
--to=mingo@elte.hu \
--cc=Valdis.Kletnieks@vt.edu \
--cc=akpm@linux-foundation.org \
--cc=cfriesen@nortel.com \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=dvhltc@us.ibm.com \
--cc=fweisbec@gmail.com \
--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=niv@us.ibm.com \
--cc=nmiell@comcast.net \
--cc=npiggin@suse.de \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.