* [patch] mm, migrate: increment fail count on ENOMEM
@ 2016-05-19 22:11 David Rientjes
2016-05-20 13:06 ` Michal Hocko
0 siblings, 1 reply; 7+ messages in thread
From: David Rientjes @ 2016-05-19 22:11 UTC (permalink / raw)
To: Andrew Morton; +Cc: Vlastimil Babka, Mel Gorman, linux-mm, linux-kernel
If page migration fails due to -ENOMEM, nr_failed should still be
incremented for proper statistics.
This was encountered recently when all page migration vmstats showed 0,
and inferred that migrate_pages() was never called, although in reality
the first page migration failed because compaction_alloc() failed to find
a migration target.
This patch increments nr_failed so the vmstat is properly accounted on
ENOMEM.
Signed-off-by: David Rientjes <rientjes@google.com>
---
mm/migrate.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/migrate.c b/mm/migrate.c
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1171,6 +1171,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
switch(rc) {
case -ENOMEM:
+ nr_failed++;
goto out;
case -EAGAIN:
retry++;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] mm, migrate: increment fail count on ENOMEM
2016-05-19 22:11 [patch] mm, migrate: increment fail count on ENOMEM David Rientjes
@ 2016-05-20 13:06 ` Michal Hocko
2016-05-20 13:19 ` Vlastimil Babka
0 siblings, 1 reply; 7+ messages in thread
From: Michal Hocko @ 2016-05-20 13:06 UTC (permalink / raw)
To: David Rientjes
Cc: Andrew Morton, Vlastimil Babka, Mel Gorman, linux-mm, linux-kernel
On Thu 19-05-16 15:11:23, David Rientjes wrote:
> If page migration fails due to -ENOMEM, nr_failed should still be
> incremented for proper statistics.
>
> This was encountered recently when all page migration vmstats showed 0,
> and inferred that migrate_pages() was never called, although in reality
> the first page migration failed because compaction_alloc() failed to find
> a migration target.
>
> This patch increments nr_failed so the vmstat is properly accounted on
> ENOMEM.
>
> Signed-off-by: David Rientjes <rientjes@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
One question though
> ---
> mm/migrate.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1171,6 +1171,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
>
> switch(rc) {
> case -ENOMEM:
> + nr_failed++;
> goto out;
> case -EAGAIN:
> retry++;
Why don't we need also to count also retries?
---
diff --git a/mm/migrate.c b/mm/migrate.c
index 53ab6398e7a2..ef9c5211ae3c 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1190,9 +1190,9 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
}
}
}
+out:
nr_failed += retry;
rc = nr_failed;
-out:
if (nr_succeeded)
count_vm_events(PGMIGRATE_SUCCESS, nr_succeeded);
if (nr_failed)
--
Michal Hocko
SUSE Labs
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [patch] mm, migrate: increment fail count on ENOMEM
2016-05-20 13:06 ` Michal Hocko
@ 2016-05-20 13:19 ` Vlastimil Babka
2016-05-20 13:31 ` Michal Hocko
0 siblings, 1 reply; 7+ messages in thread
From: Vlastimil Babka @ 2016-05-20 13:19 UTC (permalink / raw)
To: Michal Hocko, David Rientjes
Cc: Andrew Morton, Mel Gorman, linux-mm, linux-kernel
On 05/20/2016 03:06 PM, Michal Hocko wrote:
> On Thu 19-05-16 15:11:23, David Rientjes wrote:
>> If page migration fails due to -ENOMEM, nr_failed should still be
>> incremented for proper statistics.
>>
>> This was encountered recently when all page migration vmstats showed 0,
>> and inferred that migrate_pages() was never called, although in reality
>> the first page migration failed because compaction_alloc() failed to find
>> a migration target.
>>
>> This patch increments nr_failed so the vmstat is properly accounted on
>> ENOMEM.
>>
>> Signed-off-by: David Rientjes <rientjes@google.com>
>
> Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> One question though
>
>> ---
>> mm/migrate.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/mm/migrate.c b/mm/migrate.c
>> --- a/mm/migrate.c
>> +++ b/mm/migrate.c
>> @@ -1171,6 +1171,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
>>
>> switch(rc) {
>> case -ENOMEM:
>> + nr_failed++;
>> goto out;
>> case -EAGAIN:
>> retry++;
>
> Why don't we need also to count also retries?
We could, but not like you suggest.
> ---
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 53ab6398e7a2..ef9c5211ae3c 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1190,9 +1190,9 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
> }
> }
> }
> +out:
> nr_failed += retry;
> rc = nr_failed;
This overwrites rc == -ENOMEM, which at least compaction needs to
recognize. But we could duplicate "nr_failed += retry" in the case -ENOMEM.
> -out:
> if (nr_succeeded)
> count_vm_events(PGMIGRATE_SUCCESS, nr_succeeded);
> if (nr_failed)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] mm, migrate: increment fail count on ENOMEM
2016-05-20 13:19 ` Vlastimil Babka
@ 2016-05-20 13:31 ` Michal Hocko
2016-05-23 22:02 ` Andrew Morton
0 siblings, 1 reply; 7+ messages in thread
From: Michal Hocko @ 2016-05-20 13:31 UTC (permalink / raw)
To: Vlastimil Babka
Cc: David Rientjes, Andrew Morton, Mel Gorman, linux-mm, linux-kernel
On Fri 20-05-16 15:19:12, Vlastimil Babka wrote:
> On 05/20/2016 03:06 PM, Michal Hocko wrote:
[...]
> > Why don't we need also to count also retries?
>
> We could, but not like you suggest.
>
> > ---
> > diff --git a/mm/migrate.c b/mm/migrate.c
> > index 53ab6398e7a2..ef9c5211ae3c 100644
> > --- a/mm/migrate.c
> > +++ b/mm/migrate.c
> > @@ -1190,9 +1190,9 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
> > }
> > }
> > }
> > +out:
> > nr_failed += retry;
> > rc = nr_failed;
>
> This overwrites rc == -ENOMEM, which at least compaction needs to recognize.
> But we could duplicate "nr_failed += retry" in the case -ENOMEM.
Right you are. So we should do
---
diff --git a/mm/migrate.c b/mm/migrate.c
index 53ab6398e7a2..123fed94022b 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1171,6 +1171,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
switch(rc) {
case -ENOMEM:
+ nr_failed += retry + 1;
goto out;
case -EAGAIN:
retry++;
--
Michal Hocko
SUSE Labs
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [patch] mm, migrate: increment fail count on ENOMEM
2016-05-20 13:31 ` Michal Hocko
@ 2016-05-23 22:02 ` Andrew Morton
2016-05-23 23:32 ` Hugh Dickins
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2016-05-23 22:02 UTC (permalink / raw)
To: Michal Hocko
Cc: Vlastimil Babka, David Rientjes, Mel Gorman, linux-mm, linux-kernel
On Fri, 20 May 2016 15:31:21 +0200 Michal Hocko <mhocko@kernel.org> wrote:
> On Fri 20-05-16 15:19:12, Vlastimil Babka wrote:
> > On 05/20/2016 03:06 PM, Michal Hocko wrote:
> [...]
> > > Why don't we need also to count also retries?
> >
> > We could, but not like you suggest.
> >
> > > ---
> > > diff --git a/mm/migrate.c b/mm/migrate.c
> > > index 53ab6398e7a2..ef9c5211ae3c 100644
> > > --- a/mm/migrate.c
> > > +++ b/mm/migrate.c
> > > @@ -1190,9 +1190,9 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
> > > }
> > > }
> > > }
> > > +out:
> > > nr_failed += retry;
> > > rc = nr_failed;
> >
> > This overwrites rc == -ENOMEM, which at least compaction needs to recognize.
> > But we could duplicate "nr_failed += retry" in the case -ENOMEM.
>
> Right you are. So we should do
> ---
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 53ab6398e7a2..123fed94022b 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1171,6 +1171,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
>
> switch(rc) {
> case -ENOMEM:
> + nr_failed += retry + 1;
> goto out;
> case -EAGAIN:
> retry++;
>
>
argh, this was lost. Please resend as a real patch sometime?
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] mm, migrate: increment fail count on ENOMEM
2016-05-23 22:02 ` Andrew Morton
@ 2016-05-23 23:32 ` Hugh Dickins
2016-05-24 6:17 ` Michal Hocko
0 siblings, 1 reply; 7+ messages in thread
From: Hugh Dickins @ 2016-05-23 23:32 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, Vlastimil Babka, David Rientjes, Mel Gorman,
linux-mm, linux-kernel
On Mon, 23 May 2016, Andrew Morton wrote:
> On Fri, 20 May 2016 15:31:21 +0200 Michal Hocko <mhocko@kernel.org> wrote:
> > On Fri 20-05-16 15:19:12, Vlastimil Babka wrote:
> > > On 05/20/2016 03:06 PM, Michal Hocko wrote:
> > [...]
> > > > Why don't we need also to count also retries?
> > >
> > > We could, but not like you suggest.
> > >
> > > > ---
> > > > diff --git a/mm/migrate.c b/mm/migrate.c
> > > > index 53ab6398e7a2..ef9c5211ae3c 100644
> > > > --- a/mm/migrate.c
> > > > +++ b/mm/migrate.c
> > > > @@ -1190,9 +1190,9 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
> > > > }
> > > > }
> > > > }
> > > > +out:
> > > > nr_failed += retry;
> > > > rc = nr_failed;
> > >
> > > This overwrites rc == -ENOMEM, which at least compaction needs to recognize.
> > > But we could duplicate "nr_failed += retry" in the case -ENOMEM.
> >
> > Right you are. So we should do
> > ---
> > diff --git a/mm/migrate.c b/mm/migrate.c
> > index 53ab6398e7a2..123fed94022b 100644
> > --- a/mm/migrate.c
> > +++ b/mm/migrate.c
> > @@ -1171,6 +1171,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
> >
> > switch(rc) {
> > case -ENOMEM:
> > + nr_failed += retry + 1;
> > goto out;
> > case -EAGAIN:
> > retry++;
> >
> >
>
> argh, this was lost. Please resend as a real patch sometime?
It's not correct. "retry" is reset to 0 each time around the
loop, and it's only a meaningful number to add on to nr_failed, in
the case when we've gone through the whole list: not in this "goto
out" case. We could add another loop to count how many are left
when we hit -ENOMEM, and add that on to nr_failed; but I'm not
convinced that it's worth the bother.
Hugh
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] mm, migrate: increment fail count on ENOMEM
2016-05-23 23:32 ` Hugh Dickins
@ 2016-05-24 6:17 ` Michal Hocko
0 siblings, 0 replies; 7+ messages in thread
From: Michal Hocko @ 2016-05-24 6:17 UTC (permalink / raw)
To: Hugh Dickins
Cc: Andrew Morton, Vlastimil Babka, David Rientjes, Mel Gorman,
linux-mm, linux-kernel
On Mon 23-05-16 16:32:56, Hugh Dickins wrote:
> On Mon, 23 May 2016, Andrew Morton wrote:
> > On Fri, 20 May 2016 15:31:21 +0200 Michal Hocko <mhocko@kernel.org> wrote:
> > > On Fri 20-05-16 15:19:12, Vlastimil Babka wrote:
> > > > On 05/20/2016 03:06 PM, Michal Hocko wrote:
> > > [...]
> > > > > Why don't we need also to count also retries?
> > > >
> > > > We could, but not like you suggest.
> > > >
> > > > > ---
> > > > > diff --git a/mm/migrate.c b/mm/migrate.c
> > > > > index 53ab6398e7a2..ef9c5211ae3c 100644
> > > > > --- a/mm/migrate.c
> > > > > +++ b/mm/migrate.c
> > > > > @@ -1190,9 +1190,9 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
> > > > > }
> > > > > }
> > > > > }
> > > > > +out:
> > > > > nr_failed += retry;
> > > > > rc = nr_failed;
> > > >
> > > > This overwrites rc == -ENOMEM, which at least compaction needs to recognize.
> > > > But we could duplicate "nr_failed += retry" in the case -ENOMEM.
> > >
> > > Right you are. So we should do
> > > ---
> > > diff --git a/mm/migrate.c b/mm/migrate.c
> > > index 53ab6398e7a2..123fed94022b 100644
> > > --- a/mm/migrate.c
> > > +++ b/mm/migrate.c
> > > @@ -1171,6 +1171,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
> > >
> > > switch(rc) {
> > > case -ENOMEM:
> > > + nr_failed += retry + 1;
> > > goto out;
> > > case -EAGAIN:
> > > retry++;
> > >
> > >
> >
> > argh, this was lost. Please resend as a real patch sometime?
>
> It's not correct. "retry" is reset to 0 each time around the
> loop, and it's only a meaningful number to add on to nr_failed, in
> the case when we've gone through the whole list: not in this "goto
> out" case.
You are right! I've missed that, my bad.
> We could add another loop to count how many are left
> when we hit -ENOMEM, and add that on to nr_failed; but I'm not
> convinced that it's worth the bother.
Agreed!
Sorry about the noise!
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-05-24 6:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-19 22:11 [patch] mm, migrate: increment fail count on ENOMEM David Rientjes
2016-05-20 13:06 ` Michal Hocko
2016-05-20 13:19 ` Vlastimil Babka
2016-05-20 13:31 ` Michal Hocko
2016-05-23 22:02 ` Andrew Morton
2016-05-23 23:32 ` Hugh Dickins
2016-05-24 6:17 ` Michal Hocko
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).