Skip to contentSkip to conversation

mm/sparse: set section nid for hot-add memory

PATCH In review Wei Yang 4 participants 17 messages Jun 18, 2019 – Jun 19, 2019

Subsystems (2)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH v2 1/1 mm/sparse: set section nid for hot-add memory

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

BTW, current online_pages works because it leverages nid in memory_block. But the granularity of node id should be mem_section wide.

---
v2:
* specify the case NODE_NOT_IN_PAGE_FLAGS is effected.
* list one of the victim page_to_nid()

---
 mm/sparse.c | 1 +
 1 file changed, 1 insertion(+)
mm/sparse.c +1 -0
index 4012d7f50010..48fa16038cf5 100644
@@ -733,6 +733,7 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn,
 	 */
 	page_init_poison(memmap, sizeof(struct page) * PAGES_PER_SECTION);
 
+	set_section_nid(section_nr, nid);
 	section_mark_present(ms);
 	sparse_init_one_section(ms, section_nr, memmap, usemap);
 
Signature · 1 line
2.19.1
#1 lore raw
Quoted 6 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

BTW, current online_pages works because it leverages nid in memory_block. But the granularity of node id should be mem_section wide.

I forgot to ask this before, but why do you mention online_pages here? IMHO, it does not add any value to the changelog, and it does not have much to do with the matter.

online_pages() works with memblock granularity and not section granularity. That memblock is just a hot-added range of memory, worth of either 1 section or multiple sections, depending on the arch or on the size of the current memory.
And we assume that each hot-added memory all belongs to the same node.

Quoted 29 lines

---
v2:
* specify the case NODE_NOT_IN_PAGE_FLAGS is effected.
* list one of the victim page_to_nid()

---
 mm/sparse.c | 1 +
 1 file changed, 1 insertion(+)
mm/sparse.c +1 -0
index 4012d7f50010..48fa16038cf5 100644
@@ -733,6 +733,7 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn,
 	 */
 	page_init_poison(memmap, sizeof(struct page) * PAGES_PER_SECTION);
 
+	set_section_nid(section_nr, nid);
 	section_mark_present(ms);
 	sparse_init_one_section(ms, section_nr, memmap, usemap);
 
Signature · 1 line
2.19.1
Signature · 2 lines
Oscar Salvador
SUSE L3
author
#2 lore raw
Quoted 5 lines · Oscar Salvador
Quoted 4 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

Quoted 7 lines
Quoted 2 lines

BTW, current online_pages works because it leverages nid in memory_block. But the granularity of node id should be mem_section wide.

I forgot to ask this before, but why do you mention online_pages here? IMHO, it does not add any value to the changelog, and it does not have much to do with the matter.

Since to me it is a little confused why we don't set the node info but still could online memory to the correct node. It turns out we leverage the information in memblock.

Quoted 5 lines

online_pages() works with memblock granularity and not section granularity. That memblock is just a hot-added range of memory, worth of either 1 section or multiple sections, depending on the arch or on the size of the current memory.
And we assume that each hot-added memory all belongs to the same node.

So I am not clear about the granularity of node id. section based or memblock based. Or we have two cases:

* for initial memory, section wide
* for hot-add memory, mem_block wide

Quoted 34 lines
Quoted 30 lines

---
v2:
* specify the case NODE_NOT_IN_PAGE_FLAGS is effected.
* list one of the victim page_to_nid()

---
 mm/sparse.c | 1 +
 1 file changed, 1 insertion(+)
mm/sparse.c +1 -0
index 4012d7f50010..48fa16038cf5 100644
@@ -733,6 +733,7 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn,
 	 */
 	page_init_poison(memmap, sizeof(struct page) * PAGES_PER_SECTION);
 
+	set_section_nid(section_nr, nid);
 	section_mark_present(ms);
 	sparse_init_one_section(ms, section_nr, memmap, usemap);
 
Signature · 1 line
2.19.1
Signature · 2 lines
Oscar Salvador
SUSE L3
Signature · 2 lines
Wei Yang
Help you, Help me
#3 lore raw
Quoted 9 lines · Wei Yang
Quoted 8 lines · Oscar Salvador
Quoted 6 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

BTW, current online_pages works because it leverages nid in memory_block. But the granularity of node id should be mem_section wide.

Quoted 8 lines
Quoted 4 lines

I forgot to ask this before, but why do you mention online_pages here? IMHO, it does not add any value to the changelog, and it does not have much to do with the matter.

Since to me it is a little confused why we don't set the node info but still could online memory to the correct node. It turns out we leverage the information in memblock.

I'd also drop the comment here.

Quoted 7 lines
Quoted 6 lines

online_pages() works with memblock granularity and not section granularity. That memblock is just a hot-added range of memory, worth of either 1 section or multiple sections, depending on the arch or on the size of the current memory.
And we assume that each hot-added memory all belongs to the same node.

Quoted 5 lines

So I am not clear about the granularity of node id. section based or memblock based. Or we have two cases:

* for initial memory, section wide
* for hot-add memory, mem_block wide

It's all a big mess. Right now, you can offline initial memory with mixed nodes. Also on my list of many ugly things to clean up.

(I even remember that we can have mixed nodes within a section, but I haven't figured out yet how that is supposed to work in some scenarios)

Signature · 3 lines
Thanks,

David / dhildenb
reviewer
#4 lore raw
Quoted 31 lines · David Hildenbrand
Quoted 9 lines · Wei Yang
Quoted 8 lines · Oscar Salvador
Quoted 6 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

BTW, current online_pages works because it leverages nid in memory_block. But the granularity of node id should be mem_section wide.

Quoted 8 lines
Quoted 4 lines

I forgot to ask this before, but why do you mention online_pages here? IMHO, it does not add any value to the changelog, and it does not have much to do with the matter.

Since to me it is a little confused why we don't set the node info but still could online memory to the correct node. It turns out we leverage the information in memblock.

I'd also drop the comment here.

Quoted 10 lines
Quoted 6 lines

online_pages() works with memblock granularity and not section granularity. That memblock is just a hot-added range of memory, worth of either 1 section or multiple sections, depending on the arch or on the size of the current memory.
And we assume that each hot-added memory all belongs to the same node.

So I am not clear about the granularity of node id. section based or memblock based. Or we have two cases:

Quoted 8 lines
Quoted 2 lines

* for initial memory, section wide
* for hot-add memory, mem_block wide

It's all a big mess. Right now, you can offline initial memory with mixed nodes. Also on my list of many ugly things to clean up.

(I even remember that we can have mixed nodes within a section, but I haven't figured out yet how that is supposed to work in some scenarios)

Yes, that is indeed the case. See 4aa9fc2a435abe95a1e8d7f8c7b3d6356514b37a. How to fix this? Well, I do not think we can. Section based granularity simply doesn't agree with the reality and so we have to live with that. There is a long way to remove all those section size assumptions from the code though.

Signature · 2 lines
Michal Hocko
SUSE Labs
#5 lore raw
Quoted 38 lines · Michal Hocko
Quoted 37 lines · David Hildenbrand
Quoted 9 lines · Wei Yang
Quoted 8 lines · Oscar Salvador
Quoted 6 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

BTW, current online_pages works because it leverages nid in memory_block. But the granularity of node id should be mem_section wide.

Quoted 8 lines
Quoted 4 lines

I forgot to ask this before, but why do you mention online_pages here? IMHO, it does not add any value to the changelog, and it does not have much to do with the matter.

Since to me it is a little confused why we don't set the node info but still could online memory to the correct node. It turns out we leverage the information in memblock.

I'd also drop the comment here.

Quoted 7 lines
Quoted 6 lines

online_pages() works with memblock granularity and not section granularity. That memblock is just a hot-added range of memory, worth of either 1 section or multiple sections, depending on the arch or on the size of the current memory.
And we assume that each hot-added memory all belongs to the same node.

Quoted 5 lines

So I am not clear about the granularity of node id. section based or memblock based. Or we have two cases:

* for initial memory, section wide
* for hot-add memory, mem_block wide

It's all a big mess. Right now, you can offline initial memory with mixed nodes. Also on my list of many ugly things to clean up.

Quoted 9 lines
Quoted 2 lines

(I even remember that we can have mixed nodes within a section, but I haven't figured out yet how that is supposed to work in some scenarios)

Yes, that is indeed the case. See 4aa9fc2a435abe95a1e8d7f8c7b3d6356514b37a. How to fix this? Well, I do not think we can. Section based granularity simply doesn't agree with the reality and so we have to live with that. There is a long way to remove all those section size assumptions from the code though.

Trying to remove NODE_NOT_IN_PAGE_FLAGS could work, but we would have to identify how exactly needs that. For memory blocks, we need a different approach (I have in my head to make ->nid indicate if we are dealing with mixed nodes. If mixed, disallow onlining/offlining).

Signature · 3 lines
Thanks,

David / dhildenb
reviewer
#6 lore raw
Quoted 49 lines · David Hildenbrand
Quoted 38 lines · Michal Hocko
Quoted 37 lines · David Hildenbrand
Quoted 9 lines · Wei Yang
Quoted 8 lines · Oscar Salvador
Quoted 6 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

BTW, current online_pages works because it leverages nid in memory_block. But the granularity of node id should be mem_section wide.

Quoted 8 lines
Quoted 4 lines

I forgot to ask this before, but why do you mention online_pages here? IMHO, it does not add any value to the changelog, and it does not have much to do with the matter.

Since to me it is a little confused why we don't set the node info but still could online memory to the correct node. It turns out we leverage the information in memblock.

I'd also drop the comment here.

Quoted 7 lines
Quoted 6 lines

online_pages() works with memblock granularity and not section granularity. That memblock is just a hot-added range of memory, worth of either 1 section or multiple sections, depending on the arch or on the size of the current memory.
And we assume that each hot-added memory all belongs to the same node.

Quoted 5 lines

So I am not clear about the granularity of node id. section based or memblock based. Or we have two cases:

* for initial memory, section wide
* for hot-add memory, mem_block wide

It's all a big mess. Right now, you can offline initial memory with mixed nodes. Also on my list of many ugly things to clean up.

Quoted 9 lines
Quoted 2 lines

(I even remember that we can have mixed nodes within a section, but I haven't figured out yet how that is supposed to work in some scenarios)

Yes, that is indeed the case. See 4aa9fc2a435abe95a1e8d7f8c7b3d6356514b37a. How to fix this? Well, I do not think we can. Section based granularity simply doesn't agree with the reality and so we have to live with that. There is a long way to remove all those section size assumptions from the code though.

Quoted 4 lines

Trying to remove NODE_NOT_IN_PAGE_FLAGS could work, but we would have to identify how exactly needs that. For memory blocks, we need a different approach (I have in my head to make ->nid indicate if we are dealing with mixed nodes. If mixed, disallow onlining/offlining).

Well, I am not sure we really have to care about mutli-nodes memblocks much. The API is clumsy but does anybody actually care? The vast majority of hotplug usecases simply do not do that in the first place right? And if they do need a smaller granularity to describe their memory topology then we need a different user API rather the fiddle with implementation details I would argue.

Signature · 2 lines
Michal Hocko
SUSE Labs
#7 lore raw
Quoted 55 lines · Michal Hocko
Quoted 49 lines · David Hildenbrand
Quoted 38 lines · Michal Hocko
Quoted 37 lines · David Hildenbrand
Quoted 9 lines · Wei Yang
Quoted 8 lines · Oscar Salvador
Quoted 6 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

BTW, current online_pages works because it leverages nid in memory_block. But the granularity of node id should be mem_section wide.

Quoted 8 lines
Quoted 4 lines

I forgot to ask this before, but why do you mention online_pages here? IMHO, it does not add any value to the changelog, and it does not have much to do with the matter.

Since to me it is a little confused why we don't set the node info but still could online memory to the correct node. It turns out we leverage the information in memblock.

I'd also drop the comment here.

Quoted 7 lines
Quoted 6 lines

online_pages() works with memblock granularity and not section granularity. That memblock is just a hot-added range of memory, worth of either 1 section or multiple sections, depending on the arch or on the size of the current memory.
And we assume that each hot-added memory all belongs to the same node.

Quoted 5 lines

So I am not clear about the granularity of node id. section based or memblock based. Or we have two cases:

* for initial memory, section wide
* for hot-add memory, mem_block wide

It's all a big mess. Right now, you can offline initial memory with mixed nodes. Also on my list of many ugly things to clean up.

Quoted 9 lines
Quoted 2 lines

(I even remember that we can have mixed nodes within a section, but I haven't figured out yet how that is supposed to work in some scenarios)

Yes, that is indeed the case. See 4aa9fc2a435abe95a1e8d7f8c7b3d6356514b37a. How to fix this? Well, I do not think we can. Section based granularity simply doesn't agree with the reality and so we have to live with that. There is a long way to remove all those section size assumptions from the code though.

Quoted 4 lines

Trying to remove NODE_NOT_IN_PAGE_FLAGS could work, but we would have to identify how exactly needs that. For memory blocks, we need a different approach (I have in my head to make ->nid indicate if we are dealing with mixed nodes. If mixed, disallow onlining/offlining).

Quoted 4 lines

Well, I am not sure we really have to care about mutli-nodes memblocks much. The API is clumsy but does anybody actually care? The vast majority of hotplug usecases simply do not do that in the first place right?

Yes, AFAIK it could be done, resulting in unpredictable outcome.

And if they do need a smaller granularity to describe their

Quoted 3 lines

memory topology then we need a different user API rather the fiddle with implementation details I would argue.

It is not about supporting it, it is about properly blocking it.

Signature · 3 lines
Thanks,

David / dhildenb
reviewer
#8 lore raw
Quoted 1 line · David Hildenbrand

On 19.06.19 11:01, Michal Hocko wrote:

[...]

Quoted 6 lines
Quoted 4 lines

And if they do need a smaller granularity to describe their memory topology then we need a different user API rather the fiddle with implementation details I would argue.

It is not about supporting it, it is about properly blocking it.

We already do that in test_pages_in_a_zone, right? Albeit in MAX_ORDER_NR_PAGES granularity.

Signature · 2 lines
Michal Hocko
SUSE Labs
#9 lore raw
Quoted 8 lines · Michal Hocko
Quoted 1 line · David Hildenbrand

On 19.06.19 11:01, Michal Hocko wrote:

[...]

Quoted 5 lines
Quoted 4 lines

And if they do need a smaller granularity to describe their memory topology then we need a different user API rather the fiddle with implementation details I would argue.

Quoted 5 lines
Quoted 1 line

It is not about supporting it, it is about properly blocking it.

We already do that in test_pages_in_a_zone, right? Albeit in MAX_ORDER_NR_PAGES granularity.

Indeed, thanks for pointing that out. I knew that we were checking zones but had in my head that it was working on zone idx.

Signature · 3 lines
Thanks,

David / dhildenb
reviewer Acked-by on v2 1/1
#10 lore raw
In reply to Wei Yang
Quoted 3 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

Which would mean that NODE_NOT_IN_PAGE_FLAGS doesn't really work with the hotpluged memory, right? Any idea why nobody has noticed this so far? Is it because NODE_NOT_IN_PAGE_FLAGS is rare and essentially unused with the hotplug? page_to_nid providing an incorrect result sounds quite serious to me.

Could you identify when we have introduced this problem? A Fixes tag would sound very useful to me.

Quoted 2 lines

BTW, current online_pages works because it leverages nid in memory_block. But the granularity of node id should be mem_section wide.

This is not really helpful because nothing except for the hotplug really cares about mem blocks. The whole MM really does care about page_to_nid and that is why it matters much more so spending a word or two on that would be more helpful.

Quoted 4 lines

The patch itself looks good to me.

Thanks!

Quoted 24 lines

---
v2:
* specify the case NODE_NOT_IN_PAGE_FLAGS is effected.
* list one of the victim page_to_nid()

---
 mm/sparse.c | 1 +
 1 file changed, 1 insertion(+)
mm/sparse.c +1 -0
index 4012d7f50010..48fa16038cf5 100644
@@ -733,6 +733,7 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn,
 	 */
 	page_init_poison(memmap, sizeof(struct page) * PAGES_PER_SECTION);
 
+	set_section_nid(section_nr, nid);
 	section_mark_present(ms);
 	sparse_init_one_section(ms, section_nr, memmap, usemap);
 
Signature · 1 line
2.19.1
Signature · 2 lines
Michal Hocko
SUSE Labs
#11 lore raw
Quoted 10 lines · Michal Hocko
Quoted 3 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

Which would mean that NODE_NOT_IN_PAGE_FLAGS doesn't really work with the hotpluged memory, right? Any idea why nobody has noticed this so far? Is it because NODE_NOT_IN_PAGE_FLAGS is rare and essentially unused with the hotplug? page_to_nid providing an incorrect result sounds quite serious to me.

The thing is that for NODE_NOT_IN_PAGE_FLAGS to be enabled we need to run out of space in page->flags to store zone, nid and section.
Currently, even with the largest values (with pagetable level 5), that is not possible on x86_64.
It is possible though, that somewhere in the future, when the values get larger (e.g: we add more zones, NODE_SHIFT grows, or we need more space to store the section) we finally run out of room for the flags though.

I am not sure about the other arches though, we probably should audit them and see which ones can fall in there.

Signature · 2 lines
Oscar Salvador
SUSE L3
#12 lore raw
Quoted 20 lines · Oscar Salvador
Quoted 10 lines · Michal Hocko
Quoted 3 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

Which would mean that NODE_NOT_IN_PAGE_FLAGS doesn't really work with the hotpluged memory, right? Any idea why nobody has noticed this so far? Is it because NODE_NOT_IN_PAGE_FLAGS is rare and essentially unused with the hotplug? page_to_nid providing an incorrect result sounds quite serious to me.

The thing is that for NODE_NOT_IN_PAGE_FLAGS to be enabled we need to run out of space in page->flags to store zone, nid and section.
Currently, even with the largest values (with pagetable level 5), that is not possible on x86_64.
It is possible though, that somewhere in the future, when the values get larger (e.g: we add more zones, NODE_SHIFT grows, or we need more space to store the section) we finally run out of room for the flags though.

Quoted 3 lines

I am not sure about the other arches though, we probably should audit them and see which ones can fall in there.

I'd love to see NODE_NOT_IN_PAGE_FLAGS go.

Signature · 3 lines
Thanks,

David / dhildenb
reviewer
#13 lore raw
Quoted 21 lines · David Hildenbrand
Quoted 20 lines · Oscar Salvador
Quoted 10 lines · Michal Hocko
Quoted 3 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

Which would mean that NODE_NOT_IN_PAGE_FLAGS doesn't really work with the hotpluged memory, right? Any idea why nobody has noticed this so far? Is it because NODE_NOT_IN_PAGE_FLAGS is rare and essentially unused with the hotplug? page_to_nid providing an incorrect result sounds quite serious to me.

The thing is that for NODE_NOT_IN_PAGE_FLAGS to be enabled we need to run out of space in page->flags to store zone, nid and section.
Currently, even with the largest values (with pagetable level 5), that is not possible on x86_64.
It is possible though, that somewhere in the future, when the values get larger (e.g: we add more zones, NODE_SHIFT grows, or we need more space to store the section) we finally run out of room for the flags though.

Quoted 5 lines
Quoted 3 lines

I am not sure about the other arches though, we probably should audit them and see which ones can fall in there.

I'd love to see NODE_NOT_IN_PAGE_FLAGS go.

NODE_NOT_IN_PAGE_FLAGS is an implementation detail on where the information is stored. I cannot say how much it is really needed now but I can see there will be a demand for it in a longer term because page->flags space is scarce and very interesting storage. So I do not see it go away I am afraid.

Signature · 2 lines
Michal Hocko
SUSE Labs
#14 lore raw
Quoted 22 lines · Michal Hocko
Quoted 21 lines · David Hildenbrand
Quoted 20 lines · Oscar Salvador
Quoted 10 lines · Michal Hocko
Quoted 3 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

Which would mean that NODE_NOT_IN_PAGE_FLAGS doesn't really work with the hotpluged memory, right? Any idea why nobody has noticed this so far? Is it because NODE_NOT_IN_PAGE_FLAGS is rare and essentially unused with the hotplug? page_to_nid providing an incorrect result sounds quite serious to me.

The thing is that for NODE_NOT_IN_PAGE_FLAGS to be enabled we need to run out of space in page->flags to store zone, nid and section.
Currently, even with the largest values (with pagetable level 5), that is not possible on x86_64.
It is possible though, that somewhere in the future, when the values get larger (e.g: we add more zones, NODE_SHIFT grows, or we need more space to store the section) we finally run out of room for the flags though.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I am not sure about the other arches though, we probably should audit them and see which ones can fall in there.

I'd love to see NODE_NOT_IN_PAGE_FLAGS go.

NODE_NOT_IN_PAGE_FLAGS is an implementation detail on where the information is stored.

Yes and no. Storing it per section clearly doesn't allow storing node information on smaller granularity, like storing in page->flags does.

So no, it is not only an implementation detail.

I cannot say how much it is really needed now but

Quoted 3 lines

I can see there will be a demand for it in a longer term because page->flags space is scarce and very interesting storage. So I do not see it go away I am afraid.

Depends on how performance-critical pfn_to_nid() is. I can't tell.

Signature · 3 lines
Thanks,

David / dhildenb
reviewer
#15 lore raw
Quoted 29 lines · David Hildenbrand
Quoted 28 lines · Michal Hocko
Quoted 26 lines · David Hildenbrand
Quoted 20 lines · Oscar Salvador
Quoted 10 lines · Michal Hocko
Quoted 3 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

Which would mean that NODE_NOT_IN_PAGE_FLAGS doesn't really work with the hotpluged memory, right? Any idea why nobody has noticed this so far? Is it because NODE_NOT_IN_PAGE_FLAGS is rare and essentially unused with the hotplug? page_to_nid providing an incorrect result sounds quite serious to me.

The thing is that for NODE_NOT_IN_PAGE_FLAGS to be enabled we need to run out of space in page->flags to store zone, nid and section.
Currently, even with the largest values (with pagetable level 5), that is not possible on x86_64.
It is possible though, that somewhere in the future, when the values get larger (e.g: we add more zones, NODE_SHIFT grows, or we need more space to store the section) we finally run out of room for the flags though.

Quoted 3 lines

I am not sure about the other arches though, we probably should audit them and see which ones can fall in there.

I'd love to see NODE_NOT_IN_PAGE_FLAGS go.

Quoted 7 lines
Quoted 2 lines

NODE_NOT_IN_PAGE_FLAGS is an implementation detail on where the information is stored.

Yes and no. Storing it per section clearly doesn't allow storing node information on smaller granularity, like storing in page->flags does.

So no, it is not only an implementation detail.

Let me try to put it differently. NODE_NOT_IN_PAGE_FLAGS is not about storing the mapping per section. You can do what ever other data structure. NODE_NOT_IN_PAGE_FLAGS is in fact about telling that it is not in page->flags.

Quoted 5 lines
Quoted 4 lines

I cannot say how much it is really needed now but
I can see there will be a demand for it in a longer term because page->flags space is scarce and very interesting storage. So I do not see it go away I am afraid.

Depends on how performance-critical pfn_to_nid() is. I can't tell.

page_to_node is used in many important code paths. Not in the hotest ones I believe but many of them are quite hot I would say.

Signature · 2 lines
Michal Hocko
SUSE Labs
#16 lore raw
Quoted 36 lines · Michal Hocko
Quoted 35 lines · David Hildenbrand
Quoted 22 lines · Michal Hocko
Quoted 21 lines · David Hildenbrand
Quoted 20 lines · Oscar Salvador
Quoted 10 lines · Michal Hocko
Quoted 3 lines · Wei Yang

In case of NODE_NOT_IN_PAGE_FLAGS is set, we store section's node id in section_to_node_table[]. While for hot-add memory, this is missed. Without this information, page_to_nid() may not give the right node id.

Which would mean that NODE_NOT_IN_PAGE_FLAGS doesn't really work with the hotpluged memory, right? Any idea why nobody has noticed this so far? Is it because NODE_NOT_IN_PAGE_FLAGS is rare and essentially unused with the hotplug? page_to_nid providing an incorrect result sounds quite serious to me.

The thing is that for NODE_NOT_IN_PAGE_FLAGS to be enabled we need to run out of space in page->flags to store zone, nid and section.
Currently, even with the largest values (with pagetable level 5), that is not possible on x86_64.
It is possible though, that somewhere in the future, when the values get larger (e.g: we add more zones, NODE_SHIFT grows, or we need more space to store the section) we finally run out of room for the flags though.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I am not sure about the other arches though, we probably should audit them and see which ones can fall in there.

I'd love to see NODE_NOT_IN_PAGE_FLAGS go.

NODE_NOT_IN_PAGE_FLAGS is an implementation detail on where the information is stored.

Yes and no. Storing it per section clearly doesn't allow storing node information on smaller granularity, like storing in page->flags does.

Quoted 6 lines
Quoted 1 line

So no, it is not only an implementation detail.

Let me try to put it differently. NODE_NOT_IN_PAGE_FLAGS is not about storing the mapping per section. You can do what ever other data structure. NODE_NOT_IN_PAGE_FLAGS is in fact about telling that it is not in page->flags.

Okay, I get what you are saying. Storing it differently is problematic, though, if we want o minimize memory consumption and have a fast lookup.

I was also looking into avoiding to store the section number in page-flags with CONFIG_SPARSEMEM. Especially, because the CONFIG_HAVE_ARCH_PFN_VALID hack is really ugly. But it's tricky :(

Signature · 3 lines
Thanks,

David / dhildenb