* [PATCH -next] mm/hotplug: silence a lockdep splat with printk()
@ 2020-01-14 20:11 Qian Cai
2020-01-14 20:20 ` David Hildenbrand
0 siblings, 1 reply; 13+ messages in thread
From: Qian Cai @ 2020-01-14 20:11 UTC (permalink / raw)
To: akpm
Cc: mhocko, sergey.senozhatsky.work, pmladek, rostedt, peterz, david,
linux-mm, linux-kernel, Qian Cai
Similar to the recent commit [1] merged into the random and -next trees,
it is not a good idea to call printk() with zone->lock held. The
standard fix is to use printk_deferred() in those places, but memory
offline will call dump_page() which need to defer after the lock. While
at it, remove a similar but unnecessary debug printk() as well.
[1] https://lore.kernel.org/lkml/1573679785-21068-1-git-send-email-cai@lca.pw/
Signed-off-by: Qian Cai <cai@lca.pw>
---
include/linux/page-isolation.h | 2 +-
mm/memory_hotplug.c | 2 +-
mm/page_alloc.c | 12 +++++-------
mm/page_isolation.c | 10 +++++++++-
4 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
index 148e65a9c606..5d8ba078006f 100644
--- a/include/linux/page-isolation.h
+++ b/include/linux/page-isolation.h
@@ -34,7 +34,7 @@ static inline bool is_migrate_isolate(int migratetype)
#define REPORT_FAILURE 0x2
bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype,
- int flags);
+ int flags, char *dump);
void set_pageblock_migratetype(struct page *page, int migratetype);
int move_freepages_block(struct zone *zone, struct page *page,
int migratetype, int *num_movable);
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 7a6de9b0dcab..f10928538fa3 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1149,7 +1149,7 @@ static bool is_pageblock_removable_nolock(unsigned long pfn)
return false;
return !has_unmovable_pages(zone, page, MIGRATE_MOVABLE,
- MEMORY_OFFLINE);
+ MEMORY_OFFLINE, NULL);
}
/* Checks if this range of memory is likely to be hot-removable. */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e56cd1f33242..b6bec3925e80 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -8204,7 +8204,7 @@ void *__init alloc_large_system_hash(const char *tablename,
* race condition. So you can't expect this function should be exact.
*/
bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype,
- int flags)
+ int flags, char *dump)
{
unsigned long iter = 0;
unsigned long pfn = page_to_pfn(page);
@@ -8305,8 +8305,10 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype,
return false;
unmovable:
WARN_ON_ONCE(zone_idx(zone) == ZONE_MOVABLE);
- if (flags & REPORT_FAILURE)
- dump_page(pfn_to_page(pfn + iter), reason);
+ if (flags & REPORT_FAILURE) {
+ page = pfn_to_page(pfn + iter);
+ strscpy(dump, reason, 64);
+ }
return true;
}
@@ -8711,10 +8713,6 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn)
BUG_ON(!PageBuddy(page));
order = page_order(page);
offlined_pages += 1 << order;
-#ifdef CONFIG_DEBUG_VM
- pr_info("remove from free list %lx %d %lx\n",
- pfn, 1 << order, end_pfn);
-#endif
del_page_from_free_area(page, &zone->free_area[order]);
pfn += (1 << order);
}
diff --git a/mm/page_isolation.c b/mm/page_isolation.c
index 1f8b9dfecbe8..ce0fe3c1ceff 100644
--- a/mm/page_isolation.c
+++ b/mm/page_isolation.c
@@ -20,6 +20,7 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_
struct zone *zone;
unsigned long flags;
int ret = -EBUSY;
+ char dump[64];
zone = page_zone(page);
@@ -37,7 +38,8 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_
* FIXME: Now, memory hotplug doesn't call shrink_slab() by itself.
* We just check MOVABLE pages.
*/
- if (!has_unmovable_pages(zone, page, migratetype, isol_flags)) {
+ if (!has_unmovable_pages(zone, page, migratetype, isol_flags,
+ dump)) {
unsigned long nr_pages;
int mt = get_pageblock_migratetype(page);
@@ -54,6 +56,12 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_
spin_unlock_irqrestore(&zone->lock, flags);
if (!ret)
drain_all_pages(zone);
+ else if (isol_flags & REPORT_FAILURE)
+ /*
+ * printk() with zone->lock held will guarantee to trigger a
+ * lockdep splat, so defer it here.
+ */
+ dump_page(page, dump);
return ret;
}
--
2.21.0 (Apple Git-122.2)
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH -next] mm/hotplug: silence a lockdep splat with printk()
2020-01-14 20:11 [PATCH -next] mm/hotplug: silence a lockdep splat with printk() Qian Cai
@ 2020-01-14 20:20 ` David Hildenbrand
2020-01-14 21:02 ` Michal Hocko
0 siblings, 1 reply; 13+ messages in thread
From: David Hildenbrand @ 2020-01-14 20:20 UTC (permalink / raw)
To: Qian Cai, akpm
Cc: mhocko, sergey.senozhatsky.work, pmladek, rostedt, peterz,
linux-mm, linux-kernel
On 14.01.20 21:11, Qian Cai wrote:
> Similar to the recent commit [1] merged into the random and -next trees,
> it is not a good idea to call printk() with zone->lock held. The
> standard fix is to use printk_deferred() in those places, but memory
> offline will call dump_page() which need to defer after the lock. While
> at it, remove a similar but unnecessary debug printk() as well.
>
> [1] https://lore.kernel.org/lkml/1573679785-21068-1-git-send-email-cai@lca.pw/
>
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
> include/linux/page-isolation.h | 2 +-
> mm/memory_hotplug.c | 2 +-
> mm/page_alloc.c | 12 +++++-------
> mm/page_isolation.c | 10 +++++++++-
> 4 files changed, 16 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
> index 148e65a9c606..5d8ba078006f 100644
> --- a/include/linux/page-isolation.h
> +++ b/include/linux/page-isolation.h
> @@ -34,7 +34,7 @@ static inline bool is_migrate_isolate(int migratetype)
> #define REPORT_FAILURE 0x2
>
> bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype,
> - int flags);
> + int flags, char *dump);
> void set_pageblock_migratetype(struct page *page, int migratetype);
> int move_freepages_block(struct zone *zone, struct page *page,
> int migratetype, int *num_movable);
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 7a6de9b0dcab..f10928538fa3 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1149,7 +1149,7 @@ static bool is_pageblock_removable_nolock(unsigned long pfn)
> return false;
>
> return !has_unmovable_pages(zone, page, MIGRATE_MOVABLE,
> - MEMORY_OFFLINE);
> + MEMORY_OFFLINE, NULL);
> }
>
> /* Checks if this range of memory is likely to be hot-removable. */
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index e56cd1f33242..b6bec3925e80 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -8204,7 +8204,7 @@ void *__init alloc_large_system_hash(const char *tablename,
> * race condition. So you can't expect this function should be exact.
> */
> bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype,
> - int flags)
> + int flags, char *dump)
> {
> unsigned long iter = 0;
> unsigned long pfn = page_to_pfn(page);
> @@ -8305,8 +8305,10 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype,
> return false;
> unmovable:
> WARN_ON_ONCE(zone_idx(zone) == ZONE_MOVABLE);
> - if (flags & REPORT_FAILURE)
> - dump_page(pfn_to_page(pfn + iter), reason);
> + if (flags & REPORT_FAILURE) {
> + page = pfn_to_page(pfn + iter);
> + strscpy(dump, reason, 64);
> + }
> return true;
> }
>
> @@ -8711,10 +8713,6 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn)
> BUG_ON(!PageBuddy(page));
> order = page_order(page);
> offlined_pages += 1 << order;
> -#ifdef CONFIG_DEBUG_VM
> - pr_info("remove from free list %lx %d %lx\n",
> - pfn, 1 << order, end_pfn);
> -#endif
ack to getting rid of this.
Regarding the other stuff, I remember Michal had an opinion about the
previous approach, so it's best if he comments.
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] mm/hotplug: silence a lockdep splat with printk()
2020-01-14 20:20 ` David Hildenbrand
@ 2020-01-14 21:02 ` Michal Hocko
2020-01-14 21:40 ` Qian Cai
0 siblings, 1 reply; 13+ messages in thread
From: Michal Hocko @ 2020-01-14 21:02 UTC (permalink / raw)
To: David Hildenbrand
Cc: Qian Cai, akpm, sergey.senozhatsky.work, pmladek, rostedt,
peterz, linux-mm, linux-kernel
On Tue 14-01-20 21:20:08, David Hildenbrand wrote:
> On 14.01.20 21:11, Qian Cai wrote:
> > Similar to the recent commit [1] merged into the random and -next trees,
> > it is not a good idea to call printk() with zone->lock held. The
> > standard fix is to use printk_deferred() in those places, but memory
> > offline will call dump_page() which need to defer after the lock. While
> > at it, remove a similar but unnecessary debug printk() as well.
> >
> > [1] https://lore.kernel.org/lkml/1573679785-21068-1-git-send-email-cai@lca.pw/
> >
> > Signed-off-by: Qian Cai <cai@lca.pw>
> > ---
> > include/linux/page-isolation.h | 2 +-
> > mm/memory_hotplug.c | 2 +-
> > mm/page_alloc.c | 12 +++++-------
> > mm/page_isolation.c | 10 +++++++++-
> > 4 files changed, 16 insertions(+), 10 deletions(-)
> >
> > diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
> > index 148e65a9c606..5d8ba078006f 100644
> > --- a/include/linux/page-isolation.h
> > +++ b/include/linux/page-isolation.h
> > @@ -34,7 +34,7 @@ static inline bool is_migrate_isolate(int migratetype)
> > #define REPORT_FAILURE 0x2
> >
> > bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype,
> > - int flags);
> > + int flags, char *dump);
> > void set_pageblock_migratetype(struct page *page, int migratetype);
> > int move_freepages_block(struct zone *zone, struct page *page,
> > int migratetype, int *num_movable);
> > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> > index 7a6de9b0dcab..f10928538fa3 100644
> > --- a/mm/memory_hotplug.c
> > +++ b/mm/memory_hotplug.c
> > @@ -1149,7 +1149,7 @@ static bool is_pageblock_removable_nolock(unsigned long pfn)
> > return false;
> >
> > return !has_unmovable_pages(zone, page, MIGRATE_MOVABLE,
> > - MEMORY_OFFLINE);
> > + MEMORY_OFFLINE, NULL);
> > }
> >
> > /* Checks if this range of memory is likely to be hot-removable. */
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index e56cd1f33242..b6bec3925e80 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -8204,7 +8204,7 @@ void *__init alloc_large_system_hash(const char *tablename,
> > * race condition. So you can't expect this function should be exact.
> > */
> > bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype,
> > - int flags)
> > + int flags, char *dump)
> > {
> > unsigned long iter = 0;
> > unsigned long pfn = page_to_pfn(page);
> > @@ -8305,8 +8305,10 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype,
> > return false;
> > unmovable:
> > WARN_ON_ONCE(zone_idx(zone) == ZONE_MOVABLE);
> > - if (flags & REPORT_FAILURE)
> > - dump_page(pfn_to_page(pfn + iter), reason);
> > + if (flags & REPORT_FAILURE) {
> > + page = pfn_to_page(pfn + iter);
> > + strscpy(dump, reason, 64);
> > + }
> > return true;
> > }
> >
> > @@ -8711,10 +8713,6 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn)
> > BUG_ON(!PageBuddy(page));
> > order = page_order(page);
> > offlined_pages += 1 << order;
> > -#ifdef CONFIG_DEBUG_VM
> > - pr_info("remove from free list %lx %d %lx\n",
> > - pfn, 1 << order, end_pfn);
> > -#endif
>
> ack to getting rid of this.
Yeah and that should go into it's own patch.
> Regarding the other stuff, I remember Michal had an opinion about the
> previous approach, so it's best if he comments.
Yeah, that was a long discussion with a lot of lockdep false positives.
I believe I have made it clear that the console code shouldn't depend on
memory allocation because that is just too fragile. If that is not
possible for some reason then it has to be mentioned in the changelog.
I really do not want us to add kludges to the MM code just because of
printk deficiencies unless that is absolutely inevitable.
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] mm/hotplug: silence a lockdep splat with printk()
2020-01-14 21:02 ` Michal Hocko
@ 2020-01-14 21:40 ` Qian Cai
2020-01-14 23:53 ` Andrew Morton
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Qian Cai @ 2020-01-14 21:40 UTC (permalink / raw)
To: Michal Hocko
Cc: David Hildenbrand, akpm, sergey.senozhatsky.work, pmladek,
rostedt, peterz, linux-mm, linux-kernel
> On Jan 14, 2020, at 4:02 PM, Michal Hocko <mhocko@kernel.org> wrote:
>
> Yeah, that was a long discussion with a lot of lockdep false positives.
> I believe I have made it clear that the console code shouldn't depend on
> memory allocation because that is just too fragile. If that is not
> possible for some reason then it has to be mentioned in the changelog.
> I really do not want us to add kludges to the MM code just because of
> printk deficiencies unless that is absolutely inevitable.
I don’t know how to convince you, but both random number generator and printk() maintainers agreed to get ride of printk() with zone->lock held as you can see in the approved commit mentioned in this patch description because it is a whac-a-mole to fix other places. In other word, the patch alone fixes quite a few false positives and potential real deadlocks. Maybe Andrew please has a look at this directly?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] mm/hotplug: silence a lockdep splat with printk()
2020-01-14 21:40 ` Qian Cai
@ 2020-01-14 23:53 ` Andrew Morton
2020-01-15 1:02 ` Qian Cai
2020-01-15 8:37 ` Michal Hocko
2020-01-15 9:52 ` Petr Mladek
2 siblings, 1 reply; 13+ messages in thread
From: Andrew Morton @ 2020-01-14 23:53 UTC (permalink / raw)
To: Qian Cai
Cc: Michal Hocko, David Hildenbrand, sergey.senozhatsky.work,
pmladek, rostedt, peterz, linux-mm, linux-kernel
> On Jan 14, 2020, at 4:02 PM, Michal Hocko <mhocko@kernel.org> wrote:
>>
>> Yeah, that was a long discussion with a lot of lockdep false positives.
>> I believe I have made it clear that the console code shouldn't depend on
>> memory allocation because that is just too fragile. If that is not
>> possible for some reason then it has to be mentioned in the changelog.
>> I really do not want us to add kludges to the MM code just because of
>> printk deficiencies unless that is absolutely inevitable.
>
> I don't know how to convince you, but both random number generator and
> printk() maintainers agreed to get ride of printk() with zone->lock
> held as you can see in the approved commit mentioned in this patch
> description because it is a whac-a-mole to fix other places. In other
> word, the patch alone fixes quite a few false positives and potential
> real deadlocks. Maybe Andrew please has a look at this directly?
>
Well, a few things.
The changelog is quite poor. It doesn't describe the problem (console
drivers allocating memory) not does it describe the solution
(deferring the dump_page() until after release of zone->lock).
So I changed it to this:
: Some console drivers can perform memory allocation at inappropriate times,
: which can result in lockdep warnings (and presumably deadlocks) if printk
: is called with zone->lock held.
:
: By far the best fix is to reeducate those console drivers to not perform
: these allocations, but this is proving difficult.
:
: Another but poorer approach is to call printk_deferred() when holding
: zone->lock, but memory offline will call dump_page() which needs to defer
: after the lock.
:
: So change has_unmovable_pages() so that it no longer calls dump_page()
: itself - instead it passes the page's descripton (as a string) back to the
: caller so that in the case of a has_unmovable_pages() failure, the caller
: can call dump_page() after releasing zone->lock.
:
: While at it, remove a similar but unnecessary debug printk() as well.
But I see a couple of other issues.
> @@ -8290,8 +8290,10 @@ bool has_unmovable_pages(struct zone *zo
> return false;
> unmovable:
> WARN_ON_ONCE(zone_idx(zone) == ZONE_MOVABLE);
> - if (flags & REPORT_FAILURE)
> - dump_page(pfn_to_page(pfn + iter), reason);
> + if (flags & REPORT_FAILURE) {
> + page = pfn_to_page(pfn + iter);
This statement appears to be unnecessary.
> + strscpy(dump, reason, 64);
> + }
Also, that whole `reason' thing in has_unmovable_pages() is just there
to tell us whether it was an "unmovable page" or a "CMA page". This
doesn't seem terribly useful to me. Also, I expect that the
dump_page() output will permit the user to determine that it was a CMA
page anyway. If not, we can change dump_page() to add that info.
So how about we remove that whole `reason' thing and possibly enhance
dump_page()? The patch then becomes much simpler.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] mm/hotplug: silence a lockdep splat with printk()
2020-01-14 23:53 ` Andrew Morton
@ 2020-01-15 1:02 ` Qian Cai
2020-01-15 1:19 ` Andrew Morton
0 siblings, 1 reply; 13+ messages in thread
From: Qian Cai @ 2020-01-15 1:02 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, David Hildenbrand, Sergey Senozhatsky, pmladek,
rostedt, peterz, linux-mm, linux-kernel
> On Jan 14, 2020, at 6:53 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
>
>> On Jan 14, 2020, at 4:02 PM, Michal Hocko <mhocko@kernel.org> wrote:
>>>
>>> Yeah, that was a long discussion with a lot of lockdep false positives.
>>> I believe I have made it clear that the console code shouldn't depend on
>>> memory allocation because that is just too fragile. If that is not
>>> possible for some reason then it has to be mentioned in the changelog.
>>> I really do not want us to add kludges to the MM code just because of
>>> printk deficiencies unless that is absolutely inevitable.
>>
>> I don't know how to convince you, but both random number generator and
>> printk() maintainers agreed to get ride of printk() with zone->lock
>> held as you can see in the approved commit mentioned in this patch
>> description because it is a whac-a-mole to fix other places. In other
>> word, the patch alone fixes quite a few false positives and potential
>> real deadlocks. Maybe Andrew please has a look at this directly?
>>
>
> Well, a few things.
>
> The changelog is quite poor. It doesn't describe the problem (console
> drivers allocating memory) not does it describe the solution
> (deferring the dump_page() until after release of zone->lock).
>
> So I changed it to this:
>
> : Some console drivers can perform memory allocation at inappropriate times,
> : which can result in lockdep warnings (and presumably deadlocks) if printk
> : is called with zone->lock held.
> :
> : By far the best fix is to reeducate those console drivers to not perform
> : these allocations, but this is proving difficult.
… but this is proving difficult because even if we fixed that directly, lockdep
Is still able to find an indirect dependency chain, for example [1]
CPU1: console_owner —> port_lock_key
CPU2: port_lock_key —> (&port->lock)->rlock
CPU3: (&port->lock)->rlock —> zone->lock
which will trigger a splat with
zone->lock —> console_owner
[1] https://lore.kernel.org/linux-mm/1570460350.5576.290.camel@lca.pw/
> :
> : Another but poorer approach is to call printk_deferred() when holding
> : zone->lock, but memory offline will call dump_page() which needs to defer
> : after the lock.
> :
> : So change has_unmovable_pages() so that it no longer calls dump_page()
> : itself - instead it passes the page's descripton (as a string) back to the
> : caller so that in the case of a has_unmovable_pages() failure, the caller
> : can call dump_page() after releasing zone->lock.
> :
> : While at it, remove a similar but unnecessary debug printk() as well.
>
> But I see a couple of other issues.
>
>> @@ -8290,8 +8290,10 @@ bool has_unmovable_pages(struct zone *zo
>> return false;
>> unmovable:
>> WARN_ON_ONCE(zone_idx(zone) == ZONE_MOVABLE);
>> - if (flags & REPORT_FAILURE)
>> - dump_page(pfn_to_page(pfn + iter), reason);
>> + if (flags & REPORT_FAILURE) {
>> + page = pfn_to_page(pfn + iter);
>
> This statement appears to be unnecessary.
dump_page() in set_migratetype_isolate() needs that “page”.
>
>> + strscpy(dump, reason, 64);
>> + }
>
>
> Also, that whole `reason' thing in has_unmovable_pages() is just there
> to tell us whether it was an "unmovable page" or a "CMA page". This
> doesn't seem terribly useful to me. Also, I expect that the
> dump_page() output will permit the user to determine that it was a CMA
> page anyway. If not, we can change dump_page() to add that info.
>
> So how about we remove that whole `reason' thing and possibly enhance
> dump_page()? The patch then becomes much simpler.
Sounds like a good idea. I’ll send a v2.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] mm/hotplug: silence a lockdep splat with printk()
2020-01-15 1:02 ` Qian Cai
@ 2020-01-15 1:19 ` Andrew Morton
2020-01-15 1:38 ` Qian Cai
0 siblings, 1 reply; 13+ messages in thread
From: Andrew Morton @ 2020-01-15 1:19 UTC (permalink / raw)
To: Qian Cai
Cc: Michal Hocko, David Hildenbrand, Sergey Senozhatsky, pmladek,
rostedt, peterz, linux-mm, linux-kernel
On Tue, 14 Jan 2020 20:02:31 -0500 Qian Cai <cai@lca.pw> wrote:
>
>
> >> @@ -8290,8 +8290,10 @@ bool has_unmovable_pages(struct zone *zo
> >> return false;
> >> unmovable:
> >> WARN_ON_ONCE(zone_idx(zone) == ZONE_MOVABLE);
> >> - if (flags & REPORT_FAILURE)
> >> - dump_page(pfn_to_page(pfn + iter), reason);
> >> + if (flags & REPORT_FAILURE) {
> >> + page = pfn_to_page(pfn + iter);
> >
> > This statement appears to be unnecessary.
>
> dump_page() in set_migratetype_isolate() needs that “page”.
local var `page' is never used after this statement.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] mm/hotplug: silence a lockdep splat with printk()
2020-01-15 1:19 ` Andrew Morton
@ 2020-01-15 1:38 ` Qian Cai
0 siblings, 0 replies; 13+ messages in thread
From: Qian Cai @ 2020-01-15 1:38 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, David Hildenbrand, Sergey Senozhatsky, pmladek,
rostedt, peterz, linux-mm, linux-kernel
> On Jan 14, 2020, at 8:19 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Tue, 14 Jan 2020 20:02:31 -0500 Qian Cai <cai@lca.pw> wrote:
>
>>
>>
>>>> @@ -8290,8 +8290,10 @@ bool has_unmovable_pages(struct zone *zo
>>>> return false;
>>>> unmovable:
>>>> WARN_ON_ONCE(zone_idx(zone) == ZONE_MOVABLE);
>>>> - if (flags & REPORT_FAILURE)
>>>> - dump_page(pfn_to_page(pfn + iter), reason);
>>>> + if (flags & REPORT_FAILURE) {
>>>> + page = pfn_to_page(pfn + iter);
>>>
>>> This statement appears to be unnecessary.
>>
>> dump_page() in set_migratetype_isolate() needs that “page”.
>
> local var `page' is never used after this statement.
>
The goal is to reuse the parameter of has_unmovable_pages((…, page, …)
as a return value, so after it returns, dump_page(page, ...) could use it. I
don’t see where it was defined as a local variable.
This is probably a bit too hacky, so I’ll change has_unmovable_pages()
to either return "struct page *” or NULL which is easier to understand.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] mm/hotplug: silence a lockdep splat with printk()
2020-01-14 21:40 ` Qian Cai
2020-01-14 23:53 ` Andrew Morton
@ 2020-01-15 8:37 ` Michal Hocko
2020-01-15 9:52 ` Petr Mladek
2 siblings, 0 replies; 13+ messages in thread
From: Michal Hocko @ 2020-01-15 8:37 UTC (permalink / raw)
To: Qian Cai
Cc: David Hildenbrand, akpm, sergey.senozhatsky.work, pmladek,
rostedt, peterz, linux-mm, linux-kernel
On Tue 14-01-20 16:40:49, Qian Cai wrote:
>
>
> > On Jan 14, 2020, at 4:02 PM, Michal Hocko <mhocko@kernel.org> wrote:
> >
> > Yeah, that was a long discussion with a lot of lockdep false positives.
> > I believe I have made it clear that the console code shouldn't depend on
> > memory allocation because that is just too fragile. If that is not
> > possible for some reason then it has to be mentioned in the changelog.
> > I really do not want us to add kludges to the MM code just because of
> > printk deficiencies unless that is absolutely inevitable.
>
> I don’t know how to convince you, but both random number generator
> and printk() maintainers agreed to get ride of printk() with
> zone->lock held as you can see in the approved commit mentioned in
> this patch description because it is a whac-a-mole to fix other
> places.
I really do not understand this argument. It is quite a specific path in
the console code which cannot allocate any memory or use locks which
depend on the allocation via a lock chain, right? So how come this is a
whack a mole?
Also any console that really needs GFP_ATOMIC to write something out is
just inherently broken so it should better be fixed rather than
worked around.
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] mm/hotplug: silence a lockdep splat with printk()
2020-01-14 21:40 ` Qian Cai
2020-01-14 23:53 ` Andrew Morton
2020-01-15 8:37 ` Michal Hocko
@ 2020-01-15 9:52 ` Petr Mladek
[not found] ` <D6F57A74-7608-43BE-B909-4350DE95B68C@lca.pw>
2 siblings, 1 reply; 13+ messages in thread
From: Petr Mladek @ 2020-01-15 9:52 UTC (permalink / raw)
To: Qian Cai
Cc: Michal Hocko, David Hildenbrand, akpm, sergey.senozhatsky.work,
rostedt, peterz, linux-mm, linux-kernel
On Tue 2020-01-14 16:40:49, Qian Cai wrote:
>
>
> > On Jan 14, 2020, at 4:02 PM, Michal Hocko <mhocko@kernel.org> wrote:
> >
> > Yeah, that was a long discussion with a lot of lockdep false positives.
> > I believe I have made it clear that the console code shouldn't depend on
> > memory allocation because that is just too fragile. If that is not
> > possible for some reason then it has to be mentioned in the changelog.
> > I really do not want us to add kludges to the MM code just because of
> > printk deficiencies unless that is absolutely inevitable.
>
> I don’t know how to convince you, but both random number generator
> and printk() maintainers agreed to get ride of printk() with
> zone->lock held as you can see in the approved commit mentioned
I neither acked nor blocked the fix in the random generator. I believe
that it was false positive. But the fix was trivial and I did not have
any better solution in the pocket.
> in this patch description because it is a whac-a-mole to fix other
> places.
This is misleading. Using printk_deferred() in
_warn_unseeded_randomness() is whack-a-mole approach as well.
The most realistic real solution is to deffer consoles into kthreads.
It is being discussed for years. There is finally an agreement
to get this upstream. But the priority is to add lockless ringbuffer
first.
I could understand that Michal is against hack in -mm code that
would just hide a false positive warning.
If you really need a solution before the console offload gets
upstream then I suggest to do something really simple. For example,
disable lockdep around the allocation in console registration code
that is proven to produce the false positive chain.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2020-01-16 14:29 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 20:11 [PATCH -next] mm/hotplug: silence a lockdep splat with printk() Qian Cai
2020-01-14 20:20 ` David Hildenbrand
2020-01-14 21:02 ` Michal Hocko
2020-01-14 21:40 ` Qian Cai
2020-01-14 23:53 ` Andrew Morton
2020-01-15 1:02 ` Qian Cai
2020-01-15 1:19 ` Andrew Morton
2020-01-15 1:38 ` Qian Cai
2020-01-15 8:37 ` Michal Hocko
2020-01-15 9:52 ` Petr Mladek
[not found] ` <D6F57A74-7608-43BE-B909-4350DE95B68C@lca.pw>
2020-01-15 17:02 ` Petr Mladek
2020-01-15 17:16 ` Qian Cai
2020-01-16 14:29 ` Petr Mladek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).