xfs
[Top] [All Lists]

Re: [PATCH 1/2] mm: add context argument to shrinker callback

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: Re: [PATCH 1/2] mm: add context argument to shrinker callback
From: Avi Kivity <avi@xxxxxxxxxx>
Date: Wed, 28 Apr 2010 12:39:44 +0300
Cc: linux-kernel@xxxxxxxxxxxxxxx, linux-mm@xxxxxxxxx, linux-fsdevel@xxxxxxxxxxxxxxx, xfs@xxxxxxxxxxx
In-reply-to: <1271118255-21070-2-git-send-email-david@xxxxxxxxxxxxx>
References: <1271118255-21070-1-git-send-email-david@xxxxxxxxxxxxx> <1271118255-21070-2-git-send-email-david@xxxxxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100330 Fedora/3.0.4-1.fc12 Thunderbird/3.0.4
On 04/13/2010 03:24 AM, Dave Chinner wrote:
From: Dave Chinner<dchinner@xxxxxxxxxx>

The current shrinker implementation requires the registered callback
to have global state to work from. This makes it difficult to shrink
caches that are not global (e.g. per-filesystem caches). Add a
context argument to the shrinker callback so that it can easily be
used in such situations.

@@ -995,7 +995,8 @@ static inline void sync_mm_rss(struct task_struct *task, 
struct mm_struct *mm)
   * querying the cache size, so a fastpath for that case is appropriate.
   */
  struct shrinker {
-       int (*shrink)(int nr_to_scan, gfp_t gfp_mask);
+       int (*shrink)(void *ctx, int nr_to_scan, gfp_t gfp_mask);
+       void *ctx;      /* user callback context */
        int seeks;      /* seeks to recreate an obj */


It's nicer (and slightly cheaper) to have

  int (*shrink)(struct shrinker *shrinker, int nr_to_scan, gfp_t gfp_mask);
  /* no void *ctx; */

Clients can use container_of() to reach their context from the shrinker argument.

--
error compiling committee.c: too many arguments to function

<Prev in Thread] Current Thread [Next in Thread>