Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1214619 > unrolled thread
| Started by | Jan Stancek <jstancek@redhat.com> |
|---|---|
| First post | 2015-08-27 16:50 +0200 |
| Last post | 2015-09-01 09:20 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 1/2] drivers/base/node.c: split loop in register_mem_sect_under_node Jan Stancek <jstancek@redhat.com> - 2015-08-27 16:50 +0200
Re: [PATCH 1/2] drivers/base/node.c: split loop in register_mem_sect_under_node Dave Young <dyoung@redhat.com> - 2015-09-01 09:20 +0200
| From | Jan Stancek <jstancek@redhat.com> |
|---|---|
| Date | 2015-08-27 16:50 +0200 |
| Subject | [PATCH 1/2] drivers/base/node.c: split loop in register_mem_sect_under_node |
| Message-ID | <q26F3-7pQ-3@gated-at.bofh.it> |
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@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Dave Young <dyoung@redhat.com> |
|---|---|
| Date | 2015-09-01 09:20 +0200 |
| Subject | Re: [PATCH 1/2] drivers/base/node.c: split loop in register_mem_sect_under_node |
| Message-ID | <q3O1k-819-15@gated-at.bofh.it> |
| In reply to | #1214619 |
Ccing linux-mm
On 08/27/15 at 04:43pm, Jan Stancek wrote:
> 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@redhat.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.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@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web