2019-06-17 04:38:48

by Alastair D'Silva

[permalink] [raw]
Subject: [PATCH 4/5] mm/hotplug: Avoid RCU stalls when removing large amounts of memory

From: Alastair D'Silva <[email protected]>

When removing sufficiently large amounts of memory, we trigger RCU stall
detection. By periodically calling cond_resched(), we avoid bogus stall
warnings.

Signed-off-by: Alastair D'Silva <[email protected]>
---
mm/memory_hotplug.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index e096c987d261..382b3a0c9333 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -578,6 +578,9 @@ void __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
__remove_section(zone, __pfn_to_section(pfn), map_offset,
altmap);
map_offset = 0;
+
+ if (!(i & 0x0FFF))
+ cond_resched();
}

set_zone_contiguous(zone);
--
2.21.0


2019-06-17 06:54:59

by Mike Rapoport

[permalink] [raw]
Subject: Re: [PATCH 4/5] mm/hotplug: Avoid RCU stalls when removing large amounts of memory

On Mon, Jun 17, 2019 at 02:36:30PM +1000, Alastair D'Silva wrote:
> From: Alastair D'Silva <[email protected]>
>
> When removing sufficiently large amounts of memory, we trigger RCU stall
> detection. By periodically calling cond_resched(), we avoid bogus stall
> warnings.
>
> Signed-off-by: Alastair D'Silva <[email protected]>
> ---
> mm/memory_hotplug.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index e096c987d261..382b3a0c9333 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -578,6 +578,9 @@ void __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
> __remove_section(zone, __pfn_to_section(pfn), map_offset,
> altmap);
> map_offset = 0;
> +
> + if (!(i & 0x0FFF))

No magic numbers please. And a comment would be appreciated.

> + cond_resched();
> }
>
> set_zone_contiguous(zone);
> --
> 2.21.0
>

--
Sincerely yours,
Mike.

2019-06-17 06:59:10

by Alastair D'Silva

[permalink] [raw]
Subject: Re: [PATCH 4/5] mm/hotplug: Avoid RCU stalls when removing large amounts of memory

On Mon, 2019-06-17 at 09:53 +0300, Mike Rapoport wrote:
> On Mon, Jun 17, 2019 at 02:36:30PM +1000, Alastair D'Silva wrote:
> > From: Alastair D'Silva <[email protected]>
> >
> > When removing sufficiently large amounts of memory, we trigger RCU
> > stall
> > detection. By periodically calling cond_resched(), we avoid bogus
> > stall
> > warnings.
> >
> > Signed-off-by: Alastair D'Silva <[email protected]>
> > ---
> > mm/memory_hotplug.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> > index e096c987d261..382b3a0c9333 100644
> > --- a/mm/memory_hotplug.c
> > +++ b/mm/memory_hotplug.c
> > @@ -578,6 +578,9 @@ void __remove_pages(struct zone *zone, unsigned
> > long phys_start_pfn,
> > __remove_section(zone, __pfn_to_section(pfn),
> > map_offset,
> > altmap);
> > map_offset = 0;
> > +
> > + if (!(i & 0x0FFF))
>
> No magic numbers please. And a comment would be appreciated.
>

Agreed, thanks for the review.

--
Alastair D'Silva mob: 0423 762 819
skype: alastair_dsilva
Twitter: @EvilDeece
blog: http://alastair.d-silva.org


2019-06-17 07:47:41

by Michal Hocko

[permalink] [raw]
Subject: Re: [PATCH 4/5] mm/hotplug: Avoid RCU stalls when removing large amounts of memory

On Mon 17-06-19 14:36:30, Alastair D'Silva wrote:
> From: Alastair D'Silva <[email protected]>
>
> When removing sufficiently large amounts of memory, we trigger RCU stall
> detection. By periodically calling cond_resched(), we avoid bogus stall
> warnings.
>
> Signed-off-by: Alastair D'Silva <[email protected]>
> ---
> mm/memory_hotplug.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index e096c987d261..382b3a0c9333 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -578,6 +578,9 @@ void __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
> __remove_section(zone, __pfn_to_section(pfn), map_offset,
> altmap);
> map_offset = 0;
> +
> + if (!(i & 0x0FFF))
> + cond_resched();

We already do have cond_resched before __remove_section. Why is an
additional needed?

> }
>
> set_zone_contiguous(zone);
> --
> 2.21.0
>

--
Michal Hocko
SUSE Labs

2019-06-17 07:59:01

by Alastair D'Silva

[permalink] [raw]
Subject: RE: [PATCH 4/5] mm/hotplug: Avoid RCU stalls when removing large amounts of memory

> -----Original Message-----
> From: Michal Hocko <[email protected]>
> Sent: Monday, 17 June 2019 5:47 PM
> To: Alastair D'Silva <[email protected]>
> Cc: [email protected]; Arun KS <[email protected]>; Mukesh Ojha
> <[email protected]>; Logan Gunthorpe <[email protected]>; Wei
> Yang <[email protected]>; Peter Zijlstra <[email protected]>;
> Ingo Molnar <[email protected]>; [email protected]; Qian Cai
> <[email protected]>; Thomas Gleixner <[email protected]>; Andrew Morton
> <[email protected]>; Mike Rapoport <[email protected]>;
> Baoquan He <[email protected]>; David Hildenbrand <[email protected]>;
> Josh Poimboeuf <[email protected]>; Pavel Tatashin
> <[email protected]>; Juergen Gross <[email protected]>; Oscar
> Salvador <[email protected]>; Jiri Kosina <[email protected]>; linux-
> [email protected]
> Subject: Re: [PATCH 4/5] mm/hotplug: Avoid RCU stalls when removing large
> amounts of memory
>
> On Mon 17-06-19 14:36:30, Alastair D'Silva wrote:
> > From: Alastair D'Silva <[email protected]>
> >
> > When removing sufficiently large amounts of memory, we trigger RCU
> > stall detection. By periodically calling cond_resched(), we avoid
> > bogus stall warnings.
> >
> > Signed-off-by: Alastair D'Silva <[email protected]>
> > ---
> > mm/memory_hotplug.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index
> > e096c987d261..382b3a0c9333 100644
> > --- a/mm/memory_hotplug.c
> > +++ b/mm/memory_hotplug.c
> > @@ -578,6 +578,9 @@ void __remove_pages(struct zone *zone, unsigned
> long phys_start_pfn,
> > __remove_section(zone, __pfn_to_section(pfn),
> map_offset,
> > altmap);
> > map_offset = 0;
> > +
> > + if (!(i & 0x0FFF))
> > + cond_resched();
>
> We already do have cond_resched before __remove_section. Why is an
> additional needed?

I was getting stalls when removing ~1TB of memory.


--
Alastair D'Silva mob: 0423 762 819
skype: alastair_dsilva msn: [email protected]
blog: http://alastair.d-silva.org Twitter: @EvilDeece



2019-06-17 08:23:16

by Michal Hocko

[permalink] [raw]
Subject: Re: [PATCH 4/5] mm/hotplug: Avoid RCU stalls when removing large amounts of memory

On Mon 17-06-19 17:57:16, Alastair D'Silva wrote:
> > -----Original Message-----
> > From: Michal Hocko <[email protected]>
> > Sent: Monday, 17 June 2019 5:47 PM
> > To: Alastair D'Silva <[email protected]>
> > Cc: [email protected]; Arun KS <[email protected]>; Mukesh Ojha
> > <[email protected]>; Logan Gunthorpe <[email protected]>; Wei
> > Yang <[email protected]>; Peter Zijlstra <[email protected]>;
> > Ingo Molnar <[email protected]>; [email protected]; Qian Cai
> > <[email protected]>; Thomas Gleixner <[email protected]>; Andrew Morton
> > <[email protected]>; Mike Rapoport <[email protected]>;
> > Baoquan He <[email protected]>; David Hildenbrand <[email protected]>;
> > Josh Poimboeuf <[email protected]>; Pavel Tatashin
> > <[email protected]>; Juergen Gross <[email protected]>; Oscar
> > Salvador <[email protected]>; Jiri Kosina <[email protected]>; linux-
> > [email protected]
> > Subject: Re: [PATCH 4/5] mm/hotplug: Avoid RCU stalls when removing large
> > amounts of memory
> >
> > On Mon 17-06-19 14:36:30, Alastair D'Silva wrote:
> > > From: Alastair D'Silva <[email protected]>
> > >
> > > When removing sufficiently large amounts of memory, we trigger RCU
> > > stall detection. By periodically calling cond_resched(), we avoid
> > > bogus stall warnings.
> > >
> > > Signed-off-by: Alastair D'Silva <[email protected]>
> > > ---
> > > mm/memory_hotplug.c | 3 +++
> > > 1 file changed, 3 insertions(+)
> > >
> > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index
> > > e096c987d261..382b3a0c9333 100644
> > > --- a/mm/memory_hotplug.c
> > > +++ b/mm/memory_hotplug.c
> > > @@ -578,6 +578,9 @@ void __remove_pages(struct zone *zone, unsigned
> > long phys_start_pfn,
> > > __remove_section(zone, __pfn_to_section(pfn),
> > map_offset,
> > > altmap);
> > > map_offset = 0;
> > > +
> > > + if (!(i & 0x0FFF))
> > > + cond_resched();
> >
> > We already do have cond_resched before __remove_section. Why is an
> > additional needed?
>
> I was getting stalls when removing ~1TB of memory.

Have debugged what is the source of the stall? We do cond_resched once a
memory section which should be a constant unit of work regardless of the
total amount of memory to be removed.
--
Michal Hocko
SUSE Labs

2019-06-17 15:50:10

by Oscar Salvador

[permalink] [raw]
Subject: Re: [PATCH 4/5] mm/hotplug: Avoid RCU stalls when removing large amounts of memory

On Mon, Jun 17, 2019 at 05:57:16PM +1000, Alastair D'Silva wrote:
> I was getting stalls when removing ~1TB of memory.

Would you mind sharing one of those stalls-splats?
I am bit spectic here because as I Michal pointed out, we do cond_resched
once per section removed.

--
Oscar Salvador
SUSE L3