* [PATCH RFC] mm,vmscan: only evict file pages when we have plenty
@ 2012-10-30 18:42 Rik van Riel
2012-10-30 18:54 ` Andrew Morton
2012-10-31 15:39 ` Johannes Weiner
0 siblings, 2 replies; 5+ messages in thread
From: Rik van Riel @ 2012-10-30 18:42 UTC (permalink / raw)
To: linux-mm; +Cc: linux-kernel, klamm, akpm, mgorman, hannes
If we have more inactive file pages than active file pages, we
skip scanning the active file pages alltogether, with the idea
that we do not want to evict the working set when there is
plenty of streaming IO in the cache.
However, the code forgot to also skip scanning anonymous pages
in that situation. That lead to the curious situation of keeping
the active file pages protected from being paged out when there
are lots of inactive file pages, while still scanning and evicting
anonymous pages.
This patch fixes that situation, by only evicting file pages
when we have plenty of them and most are inactive.
Signed-off-by: Rik van Riel <riel@redhat.com>
---
mm/vmscan.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 2624edc..1a53fbb 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1686,6 +1686,15 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
fraction[1] = 0;
denominator = 1;
goto out;
+ } else if (!inactive_file_is_low_global(zone)) {
+ /*
+ * There is enough inactive page cache, do not
+ * reclaim anything from the working set right now.
+ */
+ fraction[0] = 0;
+ fraction[1] = 1;
+ denominator = 1;
+ goto out;
}
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH RFC] mm,vmscan: only evict file pages when we have plenty
2012-10-30 18:42 [PATCH RFC] mm,vmscan: only evict file pages when we have plenty Rik van Riel
@ 2012-10-30 18:54 ` Andrew Morton
2012-10-30 19:09 ` Rik van Riel
2012-10-31 15:39 ` Johannes Weiner
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2012-10-30 18:54 UTC (permalink / raw)
To: Rik van Riel; +Cc: linux-mm, linux-kernel, klamm, mgorman, hannes
On Tue, 30 Oct 2012 14:42:04 -0400
Rik van Riel <riel@redhat.com> wrote:
> If we have more inactive file pages than active file pages, we
> skip scanning the active file pages alltogether, with the idea
> that we do not want to evict the working set when there is
> plenty of streaming IO in the cache.
Yes, I've never liked that. The "(active > inactive)" thing is a magic
number. And suddenly causing a complete cessation of vm scanning at a
particular magic threshold seems rather crude, compared to some complex
graduated thing which will also always do the wrong thing, only more
obscurely ;)
Ho hum, in the absence of observed problems, I guess we don't muck with
it.
> However, the code forgot to also skip scanning anonymous pages
> in that situation. That lead to the curious situation of keeping
> the active file pages protected from being paged out when there
> are lots of inactive file pages, while still scanning and evicting
> anonymous pages.
>
> This patch fixes that situation, by only evicting file pages
> when we have plenty of them and most are inactive.
>
Any observed runtime effects from this? If so, were they good?
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1686,6 +1686,15 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
> fraction[1] = 0;
> denominator = 1;
> goto out;
> + } else if (!inactive_file_is_low_global(zone)) {
> + /*
> + * There is enough inactive page cache, do not
> + * reclaim anything from the working set right now.
> + */
> + fraction[0] = 0;
> + fraction[1] = 1;
> + denominator = 1;
> + goto out;
> }
> }
Let's make the commenting look logical:
--- a/mm/vmscan.c~mmvmscan-only-evict-file-pages-when-we-have-plenty-fix
+++ a/mm/vmscan.c
@@ -1679,9 +1679,11 @@ static void get_scan_count(struct lruvec
if (global_reclaim(sc)) {
free = zone_page_state(zone, NR_FREE_PAGES);
- /* If we have very few page cache pages,
- force-scan anon pages. */
if (unlikely(file + free <= high_wmark_pages(zone))) {
+ /*
+ * If we have very few page cache pages, force-scan
+ * anon pages.
+ */
fraction[0] = 1;
fraction[1] = 0;
denominator = 1;
_
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC] mm,vmscan: only evict file pages when we have plenty
2012-10-30 18:54 ` Andrew Morton
@ 2012-10-30 19:09 ` Rik van Riel
0 siblings, 0 replies; 5+ messages in thread
From: Rik van Riel @ 2012-10-30 19:09 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm, linux-kernel, klamm, mgorman, hannes
On 10/30/2012 02:54 PM, Andrew Morton wrote:
> On Tue, 30 Oct 2012 14:42:04 -0400
> Rik van Riel <riel@redhat.com> wrote:
>
>> If we have more inactive file pages than active file pages, we
>> skip scanning the active file pages alltogether, with the idea
>> that we do not want to evict the working set when there is
>> plenty of streaming IO in the cache.
>
> Yes, I've never liked that. The "(active > inactive)" thing is a magic
> number. And suddenly causing a complete cessation of vm scanning at a
> particular magic threshold seems rather crude, compared to some complex
> graduated thing which will also always do the wrong thing, only more
> obscurely ;)
>
> Ho hum, in the absence of observed problems, I guess we don't muck with
> it.
The thing is, when we "suddenly switch behaviour" back to
scanning all the lists, that does not have to suddenly
lead to pages from the other lists being actually evicted.
Instead, it will lead to referenced inactive_anon pages
being moved back to the active_anon list, and any pages
from the end of the active_file list being moved to the
inactive_file list.
There is a threshold, and Johannes has patches to set
the threshold in a much more intelligent way, but the
change in behaviour should not be sudden due to the
inactive lists providing a rather large buffer.
When the VM is bouncing around the threshold, it should
look like a reduction in the rate at which the other
lists are scanned.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC] mm,vmscan: only evict file pages when we have plenty
2012-10-30 18:42 [PATCH RFC] mm,vmscan: only evict file pages when we have plenty Rik van Riel
2012-10-30 18:54 ` Andrew Morton
@ 2012-10-31 15:39 ` Johannes Weiner
2012-10-31 16:17 ` Rik van Riel
1 sibling, 1 reply; 5+ messages in thread
From: Johannes Weiner @ 2012-10-31 15:39 UTC (permalink / raw)
To: Rik van Riel; +Cc: linux-mm, linux-kernel, klamm, akpm, mgorman
On Tue, Oct 30, 2012 at 02:42:04PM -0400, Rik van Riel wrote:
> If we have more inactive file pages than active file pages, we
> skip scanning the active file pages alltogether, with the idea
> that we do not want to evict the working set when there is
> plenty of streaming IO in the cache.
>
> However, the code forgot to also skip scanning anonymous pages
> in that situation. That lead to the curious situation of keeping
> the active file pages protected from being paged out when there
> are lots of inactive file pages, while still scanning and evicting
> anonymous pages.
>
> This patch fixes that situation, by only evicting file pages
> when we have plenty of them and most are inactive.
>
> Signed-off-by: Rik van Riel <riel@redhat.com>
> ---
> mm/vmscan.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 2624edc..1a53fbb 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1686,6 +1686,15 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
> fraction[1] = 0;
> denominator = 1;
> goto out;
> + } else if (!inactive_file_is_low_global(zone)) {
> + /*
> + * There is enough inactive page cache, do not
> + * reclaim anything from the working set right now.
> + */
> + fraction[0] = 0;
> + fraction[1] = 1;
> + denominator = 1;
> + goto out;
Is there a specific reason for making this exclusive to global
reclaim? The "force scan anon when file is low" HAS to be specific to
global reclaim because swapping may not be allowed in memcg limit
reclaim, but not scanning anon when there is enough easy page cache is
a legitimate memcg limit reclaim thing to do as well.
I.e. could this check be moved just below the
/* If we have no swap space, do not bother scanning anon pages. */
if (!sc->may_swap || (nr_swap_pages <= 0)) {
noswap = 1;
fraction[0] = 0;
fraction[1] = 1;
denominator = 1;
goto out;
}
section?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC] mm,vmscan: only evict file pages when we have plenty
2012-10-31 15:39 ` Johannes Weiner
@ 2012-10-31 16:17 ` Rik van Riel
0 siblings, 0 replies; 5+ messages in thread
From: Rik van Riel @ 2012-10-31 16:17 UTC (permalink / raw)
To: Johannes Weiner; +Cc: linux-mm, linux-kernel, klamm, akpm, mgorman
On 10/31/2012 11:39 AM, Johannes Weiner wrote:
> On Tue, Oct 30, 2012 at 02:42:04PM -0400, Rik van Riel wrote:
>> If we have more inactive file pages than active file pages, we
>> skip scanning the active file pages alltogether, with the idea
>> that we do not want to evict the working set when there is
>> plenty of streaming IO in the cache.
>>
>> However, the code forgot to also skip scanning anonymous pages
>> in that situation. That lead to the curious situation of keeping
>> the active file pages protected from being paged out when there
>> are lots of inactive file pages, while still scanning and evicting
>> anonymous pages.
>>
>> This patch fixes that situation, by only evicting file pages
>> when we have plenty of them and most are inactive.
>>
>> Signed-off-by: Rik van Riel <riel@redhat.com>
>> ---
>> mm/vmscan.c | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>> index 2624edc..1a53fbb 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -1686,6 +1686,15 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
>> fraction[1] = 0;
>> denominator = 1;
>> goto out;
>> + } else if (!inactive_file_is_low_global(zone)) {
>> + /*
>> + * There is enough inactive page cache, do not
>> + * reclaim anything from the working set right now.
>> + */
>> + fraction[0] = 0;
>> + fraction[1] = 1;
>> + denominator = 1;
>> + goto out;
>
> Is there a specific reason for making this exclusive to global
> reclaim? The "force scan anon when file is low" HAS to be specific to
> global reclaim because swapping may not be allowed in memcg limit
> reclaim, but not scanning anon when there is enough easy page cache is
> a legitimate memcg limit reclaim thing to do as well.
Good point. I guess this check would work fine inside
cgroup reclaim, too.
Want to give that a try?
>
> I.e. could this check be moved just below the
>
> /* If we have no swap space, do not bother scanning anon pages. */
> if (!sc->may_swap || (nr_swap_pages <= 0)) {
> noswap = 1;
> fraction[0] = 0;
> fraction[1] = 1;
> denominator = 1;
> goto out;
> }
>
> section?
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-10-31 16:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-30 18:42 [PATCH RFC] mm,vmscan: only evict file pages when we have plenty Rik van Riel
2012-10-30 18:54 ` Andrew Morton
2012-10-30 19:09 ` Rik van Riel
2012-10-31 15:39 ` Johannes Weiner
2012-10-31 16:17 ` Rik van Riel
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).