linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfio/type1: avoid redundant PageReserved checking
@ 2019-08-27 12:49 Ben Luo
  2019-08-27 18:40 ` Alex Williamson
  0 siblings, 1 reply; 9+ messages in thread
From: Ben Luo @ 2019-08-27 12:49 UTC (permalink / raw)
  To: alex.williamson, cohuck; +Cc: linux-kernel

currently, if the page is not a tail of compound page, it will be
checked twice for the same thing.

Signed-off-by: Ben Luo <luoben@linux.alibaba.com>
---
 drivers/vfio/vfio_iommu_type1.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 054391f..cbe0d88 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -291,11 +291,10 @@ static int vfio_lock_acct(struct vfio_dma *dma, long npage, bool async)
 static bool is_invalid_reserved_pfn(unsigned long pfn)
 {
 	if (pfn_valid(pfn)) {
-		bool reserved;
 		struct page *tail = pfn_to_page(pfn);
 		struct page *head = compound_head(tail);
-		reserved = !!(PageReserved(head));
 		if (head != tail) {
+			bool reserved = !!(PageReserved(head));
 			/*
 			 * "head" is not a dangling pointer
 			 * (compound_head takes care of that)
@@ -310,7 +309,7 @@ static bool is_invalid_reserved_pfn(unsigned long pfn)
 			if (PageTail(tail))
 				return reserved;
 		}
-		return PageReserved(tail);
+		return !!(PageReserved(tail));
 	}
 
 	return true;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-09-30 23:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27 12:49 [PATCH] vfio/type1: avoid redundant PageReserved checking Ben Luo
2019-08-27 18:40 ` Alex Williamson
2019-08-28  4:28   ` [PATCH v2] " Ben Luo
2019-08-28 15:55     ` Alex Williamson
2019-08-29 16:58       ` Ben Luo
2019-08-29 17:06         ` Alex Williamson
2019-09-02  7:58           ` Ben Luo
     [not found]           ` <5c9c57ba-ca5f-f080-3bb0-417a08788235@linux.alibaba.com>
2019-09-13 18:05             ` Alex Williamson
2019-09-30 23:35               ` Andrea Arcangeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).