[PATCH v2 08/28] list: add a new LRU list type
Dave Chinner
david at fromorbit.com
Fri Apr 5 01:20:48 UTC 2013
On Thu, Apr 04, 2013 at 02:53:49PM -0700, Greg Thelen wrote:
> On Fri, Mar 29 2013, Glauber Costa wrote:
> > From: Dave Chinner <dchinner at redhat.com>
> > +long
> > +list_lru_walk(
> > + struct list_lru *lru,
> > + list_lru_walk_cb isolate,
> > + void *cb_arg,
> > + long nr_to_walk)
> > +{
> > + struct list_head *item, *n;
> > + long removed = 0;
> > +restart:
> > + spin_lock(&lru->lock);
> > + list_for_each_safe(item, n, &lru->list) {
> > + int ret;
> > +
> > + if (nr_to_walk-- < 0)
> > + break;
> > +
> > + ret = isolate(item, &lru->lock, cb_arg);
> > + switch (ret) {
> > + case 0: /* item removed from list */
> > + lru->nr_items--;
> > + removed++;
> > + break;
> > + case 1: /* item referenced, give another pass */
> > + list_move_tail(item, &lru->list);
> > + break;
> > + case 2: /* item cannot be locked, skip */
> > + break;
> > + case 3: /* item not freeable, lock dropped */
> > + goto restart;
>
> These four magic return values might benefit from an enum (or #define)
> for clarity.
Obviously, and it was stated that this needed to be done by miself
when I last posted the patch set many months ago. I've been rather
busy since then, and so haven't had time to do anything with it.
> Maybe the names would be LRU_OK, LRU_REMOVED, LRU_ROTATE, LRU_RETRY.
Something like that...
Cheers,
Dave.
--
Dave Chinner
david at fromorbit.com
More information about the Containers
mailing list