mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 19:19:32 +03:00
Update global_page_state() support for 2.6.29 kernels.
Basically everything we need to monitor the global memory state of the system is now cleanly available via global_page_state(). The problem is that this interface is still fairly recent, and there has been one change in the page state enum which we need to handle. These changes basically boil down to the following: - If global_page_state() is available we should use it. Several autoconf checks have been added to detect the correct enum names. - If global_page_state() is not available check to see if get_zone_counts() symbol is available and use that. - If the get_zone_counts() symbol is not exported we have no choice be to dynamically aquire it at load time. This is an absolute last resort for old kernel which we don't want to patch to cleanly export the symbol.
This commit is contained in:
parent
6b09f73939
commit
6ae7fef5b9
@ -59,9 +59,11 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
|
|||||||
SPL_AC_NEXT_ONLINE_PGDAT
|
SPL_AC_NEXT_ONLINE_PGDAT
|
||||||
SPL_AC_NEXT_ZONE
|
SPL_AC_NEXT_ZONE
|
||||||
SPL_AC_PGDAT_LIST
|
SPL_AC_PGDAT_LIST
|
||||||
SPL_AC_GET_ZONE_COUNTS
|
|
||||||
SPL_AC_GLOBAL_PAGE_STATE
|
SPL_AC_GLOBAL_PAGE_STATE
|
||||||
SPL_AC_ZONE_STAT_ITEM_FIA
|
SPL_AC_ZONE_STAT_ITEM_FREE
|
||||||
|
SPL_AC_ZONE_STAT_ITEM_INACTIVE
|
||||||
|
SPL_AC_ZONE_STAT_ITEM_ACTIVE
|
||||||
|
SPL_AC_GET_ZONE_COUNTS
|
||||||
SPL_AC_2ARGS_VFS_UNLINK
|
SPL_AC_2ARGS_VFS_UNLINK
|
||||||
SPL_AC_4ARGS_VFS_RENAME
|
SPL_AC_4ARGS_VFS_RENAME
|
||||||
SPL_AC_CRED_STRUCT
|
SPL_AC_CRED_STRUCT
|
||||||
@ -1005,22 +1007,6 @@ AC_DEFUN([SPL_AC_PGDAT_LIST], [
|
|||||||
[])
|
[])
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl #
|
|
||||||
dnl # Proposed API change,
|
|
||||||
dnl # This symbol is not available in stock kernels. You may build a
|
|
||||||
dnl # custom kernel with the *-spl-export-symbols.patch which will export
|
|
||||||
dnl # these symbols for use. If your already rolling a custom kernel for
|
|
||||||
dnl # your environment this is recommended.
|
|
||||||
dnl #
|
|
||||||
AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
|
|
||||||
SPL_CHECK_SYMBOL_EXPORT(
|
|
||||||
[get_zone_counts],
|
|
||||||
[],
|
|
||||||
[AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
|
|
||||||
[get_zone_counts() is available])],
|
|
||||||
[])
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl #
|
dnl #
|
||||||
dnl # 2.6.18 API change,
|
dnl # 2.6.18 API change,
|
||||||
dnl # First introduced global_page_state() support as an inline.
|
dnl # First introduced global_page_state() support as an inline.
|
||||||
@ -1028,10 +1014,10 @@ dnl #
|
|||||||
AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
|
AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
|
||||||
AC_MSG_CHECKING([whether global_page_state() is available])
|
AC_MSG_CHECKING([whether global_page_state() is available])
|
||||||
SPL_LINUX_TRY_COMPILE([
|
SPL_LINUX_TRY_COMPILE([
|
||||||
#include <linux/vmstat.h>
|
#include <linux/mm.h>
|
||||||
],[
|
],[
|
||||||
unsigned long state;
|
unsigned long state;
|
||||||
state = global_page_state(NR_FREE_PAGES);
|
state = global_page_state(0);
|
||||||
],[
|
],[
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
|
AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
|
||||||
@ -1042,28 +1028,183 @@ AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
|
|||||||
])
|
])
|
||||||
|
|
||||||
dnl #
|
dnl #
|
||||||
dnl # 2.6.21 API change,
|
dnl # 2.6.21 API change (plus subsequent naming convention changes),
|
||||||
dnl # Public global zone stats now include free/inactive/active page
|
dnl # Public global zone stats now include a free page count. However
|
||||||
dnl # counts. This replaced the priviate get_zone_counts() interface.
|
dnl # the enumerated names of the counters have changed since this API
|
||||||
|
dnl # was introduced. We need to deduce the corrent name to use. This
|
||||||
|
dnl # replaces the priviate get_zone_counts() interface.
|
||||||
dnl #
|
dnl #
|
||||||
AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FIA], [
|
dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
|
||||||
AC_MSG_CHECKING([whether free/inactive/active page state is available])
|
dnl # is 2.6.30 as of when this was written.
|
||||||
|
dnl #
|
||||||
|
AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
|
||||||
|
AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
|
||||||
SPL_LINUX_TRY_COMPILE([
|
SPL_LINUX_TRY_COMPILE([
|
||||||
#include <linux/mmzone.h>
|
#include <linux/mm.h>
|
||||||
],[
|
],[
|
||||||
enum zone_stat_item i1, i2, i3;
|
enum zone_stat_item zsi;
|
||||||
i1 = NR_FREE_PAGES;
|
zsi = NR_FREE_PAGES;
|
||||||
i2 = NR_INACTIVE;
|
|
||||||
i3 = NR_ACTIVE;
|
|
||||||
],[
|
],[
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
AC_DEFINE(HAVE_ZONE_STAT_ITEM_FIA, 1,
|
AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
|
||||||
[free/inactive/active page state is available])
|
[Page state NR_FREE_PAGES is available])
|
||||||
],[
|
],[
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl #
|
||||||
|
dnl # 2.6.21 API change (plus subsequent naming convention changes),
|
||||||
|
dnl # Public global zone stats now include an inactive page count. However
|
||||||
|
dnl # the enumerated names of the counters have changed since this API
|
||||||
|
dnl # was introduced. We need to deduce the corrent name to use. This
|
||||||
|
dnl # replaces the priviate get_zone_counts() interface.
|
||||||
|
dnl #
|
||||||
|
dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
|
||||||
|
dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
|
||||||
|
dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
|
||||||
|
dnl #
|
||||||
|
AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
|
||||||
|
AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
|
||||||
|
SPL_LINUX_TRY_COMPILE([
|
||||||
|
#include <linux/mm.h>
|
||||||
|
],[
|
||||||
|
enum zone_stat_item zsi;
|
||||||
|
zsi = NR_INACTIVE;
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
|
||||||
|
[Page state NR_INACTIVE is available])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
|
||||||
|
SPL_LINUX_TRY_COMPILE([
|
||||||
|
#include <linux/mm.h>
|
||||||
|
],[
|
||||||
|
enum zone_stat_item zsi;
|
||||||
|
zsi = NR_INACTIVE_ANON;
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
|
||||||
|
[Page state NR_INACTIVE_ANON is available])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
|
||||||
|
SPL_LINUX_TRY_COMPILE([
|
||||||
|
#include <linux/mm.h>
|
||||||
|
],[
|
||||||
|
enum zone_stat_item zsi;
|
||||||
|
zsi = NR_INACTIVE_FILE;
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
|
||||||
|
[Page state NR_INACTIVE_FILE is available])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl #
|
||||||
|
dnl # 2.6.21 API change (plus subsequent naming convention changes),
|
||||||
|
dnl # Public global zone stats now include an active page count. However
|
||||||
|
dnl # the enumerated names of the counters have changed since this API
|
||||||
|
dnl # was introduced. We need to deduce the corrent name to use. This
|
||||||
|
dnl # replaces the priviate get_zone_counts() interface.
|
||||||
|
dnl #
|
||||||
|
dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
|
||||||
|
dnl # anonymous and file active pages. As of 2.6.28 it was split in
|
||||||
|
dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
|
||||||
|
dnl #
|
||||||
|
AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
|
||||||
|
AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
|
||||||
|
SPL_LINUX_TRY_COMPILE([
|
||||||
|
#include <linux/mm.h>
|
||||||
|
],[
|
||||||
|
enum zone_stat_item zsi;
|
||||||
|
zsi = NR_ACTIVE;
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
|
||||||
|
[Page state NR_ACTIVE is available])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
|
||||||
|
SPL_LINUX_TRY_COMPILE([
|
||||||
|
#include <linux/mm.h>
|
||||||
|
],[
|
||||||
|
enum zone_stat_item zsi;
|
||||||
|
zsi = NR_ACTIVE_ANON;
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
|
||||||
|
[Page state NR_ACTIVE_ANON is available])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
|
||||||
|
SPL_LINUX_TRY_COMPILE([
|
||||||
|
#include <linux/mm.h>
|
||||||
|
],[
|
||||||
|
enum zone_stat_item zsi;
|
||||||
|
zsi = NR_ACTIVE_FILE;
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
|
||||||
|
[Page state NR_ACTIVE_FILE is available])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl #
|
||||||
|
dnl # Proposed API change for legacy kernels.
|
||||||
|
dnl # This symbol is not available in older kernels. For kernels post
|
||||||
|
dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
|
||||||
|
dnl # page state information. This symbol is only used in legacy kernels
|
||||||
|
dnl # any only as a last resort.
|
||||||
|
dnl
|
||||||
|
AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
|
||||||
|
AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
|
||||||
|
SPL_LINUX_TRY_COMPILE([
|
||||||
|
],[
|
||||||
|
#if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
|
||||||
|
#error "global_page_state needs NR_FREE_PAGES"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
|
||||||
|
!defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
|
||||||
|
!defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
|
||||||
|
#error "global_page_state needs NR_ACTIVE*"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
|
||||||
|
!defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
|
||||||
|
!defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
|
||||||
|
#error "global_page_state needs NR_INACTIVE*"
|
||||||
|
#endif
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
|
||||||
|
[get_zone_counts() is needed])
|
||||||
|
|
||||||
|
SPL_CHECK_SYMBOL_EXPORT(
|
||||||
|
[get_zone_counts],
|
||||||
|
[],
|
||||||
|
[AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
|
||||||
|
[get_zone_counts() is available])],
|
||||||
|
[])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
dnl #
|
dnl #
|
||||||
dnl # SLES API change, never adopted in mainline,
|
dnl # SLES API change, never adopted in mainline,
|
||||||
dnl # Third 'struct vfsmount *' argument removed.
|
dnl # Third 'struct vfsmount *' argument removed.
|
||||||
|
@ -123,22 +123,21 @@ extern struct pglist_data *pgdat_list_addr;
|
|||||||
#endif /* HAVE_PGDAT_HELPERS */
|
#endif /* HAVE_PGDAT_HELPERS */
|
||||||
|
|
||||||
/* Source linux/mm/vmstat.c */
|
/* Source linux/mm/vmstat.c */
|
||||||
#ifndef HAVE_ZONE_STAT_ITEM_FIA
|
#if defined(NEED_GET_ZONE_COUNTS) && !defined(HAVE_GET_ZONE_COUNTS)
|
||||||
# ifndef HAVE_GET_ZONE_COUNTS
|
|
||||||
typedef void (*get_zone_counts_t)(unsigned long *, unsigned long *,
|
typedef void (*get_zone_counts_t)(unsigned long *, unsigned long *,
|
||||||
unsigned long *);
|
unsigned long *);
|
||||||
extern get_zone_counts_t get_zone_counts_fn;
|
extern get_zone_counts_t get_zone_counts_fn;
|
||||||
# define get_zone_counts(a,i,f) get_zone_counts_fn(a,i,f)
|
# define get_zone_counts(a,i,f) get_zone_counts_fn(a,i,f)
|
||||||
# endif /* HAVE_GET_ZONE_COUNTS */
|
#endif /* NEED_GET_ZONE_COUNTS && !HAVE_GET_ZONE_COUNTS */
|
||||||
|
|
||||||
extern unsigned long spl_global_page_state(int);
|
typedef enum spl_zone_stat_item {
|
||||||
/* Defines designed to simulate enum but large enough to ensure no overlap */
|
SPL_NR_FREE_PAGES,
|
||||||
# define NR_FREE_PAGES 0x8001
|
SPL_NR_INACTIVE,
|
||||||
# define NR_INACTIVE 0x8002
|
SPL_NR_ACTIVE,
|
||||||
# define NR_ACTIVE 0x8003
|
SPL_NR_ZONE_STAT_ITEMS
|
||||||
#else
|
} spl_zone_stat_item_t;
|
||||||
#define spl_global_page_state(item) global_page_state(item)
|
|
||||||
#endif /* HAVE_ZONE_STAT_ITEM_FIA */
|
extern unsigned long spl_global_page_state(spl_zone_stat_item_t);
|
||||||
|
|
||||||
#define xcopyin(from, to, size) copy_from_user(to, from, size)
|
#define xcopyin(from, to, size) copy_from_user(to, from, size)
|
||||||
#define xcopyout(from, to, size) copy_to_user(to, from, size)
|
#define xcopyout(from, to, size) copy_to_user(to, from, size)
|
||||||
|
@ -109,49 +109,82 @@ EXPORT_SYMBOL(pgdat_list_addr);
|
|||||||
|
|
||||||
#endif /* HAVE_PGDAT_HELPERS */
|
#endif /* HAVE_PGDAT_HELPERS */
|
||||||
|
|
||||||
#ifndef HAVE_ZONE_STAT_ITEM_FIA
|
#ifdef NEED_GET_ZONE_COUNTS
|
||||||
# ifndef HAVE_GET_ZONE_COUNTS
|
# ifndef HAVE_GET_ZONE_COUNTS
|
||||||
get_zone_counts_t get_zone_counts_fn = SYMBOL_POISON;
|
get_zone_counts_t get_zone_counts_fn = SYMBOL_POISON;
|
||||||
EXPORT_SYMBOL(get_zone_counts_fn);
|
EXPORT_SYMBOL(get_zone_counts_fn);
|
||||||
# endif /* HAVE_GET_ZONE_COUNTS */
|
# endif /* HAVE_GET_ZONE_COUNTS */
|
||||||
|
|
||||||
unsigned long
|
unsigned long
|
||||||
spl_global_page_state(int item)
|
spl_global_page_state(spl_zone_stat_item_t item)
|
||||||
{
|
{
|
||||||
unsigned long active;
|
unsigned long active;
|
||||||
unsigned long inactive;
|
unsigned long inactive;
|
||||||
unsigned long free;
|
unsigned long free;
|
||||||
|
|
||||||
if (item == NR_FREE_PAGES) {
|
get_zone_counts(&active, &inactive, &free);
|
||||||
get_zone_counts(&active, &inactive, &free);
|
switch (item) {
|
||||||
return free;
|
case SPL_NR_FREE_PAGES: return free;
|
||||||
|
case SPL_NR_INACTIVE: return inactive;
|
||||||
|
case SPL_NR_ACTIVE: return active;
|
||||||
|
default: ASSERT(0); /* Unsupported */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item == NR_INACTIVE) {
|
return 0;
|
||||||
get_zone_counts(&active, &inactive, &free);
|
|
||||||
return inactive;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item == NR_ACTIVE) {
|
|
||||||
get_zone_counts(&active, &inactive, &free);
|
|
||||||
return active;
|
|
||||||
}
|
|
||||||
|
|
||||||
# ifdef HAVE_GLOBAL_PAGE_STATE
|
|
||||||
return global_page_state((enum zone_stat_item)item);
|
|
||||||
# else
|
|
||||||
return 0; /* Unsupported */
|
|
||||||
# endif /* HAVE_GLOBAL_PAGE_STATE */
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
# ifdef HAVE_GLOBAL_PAGE_STATE
|
||||||
|
unsigned long
|
||||||
|
spl_global_page_state(spl_zone_stat_item_t item)
|
||||||
|
{
|
||||||
|
unsigned long pages = 0;
|
||||||
|
|
||||||
|
switch (item) {
|
||||||
|
case SPL_NR_FREE_PAGES:
|
||||||
|
# ifdef HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES
|
||||||
|
pages += global_page_state(NR_FREE_PAGES);
|
||||||
|
# endif
|
||||||
|
break;
|
||||||
|
case SPL_NR_INACTIVE:
|
||||||
|
# ifdef HAVE_ZONE_STAT_ITEM_NR_INACTIVE
|
||||||
|
pages += global_page_state(NR_INACTIVE);
|
||||||
|
# endif
|
||||||
|
# ifdef HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON
|
||||||
|
pages += global_page_state(NR_INACTIVE_ANON);
|
||||||
|
# endif
|
||||||
|
# ifdef HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE
|
||||||
|
pages += global_page_state(NR_INACTIVE_FILE);
|
||||||
|
# endif
|
||||||
|
break;
|
||||||
|
case SPL_NR_ACTIVE:
|
||||||
|
# ifdef HAVE_ZONE_STAT_ITEM_NR_ACTIVE
|
||||||
|
pages += global_page_state(NR_ACTIVE);
|
||||||
|
# endif
|
||||||
|
# ifdef HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON
|
||||||
|
pages += global_page_state(NR_ACTIVE_ANON);
|
||||||
|
# endif
|
||||||
|
# ifdef HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE
|
||||||
|
pages += global_page_state(NR_ACTIVE_FILE);
|
||||||
|
# endif
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ASSERT(0); /* Unsupported */
|
||||||
|
}
|
||||||
|
|
||||||
|
return pages;
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
# error "Both global_page_state() and get_zone_counts() unavailable"
|
||||||
|
# endif /* HAVE_GLOBAL_PAGE_STATE */
|
||||||
|
#endif /* NEED_GET_ZONE_COUNTS */
|
||||||
EXPORT_SYMBOL(spl_global_page_state);
|
EXPORT_SYMBOL(spl_global_page_state);
|
||||||
#endif /* HAVE_ZONE_STAT_ITEM_FIA */
|
|
||||||
|
|
||||||
pgcnt_t
|
pgcnt_t
|
||||||
spl_kmem_availrmem(void)
|
spl_kmem_availrmem(void)
|
||||||
{
|
{
|
||||||
/* The amount of easily available memory */
|
/* The amount of easily available memory */
|
||||||
return (spl_global_page_state(NR_FREE_PAGES) +
|
return (spl_global_page_state(SPL_NR_FREE_PAGES) +
|
||||||
spl_global_page_state(NR_INACTIVE));
|
spl_global_page_state(SPL_NR_INACTIVE));
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(spl_kmem_availrmem);
|
EXPORT_SYMBOL(spl_kmem_availrmem);
|
||||||
|
|
||||||
@ -1856,16 +1889,14 @@ spl_kmem_init_kallsyms_lookup(void)
|
|||||||
# endif /* HAVE_PGDAT_LIST */
|
# endif /* HAVE_PGDAT_LIST */
|
||||||
#endif /* HAVE_PGDAT_HELPERS */
|
#endif /* HAVE_PGDAT_HELPERS */
|
||||||
|
|
||||||
#ifndef HAVE_ZONE_STAT_ITEM_FIA
|
#if defined(NEED_GET_ZONE_COUNTS) && !defined(HAVE_GET_ZONE_COUNTS)
|
||||||
# ifndef HAVE_GET_ZONE_COUNTS
|
|
||||||
get_zone_counts_fn = (get_zone_counts_t)
|
get_zone_counts_fn = (get_zone_counts_t)
|
||||||
spl_kallsyms_lookup_name("get_zone_counts");
|
spl_kallsyms_lookup_name("get_zone_counts");
|
||||||
if (!get_zone_counts_fn) {
|
if (!get_zone_counts_fn) {
|
||||||
printk(KERN_ERR "Error: Unknown symbol get_zone_counts\n");
|
printk(KERN_ERR "Error: Unknown symbol get_zone_counts\n");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
# endif /* HAVE_GET_ZONE_COUNTS */
|
#endif /* NEED_GET_ZONE_COUNTS && !HAVE_GET_ZONE_COUNTS */
|
||||||
#endif /* HAVE_ZONE_STAT_ITEM_FIA */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It is now safe to initialize the global tunings which rely on
|
* It is now safe to initialize the global tunings which rely on
|
||||||
|
@ -1045,16 +1045,17 @@ splat_kmem_test11(struct file *file, void *arg)
|
|||||||
static int
|
static int
|
||||||
splat_kmem_test12(struct file *file, void *arg)
|
splat_kmem_test12(struct file *file, void *arg)
|
||||||
{
|
{
|
||||||
ssize_t alloc1, free1, total1;
|
size_t alloc1, free1, total1;
|
||||||
ssize_t alloc2, free2, total2;
|
size_t alloc2, free2, total2;
|
||||||
int size = 8*1024*1024;
|
int size = 8*1024*1024;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
alloc1 = vmem_size(NULL, VMEM_ALLOC);
|
alloc1 = vmem_size(NULL, VMEM_ALLOC);
|
||||||
free1 = vmem_size(NULL, VMEM_FREE);
|
free1 = vmem_size(NULL, VMEM_FREE);
|
||||||
total1 = vmem_size(NULL, VMEM_ALLOC | VMEM_FREE);
|
total1 = vmem_size(NULL, VMEM_ALLOC | VMEM_FREE);
|
||||||
splat_vprint(file, SPLAT_KMEM_TEST12_NAME, "Vmem alloc=%d free=%d "
|
splat_vprint(file, SPLAT_KMEM_TEST12_NAME, "Vmem alloc=%lu "
|
||||||
"total=%d\n", (int)alloc1, (int)free1, (int)total1);
|
"free=%lu total=%lu\n", (unsigned long)alloc1,
|
||||||
|
(unsigned long)free1, (unsigned long)total1);
|
||||||
|
|
||||||
splat_vprint(file, SPLAT_KMEM_TEST12_NAME, "Alloc %d bytes\n", size);
|
splat_vprint(file, SPLAT_KMEM_TEST12_NAME, "Alloc %d bytes\n", size);
|
||||||
ptr = vmem_alloc(size, KM_SLEEP);
|
ptr = vmem_alloc(size, KM_SLEEP);
|
||||||
@ -1067,42 +1068,44 @@ splat_kmem_test12(struct file *file, void *arg)
|
|||||||
alloc2 = vmem_size(NULL, VMEM_ALLOC);
|
alloc2 = vmem_size(NULL, VMEM_ALLOC);
|
||||||
free2 = vmem_size(NULL, VMEM_FREE);
|
free2 = vmem_size(NULL, VMEM_FREE);
|
||||||
total2 = vmem_size(NULL, VMEM_ALLOC | VMEM_FREE);
|
total2 = vmem_size(NULL, VMEM_ALLOC | VMEM_FREE);
|
||||||
splat_vprint(file, SPLAT_KMEM_TEST12_NAME, "Vmem alloc=%d free=%d "
|
splat_vprint(file, SPLAT_KMEM_TEST12_NAME, "Vmem alloc=%lu "
|
||||||
"total=%d\n", (int)alloc2, (int)free2, (int)total2);
|
"free=%lu total=%lu\n", (unsigned long)alloc2,
|
||||||
|
(unsigned long)free2, (unsigned long)total2);
|
||||||
|
|
||||||
splat_vprint(file, SPLAT_KMEM_TEST12_NAME, "Free %d bytes\n", size);
|
splat_vprint(file, SPLAT_KMEM_TEST12_NAME, "Free %d bytes\n", size);
|
||||||
vmem_free(ptr, size);
|
vmem_free(ptr, size);
|
||||||
if (alloc2 < (alloc1 + size - (size / 100)) ||
|
if (alloc2 < (alloc1 + size - (size / 100)) ||
|
||||||
alloc2 > (alloc1 + size + (size / 100))) {
|
alloc2 > (alloc1 + size + (size / 100))) {
|
||||||
splat_vprint(file, SPLAT_KMEM_TEST12_NAME,
|
splat_vprint(file, SPLAT_KMEM_TEST12_NAME, "Failed "
|
||||||
"Failed VMEM_ALLOC size: %d != %d+%d (+/- 1%%)\n",
|
"VMEM_ALLOC size: %lu != %lu+%d (+/- 1%%)\n",
|
||||||
(int)alloc2, (int)alloc1, size);
|
(unsigned long)alloc2,(unsigned long)alloc1,size);
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (free2 < (free1 - size - (size / 100)) ||
|
if (free2 < (free1 - size - (size / 100)) ||
|
||||||
free2 > (free1 - size + (size / 100))) {
|
free2 > (free1 - size + (size / 100))) {
|
||||||
splat_vprint(file, SPLAT_KMEM_TEST12_NAME,
|
splat_vprint(file, SPLAT_KMEM_TEST12_NAME, "Failed "
|
||||||
"Failed VMEM_FREE size: %d != %d-%d (+/- 1%%)\n",
|
"VMEM_FREE size: %lu != %lu-%d (+/- 1%%)\n",
|
||||||
(int)free2, (int)free1, size);
|
(unsigned long)free2, (unsigned long)free1, size);
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (total1 != total2) {
|
if (total1 != total2) {
|
||||||
splat_vprint(file, SPLAT_KMEM_TEST12_NAME,
|
splat_vprint(file, SPLAT_KMEM_TEST12_NAME, "Failed "
|
||||||
"Failed VMEM_ALLOC | VMEM_FREE not constant: "
|
"VMEM_ALLOC | VMEM_FREE not constant: "
|
||||||
"%d != %d\n", (int)total2, (int)total1);
|
"%lu != %lu\n", (unsigned long)total2,
|
||||||
|
(unsigned long)total1);
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
splat_vprint(file, SPLAT_KMEM_TEST12_NAME,
|
splat_vprint(file, SPLAT_KMEM_TEST12_NAME,
|
||||||
"VMEM_ALLOC within tolerance: ~%d%% (%d/%d)\n",
|
"VMEM_ALLOC within tolerance: ~%ld%% (%ld/%d)\n",
|
||||||
(int)(((alloc1 + size) - alloc2) * 100 / size),
|
(long)abs(alloc1 + (long)size - alloc2) * 100 / (long)size,
|
||||||
(int)((alloc1 + size) - alloc2), size);
|
(long)abs(alloc1 + (long)size - alloc2), size);
|
||||||
splat_vprint(file, SPLAT_KMEM_TEST12_NAME,
|
splat_vprint(file, SPLAT_KMEM_TEST12_NAME,
|
||||||
"VMEM_FREE within tolerance: ~%d%% (%d/%d)\n",
|
"VMEM_FREE within tolerance: ~%ld%% (%ld/%d)\n",
|
||||||
(int)(((free1 - size) - free2) * 100 / size),
|
(long)abs((free1 - (long)size) - free2) * 100 / (long)size,
|
||||||
(int)((free1 - size) - free2), size);
|
(long)abs((free1 - (long)size) - free2), size);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -159,8 +159,29 @@
|
|||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
#undef HAVE_UNISTD_H
|
#undef HAVE_UNISTD_H
|
||||||
|
|
||||||
/* free/inactive/active page state is available */
|
/* Page state NR_ACTIVE is available */
|
||||||
#undef HAVE_ZONE_STAT_ITEM_FIA
|
#undef HAVE_ZONE_STAT_ITEM_NR_ACTIVE
|
||||||
|
|
||||||
|
/* Page state NR_ACTIVE_ANON is available */
|
||||||
|
#undef HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON
|
||||||
|
|
||||||
|
/* Page state NR_ACTIVE_FILE is available */
|
||||||
|
#undef HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE
|
||||||
|
|
||||||
|
/* Page state NR_FREE_PAGES is available */
|
||||||
|
#undef HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES
|
||||||
|
|
||||||
|
/* Page state NR_INACTIVE is available */
|
||||||
|
#undef HAVE_ZONE_STAT_ITEM_NR_INACTIVE
|
||||||
|
|
||||||
|
/* Page state NR_INACTIVE_ANON is available */
|
||||||
|
#undef HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON
|
||||||
|
|
||||||
|
/* Page state NR_INACTIVE_FILE is available */
|
||||||
|
#undef HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE
|
||||||
|
|
||||||
|
/* get_zone_counts() is needed */
|
||||||
|
#undef NEED_GET_ZONE_COUNTS
|
||||||
|
|
||||||
/* Name of package */
|
/* Name of package */
|
||||||
#undef PACKAGE
|
#undef PACKAGE
|
||||||
|
Loading…
Reference in New Issue
Block a user