Skip to content

Commit

Permalink
Linux 3.1 compat, shrink_*cache_memory
Browse files Browse the repository at this point in the history
As of Linux 3.1 the shrink_dcache_memory and shrink_icache_memory
functions have been removed.  This same task is now accomplished
more cleanly with per super block shrinkers.  This unfortunately
leaves us no easy way to support the dnlc_reduce_cache() function.

This support has always been entirely optional.  So when no
reasonable interface is available allow the dnlc_reduce_cache()
function to effectively become a no-op.

The downside of this change is that it will prevent the zfs arc
meta data limts from being enforced.  However, the current zfs
implementation in this regard is already flawed and needs to
be reworked.  If the arc needs to enfore a meta data limit it
will need to be extended to coordinate directly with the zpl.
This will allow us to drop all this compatibility code and get
more fine grained control over the cache management.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #52
  • Loading branch information
behlendorf committed Nov 10, 2011
1 parent 0d0b523 commit fe71c0e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 16 deletions.
54 changes: 48 additions & 6 deletions include/linux/mm_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,37 @@ extern shrink_dcache_memory_t shrink_dcache_memory_fn;
# define shrink_dcache_memory(nr, gfp) \
({ \
struct shrink_control sc = { .nr_to_scan = nr, .gfp_mask = gfp }; \
shrink_dcache_memory_fn(NULL, &sc); \
int __ret__ = 0; \
\
if (shrink_dcache_memory_fn) \
__ret__ = shrink_dcache_memory_fn(NULL, &sc); \
\
__ret__; \
})
# elif defined(HAVE_3ARGS_SHRINKER_CALLBACK)
typedef int (*shrink_dcache_memory_t)(struct shrinker *, int, gfp_t);
extern shrink_dcache_memory_t shrink_dcache_memory_fn;
# define shrink_dcache_memory(nr, gfp) shrink_dcache_memory_fn(NULL, nr, gfp)
# define shrink_dcache_memory(nr, gfp) \
({ \
int __ret__ = 0; \
\
if (shrink_dcache_memory_fn) \
__ret__ = shrink_dcache_memory_fn(NULL, nr, gfp); \
\
__ret__; \
})
# else
typedef int (*shrink_dcache_memory_t)(int, gfp_t);
extern shrink_dcache_memory_t shrink_dcache_memory_fn;
# define shrink_dcache_memory(nr, gfp) shrink_dcache_memory_fn(nr, gfp)
# define shrink_dcache_memory(nr, gfp) \
({ \
int __ret__ = 0; \
\
if (shrink_dcache_memory_fn) \
__ret__ = shrink_dcache_memory_fn(nr, gfp); \
\
__ret__; \
})
# endif /* HAVE_3ARGS_SHRINKER_CALLBACK */
#endif /* HAVE_SHRINK_DCACHE_MEMORY */

Expand All @@ -120,16 +141,37 @@ extern shrink_icache_memory_t shrink_icache_memory_fn;
# define shrink_icache_memory(nr, gfp) \
({ \
struct shrink_control sc = { .nr_to_scan = nr, .gfp_mask = gfp }; \
shrink_icache_memory_fn(NULL, &sc); \
int __ret__ = 0; \
\
if (shrink_icache_memory_fn) \
__ret__ = shrink_icache_memory_fn(NULL, &sc); \
\
__ret__; \
})
# elif defined(HAVE_3ARGS_SHRINKER_CALLBACK)
typedef int (*shrink_icache_memory_t)(struct shrinker *, int, gfp_t);
extern shrink_icache_memory_t shrink_icache_memory_fn;
# define shrink_icache_memory(nr, gfp) shrink_icache_memory_fn(NULL, nr, gfp)
# define shrink_icache_memory(nr, gfp) \
({ \
int __ret__ = 0; \
\
if (shrink_icache_memory_fn) \
__ret__ = shrink_icache_memory_fn(NULL, nr, gfp); \
\
__ret__; \
})
# else
typedef int (*shrink_icache_memory_t)(int, gfp_t);
extern shrink_icache_memory_t shrink_icache_memory_fn;
# define shrink_icache_memory(nr, gfp) shrink_icache_memory_fn(nr, gfp)
# define shrink_icache_memory(nr, gfp) \
({ \
int __ret__ = 0; \
\
if (shrink_icache_memory_fn) \
__ret__ = shrink_icache_memory_fn(nr, gfp); \
\
__ret__; \
})
# endif /* HAVE_3ARGS_SHRINKER_CALLBACK */
#endif /* HAVE_SHRINK_ICACHE_MEMORY */

Expand Down
14 changes: 4 additions & 10 deletions module/spl/spl-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -2123,21 +2123,15 @@ spl_kmem_init_kallsyms_lookup(void)
#endif /* HAVE_INVALIDATE_INODES */

#ifndef HAVE_SHRINK_DCACHE_MEMORY
/* When shrink_dcache_memory_fn == NULL support is disabled */
shrink_dcache_memory_fn = (shrink_dcache_memory_t)
spl_kallsyms_lookup_name("shrink_dcache_memory");
if (!shrink_dcache_memory_fn) {
printk(KERN_ERR "Error: Unknown symbol shrink_dcache_memory\n");
return -EFAULT;
}
spl_kallsyms_lookup_name("shrink_dcache_memory");
#endif /* HAVE_SHRINK_DCACHE_MEMORY */

#ifndef HAVE_SHRINK_ICACHE_MEMORY
/* When shrink_icache_memory_fn == NULL support is disabled */
shrink_icache_memory_fn = (shrink_icache_memory_t)
spl_kallsyms_lookup_name("shrink_icache_memory");
if (!shrink_icache_memory_fn) {
printk(KERN_ERR "Error: Unknown symbol shrink_icache_memory\n");
return -EFAULT;
}
spl_kallsyms_lookup_name("shrink_icache_memory");
#endif /* HAVE_SHRINK_ICACHE_MEMORY */

return 0;
Expand Down

0 comments on commit fe71c0e

Please sign in to comment.