All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <levinsasha928@gmail.com>
To: Seth Jennings <sjenning@linux.vnet.ibm.com>
Cc: gregkh@linuxfoundation.org, dan.magenheimer@oracle.com,
	konrad.wilk@oracle.com, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] zcache: don't limit number of pools per client
Date: Tue, 05 Jun 2012 22:41:46 +0200	[thread overview]
Message-ID: <1338928906.3292.45.camel@lappy> (raw)
In-Reply-To: <4FCE69BC.6060300@linux.vnet.ibm.com>

On Tue, 2012-06-05 at 15:19 -0500, Seth Jennings wrote:
> > +	pool = idr_find(&cli->tmem_pools, poolid);
> > +	if (pool != NULL)
> > +		atomic_inc(&pool->refcount);
> 
> 
> This is called on the main path, so it needs to be fast.  There is so much
> contention elsewhere in the stack I don't think it'll be an issue. It looks
> like idr_find() is fast, even though it contains a loop.  Just needs to be
> considered.

Agreed. idr actually uses something which looks like a hash table, so it
should be fast enough for this case.

> > +retry:
> > +	r = idr_pre_get(&cli->tmem_pools, GFP_ATOMIC);
> 
> > +	if (r != 1) {
> > +		kfree(pool);
> > +		pr_info("zcache: pool creation failed: out of memory\n");
> > +		goto out;
> > +	}
> > +	r = idr_get_new(&cli->tmem_pools, pool, &poolid);
> > +	switch (r) {
> > +	case 0:
> > +		break;
> > +	case -EAGAIN:
> > +		goto retry;
> > +	default:
> > +		pr_info("zcache: pool creation failed: error %d\n", r);
> >  		kfree(pool);
> > -		poolid = -1;
> >  		goto out;
> >  	}
> > +
> 
> 
> how about:
> =====
> do {
> 	r = idr_pre_get(&cli->tmem_pools, GFP_ATOMIC);
> 	if (r != 1) {
> 		kfree(pool);
> 		pr_info("zcache: pool creation failed: out of memory\n");
> 		goto out;
> 	}
> 	r = idr_get_new(&cli->tmem_pools, pool, &poolid);
> }
> while (r == -EAGAIN)
> 
> if (r) {
> 	pr_info("zcache: pool creation failed: error %d\n", r);
> 	kfree(pool);
> 	goto out;
> }
> =====
> so we can lose the label/goto.
> 
> Also, do we want GFP_ATOMIC?  Why not GFP_KERNEL?

I wasn't sure about the context this code runs at, and assumed it's
atomic one due to the kmalloc allocating with GFP_ATOMIC just couple of
lines above the idr_pre_get. If that's wrong, we can switch that kmalloc
as well.


      reply	other threads:[~2012-06-05 20:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-05 11:05 [PATCH] zcache: don't limit number of pools per client Sasha Levin
2012-06-05 20:19 ` Seth Jennings
2012-06-05 20:41   ` Sasha Levin [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=1338928906.3292.45.camel@lappy \
    --to=levinsasha928@gmail.com \
    --cc=dan.magenheimer@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sjenning@linux.vnet.ibm.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 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.