svn commit: r243631 - in head/sys: kern sys

Andre Oppermann andre at freebsd.org
Fri Jan 18 19:57:39 UTC 2013


On 14.01.2013 16:00, Andre Oppermann wrote:
> On 13.01.2013 11:10, Alan Cox wrote:
>> 3. The function vm_ksubmap_init() has a dependency on the global
>> variable maxpipekva.  vm_ksubmap_init() is executed under SI_SUB_CPU,
>> which comes after SI_SUB_KMEM.
>>
>> Am I missing anything?
>>
>> I'm attaching a patch that defers the calculation of maxpipekva until we
>> actually need it in vm_ksubmap_init().  Any comments on this patch are
>> welcome.
>
> Looks good to me.  Perhaps the whole calculation and setup of the pipe_map
> could be moved to kern/sys_pipe.c:pipeinit() to have it all together.

Attached is a patch moving the whole calculation and pipe_map creation
to kern/sys_pipe.c.

-- 
Andre

Index: vm/vm_kern.c
===================================================================
--- vm/vm_kern.c	(revision 245601)
+++ vm/vm_kern.c	(working copy)
@@ -88,7 +88,6 @@
  vm_map_t kernel_map=0;
  vm_map_t kmem_map=0;
  vm_map_t exec_map=0;
-vm_map_t pipe_map;
  vm_map_t buffer_map=0;

  const void *zero_region;
Index: vm/vm_kern.h
===================================================================
--- vm/vm_kern.h	(revision 245601)
+++ vm/vm_kern.h	(working copy)
@@ -68,7 +68,6 @@
  extern vm_map_t kernel_map;
  extern vm_map_t kmem_map;
  extern vm_map_t exec_map;
-extern vm_map_t pipe_map;
  extern u_long vm_kmem_size;

  #endif				/* _VM_VM_KERN_H_ */
Index: vm/vm_init.c
===================================================================
--- vm/vm_init.c	(revision 245601)
+++ vm/vm_init.c	(working copy)
@@ -73,7 +73,6 @@
  #include <sys/sysctl.h>
  #include <sys/systm.h>
  #include <sys/selinfo.h>
-#include <sys/pipe.h>
  #include <sys/bio.h>
  #include <sys/buf.h>

@@ -195,8 +194,6 @@
  	pager_map->system_map = 1;
  	exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr,
  	    exec_map_entries * round_page(PATH_MAX + ARG_MAX), FALSE);
-	pipe_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, maxpipekva,
-	    FALSE);

  	/*
  	 * XXX: Mbuf system machine-specific initializations should
Index: sys/pipe.h
===================================================================
--- sys/pipe.h	(revision 245601)
+++ sys/pipe.h	(working copy)
@@ -53,10 +53,6 @@

  #define PIPENPAGES	(BIG_PIPE_SIZE / PAGE_SIZE + 1)

-/*
- * See sys_pipe.c for info on what these limits mean.
- */
-extern long	maxpipekva;
  extern struct	fileops pipeops;

  /*
Index: kern/subr_param.c
===================================================================
--- kern/subr_param.c	(revision 245601)
+++ kern/subr_param.c	(working copy)
@@ -96,7 +96,6 @@
  pid_t	pid_max = PID_MAX;
  long	maxswzone;			/* max swmeta KVA storage */
  long	maxbcache;			/* max buffer cache KVA storage */
-long	maxpipekva;			/* Limit on pipe KVA */
  int 	vm_guest;			/* Running as virtual machine guest? */
  u_long	maxtsiz;			/* max text size */
  u_long	dfldsiz;			/* initial data size limit */
@@ -330,18 +329,6 @@
  	 */
  	ncallout = imin(16 + maxproc + maxfiles, 18508);
  	TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
-
-	/*
-	 * The default for maxpipekva is min(1/64 of the kernel address space,
-	 * max(1/64 of main memory, 512KB)).  See sys_pipe.c for more details.
-	 */
-	maxpipekva = (physpages / 64) * PAGE_SIZE;
-	TUNABLE_LONG_FETCH("kern.ipc.maxpipekva", &maxpipekva);
-	if (maxpipekva < 512 * 1024)
-		maxpipekva = 512 * 1024;
-	if (maxpipekva > (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / 64)
-		maxpipekva = (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) /
-		    64;
  }

  /*
Index: kern/sys_pipe.c
===================================================================
--- kern/sys_pipe.c	(revision 245601)
+++ kern/sys_pipe.c	(working copy)
@@ -202,6 +202,7 @@
  #define MAXPIPESIZE (2*PIPE_SIZE/3)

  static long amountpipekva;
+static long maxpipekva;
  static int pipefragretry;
  static int pipeallocfail;
  static int piperesizefail;
@@ -220,7 +221,6 @@
  SYSCTL_INT(_kern_ipc, OID_AUTO, piperesizeallowed, CTLFLAG_RW,
  	  &piperesizeallowed, 0, "Pipe resizing allowed");

-static void pipeinit(void *dummy __unused);
  static void pipeclose(struct pipe *cpipe);
  static void pipe_free_kmem(struct pipe *cpipe);
  static int pipe_create(struct pipe *pipe, int backing);
@@ -244,12 +244,29 @@
  static struct unrhdr *pipeino_unr;
  static dev_t pipedev_ino;

-SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_ANY, pipeinit, NULL);
+static vm_map_t	pipe_map;

+/*
+ * Set up the kmem suballocation and UMA zone for the pipe memory.
+ */
  static void
  pipeinit(void *dummy __unused)
  {
+	quad_t realkmem;
+	vm_offset_t minaddr, maxaddr;

+	realkmem = qmin((quad_t)physmem * PAGE_SIZE,
+	    vm_map_max(kernel_map) - vm_map_min(kernel_map));
+
+	maxpipekva = realkmem / 64;
+	TUNABLE_LONG_FETCH("kern.ipc.maxpipekva", &maxpipekva);
+	if (maxpipekva > realmem / 64)
+		maxpipekva = realkmem / 64;
+	if (maxpipekva < 512 * 1024)
+		maxpipekva = 512 * 1024;
+ 	pipe_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, maxpipekva,
+	    FALSE);
+
  	pipe_zone = uma_zcreate("pipe", sizeof(struct pipepair),
  	    pipe_zone_ctor, NULL, pipe_zone_init, pipe_zone_fini,
  	    UMA_ALIGN_PTR, 0);
@@ -259,6 +276,7 @@
  	pipedev_ino = devfs_alloc_cdp_inode();
  	KASSERT(pipedev_ino > 0, ("pipe dev inode not initialized"));
  }
+SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_ANY, pipeinit, NULL);

  static int
  pipe_zone_ctor(void *mem, int size, void *arg, int flags)


More information about the svn-src-all mailing list