Skip to contentSkip to conversation

mapped pagecache pages vs unmapped pages

DISCUSSION Alexey Ivanov 5 participants 9 messages Apr 6, 2012 – Apr 10, 2012 Memory management

lore
Share & tools
lore
#0 lore raw

In progress of migration from FreeBSD to Linux and we found some strange behavior: periodically running tasks (like rsync/p2p deployment) evict mapped pages from memory.

Quoted 1 line

From my little research I've found following lkml thread:

https://lkml.org/lkml/2008/6/11/278
And more precisely this commit: https://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4f98a2fee8acdb4ac84545df98cccecfd130f8db
which along with splitting LRU into "anon" and "file" removed support of reclaim_mapped.

Is there a knob to prioritize mapped memory over unmapped (without modifying all apps to use O_DIRECT/fadvise/madvise or mlocking our data in memory) or at least some way to change proportion of Active(file)/Inactive(file)?

Signature · 2 lines
Sincerely,
Alexey Ivanov
#1 lore raw
Quoted 9 lines · Alexey Ivanov

In progress of migration from FreeBSD to Linux and we found some strange behavior: periodically running tasks (like rsync/p2p deployment) evict mapped pages from memory.

From my little research I've found following lkml thread:
https://lkml.org/lkml/2008/6/11/278
And more precisely this commit: https://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4f98a2fee8acdb4ac84545df98cccecfd130f8db
which along with splitting LRU into "anon" and "file" removed support of reclaim_mapped.

Is there a knob to prioritize mapped memory over unmapped (without modifying all apps to use O_DIRECT/fadvise/madvise or mlocking our data in memory) or at least some way to change proportion of Active(file)/Inactive(file)?

Hi Alexey,

Cc to linux-mm mailing list.

I have met the similar problem and I have sent a mail to discuss it. Maybe it can help you
(http://marc.info/?l=linux-mm&m=132947026019538&w=2).

Now Konstantin has sent a patch set to try to expand vm_flags from 32 bit to 64 bit. Then we can add the new flag into vm_flags and prioritize mmaped pages in madvise(2).

Regards,
Zheng

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw

Thanks for the hint!

Can anyone clarify the reason of not using zone->inactive_ratio in inactive_file_is_low_global()?

06.04.2012, 11:16, "[email protected]" <[email protected]>:

Quoted 30 lines · Alexey Ivanov
Quoted 9 lines

?In progress of migration from FreeBSD to Linux and we found some strange behavior: periodically running tasks (like rsync/p2p deployment) evict mapped pages from memory.

?From my little research I've found following lkml thread:
?https://lkml.org/lkml/2008/6/11/278
?And more precisely this commit: https://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4f98a2fee8acdb4ac84545df98cccecfd130f8db
?which along with splitting LRU into "anon" and "file" removed support of reclaim_mapped.

?Is there a knob to prioritize mapped memory over unmapped (without modifying all apps to use O_DIRECT/fadvise/madvise or mlocking our data in memory) or at least some way to change proportion of Active(file)/Inactive(file)?

Hi Alexey,

Cc to linux-mm mailing list.

I have met the similar problem and I have sent a mail to discuss it. Maybe it can help you
(http://marc.info/?l=linux-mm&m=132947026019538&w=2).

Now Konstantin has sent a patch set to try to expand vm_flags from 32 bit to 64 bit. ?Then we can add the new flag into vm_flags and prioritize mmaped pages in madvise(2).

Regards,
Zheng
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at ?http://vger.kernel.org/majordomo-info.html Please read the FAQ at ?http://www.tux.org/lkml/

Signature · 13 lines
Alexey Ivanov
Yandex Search Admin Team
*************
tel.: +7 (985) 120-35-83 (int. 7176)
http://staff.yandex-team.ru/rbtz
*************

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw
Quoted 3 lines · Alexey Ivanov

Thanks for the hint!

Can anyone clarify the reason of not using zone->inactive_ratio in inactive_file_is_low_global()?

anonymous pages starts out referenced in active list, and scanning the whole active list will only rotate those pages. So we would like to limit the size of inactive anon to save scanning.

--Ying

Quoted 41 lines

06.04.2012, 11:16, "[email protected]" <[email protected]>:

Quoted 23 lines · Alexey Ivanov
Quoted 9 lines

 In progress of migration from FreeBSD to Linux and we found some strange behavior: periodically running tasks (like rsync/p2p deployment) evict mapped pages from memory.

 From my little research I've found following lkml thread:
 https://lkml.org/lkml/2008/6/11/278
 And more precisely this commit: https://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4f98a2fee8acdb4ac84545df98cccecfd130f8db
 which along with splitting LRU into "anon" and "file" removed support of reclaim_mapped.

 Is there a knob to prioritize mapped memory over unmapped (without modifying all apps to use O_DIRECT/fadvise/madvise or mlocking our data in memory) or at least some way to change proportion of Active(file)/Inactive(file)?

Hi Alexey,

Cc to linux-mm mailing list.

I have met the similar problem and I have sent a mail to discuss it. Maybe it can help you
(http://marc.info/?l=linux-mm&m=132947026019538&w=2).

Now Konstantin has sent a patch set to try to expand vm_flags from 32 bit to 64 bit.  Then we can add the new flag into vm_flags and prioritize mmaped pages in madvise(2).

Quoted 7 lines

Regards,
Zheng
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

--
Alexey Ivanov
Yandex Search Admin Team
*************
tel.: +7 (985) 120-35-83 (int. 7176)
http://staff.yandex-team.ru/rbtz
*************

Quoted 6 lines

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
In reply to Alexey Ivanov
Quoted 3 lines · Alexey Ivanov

Thanks for the hint!

Can anyone clarify the reason of not using zone->inactive_ratio in inactive_file_is_low_global()?

New anonymous pages start out on the active anon list, and are always referenced. If memory fills up, they may end up getting moved to the inactive anon list; being referenced while on the inactive anon list is enough to get them promoted back to the active list.

New file pages start out on the INACTIVE file list, and start their lives not referenced at all. Due to readahead extra reads, many file pages may never be referenced.

Only file pages that are referenced twice make it onto the active list.

This means the inactive file list has to be large enough for all the readahead buffers, and give pages enough time on the list that frequently accessed ones can get accessed twice and promoted.

http://linux-mm.org/PageReplacementDesign

Signature · 8 lines
All rights reversed

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#5 lore raw

Did you consider making this ratio tunable, at least manually(i.e. via sysctl)? I suppose we are not the only ones with almost-whole-ram-mmaped workload.

09.04.2012, 22:56, "Rik van Riel" <[email protected]>:

Quoted 28 lines · Alexey Ivanov
Quoted 4 lines

?Thanks for the hint!

?Can anyone clarify the reason of not using zone->inactive_ratio in inactive_file_is_low_global()?

New anonymous pages start out on the active anon list, and are always referenced. ?If memory fills up, they may end up getting moved to the inactive anon list; being referenced while on the inactive anon list is enough to get them promoted back to the active list.

New file pages start out on the INACTIVE file list, and start their lives not referenced at all. Due to readahead extra reads, many file pages may never be referenced.

Only file pages that are referenced twice make it onto the active list.

This means the inactive file list has to be large enough for all the readahead buffers, and give pages enough time on the list that frequently accessed ones can get accessed twice and promoted.

http://linux-mm.org/PageReplacementDesign

--
All rights reversed

Signature · 9 lines
Alexey Ivanov
Yandex Search Admin Team

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#6 lore raw

2012-04-10 i??i ? 8:50, Alexey Ivanov i?' e,?:

Quoted 2 lines

Did you consider making this ratio tunable, at least manually(i.e. via sysctl)? I suppose we are not the only ones with almost-whole-ram-mmaped workload.

Personally, I think it's not good approach.
It depends on kernel's internal implemenatation which would be changed in future as we chagend it at 2.6.28.

In my opinion, kernel just should do best effort to keep active working set except some critical pages which are code pages. If it's not active working set but user want to keep them, we have to add new feature like fadvise/madvise(WORKING_SET) to give the hint to kenrel. Although it causes changing legacy programs, it doesn't copuled kernel's reclaim algorithm and it's way to go, I think.

Quoted 31 lines

09.04.2012, 22:56, "Rik van Riel" <[email protected]>:

Quoted 28 lines · Alexey Ivanov
Quoted 4 lines

Thanks for the hint!

Can anyone clarify the reason of not using zone->inactive_ratio in inactive_file_is_low_global()?

New anonymous pages start out on the active anon list, and are always referenced. If memory fills up, they may end up getting moved to the inactive anon list; being referenced while on the inactive anon list is enough to get them promoted back to the active list.

New file pages start out on the INACTIVE file list, and start their lives not referenced at all. Due to readahead extra reads, many file pages may never be referenced.

Only file pages that are referenced twice make it onto the active list.

This means the inactive file list has to be large enough for all the readahead buffers, and give pages enough time on the list that frequently accessed ones can get accessed twice and promoted.

http://linux-mm.org/PageReplacementDesign

--
All rights reversed

Signature · 9 lines
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#7 lore raw
Quoted 8 lines · Minchan Kim

2012-04-10 i??i ? 8:50, Alexey Ivanov i?' e,?:

Quoted 2 lines

Did you consider making this ratio tunable, at least manually(i.e. via sysctl)? I suppose we are not the only ones with almost-whole-ram-mmaped workload.

Personally, I think it's not good approach.
It depends on kernel's internal implemenatation which would be changed in future as we chagend it at 2.6.28.

I also believe that a tunable for this is not going to be a very workable approach, for the simple reason that changing the value does not make a predictable change in the effectiveness of working set detection or protection.

Quoted 2 lines

In my opinion, kernel just should do best effort to keep active working set except some critical pages which are code pages.

Johannes has some experimental code to measure refaults, and calculate their distance in a multi-zone, multi-cgroup environment.

That would allow us to predictably place things in the working set as required.

Signature · 8 lines
All rights reversed

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#8 lore raw

2012-04-10 i??i ? 9:49, Rik van Riel i?' e,?:

Quoted 17 lines · Minchan Kim
Quoted 10 lines

2012-04-10 i??i ? 8:50, Alexey Ivanov i?' e,?:

Quoted 4 lines

Did you consider making this ratio tunable, at least manually(i.e. via sysctl)?
I suppose we are not the only ones with almost-whole-ram-mmaped workload.

Personally, I think it's not good approach.
It depends on kernel's internal implemenatation which would be changed in future as we chagend it at 2.6.28.

I also believe that a tunable for this is not going to be a very workable approach, for the simple reason that changing the value does not make a predictable change in the effectiveness of working set detection or protection.

Quoted 9 lines
Quoted 2 lines

In my opinion, kernel just should do best effort to keep active working set except some critical pages which are code pages.

Johannes has some experimental code to measure refaults, and calculate their distance in a multi-zone, multi-cgroup environment.

That would allow us to predictably place things in the working set as required.

Hannes, it can help many people if you post your code. ;)

Signature · 9 lines
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>