lkml.org 
[lkml]   [2010]   [Apr]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] mm: add context argument to shrinker callback
On 04/13/2010 03:24 AM, Dave Chinner wrote:
> From: Dave Chinner<dchinner@redhat.com>
>
> 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



\
 
 \ /
  Last update: 2010-04-28 11:43    [W:0.105 / U:0.780 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site