lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Mon,  9 Jul 2012 18:12:41 +0800
From:	Wanpeng Li <liwp.linux@...il.com>
To:	linux-mm@...ck.org
Cc:	Michal Hocko <mhocko@...e.cz>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
	Mel Gorman <mel@....ul.ie>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org, Wanpeng Li <liwp.linux@...il.com>
Subject: [PATCH] mm/hugetlb: split out is_hugetlb_entry_migration_or_hwpoison

From: Wanpeng Li <liwp@...ux.vnet.ibm.com>

Code was duplicated in two functions, clean it up.

Signed-off-by: Wanpeng Li <liwp.linux@...il.com>
---
 mm/hugetlb.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index e198831..4f9ce3f 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2282,30 +2282,28 @@ nomem:
 	return -ENOMEM;
 }
 
-static int is_hugetlb_entry_migration(pte_t pte)
+static int is_hugetlb_entry_migration_or_hwpoison(pte_t pte, bool migration)
 {
 	swp_entry_t swp;
 
 	if (huge_pte_none(pte) || pte_present(pte))
 		return 0;
 	swp = pte_to_swp_entry(pte);
-	if (non_swap_entry(swp) && is_migration_entry(swp))
+	if (non_swap_entry(pte) && ((migration && is_migration_entry(pte))
+				|| !migration && is_hwpoison_entry(pte)))
 		return 1;
 	else
 		return 0;
 }
 
-static int is_hugetlb_entry_hwpoisoned(pte_t pte)
+static int is_hugetlb_entry_migration(pte_t pte)
 {
-	swp_entry_t swp;
+	return is_hugetlb_entry_migration_or_hwpoison(pte, true);
+}
 
-	if (huge_pte_none(pte) || pte_present(pte))
-		return 0;
-	swp = pte_to_swp_entry(pte);
-	if (non_swap_entry(swp) && is_hwpoison_entry(swp))
-		return 1;
-	else
-		return 0;
+static int is_hugetlb_entry_hwpoisoned(pte_t pte)
+{
+	return is_hugetlb_entry_migration_or_hwpoison(pte, false);
 }
 
 void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ