Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Jan 2013 20:57:30 +0100
From:      Andre Oppermann <andre@freebsd.org>
To:        Alan Cox <alc@rice.edu>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r243631 - in head/sys: kern sys
Message-ID:  <50F9A92A.9040706@freebsd.org>
In-Reply-To: <50F41DA3.8060300@freebsd.org>
References:  <201211272119.qARLJxXV061083@svn.freebsd.org> <ABB3E29B-91F3-4C25-8FAB-869BBD7459E1@bluezbox.com> <50C1BC90.90106@freebsd.org> <50C25A27.4060007@bluezbox.com> <50C26331.6030504@freebsd.org> <50C26AE9.4020600@bluezbox.com> <50C3A3D3.9000804@freebsd.org> <50C3AF72.4010902@rice.edu> <330405A1-312A-45A5-BB86-4969478D8BBD@bluezbox.com> <50D03E83.8060908@rice.edu> <50DD081E.8000409@bluezbox.com> <50EB1841.5030006@bluezbox.com> <50F28806.10505@rice.edu> <50F41DA3.8060300@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50F9A92A.9040706>