[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20100609154102.9795ff07.akpm@linux-foundation.org>
Date: Wed, 9 Jun 2010 15:41:02 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Tim Chen <tim.c.chen@...ux.intel.com>
Cc: linux-kernel@...r.kernel.org, Andi Kleen <ak@...ux.intel.com>,
Hugh Dickins <hughd@...gle.com>
Subject: Re: [PATCH v2 1/2] tmpfs: Quick token library to allow scalable
retrieval of tokens from token jar
On Wed, 02 Jun 2010 10:32:49 -0700
Tim Chen <tim.c.chen@...ux.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?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists