mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Darren Hart <dvhart@linux.intel.com>,
	Andi Kleen <andi@firstfloor.org>,
	Waiman Long <Waiman.Long@hp.com>, Ingo Molnar <mingo@kernel.org>,
	Davidlohr Bueso <davidlohr@hp.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	linux-kernel@vger.kernel.org, linux-api@vger.kernel.org,
	linux-doc@vger.kernel.org, Jason Low <jason.low2@hp.com>,
	Scott J Norton <scott.norton@hp.com>
Subject: Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex
Date: Mon, 21 Jul 2014 23:43:53 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.10.1407212341290.20847@nanos> (raw)
In-Reply-To: <20140721212740.GS3935@laptop>



On Mon, 21 Jul 2014, Peter Zijlstra wrote:

> On Mon, Jul 21, 2014 at 10:16:37PM +0200, Thomas Gleixner wrote:
> > On Mon, 21 Jul 2014, Darren Hart wrote:
> > > We observed some significant improvements under some very specific use
> > > cases, but a more thorough dive into performance impact in the other cases
> > > as well as security implications with the vdso is still wanting.
> > 
> > The security implication is that the feature can only be available for
> > process private futexes. There is no way to expose information which
> > crosses the process spaces.
> > 
> > But the way worse issue is storage.
> > 
> > While you can cache the namespace specific TID of a thread in the
> > task_struct, you still need a O(1) zero overhead mechanism to update
> > the thread state (only on/off cpu is interesting) in a per process
> > shared data structure from the guts of schedule()
> > 
> > For that you have basically two choices:
> > 
> > 1) cpu_thread_id[NR_CPUS]
> > 
> >    Simple to update from the scheduler, and a halfways moderate
> >    storage size (NR_CPUS * 4 bytes) in the worst case, i.e. 16k
> >    today. Set to 0 on scheduling out and to the namespace specific TID
> >    on scheduling in.
> > 
> >    But that requires a linear search in the user space spin loop. And
> >    that's required for every iteration of the loop. Can you imagine
> >    how well that works performance wise?
> > 
> > 2) Bitmap threads_on_cpu
> >    
> >    Again, simple to update from the scheduler, cache line bouncing
> >    issues aside. Clear the bit on schedule out and set it on schedule
> >    in.
> > 
> >    But the bitmap needs the size of PID_MAX_LIMIT, which is a whopping
> >    512k per process in the worst case.
> > 
> > Anything else would involve search/lookup schemes which are just
> > overkill in both the scheduler and the user space loop.
> >    
> > Now for enhanced fun you need immutable pages for that storage, as you
> > can't have pagefaults in the guts of schedule().
> > 
> > So once you found a way to make that opt-in as you don't want inflict
> > any of this to all processes by default, it might be a worthwhile
> > optimization. So the probably tolerable impact on schedule() would be
> > 
> > schedule_out()
> > 	if (curr->threads_on_cpu)
> > 		clear_bit(curr->ns_tid, curr->threads_on_cpu);
> > and
> > 
> > schedule_in()
> > 	if (curr->threads_on_cpu)
> > 		clear_bit(curr->ns_tid, curr->threads_on_cpu);
> > 
> > Anything more complex is just going to defeat the whole purpose.
> 
> All this is predicated on the fact that syscalls are 'expensive'.
> Weren't syscalls only 100s of cycles? All this bitmap mucking is far
> more expensive due to cacheline misses, which due to the size of the
> things is almost guaranteed.

I completely agree.

This wants to backed by proper numbers taken from a proper
implementation and not from some randomly cobbled together works for
me hackery.

As I said: It might be a worthwhile optimization....

Thanks,

	tglx


  parent reply	other threads:[~2014-07-21 21:44 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-21 15:24 Waiman Long
2014-07-21 15:24 ` [RFC PATCH 1/5] futex: add new exclusive lock & unlock command codes Waiman Long
2014-07-21 16:42   ` Thomas Gleixner
2014-07-22 18:22     ` Waiman Long
2014-07-22 21:00       ` Thomas Gleixner
2014-07-21 15:24 ` [RFC PATCH 2/5] futex: add optimistic spinning to FUTEX_SPIN_LOCK Waiman Long
2014-07-21 17:15   ` Davidlohr Bueso
2014-07-22 18:46     ` Waiman Long
2014-07-21 20:17   ` Jason Low
2014-07-22 19:34     ` Waiman Long
2014-07-21 15:24 ` [RFC PATCH 3/5] spinning futex: move a wakened task to spinning Waiman Long
2014-07-21 15:24 ` [RFC PATCH 4/5] spinning futex: put waiting tasks in a sorted rbtree Waiman Long
2014-07-21 15:24 ` [RFC PATCH 5/5] futex, doc: add a document on how to use the spinning futexes Waiman Long
2014-07-21 15:45   ` Randy Dunlap
2014-07-22  3:19     ` Waiman Long
2014-07-21 16:42 ` [RFC PATCH 0/5] futex: introduce an optimistic spinning futex Andi Kleen
2014-07-21 16:45   ` Andi Kleen
2014-07-21 17:20     ` Darren Hart
     [not found]     ` <CFF29A00.9D44A%dvhart@linux.intel.com>
2014-07-21 17:41       ` Darren Hart
2014-07-21 20:16         ` Thomas Gleixner
2014-07-21 21:27           ` Peter Zijlstra
2014-07-21 21:31             ` Andy Lutomirski
2014-07-21 21:47               ` Thomas Gleixner
2014-07-21 22:41                 ` Darren Hart
2014-07-22  1:01                   ` Thomas Gleixner
2014-07-22  1:34                     ` Steven Rostedt
2014-07-22  2:31                       ` Mike Galbraith
2014-07-22  3:06                       ` Davidlohr Bueso
2014-07-22  7:47                       ` Peter Zijlstra
2014-07-22  8:39                         ` Thomas Gleixner
2014-07-22  8:48                           ` Peter Zijlstra
2014-07-22  9:59                             ` Thomas Gleixner
2014-07-22 20:25                               ` Waiman Long
2014-07-22 20:52                                 ` Thomas Gleixner
2014-07-22 20:21                     ` Waiman Long
2014-07-22 21:03                       ` Thomas Gleixner
2014-07-22  0:32               ` Davidlohr Bueso
2014-07-22  7:35                 ` Peter Zijlstra
2014-07-21 21:43             ` Thomas Gleixner [this message]
2014-07-21 18:24     ` Thomas Gleixner
2014-07-22 18:35     ` Waiman Long
2014-07-22 18:28   ` Waiman Long
2014-07-23  4:55   ` Mike Galbraith
2014-07-23  6:57     ` Peter Zijlstra
2014-07-23  7:25       ` Mike Galbraith
2014-07-23  7:35         ` Peter Zijlstra
2014-07-23  7:39           ` Mike Galbraith
2014-07-23  7:52             ` Peter Zijlstra
2014-07-21 21:18 ` Ingo Molnar
2014-07-21 21:41   ` Thomas Gleixner
2014-07-22 19:36   ` Waiman Long

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.10.1407212341290.20847@nanos \
    --to=tglx@linutronix.de \
    --cc=Waiman.Long@hp.com \
    --cc=andi@firstfloor.org \
    --cc=davidlohr@hp.com \
    --cc=dvhart@linux.intel.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jason.low2@hp.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=scott.norton@hp.com \
    /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®