[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZK2/3Kq8VlDwcCpc@dhcp22.suse.cz>
Date: Tue, 11 Jul 2023 22:47:24 +0200
From: Michal Hocko <mhocko@...e.com>
To: David Hildenbrand <david@...hat.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
linux-doc@...r.kernel.org, Oscar Salvador <osalvador@...e.de>,
Jonathan Corbet <corbet@....net>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v1] mm/memory_hotplug: document the signal_pending()
check in offline_pages()
On Tue 11-07-23 19:40:50, David Hildenbrand wrote:
> 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).
> Cc: Michal Hocko <mhocko@...e.com>
> Cc: Oscar Salvador <osalvador@...e.de>
> Cc: Jonathan Corbet <corbet@....net>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Signed-off-by: David Hildenbrand <david@...hat.com>
Acked-by: Michal Hocko <mhocko@...e.com>
> ---
> Documentation/admin-guide/mm/memory-hotplug.rst | 2 +-
> mm/memory_hotplug.c | 5 +++++
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/admin-guide/mm/memory-hotplug.rst b/Documentation/admin-guide/mm/memory-hotplug.rst
> index 1b02fe5807cc..bd77841041af 100644
> --- a/Documentation/admin-guide/mm/memory-hotplug.rst
> +++ b/Documentation/admin-guide/mm/memory-hotplug.rst
> @@ -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
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 3f231cf1b410..7cfd13c91568 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -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";
> --
> 2.41.0
--
Michal Hocko
SUSE Labs
Powered by blists - more mailing lists