2008-05-26 08:38:26 +04:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2008-03-05 03:58:54 +03:00
|
|
|
#ifndef _SPL_VMSYSTM_H
|
|
|
|
#define _SPL_VMSYSTM_H
|
|
|
|
|
2009-02-05 02:15:41 +03:00
|
|
|
#include <linux/mmzone.h>
|
2008-03-05 03:58:54 +03:00
|
|
|
#include <linux/mm.h>
|
2008-05-16 03:39:19 +04:00
|
|
|
#include <linux/swap.h>
|
2008-03-14 03:04:01 +03:00
|
|
|
#include <sys/types.h>
|
2008-03-15 03:05:38 +03:00
|
|
|
#include <asm/uaccess.h>
|
2008-03-14 03:04:01 +03:00
|
|
|
|
2009-02-05 02:15:41 +03:00
|
|
|
/* These values are loosely coupled with the 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 reclaimation
|
|
|
|
* is or is not currently in progress.
|
|
|
|
*/
|
|
|
|
#define ptob(pages) (pages * PAGE_SIZE)
|
|
|
|
#define membar_producer() smp_wmb()
|
2008-03-05 03:58:54 +03:00
|
|
|
|
|
|
|
#define physmem num_physpages
|
2009-01-31 07:54:49 +03:00
|
|
|
#define freemem nr_free_pages()
|
2009-02-05 02:15:41 +03:00
|
|
|
|
|
|
|
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 */
|
|
|
|
extern pgcnt_t swapfs_minfree;
|
|
|
|
extern pgcnt_t swapfs_desfree;
|
|
|
|
extern pgcnt_t swapfs_reserve;
|
|
|
|
extern pgcnt_t availrmem;
|
|
|
|
|
|
|
|
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 */
|
|
|
|
|
|
|
|
#define VMEM_ALLOC 0x01
|
|
|
|
#define VMEM_FREE 0x02
|
|
|
|
|
|
|
|
static __inline__ size_t
|
|
|
|
vmem_size(vmem_t *vmp, int typemask)
|
|
|
|
{
|
|
|
|
/* Arena's unsupported */
|
|
|
|
ASSERT(vmp == NULL);
|
|
|
|
ASSERT(typemask & (VMEM_ALLOC | VMEM_FREE));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-03-07 02:12:55 +03:00
|
|
|
|
2008-03-15 03:05:38 +03:00
|
|
|
#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)
|
|
|
|
{
|
2008-04-01 21:00:06 +04:00
|
|
|
size_t rc;
|
|
|
|
|
2008-03-15 03:05:38 +03:00
|
|
|
if (len == 0)
|
|
|
|
return -ENAMETOOLONG;
|
|
|
|
|
|
|
|
/* XXX: Should return ENAMETOOLONG if 'strlen(from) > len' */
|
|
|
|
|
|
|
|
memset(to, 0, len);
|
2008-04-01 21:00:06 +04:00
|
|
|
rc = copyin(from, to, len - 1);
|
|
|
|
if (done != NULL)
|
|
|
|
*done = rc;
|
2008-03-15 03:05:38 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-03-13 00:33:28 +03:00
|
|
|
|
2008-03-05 03:58:54 +03:00
|
|
|
#endif /* SPL_VMSYSTM_H */
|