All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Tim Chen <tim.c.chen@linux.intel.com>,
	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, 02 Jun 2010 10:58:42 +0200	[thread overview]
Message-ID: <87ocftyfnh.fsf@basil.nowhere.org> (raw)
In-Reply-To: <20100601145126.f46572d1.akpm@linux-foundation.org> (Andrew Morton's message of "Tue\, 1 Jun 2010 14\:51\:26 -0700")

Andrew Morton <akpm@linux-foundation.org> writes:

I am to blame for the "token jar" name.

> OK, thanks.  But I'm still struggling a bit in understanding the
> applicability.  Where else might one use this?  What particular
> problem is it good at solving?

I wrote a similar scheme a long time ago for IP protocol ID
allocation (but that code never ended up in mainline).
Back then it was called "cookie jar" and you can actually
still google for it :)

It can be used for pretty much anything where you have
a global resource and want to hand it out to different CPUs,
but still have a global limit that is enforced.

For example a file system could use it for accounting 
free space too.

In principle you could even use it for pids for example
or other IDs.

>
> I think the problem here is that you're using the term "token jar" as
> if others already know what a token jar _is_.  I guess I was asleep
> during that compsci lecture, but google doesn't appear to know about
> the term either.
>
> And from looking at the tmpfs caller, it appears that the token jar is
> being used to speed up the access to a single `unsigned long
> free_blocks'.  Could we have used say a percpu_counter instead?

You need some synchronization, otherwise the accounting
would not be exact and you could overflow. Yes you could
open code it, but having it in a library is nicer.

That's what the token jar provides.

You grab some tokens out of the jar and to be fast take multiple in
advance. And there's a watchman who forces you to give them back if you
don't really need them all and they run low.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.

  reply	other threads:[~2010-06-02  8:58 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 [this message]
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

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=87ocftyfnh.fsf@basil.nowhere.org \
    --to=andi@firstfloor.org \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --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.