lkml.org 
[lkml]   [2010]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@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?


\
 
 \ /
  Last update: 2010-06-10 00:43    [W:0.108 / U:5.832 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site