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]
Message-Id: <1a7c81db42986a6fa27260fe189890bffc8a9cce.1440665740.git.jstancek@redhat.com>
Date:	Thu, 27 Aug 2015 16:43:49 +0200
From:	Jan Stancek <jstancek@...hat.com>
To:	gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org
Cc:	jstancek@...hat.com
Subject: [PATCH 1/2] drivers/base/node.c: split loop in register_mem_sect_under_node

Split single loop going over all pfn in mem_blk into 2 loops,
where outer loop goes over all sections and inner loop goes over
pfn from that section.

This is preparatory patch for next patch:
  "skip non-present sections in register_mem_sect_under_node"

Signed-off-by: Jan Stancek <jstancek@...hat.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
 drivers/base/node.c | 41 ++++++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/drivers/base/node.c b/drivers/base/node.c
index 31df474d72f4..4c7423a4b5f4 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -379,33 +379,40 @@ static int __init_refok get_nid_for_pfn(unsigned long pfn)
 int register_mem_sect_under_node(struct memory_block *mem_blk, int nid)
 {
 	int ret;
-	unsigned long pfn, sect_start_pfn, sect_end_pfn;
+	unsigned long pfn, sect_start_pfn, sect_end_pfn, sect_no;
 
 	if (!mem_blk)
 		return -EFAULT;
 	if (!node_online(nid))
 		return 0;
 
-	sect_start_pfn = section_nr_to_pfn(mem_blk->start_section_nr);
-	sect_end_pfn = section_nr_to_pfn(mem_blk->end_section_nr);
-	sect_end_pfn += PAGES_PER_SECTION - 1;
-	for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) {
-		int page_nid;
+	for (sect_no = mem_blk->start_section_nr;
+		sect_no <= mem_blk->end_section_nr;
+		sect_no++) {
 
-		page_nid = get_nid_for_pfn(pfn);
-		if (page_nid < 0)
-			continue;
-		if (page_nid != nid)
-			continue;
-		ret = sysfs_create_link_nowarn(&node_devices[nid]->dev.kobj,
-					&mem_blk->dev.kobj,
-					kobject_name(&mem_blk->dev.kobj));
-		if (ret)
-			return ret;
+		sect_start_pfn = section_nr_to_pfn(sect_no);
+		sect_end_pfn = sect_start_pfn + PAGES_PER_SECTION - 1;
+
+		for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) {
+			int page_nid;
 
-		return sysfs_create_link_nowarn(&mem_blk->dev.kobj,
+			page_nid = get_nid_for_pfn(pfn);
+			if (page_nid < 0)
+				continue;
+			if (page_nid != nid)
+				continue;
+
+			ret = sysfs_create_link_nowarn(
+				&node_devices[nid]->dev.kobj,
+				&mem_blk->dev.kobj,
+				kobject_name(&mem_blk->dev.kobj));
+			if (ret)
+				return ret;
+
+			return sysfs_create_link_nowarn(&mem_blk->dev.kobj,
 				&node_devices[nid]->dev.kobj,
 				kobject_name(&node_devices[nid]->dev.kobj));
+		}
 	}
 	/* mem section does not span the specified node */
 	return 0;
-- 
1.8.3.1

--
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