Move the ZERO_REGION_SIZE to a machine-dependent file, as on many

architectures (i386, for example) the virtual memory space may be
constrained enough that 2MB is a large chunk.  Use 64K for arches
other than amd64 and ia64, with special handling for sparc64 due to
differing hardware.

Also commit the comment changes to kmem_init_zero_region() that I
missed due to not saving the file.  (Darn the unfamiliar development
environment).

Arch maintainers, please feel free to adjust ZERO_REGION_SIZE as you
see fit.

Requested by:	alc
MFC after:	1 week
MFC with:	r221853
This commit is contained in:
Matthew D Fleming 2011-05-13 19:35:01 +00:00
parent 89cb2a19ec
commit cfb00e5aa7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=221855
12 changed files with 32 additions and 10 deletions

View File

@ -212,4 +212,6 @@
#define VM_INITIAL_PAGEIN 16
#endif
#define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */
#endif /* _MACHINE_VMPARAM_H_ */

View File

@ -150,4 +150,7 @@
#ifdef ARM_USE_SMALL_ALLOC
#define UMA_MD_SMALL_ALLOC
#endif /* ARM_USE_SMALL_ALLOC */
#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
#endif /* _MACHINE_VMPARAM_H_ */

View File

@ -89,6 +89,8 @@
#include <vm/swap_pager.h>
#include <vm/uma.h>
#include <machine/vmparam.h>
#define MD_MODVER 1
#define MD_SHUTDOWN 0x10000 /* Tell worker thread to terminate. */

View File

@ -39,7 +39,9 @@ __FBSDID("$FreeBSD$");
#include <sys/priv.h>
#include <sys/disk.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <machine/vmparam.h>
/* For use with destroy_dev(9). */
static struct cdev *null_dev;

View File

@ -198,4 +198,6 @@
#define VM_INITIAL_PAGEIN 16
#endif
#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
#endif /* _MACHINE_VMPARAM_H_ */

View File

@ -215,4 +215,6 @@
#define VM_INITIAL_PAGEIN 16
#endif
#define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */
#endif /* !_MACHINE_VMPARAM_H_ */

View File

@ -187,4 +187,6 @@
*/
#define VM_NFREEORDER 9
#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
#endif /* !_MACHINE_VMPARAM_H_ */

View File

@ -198,4 +198,6 @@ struct pmap_physseg {
#endif
#endif
#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
#endif /* _MACHINE_VMPARAM_H_ */

View File

@ -240,4 +240,11 @@
extern vm_offset_t vm_max_kernel_address;
/*
* Older sparc64 machines have a virtually indexed L1 data cache of 16KB.
* Consequently, mapping the same physical page multiple times may have
* caching disabled.
*/
#define ZERO_REGION_SIZE PAGE_SIZE
#endif /* !_MACHINE_VMPARAM_H_ */

View File

@ -223,4 +223,6 @@
#define UMA_MD_SMALL_ALLOC
extern vm_offset_t vm_max_kernel_address;
#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
#endif /* !_MACHINE_VMPARAM_H_ */

View File

@ -126,7 +126,6 @@ extern char static_hints[]; /* by config for now */
extern char **kenvp;
extern const void *zero_region; /* address space maps to a zeroed page */
#define ZERO_REGION_SIZE (2048 * 1024)
/*
* General function declarations.

View File

@ -533,25 +533,22 @@ kmem_free_wakeup(map, addr, size)
static void
kmem_init_zero_region(void)
{
vm_offset_t addr;
vm_offset_t addr, i;
vm_page_t m;
unsigned int i;
int error;
/* Allocate virtual address space. */
/*
* Map a single physical page of zeros to a larger virtual range.
* This requires less looping in places that want large amounts of
* zeros, while not using much more physical resources.
*/
addr = kmem_alloc_nofault(kernel_map, ZERO_REGION_SIZE);
/* Allocate a page and zero it. */
m = vm_page_alloc(NULL, OFF_TO_IDX(addr - VM_MIN_KERNEL_ADDRESS),
VM_ALLOC_NOOBJ | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
if ((m->flags & PG_ZERO) == 0)
pmap_zero_page(m);
/* Map the address space to the page. */
for (i = 0; i < ZERO_REGION_SIZE; i += PAGE_SIZE)
pmap_qenter(addr + i, &m, 1);
/* Protect it r/o. */
error = vm_map_protect(kernel_map, addr, addr + ZERO_REGION_SIZE,
VM_PROT_READ, TRUE);
KASSERT(error == 0, ("error=%d", error));