linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: warn only once if page table misaccounting is detected
@ 2018-11-27  8:36 Heiko Carstens
  2018-11-27  8:46 ` Kirill A. Shutemov
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Heiko Carstens @ 2018-11-27  8:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, linux-s390, linux-mm, Heiko Carstens,
	Kirill A . Shutemov, Martin Schwidefsky

Use pr_alert_once() instead of pr_alert() if page table misaccounting
has been detected.

If this happens once it is very likely that there will be numerous
other occurrence as well, which would flood dmesg and the console with
hardly any added information. Therefore print the warning only once.

Cc: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 kernel/fork.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/fork.c b/kernel/fork.c
index 07cddff89c7b..c887e9eba89f 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -647,8 +647,8 @@ static void check_mm(struct mm_struct *mm)
 	}
 
 	if (mm_pgtables_bytes(mm))
-		pr_alert("BUG: non-zero pgtables_bytes on freeing mm: %ld\n",
-				mm_pgtables_bytes(mm));
+		pr_alert_once("BUG: non-zero pgtables_bytes on freeing mm: %ld\n",
+			      mm_pgtables_bytes(mm));
 
 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS
 	VM_BUG_ON_MM(mm->pmd_huge_pte, mm);
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm: warn only once if page table misaccounting is detected
  2018-11-27  8:36 [PATCH] mm: warn only once if page table misaccounting is detected Heiko Carstens
@ 2018-11-27  8:46 ` Kirill A. Shutemov
  2018-11-27 13:19 ` Michal Hocko
  2018-11-27 15:52 ` Sean Christopherson
  2 siblings, 0 replies; 7+ messages in thread
From: Kirill A. Shutemov @ 2018-11-27  8:46 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Andrew Morton, linux-kernel, linux-s390, linux-mm, Martin Schwidefsky

On Tue, Nov 27, 2018 at 09:36:03AM +0100, Heiko Carstens wrote:
> Use pr_alert_once() instead of pr_alert() if page table misaccounting
> has been detected.
> 
> If this happens once it is very likely that there will be numerous
> other occurrence as well, which would flood dmesg and the console with
> hardly any added information. Therefore print the warning only once.
> 
> Cc: Kirill A. Shutemov <kirill@shutemov.name>
> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>

Fair enough.

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

-- 
 Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm: warn only once if page table misaccounting is detected
  2018-11-27  8:36 [PATCH] mm: warn only once if page table misaccounting is detected Heiko Carstens
  2018-11-27  8:46 ` Kirill A. Shutemov
@ 2018-11-27 13:19 ` Michal Hocko
  2018-11-27 14:36   ` Heiko Carstens
  2018-11-27 15:52 ` Sean Christopherson
  2 siblings, 1 reply; 7+ messages in thread
From: Michal Hocko @ 2018-11-27 13:19 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Andrew Morton, linux-kernel, linux-s390, linux-mm,
	Kirill A . Shutemov, Martin Schwidefsky

On Tue 27-11-18 09:36:03, Heiko Carstens wrote:
> Use pr_alert_once() instead of pr_alert() if page table misaccounting
> has been detected.
> 
> If this happens once it is very likely that there will be numerous
> other occurrence as well, which would flood dmesg and the console with
> hardly any added information. Therefore print the warning only once.

Have you actually experience a flood of these messages? Is one per mm
message really that much? If yes why rss counters do not exhibit the
same problem?

> Cc: Kirill A. Shutemov <kirill@shutemov.name>
> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
> ---
>  kernel/fork.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 07cddff89c7b..c887e9eba89f 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -647,8 +647,8 @@ static void check_mm(struct mm_struct *mm)
>  	}
>  
>  	if (mm_pgtables_bytes(mm))
> -		pr_alert("BUG: non-zero pgtables_bytes on freeing mm: %ld\n",
> -				mm_pgtables_bytes(mm));
> +		pr_alert_once("BUG: non-zero pgtables_bytes on freeing mm: %ld\n",
> +			      mm_pgtables_bytes(mm));
>  
>  #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS
>  	VM_BUG_ON_MM(mm->pmd_huge_pte, mm);
> -- 
> 2.16.4

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm: warn only once if page table misaccounting is detected
  2018-11-27 13:19 ` Michal Hocko
@ 2018-11-27 14:36   ` Heiko Carstens
  2018-11-27 16:29     ` Michal Hocko
  0 siblings, 1 reply; 7+ messages in thread
From: Heiko Carstens @ 2018-11-27 14:36 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Andrew Morton, linux-kernel, linux-s390, linux-mm,
	Kirill A . Shutemov, Martin Schwidefsky

On Tue, Nov 27, 2018 at 02:19:16PM +0100, Michal Hocko wrote:
> On Tue 27-11-18 09:36:03, Heiko Carstens wrote:
> > Use pr_alert_once() instead of pr_alert() if page table misaccounting
> > has been detected.
> > 
> > If this happens once it is very likely that there will be numerous
> > other occurrence as well, which would flood dmesg and the console with
> > hardly any added information. Therefore print the warning only once.
> 
> Have you actually experience a flood of these messages? Is one per mm
> message really that much?

Yes, I did. Since in this case all compat processes caused the message
to appear, I saw thousands of these messages.

> If yes why rss counters do not exhibit the same problem?

No rss counter messages appeared. Or do you suggest that the other
pr_alert() within check_mm() should also be changed?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm: warn only once if page table misaccounting is detected
  2018-11-27  8:36 [PATCH] mm: warn only once if page table misaccounting is detected Heiko Carstens
  2018-11-27  8:46 ` Kirill A. Shutemov
  2018-11-27 13:19 ` Michal Hocko
@ 2018-11-27 15:52 ` Sean Christopherson
  2018-11-27 15:55   ` William Kucharski
  2 siblings, 1 reply; 7+ messages in thread
From: Sean Christopherson @ 2018-11-27 15:52 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Andrew Morton, linux-kernel, linux-s390, linux-mm,
	Kirill A . Shutemov, Martin Schwidefsky

On Tue, Nov 27, 2018 at 09:36:03AM +0100, Heiko Carstens wrote:
> Use pr_alert_once() instead of pr_alert() if page table misaccounting
> has been detected.
> 
> If this happens once it is very likely that there will be numerous
> other occurrence as well, which would flood dmesg and the console with
> hardly any added information. Therefore print the warning only once.
> 
> Cc: Kirill A. Shutemov <kirill@shutemov.name>
> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
> ---
>  kernel/fork.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 07cddff89c7b..c887e9eba89f 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -647,8 +647,8 @@ static void check_mm(struct mm_struct *mm)
>  	}
>  
>  	if (mm_pgtables_bytes(mm))
> -		pr_alert("BUG: non-zero pgtables_bytes on freeing mm: %ld\n",
> -				mm_pgtables_bytes(mm));
> +		pr_alert_once("BUG: non-zero pgtables_bytes on freeing mm: %ld\n",
> +			      mm_pgtables_bytes(mm));

I found the print-always behavior to be useful when developing a driver
that mucked with PTEs directly via vmf_insert_pfn() and had issues with
racing against exit_mmap().  It was nice to be able to recompile only
the driver and rely on dmesg to let me know when I messed up yet again.

Would pr_alert_ratelimited() suffice?

>  #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS
>  	VM_BUG_ON_MM(mm->pmd_huge_pte, mm);
> -- 
> 2.16.4
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm: warn only once if page table misaccounting is detected
  2018-11-27 15:52 ` Sean Christopherson
@ 2018-11-27 15:55   ` William Kucharski
  0 siblings, 0 replies; 7+ messages in thread
From: William Kucharski @ 2018-11-27 15:55 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: Heiko Carstens, Andrew Morton, linux-kernel, linux-s390,
	linux-mm, Kirill A . Shutemov, Martin Schwidefsky



> On Nov 27, 2018, at 8:52 AM, Sean Christopherson <sean.j.christopherson@intel.com> wrote:
> 
> On Tue, Nov 27, 2018 at 09:36:03AM +0100, Heiko Carstens wrote:
>> Use pr_alert_once() instead of pr_alert() if page table misaccounting
>> has been detected.
>> 
>> If this happens once it is very likely that there will be numerous
>> other occurrence as well, which would flood dmesg and the console with
>> hardly any added information. Therefore print the warning only once.
>> 
>> Cc: Kirill A. Shutemov <kirill@shutemov.name>
>> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
>> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
>> ---
>> kernel/fork.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/kernel/fork.c b/kernel/fork.c
>> index 07cddff89c7b..c887e9eba89f 100644
>> --- a/kernel/fork.c
>> +++ b/kernel/fork.c
>> @@ -647,8 +647,8 @@ static void check_mm(struct mm_struct *mm)
>> 	}
>> 
>> 	if (mm_pgtables_bytes(mm))
>> -		pr_alert("BUG: non-zero pgtables_bytes on freeing mm: %ld\n",
>> -				mm_pgtables_bytes(mm));
>> +		pr_alert_once("BUG: non-zero pgtables_bytes on freeing mm: %ld\n",
>> +			      mm_pgtables_bytes(mm));
> 
> I found the print-always behavior to be useful when developing a driver
> that mucked with PTEs directly via vmf_insert_pfn() and had issues with
> racing against exit_mmap().  It was nice to be able to recompile only
> the driver and rely on dmesg to let me know when I messed up yet again.
> 
> Would pr_alert_ratelimited() suffice?

Actually, I really like that idea.

There are certainly times when it is useful to see a cascade of messages, within reason;
one there are so many they overflow the dmesg buffer they're of limited usefulness.

Something like a pr_alert() that could rate limit to a preset value, perhaps a default of
fifty or so, could prove quite useful indeed without being an all or once choice.

    William Kucharski

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm: warn only once if page table misaccounting is detected
  2018-11-27 14:36   ` Heiko Carstens
@ 2018-11-27 16:29     ` Michal Hocko
  0 siblings, 0 replies; 7+ messages in thread
From: Michal Hocko @ 2018-11-27 16:29 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Andrew Morton, linux-kernel, linux-s390, linux-mm,
	Kirill A . Shutemov, Martin Schwidefsky

On Tue 27-11-18 15:36:38, Heiko Carstens wrote:
> On Tue, Nov 27, 2018 at 02:19:16PM +0100, Michal Hocko wrote:
> > On Tue 27-11-18 09:36:03, Heiko Carstens wrote:
> > > Use pr_alert_once() instead of pr_alert() if page table misaccounting
> > > has been detected.
> > > 
> > > If this happens once it is very likely that there will be numerous
> > > other occurrence as well, which would flood dmesg and the console with
> > > hardly any added information. Therefore print the warning only once.
> > 
> > Have you actually experience a flood of these messages? Is one per mm
> > message really that much?
> 
> Yes, I did. Since in this case all compat processes caused the message
> to appear, I saw thousands of these messages.

This means something went colossally wrong and seeing an avalanche of
messages might be actually helpful because you can at least see the
pattern. I wonder whether the underlying issue would be obvious from a
single instance.

Maybe we want ratelimit instead?
 
> > If yes why rss counters do not exhibit the same problem?
> 
> No rss counter messages appeared. Or do you suggest that the other
> pr_alert() within check_mm() should also be changed?

Whatever we go with (and I do not have a strong opinion here) we should
be consistent I believe.

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-11-27 16:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-27  8:36 [PATCH] mm: warn only once if page table misaccounting is detected Heiko Carstens
2018-11-27  8:46 ` Kirill A. Shutemov
2018-11-27 13:19 ` Michal Hocko
2018-11-27 14:36   ` Heiko Carstens
2018-11-27 16:29     ` Michal Hocko
2018-11-27 15:52 ` Sean Christopherson
2018-11-27 15:55   ` William Kucharski

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).