From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Chinner Subject: Re: [PATCH v2 08/28] list: add a new LRU list type Date: Fri, 5 Apr 2013 12:20:48 +1100 Message-ID: <20130405012048.GH12011@dastard> References: <1364548450-28254-1-git-send-email-glommer@parallels.com> <1364548450-28254-9-git-send-email-glommer@parallels.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Glauber Costa , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, containers@lists.linux-foundation.org, Michal Hocko , Johannes Weiner , kamezawa.hiroyu@jp.fujitsu.com, Andrew Morton , hughd@google.com, yinghan@google.com, Dave Chinner To: Greg Thelen Return-path: Received: from ipmail04.adl6.internode.on.net ([150.101.137.141]:32722 "EHLO ipmail04.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1765953Ab3DEBUv (ORCPT ); Thu, 4 Apr 2013 21:20:51 -0400 Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Apr 04, 2013 at 02:53:49PM -0700, Greg Thelen wrote: > On Fri, Mar 29 2013, Glauber Costa wrote: > > From: Dave Chinner > > +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@fromorbit.com