Remove shrink_{i,d}node_cache() wrappers

This is optional functionality which may or may not be useful to
ZFS when using older kernels.  It is never a hard requirement.
Therefore this functionality is being removed from the SPL and
a simpler slimmed down version will be added to ZFS.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
Brian Behlendorf 2014-10-01 19:27:29 -04:00
parent 8bbbe46f86
commit 89a461e70c
7 changed files with 15 additions and 268 deletions

View File

@ -46,8 +46,6 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
SPL_AC_KVASPRINTF SPL_AC_KVASPRINTF
SPL_AC_EXPORTED_RWSEM_IS_LOCKED SPL_AC_EXPORTED_RWSEM_IS_LOCKED
SPL_AC_KERNEL_FALLOCATE SPL_AC_KERNEL_FALLOCATE
SPL_AC_SHRINK_DCACHE_MEMORY
SPL_AC_SHRINK_ICACHE_MEMORY
SPL_AC_KERN_PATH SPL_AC_KERN_PATH
SPL_AC_CONFIG_KALLSYMS SPL_AC_CONFIG_KALLSYMS
SPL_AC_CONFIG_ZLIB_INFLATE SPL_AC_CONFIG_ZLIB_INFLATE
@ -1465,48 +1463,6 @@ AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
]) ])
]) ])
dnl #
dnl # 2.6.xx API compat,
dnl # There currently exists no exposed API to partially shrink the dcache.
dnl # The expected mechanism to shrink the cache is a registered shrinker
dnl # which is called during memory pressure.
dnl #
AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
[AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
SPL_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/dcache.h>
], [
shrink_dcache_memory(0, 0);
], [shrink_dcache_memory], [fs/dcache.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
[shrink_dcache_memory() is available])
], [
AC_MSG_RESULT(no)
])
])
dnl #
dnl # 2.6.xx API compat,
dnl # There currently exists no exposed API to partially shrink the icache.
dnl # The expected mechanism to shrink the cache is a registered shrinker
dnl # which is called during memory pressure.
dnl #
AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
[AC_MSG_CHECKING([whether shrink_icache_memory() is available])
SPL_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/dcache.h>
], [
shrink_icache_memory(0, 0);
], [shrink_icache_memory], [fs/inode.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
[shrink_icache_memory() is available])
], [
AC_MSG_RESULT(no)
])
])
dnl # dnl #
dnl # 2.6.28 API change dnl # 2.6.28 API change
dnl # The kern_path() function has been introduced. We adopt it as the new way dnl # The kern_path() function has been introduced. We adopt it as the new way

View File

@ -35,102 +35,6 @@ struct shrink_control {
}; };
#endif /* HAVE_SHRINK_CONTROL_STRUCT */ #endif /* HAVE_SHRINK_CONTROL_STRUCT */
/*
* 2.6.xx API compat,
* There currently exists no exposed API to partially shrink the dcache.
* The expected mechanism to shrink the cache is a registered shrinker
* which is called during memory pressure.
*/
#ifndef HAVE_SHRINK_DCACHE_MEMORY
# if defined(HAVE_SHRINK_CONTROL_STRUCT)
typedef int (*shrink_dcache_memory_t)(struct shrinker *,
struct shrink_control *);
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 }; \
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) \
({ \
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) \
({ \
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 */
/*
* 2.6.xx API compat,
* There currently exists no exposed API to partially shrink the icache.
* The expected mechanism to shrink the cache is a registered shrinker
* which is called during memory pressure.
*/
#ifndef HAVE_SHRINK_ICACHE_MEMORY
# if defined(HAVE_SHRINK_CONTROL_STRUCT)
typedef int (*shrink_icache_memory_t)(struct shrinker *,
struct shrink_control *);
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 }; \
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) \
({ \
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) \
({ \
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 */
/* /*
* Due to frequent changes in the shrinker API the following * Due to frequent changes in the shrinker API the following
* compatibility wrappers should be used. They are as follows: * compatibility wrappers should be used. They are as follows:

View File

@ -25,22 +25,4 @@
#ifndef _SPL_DNLC_H #ifndef _SPL_DNLC_H
#define _SPL_DNLC_H #define _SPL_DNLC_H
/*
* Reduce the dcache and icache then reap the free'd slabs. Note the
* interface takes a reclaim percentage but we don't have easy access to
* the total number of entries to calculate the reclaim count. However,
* in practice this doesn't need to be even close to correct. We simply
* need to reclaim some useful fraction of the cache. The caller can
* determine if more needs to be done.
*/
static inline void
dnlc_reduce_cache(void *reduce_percent)
{
int nr = (uintptr_t)reduce_percent * 10000;
shrink_dcache_memory(nr, GFP_KERNEL);
shrink_icache_memory(nr, GFP_KERNEL);
kmem_reap();
}
#endif /* SPL_DNLC_H */ #endif /* SPL_DNLC_H */

View File

@ -498,7 +498,6 @@ extern void spl_kmem_cache_free(spl_kmem_cache_t *skc, void *obj);
extern void spl_kmem_cache_reap_now(spl_kmem_cache_t *skc, int count); extern void spl_kmem_cache_reap_now(spl_kmem_cache_t *skc, int count);
extern void spl_kmem_reap(void); extern void spl_kmem_reap(void);
int spl_kmem_init_kallsyms_lookup(void);
int spl_kmem_init(void); int spl_kmem_init(void);
void spl_kmem_fini(void); void spl_kmem_fini(void);

View File

@ -490,7 +490,6 @@ zone_get_hostid(void *zone)
} }
EXPORT_SYMBOL(zone_get_hostid); EXPORT_SYMBOL(zone_get_hostid);
#ifndef HAVE_KALLSYMS_LOOKUP_NAME
/* /*
* The kallsyms_lookup_name() kernel function is not an exported symbol in * The kallsyms_lookup_name() kernel function is not an exported symbol in
* Linux 2.6.19 through 2.6.32 inclusive. * Linux 2.6.19 through 2.6.32 inclusive.
@ -499,7 +498,6 @@ EXPORT_SYMBOL(zone_get_hostid);
* space where /proc/kallsyms is consulted for the requested address. * space where /proc/kallsyms is consulted for the requested address.
* *
*/ */
#define GET_KALLSYMS_ADDR_CMD \ #define GET_KALLSYMS_ADDR_CMD \
"exec 0</dev/null " \ "exec 0</dev/null " \
" 1>/proc/sys/kernel/spl/kallsyms_lookup_name " \ " 1>/proc/sys/kernel/spl/kallsyms_lookup_name " \
@ -510,6 +508,7 @@ EXPORT_SYMBOL(zone_get_hostid);
static int static int
set_kallsyms_lookup_name(void) set_kallsyms_lookup_name(void)
{ {
#ifndef HAVE_KALLSYMS_LOOKUP_NAME
char *argv[] = { "/bin/sh", char *argv[] = { "/bin/sh",
"-c", "-c",
GET_KALLSYMS_ADDR_CMD, GET_KALLSYMS_ADDR_CMD,
@ -543,9 +542,11 @@ set_kallsyms_lookup_name(void)
printk("SPL: Failed user helper '%s %s %s', rc = %d\n", printk("SPL: Failed user helper '%s %s %s', rc = %d\n",
argv[0], argv[1], argv[2], rc); argv[0], argv[1], argv[2], rc);
return rc; return (rc);
#else
return (0);
#endif /* HAVE_KALLSYMS_LOOKUP_NAME */
} }
#endif
static int static int
__init spl_init(void) __init spl_init(void)
@ -582,13 +583,8 @@ __init spl_init(void)
if ((rc = spl_zlib_init())) if ((rc = spl_zlib_init()))
SGOTO(out9, rc); SGOTO(out9, rc);
#ifndef HAVE_KALLSYMS_LOOKUP_NAME
if ((rc = set_kallsyms_lookup_name())) if ((rc = set_kallsyms_lookup_name()))
SGOTO(out10, rc = -EADDRNOTAVAIL); SGOTO(out10, rc = -EADDRNOTAVAIL);
#endif /* HAVE_KALLSYMS_LOOKUP_NAME */
if ((rc = spl_kmem_init_kallsyms_lookup()))
SGOTO(out10, rc);
printk(KERN_NOTICE "SPL: Loaded module v%s-%s%s\n", SPL_META_VERSION, printk(KERN_NOTICE "SPL: Loaded module v%s-%s%s\n", SPL_META_VERSION,
SPL_META_RELEASE, SPL_DEBUG_STR); SPL_META_RELEASE, SPL_DEBUG_STR);

View File

@ -110,16 +110,6 @@ EXPORT_SYMBOL(zio_alloc_arena);
vmem_t *zio_arena = NULL; vmem_t *zio_arena = NULL;
EXPORT_SYMBOL(zio_arena); EXPORT_SYMBOL(zio_arena);
#ifndef HAVE_SHRINK_DCACHE_MEMORY
shrink_dcache_memory_t shrink_dcache_memory_fn = SYMBOL_POISON;
EXPORT_SYMBOL(shrink_dcache_memory_fn);
#endif /* HAVE_SHRINK_DCACHE_MEMORY */
#ifndef HAVE_SHRINK_ICACHE_MEMORY
shrink_icache_memory_t shrink_icache_memory_fn = SYMBOL_POISON;
EXPORT_SYMBOL(shrink_icache_memory_fn);
#endif /* HAVE_SHRINK_ICACHE_MEMORY */
size_t size_t
vmem_size(vmem_t *vmp, int typemask) vmem_size(vmem_t *vmp, int typemask)
{ {
@ -2316,27 +2306,6 @@ spl_kmem_fini_tracking(struct list_head *list, spinlock_t *lock)
#define spl_kmem_fini_tracking(list, lock) #define spl_kmem_fini_tracking(list, lock)
#endif /* DEBUG_KMEM && DEBUG_KMEM_TRACKING */ #endif /* DEBUG_KMEM && DEBUG_KMEM_TRACKING */
/*
* Called at module init when it is safe to use spl_kallsyms_lookup_name()
*/
int
spl_kmem_init_kallsyms_lookup(void)
{
#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");
#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");
#endif /* HAVE_SHRINK_ICACHE_MEMORY */
return 0;
}
int int
spl_kmem_init(void) spl_kmem_init(void)
{ {

View File

@ -30,61 +30,8 @@
#define SPLAT_LINUX_DESC "Kernel Compatibility Tests" #define SPLAT_LINUX_DESC "Kernel Compatibility Tests"
#define SPLAT_LINUX_TEST1_ID 0x1001 #define SPLAT_LINUX_TEST1_ID 0x1001
#define SPLAT_LINUX_TEST1_NAME "shrink_dcache" #define SPLAT_LINUX_TEST1_NAME "shrinker"
#define SPLAT_LINUX_TEST1_DESC "Shrink dcache test" #define SPLAT_LINUX_TEST1_DESC "Shrinker test"
#define SPLAT_LINUX_TEST2_ID 0x1002
#define SPLAT_LINUX_TEST2_NAME "shrink_icache"
#define SPLAT_LINUX_TEST2_DESC "Shrink icache test"
#define SPLAT_LINUX_TEST3_ID 0x1003
#define SPLAT_LINUX_TEST3_NAME "shrinker"
#define SPLAT_LINUX_TEST3_DESC "Shrinker test"
/*
* Attempt to shrink the dcache memory. This is simply a functional
* to ensure we can correctly call the shrinker. We don't check that
* the cache actually decreased because we have no control over what
* else may be running on the system. This avoid false positives.
*/
static int
splat_linux_test1(struct file *file, void *arg)
{
int remain_before;
int remain_after;
remain_before = shrink_dcache_memory(0, GFP_KERNEL);
remain_after = shrink_dcache_memory(KMC_REAP_CHUNK, GFP_KERNEL);
splat_vprint(file, SPLAT_LINUX_TEST1_NAME,
"Shrink dcache memory, remain %d -> %d\n",
remain_before, remain_after);
return 0;
}
/*
* Attempt to shrink the icache memory. This is simply a functional
* to ensure we can correctly call the shrinker. We don't check that
* the cache actually decreased because we have no control over what
* else may be running on the system. This avoid false positives.
*/
static int
splat_linux_test2(struct file *file, void *arg)
{
int remain_before;
int remain_after;
remain_before = shrink_icache_memory(0, GFP_KERNEL);
remain_after = shrink_icache_memory(KMC_REAP_CHUNK, GFP_KERNEL);
splat_vprint(file, SPLAT_LINUX_TEST2_NAME,
"Shrink icache memory, remain %d -> %d\n",
remain_before, remain_after);
return 0;
}
/* /*
* Wait queue used to eliminate race between dropping of slab * Wait queue used to eliminate race between dropping of slab
@ -117,17 +64,17 @@ __splat_linux_shrinker_fn(struct shrinker *shrink, struct shrink_control *sc)
splat_linux_shrinker_size = splat_linux_shrinker_size - splat_linux_shrinker_size = splat_linux_shrinker_size -
MIN(sc->nr_to_scan, splat_linux_shrinker_size); MIN(sc->nr_to_scan, splat_linux_shrinker_size);
splat_vprint(splat_linux_shrinker_file, SPLAT_LINUX_TEST3_NAME, splat_vprint(splat_linux_shrinker_file, SPLAT_LINUX_TEST1_NAME,
"Reclaimed %lu objects, size now %lu\n", "Reclaimed %lu objects, size now %lu\n",
sc->nr_to_scan, splat_linux_shrinker_size); sc->nr_to_scan, splat_linux_shrinker_size);
} else { } else {
splat_vprint(splat_linux_shrinker_file, SPLAT_LINUX_TEST3_NAME, splat_vprint(splat_linux_shrinker_file, SPLAT_LINUX_TEST1_NAME,
"Cache size is %lu\n", splat_linux_shrinker_size); "Cache size is %lu\n", splat_linux_shrinker_size);
} }
/* Far more calls than expected abort drop_slab as a failsafe */ /* Far more calls than expected abort drop_slab as a failsafe */
if (failsafe > 100) { if (failsafe > 100) {
splat_vprint(splat_linux_shrinker_file, SPLAT_LINUX_TEST3_NAME, splat_vprint(splat_linux_shrinker_file, SPLAT_LINUX_TEST1_NAME,
"Far more calls than expected (%d), size now %lu\n", "Far more calls than expected (%d), size now %lu\n",
failsafe, splat_linux_shrinker_size); failsafe, splat_linux_shrinker_size);
return -1; return -1;
@ -168,7 +115,7 @@ splat_linux_drop_slab(struct file *file)
rc = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC); rc = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
if (rc) if (rc)
splat_vprint(file, SPLAT_LINUX_TEST3_NAME, splat_vprint(file, SPLAT_LINUX_TEST1_NAME,
"Failed user helper '%s %s %s', rc = %d\n", "Failed user helper '%s %s %s', rc = %d\n",
argv[0], argv[1], argv[2], rc); argv[0], argv[1], argv[2], rc);
@ -185,7 +132,7 @@ splat_linux_drop_slab(struct file *file)
* API and this test ensures the compatibility code is correct. * API and this test ensures the compatibility code is correct.
*/ */
static int static int
splat_linux_test3(struct file *file, void *arg) splat_linux_test1(struct file *file, void *arg)
{ {
int rc = -EINVAL; int rc = -EINVAL;
@ -196,7 +143,7 @@ splat_linux_test3(struct file *file, void *arg)
* use is detected. * use is detected.
*/ */
if (splat_linux_shrinker_size || splat_linux_shrinker_file) { if (splat_linux_shrinker_size || splat_linux_shrinker_file) {
splat_vprint(file, SPLAT_LINUX_TEST3_NAME, splat_vprint(file, SPLAT_LINUX_TEST1_NAME,
"Failed due to concurrent shrinker test, rc = %d\n", rc); "Failed due to concurrent shrinker test, rc = %d\n", rc);
return (rc); return (rc);
} }
@ -218,7 +165,7 @@ splat_linux_test3(struct file *file, void *arg)
*/ */
rc = wait_event_timeout(shrinker_wait, !splat_linux_shrinker_size, HZ); rc = wait_event_timeout(shrinker_wait, !splat_linux_shrinker_size, HZ);
if (!rc) { if (!rc) {
splat_vprint(file, SPLAT_LINUX_TEST3_NAME, splat_vprint(file, SPLAT_LINUX_TEST1_NAME,
"Failed cache shrinking timed out, size now %lu", "Failed cache shrinking timed out, size now %lu",
splat_linux_shrinker_size); splat_linux_shrinker_size);
rc = -ETIMEDOUT; rc = -ETIMEDOUT;
@ -227,7 +174,7 @@ splat_linux_test3(struct file *file, void *arg)
} }
if (!rc && splat_linux_shrinker_size != 0) { if (!rc && splat_linux_shrinker_size != 0) {
splat_vprint(file, SPLAT_LINUX_TEST3_NAME, splat_vprint(file, SPLAT_LINUX_TEST1_NAME,
"Failed cache was not shrunk to 0, size now %lu", "Failed cache was not shrunk to 0, size now %lu",
splat_linux_shrinker_size); splat_linux_shrinker_size);
rc = -EDOM; rc = -EDOM;
@ -260,10 +207,6 @@ splat_linux_init(void)
SPLAT_TEST_INIT(sub, SPLAT_LINUX_TEST1_NAME, SPLAT_LINUX_TEST1_DESC, SPLAT_TEST_INIT(sub, SPLAT_LINUX_TEST1_NAME, SPLAT_LINUX_TEST1_DESC,
SPLAT_LINUX_TEST1_ID, splat_linux_test1); SPLAT_LINUX_TEST1_ID, splat_linux_test1);
SPLAT_TEST_INIT(sub, SPLAT_LINUX_TEST2_NAME, SPLAT_LINUX_TEST2_DESC,
SPLAT_LINUX_TEST2_ID, splat_linux_test2);
SPLAT_TEST_INIT(sub, SPLAT_LINUX_TEST3_NAME, SPLAT_LINUX_TEST3_DESC,
SPLAT_LINUX_TEST3_ID, splat_linux_test3);
return sub; return sub;
} }
@ -272,8 +215,6 @@ void
splat_linux_fini(splat_subsystem_t *sub) splat_linux_fini(splat_subsystem_t *sub)
{ {
ASSERT(sub); ASSERT(sub);
SPLAT_TEST_FINI(sub, SPLAT_LINUX_TEST3_ID);
SPLAT_TEST_FINI(sub, SPLAT_LINUX_TEST2_ID);
SPLAT_TEST_FINI(sub, SPLAT_LINUX_TEST1_ID); SPLAT_TEST_FINI(sub, SPLAT_LINUX_TEST1_ID);
kfree(sub); kfree(sub);