Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Nov 2017 13:09:07 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r325588 - head/sys/x86/iommu
Message-ID:  <201711091309.vA9D977J080409@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Nov  9 13:09:07 2017
New Revision: 325588
URL: https://svnweb.freebsd.org/changeset/base/325588

Log:
  Correct operators precedence.
  Also keep the calculated vm_page_alloc_contig() flags in the variable
  to not re-evaluate it on the loop iteration.
  
  Noted by:	alc
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/x86/iommu/intel_utils.c

Modified: head/sys/x86/iommu/intel_utils.c
==============================================================================
--- head/sys/x86/iommu/intel_utils.c	Thu Nov  9 12:39:26 2017	(r325587)
+++ head/sys/x86/iommu/intel_utils.c	Thu Nov  9 13:09:07 2017	(r325588)
@@ -257,9 +257,12 @@ vm_page_t
 dmar_pgalloc(vm_object_t obj, vm_pindex_t idx, int flags)
 {
 	vm_page_t m;
-	int zeroed;
+	int zeroed, aflags;
 
 	zeroed = (flags & DMAR_PGF_ZERO) != 0 ? VM_ALLOC_ZERO : 0;
+	aflags = zeroed | VM_ALLOC_NOBUSY | VM_ALLOC_SYSTEM | VM_ALLOC_NODUMP |
+	    ((flags & DMAR_PGF_WAITOK) != 0 ? VM_ALLOC_WAITFAIL :
+	    VM_ALLOC_NOWAIT);
 	for (;;) {
 		if ((flags & DMAR_PGF_OBJL) == 0)
 			VM_OBJECT_WLOCK(obj);
@@ -269,10 +272,7 @@ dmar_pgalloc(vm_object_t obj, vm_pindex_t idx, int fla
 				VM_OBJECT_WUNLOCK(obj);
 			break;
 		}
-		m = vm_page_alloc_contig(obj, idx, VM_ALLOC_NOBUSY |
-		    VM_ALLOC_SYSTEM | VM_ALLOC_NODUMP | zeroed |
-		    (flags & DMAR_PGF_WAITOK) ?
-		    VM_ALLOC_WAITFAIL : VM_ALLOC_NOWAIT, 1, 0,
+		m = vm_page_alloc_contig(obj, idx, aflags, 1, 0,
 		    dmar_high, PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
 		if ((flags & DMAR_PGF_OBJL) == 0)
 			VM_OBJECT_WUNLOCK(obj);



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