mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avi Kivity <avi@scylladb.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Nicholas Piggin <npiggin@gmail.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Boqun Feng <boqun.feng@gmail.com>, Andrew Hunter <ahh@google.com>,
	maged michael <maged.michael@gmail.com>,
	gromer <gromer@google.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Dave Watson <davejwatson@fb.com>
Subject: Re: [RFC PATCH v2] membarrier: expedited private command
Date: Tue, 1 Aug 2017 13:32:43 +0300	[thread overview]
Message-ID: <3db6b20b-df76-8284-5bc1-37a511ee0534@scylladb.com> (raw)
In-Reply-To: <20170801102203.urldoripgbh2ohun@hirez.programming.kicks-ass.net>



On 08/01/2017 01:22 PM, Peter Zijlstra wrote:
>
>> If mm cpumask is used, I think it's okay. You can cause quite similar
>> kind of iteration over CPUs and lots of IPIs, tlb flushes, etc using
>> munmap/mprotect/etc, or context switch IPIs, etc. Are we reaching the
>> stage where we're controlling those kinds of ops in terms of impact
>> to the rest of the system?
> So x86 has a tight mm_cpumask(), we only broadcast TLB invalidate IPIs
> to those CPUs actually running threads of our process (or very
> recently). So while there can be the sporadic stray IPI for a CPU that
> recently ran a thread of the target process, it will not get another one
> until it switches back into the process.
>
> On machines that need manual TLB broadcasts and don't keep a tight mask,
> yes you can interfere at will, but if they care they can fix by
> tightening the mask.
>
> In either case, the mm_cpumask() will be bounded by the set of CPUs the
> threads are allowed to run on and will not interfere with the rest of
> the system.
>
> As to scheduler IPIs, those are limited to the CPUs the user is limited
> to and are rate limited by the wakeup-latency of the tasks. After all,
> all the time a task is runnable but not running, wakeups are no-ops.
>
> Trouble is of course, that not everybody even sets a single bit in
> mm_cpumask() and those that never clear bits will end up with a fairly
> wide mask, still interfering with work that isn't hard partitioned.

I hate to propose a way to make this more complicated, but this could be 
fixed by a process first declaring its intent to use expedited 
process-wide membarrier; if it does, then every context switch updates a 
process-wide cpumask indicating which cpus are currently running threads 
of that process:

   if (prev->mm != next->mm)
       if (prev->mm->running_cpumask)
              cpumask_clear(...);
       else if (next->mm->running_cpumask)
              cpumask_set(...);

now only processes that want expedited process-wide membarrier pay for 
it (in other than some predictable branches). You can even have threads 
opt-in, so unrelated threads that don't participate in the party don't 
cause those bits to be set.

  reply	other threads:[~2017-08-01 10:32 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-27 21:13 Mathieu Desnoyers
2017-07-27 22:13 ` Paul E. McKenney
2017-07-27 22:41   ` Mathieu Desnoyers
2017-07-27 22:57     ` Paul E. McKenney
2017-07-28  8:55 ` Peter Zijlstra
2017-07-28 11:10   ` Peter Zijlstra
2017-07-28 11:57   ` Peter Zijlstra
2017-07-28 15:38     ` Mathieu Desnoyers
2017-07-28 16:46       ` Peter Zijlstra
2017-07-28 17:06         ` Mathieu Desnoyers
2017-07-29  1:58           ` Nicholas Piggin
2017-07-29  9:23             ` Peter Zijlstra
2017-07-29  9:45               ` Nicholas Piggin
2017-07-29  9:48                 ` Nicholas Piggin
2017-07-29 10:51                   ` Peter Zijlstra
2017-07-31 19:31             ` Mathieu Desnoyers
2017-07-31 13:20     ` Michael Ellerman
2017-07-31 13:36       ` Peter Zijlstra
2017-08-01  0:35       ` Nicholas Piggin
2017-08-01  1:33         ` Mathieu Desnoyers
2017-08-01  2:00           ` Nicholas Piggin
2017-08-01  8:12             ` Peter Zijlstra
2017-08-01  9:57               ` Nicholas Piggin
2017-08-01 10:22                 ` Peter Zijlstra
2017-08-01 10:32                   ` Avi Kivity [this message]
2017-08-01 10:46                     ` Peter Zijlstra
2017-08-01 10:39                   ` Nicholas Piggin
2017-08-01 11:00                     ` Peter Zijlstra
2017-08-01 11:54                       ` Nicholas Piggin
2017-08-01 13:23                   ` Paul E. McKenney
2017-08-01 14:16                     ` Peter Zijlstra
2017-08-01 23:32                       ` Paul E. McKenney
2017-08-02  0:45                         ` Nicholas Piggin
2017-07-28 15:36   ` 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=3db6b20b-df76-8284-5bc1-37a511ee0534@scylladb.com \
    --to=avi@scylladb.com \
    --cc=ahh@google.com \
    --cc=benh@kernel.crashing.org \
    --cc=boqun.feng@gmail.com \
    --cc=davejwatson@fb.com \
    --cc=gromer@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maged.michael@gmail.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.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®