All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Tim Chen <tim.c.chen@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
	Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH v2 1/2] tmpfs: Quick token library to allow scalable retrieval of tokens from token jar
Date: Wed, 9 Jun 2010 15:41:02 -0700	[thread overview]
Message-ID: <20100609154102.9795ff07.akpm@linux-foundation.org> (raw)
In-Reply-To: <1275499969.2385.16.camel@mudge.jf.intel.com>

On Wed, 02 Jun 2010 10:32:49 -0700
Tim Chen <tim.c.chen@linux.intel.com> wrote:

> On Tue, 2010-06-01 at 14:51 -0700, Andrew Morton wrote:
> 
> > >
> > > +static void qtoken_reap_cache(struct qtoken *token_jar)
> > > +{
> > > +	long cnt;
> > > +	int i;
> > > +
> > > +	for_each_possible_cpu(i) {
> > > +		atomic_long_t	*cache;
> > > +
> > > +		cache = per_cpu_ptr(token_jar->cache, i);
> > > +		cnt = atomic_long_xchg(cache, -1);
> > > +		if (cnt > 0)
> > > +			token_jar->pool += cnt;
> > > +	}
> > > +}
> > 
> > Not cpu-hotplug aware.  Also, inefficient if num_online_cpus is much
> > less than num_possible_cpus.
> > 
> > It's really not hard to do!  lib/percpu_counter.c is per-cpu aware and
> > it does this by sneakily connecting all counters together system-wide.
> > 
> 
> I've thought about using "for_each_online_cpu" in the above loop.
> However, it someone takes a cpu offline, then we will lose the tokens
> in that cpu's cache when we do reap cache.

No, that's what cpu hotplug notifiers are for.  pecpu_counters does all
this.

> > > +	/* We should have acquired lock of token pool before coming here */
> > > +	if (token_jar->pool < (reserve + tokens))
> > > +		qtoken_reap_cache(token_jar);
> > > +	if (token_jar->pool >= (reserve + tokens)) {
> > > +		token_jar->pool -= tokens;
> > > +		allocated = 0;
> > > +	}
> > > +	return allocated;
> > > +}
> > 
> > ENOSPC means "your disk is full".  But my disk isn't full.  If this
> > inappropriate (indeed, incorrect) error code is ever propagated back to
> > userspace then users will be justifiably confused.
> > 
> 
> Originally, I was using -ENOSPC to mean tmpfs being full and out of
> space.  Will -EBUSY to denote all resources are used be more
> appropriate?  
> 

Return the number of tokens which were allocated?

      reply	other threads:[~2010-06-09 22:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-26 19:32 [PATCH v2 1/2] tmpfs: Quick token library to allow scalable retrieval of tokens from token jar Tim Chen
2010-06-01 21:51 ` Andrew Morton
2010-06-02  8:58   ` Andi Kleen
2010-06-09 22:36     ` Andrew Morton
2010-06-10 17:06       ` Tim Chen
2010-06-11 21:52         ` Andrew Morton
2010-06-11 22:06           ` Tim Chen
2010-06-11 22:26             ` Andrew Morton
2010-06-11 23:29               ` Tim Chen
2010-06-11 23:54                 ` Andrew Morton
2010-06-12  7:36                   ` Andi Kleen
2010-06-12 15:27                     ` Andrew Morton
2010-06-15  1:24                       ` Tim Chen
2010-06-02 17:32   ` Tim Chen
2010-06-09 22:41     ` Andrew Morton [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=20100609154102.9795ff07.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ak@linux.intel.com \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tim.c.chen@linux.intel.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.