Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Nov 2013 17:46:11 +0000 (UTC)
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r258056 - head/sys/kern
Message-ID:  <201311121746.rACHkBCZ040342@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alc
Date: Tue Nov 12 17:46:11 2013
New Revision: 258056
URL: http://svnweb.freebsd.org/changeset/base/258056

Log:
  Eliminate the gratuitous use of mmap(2) flags from the implementation
  of kern_shmat().  Use a simpler approach to determine whether to pass
  VMFS_NO_SPACE or VMFS_OPTIMAL_SPACE to vm_map_find().

Modified:
  head/sys/kern/sysv_shm.c

Modified: head/sys/kern/sysv_shm.c
==============================================================================
--- head/sys/kern/sysv_shm.c	Tue Nov 12 17:44:29 2013	(r258055)
+++ head/sys/kern/sysv_shm.c	Tue Nov 12 17:46:11 2013	(r258056)
@@ -342,7 +342,7 @@ kern_shmat(td, shmid, shmaddr, shmflg)
 	int shmflg;
 {
 	struct proc *p = td->td_proc;
-	int i, flags;
+	int i;
 	struct shmid_kernel *shmseg;
 	struct shmmap_state *shmmap_s = NULL;
 	vm_offset_t attach_va;
@@ -389,9 +389,7 @@ kern_shmat(td, shmid, shmaddr, shmflg)
 	prot = VM_PROT_READ;
 	if ((shmflg & SHM_RDONLY) == 0)
 		prot |= VM_PROT_WRITE;
-	flags = MAP_ANON | MAP_SHARED;
 	if (shmaddr) {
-		flags |= MAP_FIXED;
 		if (shmflg & SHM_RND) {
 			attach_va = (vm_offset_t)shmaddr & ~(SHMLBA-1);
 		} else if (((vm_offset_t)shmaddr & (SHMLBA-1)) == 0) {
@@ -413,7 +411,7 @@ kern_shmat(td, shmid, shmaddr, shmflg)
 
 	vm_object_reference(shmseg->object);
 	rv = vm_map_find(&p->p_vmspace->vm_map, shmseg->object,
-	    0, &attach_va, size, 0, (flags & MAP_FIXED) ? VMFS_NO_SPACE :
+	    0, &attach_va, size, 0, shmaddr != NULL ? VMFS_NO_SPACE :
 	    VMFS_OPTIMAL_SPACE, prot, prot, MAP_INHERIT_SHARE);
 	if (rv != KERN_SUCCESS) {
 		vm_object_deallocate(shmseg->object);



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