mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-18 02:20:59 +03:00
e11d6c5f50
In the interests of portability I have added a FC10/i686 box to my list of development platforms. The hope is this will allow me to keep current with upstream kernel API changes, and at the same time ensure I don't accidentally break x86 support. This patch resolves all remaining issues observed under that environment. 1) SPL_AC_ZONE_STAT_ITEM_FIA autoconf check added. As of 2.6.21 the kernel added a clean API for modules to get the global count for free, inactive, and active pages. The SPL attempts to detect if this API is available and directly map spl_global_page_state() to global_page_state(). If the full API is not available then spl_global_page_state() is implemented as a thin layer to get these values via get_zone_counts() if that symbol is available. 2) New kmem:vmem_size regression test added to validate correct vmem_size() functionality. The test case acquires the current global vmem state, allocates from the vmem region, then verifies the allocation is correctly reflected in the vmem_size() stats. 3) Change splat_kmem_cache_thread_test() to always use KMC_KMEM based memory. On x86 systems with limited virtual address space failures resulted due to exhaustig the address space. The tests really need to problem exhausting all memory on the system thus we need to use the physical address space. 4) Change kmem:slab_lock to cap it's memory usage at availrmem instead of using the native linux nr_free_pages(). This provides additional test coverage of the SPL Linux VM integration. 5) Change kmem:slab_overcommit to perform allocation of 256K instead of 1M. On x86 based systems it is not possible to create a kmem backed slab with entires of that size. To compensate for this the number of allocations performed in increased by 4x. 6) Additional autoconf documentation for proposed upstream API changes to make additional symbols available to modules. 7) Console error messages added when spl_kallsyms_lookup_name() fails to locate an expected symbol. This causes the module to fail to load and we need to know exactly which symbol was not available.
179 lines
5.6 KiB
C
179 lines
5.6 KiB
C
/*
|
|
* This file is part of the SPL: Solaris Porting Layer.
|
|
*
|
|
* Copyright (c) 2008 Lawrence Livermore National Security, LLC.
|
|
* Produced at Lawrence Livermore National Laboratory
|
|
* Written by:
|
|
* Brian Behlendorf <behlendorf1@llnl.gov>,
|
|
* Herb Wartens <wartens2@llnl.gov>,
|
|
* Jim Garlick <garlick@llnl.gov>
|
|
* UCRL-CODE-235197
|
|
*
|
|
* This is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
* for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*/
|
|
|
|
#ifndef _SPL_VMSYSTM_H
|
|
#define _SPL_VMSYSTM_H
|
|
|
|
#include <linux/mmzone.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/swap.h>
|
|
#include <linux/highmem.h>
|
|
#include <sys/types.h>
|
|
#include <asm/uaccess.h>
|
|
|
|
/* These values are loosely coupled with the VM page reclaim.
|
|
* Linux uses its own heuristics to trigger page reclamation, and
|
|
* because those interface are difficult to interface with. These
|
|
* values should only be considered as a rough guide to the system
|
|
* memory state and not as direct evidence that page reclamation.
|
|
* is or is not currently in progress.
|
|
*/
|
|
#define membar_producer() smp_wmb()
|
|
|
|
#define physmem num_physpages
|
|
#define freemem nr_free_pages()
|
|
#define availrmem spl_kmem_availrmem()
|
|
|
|
extern pgcnt_t minfree; /* Sum of zone->pages_min */
|
|
extern pgcnt_t desfree; /* Sum of zone->pages_low */
|
|
extern pgcnt_t lotsfree; /* Sum of zone->pages_high */
|
|
extern pgcnt_t needfree; /* Always 0 unused in new Solaris */
|
|
extern pgcnt_t swapfs_minfree; /* Solaris default value */
|
|
extern pgcnt_t swapfs_reserve; /* Solaris default value */
|
|
|
|
extern vmem_t *heap_arena; /* primary kernel heap arena */
|
|
extern vmem_t *zio_alloc_arena; /* arena for zio caches */
|
|
extern vmem_t *zio_arena; /* arena for allocating zio memory */
|
|
|
|
extern pgcnt_t spl_kmem_availrmem(void);
|
|
extern size_t vmem_size(vmem_t *vmp, int typemask);
|
|
|
|
/*
|
|
* The following symbols are available for use within the kernel
|
|
* itself, and they used to be available in older kernels. But it
|
|
* looks like they have been removed perhaps due to lack of use.
|
|
* For our purposes we need them to access the global memory state
|
|
* of the system, which is even available to user space process
|
|
* in /proc/meminfo. It's odd to me that there is no kernel API
|
|
* to get the same information, minimally the proc handler for
|
|
* the above mentioned /proc/meminfo file would make use of it.
|
|
*/
|
|
|
|
/* Source linux/fs/proc/mmu.c */
|
|
#ifndef HAVE_GET_VMALLOC_INFO
|
|
#ifdef CONFIG_MMU
|
|
|
|
struct vmalloc_info {
|
|
unsigned long used;
|
|
unsigned long largest_chunk;
|
|
};
|
|
|
|
typedef void (*get_vmalloc_info_t)(struct vmalloc_info *);
|
|
extern get_vmalloc_info_t get_vmalloc_info_fn;
|
|
|
|
# define VMEM_ALLOC 0x01
|
|
# define VMEM_FREE 0x02
|
|
# define VMALLOC_TOTAL (VMALLOC_END - VMALLOC_START)
|
|
# define get_vmalloc_info(vmi) get_vmalloc_info_fn(vmi)
|
|
#else
|
|
# error "CONFIG_MMU must be defined"
|
|
#endif /* CONFIG_MMU */
|
|
#endif /* HAVE_GET_VMALLOC_INFO */
|
|
|
|
/* Source linux/mm/mmzone.c */
|
|
#ifndef HAVE_FIRST_ONLINE_PGDAT
|
|
typedef struct pglist_data *(*first_online_pgdat_t)(void);
|
|
extern first_online_pgdat_t first_online_pgdat_fn;
|
|
#define first_online_pgdat() first_online_pgdat_fn()
|
|
#endif /* HAVE_FIRST_ONLINE_PGDAT */
|
|
|
|
/* Source linux/mm/mmzone.c */
|
|
#ifndef HAVE_NEXT_ONLINE_PGDAT
|
|
typedef struct pglist_data *(*next_online_pgdat_t)(struct pglist_data *);
|
|
extern next_online_pgdat_t next_online_pgdat_fn;
|
|
#define next_online_pgdat(pgd) next_online_pgdat_fn(pgd)
|
|
#endif /* HAVE_NEXT_ONLINE_PGDAT */
|
|
|
|
/* Source linux/mm/mmzone.c */
|
|
#ifndef HAVE_NEXT_ZONE
|
|
typedef struct zone *(*next_zone_t)(struct zone *);
|
|
extern next_zone_t next_zone_fn;
|
|
#define next_zone(zone) next_zone_fn(zone)
|
|
#endif /* HAVE_NEXT_ZONE */
|
|
|
|
/* Source linux/mm/vmstat.c */
|
|
#ifndef HAVE_ZONE_STAT_ITEM_FIA
|
|
# ifndef HAVE_GET_ZONE_COUNTS
|
|
typedef void (*get_zone_counts_t)(unsigned long *, unsigned long *,
|
|
unsigned long *);
|
|
extern get_zone_counts_t get_zone_counts_fn;
|
|
# define get_zone_counts(a,i,f) get_zone_counts_fn(a,i,f)
|
|
|
|
extern unsigned long spl_global_page_state(int);
|
|
/* Defines designed to simulate enum but large enough to ensure no overlap */
|
|
# define NR_FREE_PAGES 0x8001
|
|
# define NR_INACTIVE 0x8002
|
|
# define NR_ACTIVE 0x8003
|
|
# else
|
|
# error "HAVE_ZONE_STAT_ITEM_FIA and HAVE_GET_ZONE_COUNTS unavailable"
|
|
# endif /* HAVE_GET_ZONE_COUNTS */
|
|
#else
|
|
#define spl_global_page_state(item) global_page_state(item)
|
|
#endif /* HAVE_ZONE_STAT_ITEM_FIA */
|
|
|
|
#define xcopyin(from, to, size) copy_from_user(to, from, size)
|
|
#define xcopyout(from, to, size) copy_to_user(to, from, size)
|
|
|
|
static __inline__ int
|
|
copyin(const void *from, void *to, size_t len)
|
|
{
|
|
/* On error copyin routine returns -1 */
|
|
if (xcopyin(from, to, len))
|
|
return -1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static __inline__ int
|
|
copyout(const void *from, void *to, size_t len)
|
|
{
|
|
/* On error copyout routine returns -1 */
|
|
if (xcopyout(from, to, len))
|
|
return -1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static __inline__ int
|
|
copyinstr(const void *from, void *to, size_t len, size_t *done)
|
|
{
|
|
size_t rc;
|
|
|
|
if (len == 0)
|
|
return -ENAMETOOLONG;
|
|
|
|
/* XXX: Should return ENAMETOOLONG if 'strlen(from) > len' */
|
|
|
|
memset(to, 0, len);
|
|
rc = copyin(from, to, len - 1);
|
|
if (done != NULL)
|
|
*done = rc;
|
|
|
|
return 0;
|
|
}
|
|
|
|
#endif /* SPL_VMSYSTM_H */
|