Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Jun 2020 21:34:39 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r362739 - in head/sys: compat/linuxkpi/common/src dev/md
Message-ID:  <202006282134.05SLYdfL040142@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Sun Jun 28 21:34:38 2020
New Revision: 362739
URL: https://svnweb.freebsd.org/changeset/base/362739

Log:
  Remove some redundant assignments and computations.
  
  Reported by:	alc
  Reviewed by:	alc, kib
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D25400

Modified:
  head/sys/compat/linuxkpi/common/src/linux_page.c
  head/sys/dev/md/md.c

Modified: head/sys/compat/linuxkpi/common/src/linux_page.c
==============================================================================
--- head/sys/compat/linuxkpi/common/src/linux_page.c	Sun Jun 28 21:33:08 2020	(r362738)
+++ head/sys/compat/linuxkpi/common/src/linux_page.c	Sun Jun 28 21:34:38 2020	(r362739)
@@ -199,7 +199,7 @@ linux_get_user_pages_internal(vm_map_t map, unsigned l
 	int count;
 
 	prot = write ? (VM_PROT_READ | VM_PROT_WRITE) : VM_PROT_READ;
-	len = ((size_t)nr_pages) << PAGE_SHIFT;
+	len = ptoa((vm_offset_t)nr_pages);
 	count = vm_fault_quick_hold_pages(map, start, len, prot, pages, nr_pages);
 	return (count == -1 ? -EFAULT : nr_pages);
 }
@@ -219,9 +219,8 @@ __get_user_pages_fast(unsigned long start, int nr_page
 		return (0);
 
 	MPASS(pages != NULL);
-	va = start;
 	map = &curthread->td_proc->p_vmspace->vm_map;
-	end = start + (((size_t)nr_pages) << PAGE_SHIFT);
+	end = start + ptoa((vm_offset_t)nr_pages);
 	if (!vm_map_range_valid(map, start, end))
 		return (-EINVAL);
 	prot = write ? (VM_PROT_READ | VM_PROT_WRITE) : VM_PROT_READ;

Modified: head/sys/dev/md/md.c
==============================================================================
--- head/sys/dev/md/md.c	Sun Jun 28 21:33:08 2020	(r362738)
+++ head/sys/dev/md/md.c	Sun Jun 28 21:34:38 2020	(r362739)
@@ -1561,8 +1561,8 @@ mdresize(struct md_s *sc, struct md_req *mdr)
 		if (mdr->md_mediasize <= 0 ||
 		    (mdr->md_mediasize % PAGE_SIZE) != 0)
 			return (EDOM);
-		oldpages = OFF_TO_IDX(round_page(sc->mediasize));
-		newpages = OFF_TO_IDX(round_page(mdr->md_mediasize));
+		oldpages = OFF_TO_IDX(sc->mediasize);
+		newpages = OFF_TO_IDX(mdr->md_mediasize);
 		if (newpages < oldpages) {
 			VM_OBJECT_WLOCK(sc->object);
 			vm_object_page_remove(sc->object, newpages, 0, 0);



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