mm/memory_hotplug: document the signal_pending() check in offline_pages()
Subsystems (4)
PATCH 1/1 mm/memory_hotplug: document the signal_pending() check in offline_pages()
Let's update the documentation that any signal is sufficient, and add a comment that not only checking for fatal signals is historical
baggage: changing it now could break existing user space. although unlikely.
For example, when an app provides a custom SIGALRM handler and triggers memory offlining, the timeout cmd would no longer stop memory offlining, because SIGALRM would no longer be considered a fatal signal.
--- Documentation/admin-guide/mm/memory-hotplug.rst | 2 +- mm/memory_hotplug.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)
Documentation/admin-guide/mm/memory-hotplug.rst +1 -1
@@ -669,7 +669,7 @@ when still encountering permanently unmovable pages within ZONE_MOVABLE (-> BUG), memory offlining will keep retrying until it eventually succeeds. When offlining is triggered from user space, the offlining context can be -terminated by sending a fatal signal. A timeout based offlining can easily be +terminated by sending a signal. A timeout based offlining can easily be implemented via:: % timeout $TIMEOUT offline_block | failure_handling
mm/memory_hotplug.c +5 -0
@@ -1843,6 +1843,11 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages, do { pfn = start_pfn; do { + /* + * Historically we always checked for any signal and + * can't limit it to fatal signals without eventually + * breaking user space. + */ if (signal_pending(current)) { ret = -EINTR; reason = "signal backoff";
Signature · 1 line
2.41.0
Quoted 8 lines · David Hildenbrand
Let's update the documentation that any signal is sufficient, and add a comment that not only checking for fatal signals is historical
baggage: changing it now could break existing user space. although unlikely.For example, when an app provides a custom SIGALRM handler and triggers memory offlining, the timeout cmd would no longer stop memory offlining, because SIGALRM would no longer be considered a fatal signal.
Yes, and it is likely goot to mention here that this is an antipattern for many other kernel operations like IO (e.g. write) but it is a long term behavior that somebody might depend on and it is safer to reflect the documentation to the realitity rather than other way around (which would be imho better).
Quoted 5 lines
Cc Michal Hocko <[email protected]>Cc Oscar Salvador <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Andrew Morton <[email protected]>Signed-off-by David Hildenbrand <[email protected]>
Quoted 36 lines
--- Documentation/admin-guide/mm/memory-hotplug.rst | 2 +- mm/memory_hotplug.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)Documentation/admin-guide/mm/memory-hotplug.rst +1
-1@@ -669,7 +669,7 @@ when still encountering permanently unmovable pages within ZONE_MOVABLE (-> BUG), memory offlining will keep retrying until it eventually succeeds. When offlining is triggered from user space, the offlining context can be -terminated by sending a fatal signal. A timeout based offlining can easily be +terminated by sending a signal. A timeout based offlining can easily be implemented via:: % timeout $TIMEOUT offline_block | failure_handlingmm/memory_hotplug.c +5
-0@@ -1843,6 +1843,11 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages, do { pfn = start_pfn; do { + /* + * Historically we always checked for any signal and + * can't limit it to fatal signals without eventually + * breaking user space. + */ if (signal_pending(current)) { ret = -EINTR; reason = "signal backoff";Signature · 1 line
2.41.0
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 37 lines · David Hildenbrand
Let's update the documentation that any signal is sufficient, and add a comment that not only checking for fatal signals is historical
baggage: changing it now could break existing user space. although unlikely.For example, when an app provides a custom SIGALRM handler and triggers memory offlining, the timeout cmd would no longer stop memory offlining, because SIGALRM would no longer be considered a fatal signal.
Cc Michal Hocko <[email protected]>Cc Oscar Salvador <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Andrew Morton <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- Documentation/admin-guide/mm/memory-hotplug.rst | 2 +- mm/memory_hotplug.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)Documentation/admin-guide/mm/memory-hotplug.rst +1
-1@@ -669,7 +669,7 @@ when still encountering permanently unmovable pages within ZONE_MOVABLE (-> BUG), memory offlining will keep retrying until it eventually succeeds. When offlining is triggered from user space, the offlining context can be -terminated by sending a fatal signal. A timeout based offlining can easily be +terminated by sending a signal. A timeout based offlining can easily be implemented via:: % timeout $TIMEOUT offline_block | failure_handlingmm/memory_hotplug.c +0
-0
mm/memory_hotplug.c int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages, · line 1849
Quoted 7 lines
mm/memory_hotplug.c +4
-0@@ -1843,6 +1843,11 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages, do { pfn = start_pfn; do { + /* + * Historically we always checked for any signal and + * can't limit it to fatal signals without eventually + * breaking user space.> + */
Just curious, could 'signal type' to stop memory offline process be considered an ABI and cannot be changed in kernel ever if required ? Just wondering if an additional '!fatal_signal_pending()' check be introduced to warn about support being deprecated, before finally replacing it with fatal_signal_pending().
Quoted 3 lines
mm/memory_hotplug.c +0
-0if (signal_pending (current)) { ret = -EINTR ; reason ="signal backoff" ;
Quoted 10 lines · Michal Hocko
Quoted 8 lines · David Hildenbrand
Let's update the documentation that any signal is sufficient, and add a comment that not only checking for fatal signals is historical
baggage: changing it now could break existing user space. although unlikely.For example, when an app provides a custom SIGALRM handler and triggers memory offlining, the timeout cmd would no longer stop memory offlining, because SIGALRM would no longer be considered a fatal signal.
Quoted 6 lines
Yes, and it is likely goot to mention here that this is an antipattern for many other kernel operations like IO (e.g. write) but it is a long term behavior that somebody might depend on and it is safer to reflect the documentation to the realitity rather than other way around (which would be imho better).
You mean adding something like
"Note that using signal_pending() instead of fatal_signal_pending() is an anti-pattern, but slowly deprecating that behavior to eventually change it in the far future is probably not worth the effort. If this ever becomes relevant for user-space, we might want to rethink."
Thanks!
Signature · 3 lines
Cheers, David / dhildenb
Quoted 44 lines · Anshuman Khandual
Quoted 41 lines · David Hildenbrand
Let's update the documentation that any signal is sufficient, and add a comment that not only checking for fatal signals is historical
baggage: changing it now could break existing user space. although unlikely.For example, when an app provides a custom SIGALRM handler and triggers memory offlining, the timeout cmd would no longer stop memory offlining, because SIGALRM would no longer be considered a fatal signal.
Cc Michal Hocko <[email protected]>Cc Oscar Salvador <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Andrew Morton <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- Documentation/admin-guide/mm/memory-hotplug.rst | 2 +- mm/memory_hotplug.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)Documentation/admin-guide/mm/memory-hotplug.rst +1
-1@@ -669,7 +669,7 @@ when still encountering permanently unmovable pages within ZONE_MOVABLE (-> BUG), memory offlining will keep retrying until it eventually succeeds. When offlining is triggered from user space, the offlining context can be -terminated by sending a fatal signal. A timeout based offlining can easily be +terminated by sending a signal. A timeout based offlining can easily be implemented via:: % timeout $TIMEOUT offline_block | failure_handlingmm/memory_hotplug.c +1
-0@@ -1843,6 +1843,11 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages, do { pfn = start_pfn; do { + /*
Quoted 8 lines
mm/memory_hotplug.c int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages,
Quoted 3 lines
mm/memory_hotplug.c +3
-0+* Historically we always checked for any signal and +* can't limit it to fatal signals without eventually +* breaking user space.> + */ Just curious, could 'signal type' to stop memory offline process be considered an ABI and cannot be changed in kernel ever if required ? Just wondering if an additional '!fatal_signal_pending()' check be introduced to warn about support being deprecated, before finally replacing it with
fatal_signal_pending().
See my reply to Michal, while that would be doable it is probably not worth the effort, and we'd still have to stick with the existing handling for quite a while.
Thanks!
Signature · 3 lines
Cheers, David / dhildenb
Michal Hocko
reviewerQuoted 18 lines · David Hildenbrand
Quoted 10 lines · Michal Hocko
Quoted 8 lines · David Hildenbrand
Let's update the documentation that any signal is sufficient, and add a comment that not only checking for fatal signals is historical
baggage: changing it now could break existing user space. although unlikely.For example, when an app provides a custom SIGALRM handler and triggers memory offlining, the timeout cmd would no longer stop memory offlining, because SIGALRM would no longer be considered a fatal signal.
Quoted 6 lines
Yes, and it is likely goot to mention here that this is an antipattern for many other kernel operations like IO (e.g. write) but it is a long term behavior that somebody might depend on and it is safer to reflect the documentation to the realitity rather than other way around (which would be imho better).
Quoted 6 lines
You mean adding something like
"Note that using
signal_pending()instead offatal_signal_pending()is an anti-pattern, but slowly deprecating that behavior to eventually change it in the far future is probably not worth the effort. If this ever becomes relevant for user-space, we might want to rethink."
Yes, something like that. Thanks!
Signature · 2 lines
Michal Hocko SUSE Labs