Skip to contentSkip to conversation

mm: clarify COMPACTION Kconfig text

PATCH In review Michal Hocko 4 participants 9 messages Aug 23, 2016 – Aug 29, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: clarify COMPACTION Kconfig text

From: Michal Hocko <[email protected]>

The current wording of the COMPACTION Kconfig help text doesn't emphasise that disabling COMPACTION might cripple the page allocator which relies on the compaction quite heavily for high order requests and an unexpected OOM can happen with the lack of compaction. Make sure we are vocal about that.

---
 mm/Kconfig | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
mm/Kconfig +8 -1
index 78a23c5c302d..0dff2f05b6d1 100644
@@ -262,7 +262,14 @@ config COMPACTION
 	select MIGRATION
 	depends on MMU
 	help
-	  Allows the compaction of memory for the allocation of huge pages.
+          Compaction is the only memory management component to form
+          high order (larger physically contiguous) memory blocks
+          reliably. Page allocator relies on the compaction heavily and
+          the lack of the feature can lead to unexpected OOM killer
+          invocation for high order memory requests. You shouldnm't
+          disable this option unless there is really a strong reason for
+          it and then we are really interested to hear about that at
+          [email protected].
 
 #
 # support for page migration
Signature · 7 lines
2.8.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 7 lines · Michal Hocko

From: Michal Hocko <[email protected]>

The current wording of the COMPACTION Kconfig help text doesn't emphasise that disabling COMPACTION might cripple the page allocator which relies on the compaction quite heavily for high order requests and an unexpected OOM can happen with the lack of compaction. Make sure we are vocal about that.

Just a few nitpicks inline below:

Quoted 8 lines
 mm/Kconfig | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
mm/Kconfig +0 -0
index 78a23c5c302d..0dff2f05b6d1 100644

mm/Kconfig config COMPACTION · line 267

Quoted 7 lines
mm/Kconfig +3 -1
@@ -262,7 +262,14 @@ config COMPACTION
 	select MIGRATION
 	depends on MMU
 	help
-	  Allows the compaction of memory for the allocation of huge pages.
+          Compaction is the only memory management component to form
+          high order (larger physically contiguous) memory blocks
+          reliably. Page allocator relies on the compaction heavily and

The page allo... on compaction

mm/Kconfig config COMPACTION · line 269

Quoted 2 lines
mm/Kconfig +2 -0
+          the lack of the feature can lead to unexpected OOM killer
+          invocation for high order memory requests. You shouldnm't

invocations shouldn't

mm/Kconfig config COMPACTION · line 270

Quoted 1 line
mm/Kconfig +1 -0
+          disable this option unless there is really a strong reason for

really is

mm/Kconfig config COMPACTION · line 271

Quoted 1 line
mm/Kconfig +1 -0
+          it and then we are really interested to hear about that at

would be

Signature · 7 lines
Markus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw
Quoted 27 lines · Markus Trippelsdorf
Quoted 7 lines · Michal Hocko

From: Michal Hocko <[email protected]>

The current wording of the COMPACTION Kconfig help text doesn't emphasise that disabling COMPACTION might cripple the page allocator which relies on the compaction quite heavily for high order requests and an unexpected OOM can happen with the lack of compaction. Make sure we are vocal about that.

Just a few nitpicks inline below:

Quoted 8 lines
 mm/Kconfig | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
mm/Kconfig +0 -0
index 78a23c5c302d..0dff2f05b6d1 100644

mm/Kconfig config COMPACTION · line 267

Quoted 7 lines
mm/Kconfig +3 -1
@@ -262,7 +262,14 @@ config COMPACTION
 	select MIGRATION
 	depends on MMU
 	help
-	  Allows the compaction of memory for the allocation of huge pages.
+          Compaction is the only memory management component to form
+          high order (larger physically contiguous) memory blocks
+          reliably. Page allocator relies on the compaction heavily and

The page allo... on compaction

Quoted 7 lines

mm/Kconfig config COMPACTION · line 269

Quoted 2 lines
mm/Kconfig +2 -0
+          the lack of the feature can lead to unexpected OOM killer
+          invocation for high order memory requests. You shouldnm't

invocations shouldn't

mm/Kconfig config COMPACTION · line 270

Quoted 1 line
mm/Kconfig +1 -0
+          disable this option unless there is really a strong reason for

really is

mm/Kconfig config COMPACTION · line 271

Quoted 1 line
mm/Kconfig +1 -0
+          it and then we are really interested to hear about that at

would be

Thanks for the review. Updated patch follows:
---

#3 lore raw
In reply to Michal Hocko
Quoted 8 lines · Michal Hocko

From: Michal Hocko <[email protected]>

The current wording of the COMPACTION Kconfig help text doesn't emphasise that disabling COMPACTION might cripple the page allocator which relies on the compaction quite heavily for high order requests and an unexpected OOM can happen with the lack of compaction. Make sure we are vocal about that.

Since when has this been an issue? I don't believe it has been an issue in the past for any archs that don't use thp.

Quoted 15 lines
---
 mm/Kconfig | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
mm/Kconfig +1 -1
index 78a23c5c302d..0dff2f05b6d1 100644
@@ -262,7 +262,14 @@ config COMPACTION
 	select MIGRATION
 	depends on MMU
 	help
-	  Allows the compaction of memory for the allocation of huge pages.
+          Compaction is the only memory management component to form

mm/Kconfig config COMPACTION · line 275

Quoted 10 lines
mm/Kconfig +7 -0
+          high order (larger physically contiguous) memory blocks
+          reliably. Page allocator relies on the compaction heavily and
+          the lack of the feature can lead to unexpected OOM killer
+          invocation for high order memory requests. You shouldnm't
+          disable this option unless there is really a strong reason for
+          it and then we are really interested to hear about that at
+          [email protected].
 
 #
 # support for page migration

This seems to strongly suggest that all kernels should be built with CONFIG_COMPACTION and its requirement, CONFIG_MIGRATION. Migration has a dependency of NUMA or memory hot-remove (not all popular). Compaction can defragment memory within single zone without reliance on NUMA.

This seems like a very bizarre requirement and I'm wondering where we regressed from this thp-only behavior.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
Quoted 4 lines · David Rientjes
Quoted 2 lines · Michal Hocko

From: Michal Hocko <[email protected]>

Quoted 8 lines
Quoted 6 lines

The current wording of the COMPACTION Kconfig help text doesn't emphasise that disabling COMPACTION might cripple the page allocator which relies on the compaction quite heavily for high order requests and an unexpected OOM can happen with the lack of compaction. Make sure we are vocal about that.

Since when has this been an issue?

Well, pretty much since we have dropped the lumpy reclaim.

Quoted 2 lines

I don't believe it has been an issue in the past for any archs that don't use thp.

Well, fragmentation is a real problem and order-0 reclaim will be never anywhere close to reliably provide higher order pages. Well, reclaiming a lot of memory can increase the probability of a success but that can quite often lead to over reclaim and long stalls. There are other sources of high order requests than THP so this is not about THP at all IMHO.

Quoted 23 lines
Quoted 23 lines
---
 mm/Kconfig | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
mm/Kconfig +8 -1
index 78a23c5c302d..0dff2f05b6d1 100644
@@ -262,7 +262,14 @@ config COMPACTION
 	select MIGRATION
 	depends on MMU
 	help
-	  Allows the compaction of memory for the allocation of huge pages.
+          Compaction is the only memory management component to form
+          high order (larger physically contiguous) memory blocks
+          reliably. Page allocator relies on the compaction heavily and
+          the lack of the feature can lead to unexpected OOM killer
+          invocation for high order memory requests. You shouldnm't
+          disable this option unless there is really a strong reason for
+          it and then we are really interested to hear about that at
+          [email protected].
 
Quoted 5 lines

mm/Kconfig config COMPACTION · line 275

Quoted 2 lines
mm/Kconfig +0 -0
 #
 # support for page migration

This seems to strongly suggest that all kernels should be built with CONFIG_COMPACTION and its requirement

Yes. Do you see any reason why the compaction should be disabled and we should rely solely on order-0 reclaim?

Quoted 3 lines

, CONFIG_MIGRATION. Migration has a
dependency of NUMA or memory hot-remove (not all popular). Compaction can defragment memory within single zone without reliance on NUMA.

I am not sure I am following you here.
MIGRATION depends on (NUMA || ARCH_ENABLE_MEMORY_HOTREMOVE || COMPACTION || CMA) && MMU

Quoted 2 lines

This seems like a very bizarre requirement and I'm wondering where we regressed from this thp-only behavior.

Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#5 lore raw
Quoted 10 lines · Michal Hocko
Quoted 2 lines

I don't believe it has been an issue in the past for any archs that don't use thp.

Well, fragmentation is a real problem and order-0 reclaim will be never anywhere close to reliably provide higher order pages. Well, reclaiming a lot of memory can increase the probability of a success but that can quite often lead to over reclaim and long stalls. There are other sources of high order requests than THP so this is not about THP at all IMHO.

Would it be possible to list the high-order allocations you are concerned about other than thp that doesn't have fallback behavior like skbuff and slub allocations? struct task_struct is an order-1 allocation and there may be order-1 slab bucket usage, but what is higher order or requires aggressive compaction to allocate? Surely you're not suggesting that order-0 reclaim cannot form order-1 memory. I am concerned about kernels that require a small memory footprint and cannot enable all of CONFIG_COMPACTION and CONFIG_MIGRATION. Embedded devices are not a negligible minority of kernels.

Quoted 7 lines
Quoted 3 lines

, CONFIG_MIGRATION. Migration has a
dependency of NUMA or memory hot-remove (not all popular). Compaction can defragment memory within single zone without reliance on NUMA.

I am not sure I am following you here.
MIGRATION depends on (NUMA || ARCH_ENABLE_MEMORY_HOTREMOVE || COMPACTION || CMA) && MMU

Embedded device may be UMA and not care for memory hotplug or failure handling and rely solely on order-0 and order-1 memory.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw
Quoted 13 lines · David Rientjes
Quoted 10 lines · Michal Hocko
Quoted 2 lines

I don't believe it has been an issue in the past for any archs that don't use thp.

Well, fragmentation is a real problem and order-0 reclaim will be never anywhere close to reliably provide higher order pages. Well, reclaiming a lot of memory can increase the probability of a success but that can quite often lead to over reclaim and long stalls. There are other sources of high order requests than THP so this is not about THP at all IMHO.

Quoted 5 lines

Would it be possible to list the high-order allocations you are concerned about other than thp that doesn't have fallback behavior like skbuff and slub allocations? struct task_struct is an order-1 allocation and there may be order-1 slab bucket usage, but what is higher order or requires aggressive compaction to allocate?

kernel stacks (order-2 on many arches), some arches need higher order pages for page table allocations (at least the upper level AFAIR).

Quoted 2 lines

Surely you're not suggesting that order-0 reclaim cannot form order-1 memory.

I haven't seen fragmentation that bad that order-1 would be completely depleted so I wouldn't be all that worried about this. But order-2 can get depleted as our last oom reports show.

Quoted 3 lines

I am concerned about kernels that require a small memory footprint and cannot enable all of CONFIG_COMPACTION and CONFIG_MIGRATION. Embedded devices are not a negligible minority of kernels.

Fair enough. And nobody discourages them from disabling the compaction. I would expect that kernels for those machines are configured by people who know what they are doing. They have to be careful about disabling many other things already and carefully weight the missing functionality vs. code size savings. I also expect that workloads on those machines are also careful to not require large physically contiguous memory blocks very much. Otherwise they would have problems described by the help text.

So I am not really sure what you are objecting to. I am not making COMPACTION on unconditionally. I just want to make sure that regular users do not think this is just a THP thing which is not true since the lumpy reclaim is gone. On my laptop I have more than 40 slab caches which have pagesperslab > 2.

Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#7 lore raw
In reply to Michal Hocko
Quoted 7 lines · Michal Hocko

From: Michal Hocko <[email protected]>

The current wording of the COMPACTION Kconfig help text doesn't emphasise that disabling COMPACTION might cripple the page allocator which relies on the compaction quite heavily for high order requests and an unexpected OOM can happen with the lack of compaction. Make sure we are vocal about that.

I find it weird to even have this as a config option after we removed lumpy reclaim. Why offer a configuration that may easily OOM on allocs that we don't even consider "costly" to generate? There might be some specialized setups that know they can live without the higher-order allocations and rather have the savings in kernel size, but I'd argue that for the vast majority of Linux setups compaction is an essential part of our VM at this point. Seems like a candidate for EXPERT to me.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw
Quoted 9 lines · Johannes Weiner
Quoted 7 lines · Michal Hocko

From: Michal Hocko <[email protected]>

The current wording of the COMPACTION Kconfig help text doesn't emphasise that disabling COMPACTION might cripple the page allocator which relies on the compaction quite heavily for high order requests and an unexpected OOM can happen with the lack of compaction. Make sure we are vocal about that.

Quoted 7 lines

I find it weird to even have this as a config option after we removed lumpy reclaim. Why offer a configuration that may easily OOM on allocs that we don't even consider "costly" to generate? There might be some specialized setups that know they can live without the higher-order allocations and rather have the savings in kernel size, but I'd argue that for the vast majority of Linux setups compaction is an essential part of our VM at this point. Seems like a candidate for EXPERT to me.

I was thinking about making it depend on EXPERT as well but then I just felt like making the text more verbose should be sufficient. If somebody runs a kernel without COMPACTION and doesn't see any issues then why should we make life harder for him. But I was thinking about a different thing. We should warn that the compaction is disabled when the oom killer hits for higher order. What do you think?
---

mm/oom_kill.c +2 -0
index 10f686969fc4..b3c47072a206 100644
@@ -406,6 +406,8 @@ static void dump_header(struct oom_control *oc, struct task_struct *p)
 	pr_warn("%s invoked oom-killer: gfp_mask=%#x(%pGg), order=%d, oom_score_adj=%hd\n",
 		current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order,
 		current->signal->oom_score_adj);
+	if (!IS_ENABLED(COMPACTION) && oc->order)
+		pr_warn("COMPACTION is disabled!!!\n");
 
 	cpuset_print_current_mems_allowed();
 	dump_stack();
Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>