mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Tejun Heo <tj@kernel.org>
Cc: Daniel Vetter <daniel@ffwll.ch>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	LKML <linux-kernel@vger.kernel.org>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Mel Gorman <mgorman@techsingularity.net>,
	Michal Hocko <mhocko@suse.com>, Vlastimil Babka <vbabka@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH] lib/ida: Document locking requirements a bit better
Date: Thu, 27 Oct 2016 09:19:07 +0200	[thread overview]
Message-ID: <20161027071907.n5ifu2pkpse3aqpb@phenom.ffwll.local> (raw)
In-Reply-To: <20161026200725.GA19388@htj.duckdns.org>

On Wed, Oct 26, 2016 at 04:07:25PM -0400, Tejun Heo wrote:
> Hello, Daniel.
> 
> On Wed, Oct 26, 2016 at 09:25:25PM +0200, Daniel Vetter wrote:
> > > > + * Note that callers must ensure that concurrent access to @ida is not possible.
> > > > + * When simplicity trumps concurrency needs look at ida_simple_get() instead.
> > > 
> > > Maybe we can make it a bit less dramatic?
> > 
> > What about?
> > 
> > "Note that callers must ensure that concurrent access to @ida is not possible.
> > See ida_simple_get() for a varaint which takes care of locking.
> 
> Yeah, that reads easier to me.
> 
> > > Hmm... so, this isn't necessarily about speed.  For example, id
> > > allocation might have to happen inside a spinlock which protects a
> > > larger scope.  To guarantee GFP_KERNEL allocation behavior in such
> > > cases, the caller would have to call ida_pre_get() outside the said
> > > spinlock and then call ida_get_new_above() inside the lock.
> > 
> > Hm, ida_simple_get does that for you already ...
> 
> Here's an example.
> 
> 	spin_lock();
> 	do some stuff;
> 	something->id = ida_simple_get(some gfp flag);
> 	do some stuff;
> 	spin_unlock();
> 
> In this scenario, you can't use sleeping GFPs for ida_simple_get()
> because it does preloading inside it.  What one has to do is...
> 
> 	ida_pre_get(GFP_KERNEL);
> 	spin_lock();
> 	do some stuff;
> 	something->id = ida_get_new_above(GFP_NOWAIT);
> 	do some stuff;
> 	spin_unlock();
> 
> So, I guess it can be sometimes about avoiding the extra locking
> overhead but it's more often about separating out allocation context
> into an earlier call.

Hm yeah, calling ida_simple_get in that case isn't recommend really.

> > > I think it'd be better to explain what the simple version does and
> > > expects and then say that unless there are specific requirements using
> > > the simple version is recommended.
> > 
> > What about:
> > 
> > "Compared to ida_get_new_above() this function does its own locking, and
> > should be used unless there are special requirements."
> 
> Yeah, looks good to me.

Ok, will respin, thanks for the review comments.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

      reply	other threads:[~2016-10-27  7:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-26 14:27 Daniel Vetter
2016-10-26 14:39 ` Tejun Heo
2016-10-26 19:25   ` Daniel Vetter
2016-10-26 20:07     ` Tejun Heo
2016-10-27  7:19       ` Daniel Vetter [this message]

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=20161027071907.n5ifu2pkpse3aqpb@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=akpm@linux-foundation.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=tj@kernel.org \
    --cc=vbabka@suse.cz \
    /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®