mm: make faultaround produce old ptes
Subsystems (6)
PATCH v3 1/1 mm: make faultaround produce old ptes
Based on Kirill's patch [1].
Currently, faultaround code produces young pte. This can screw up vmscan behaviour[2], as it makes vmscan think that these pages are hot and not push them out on first round.
During sparse file access faultaround gets more pages mapped and all of them are young. Under memory pressure, this makes vmscan swap out anon pages instead, or to drop other page cache pages which otherwise stay resident.
Modify faultaround to produce old ptes if sysctl 'want_old_faultaround_pte' is set, so they can easily be reclaimed under memory pressure.
This can to some extend defeat the purpose of faultaround on machines without hardware accessed bit as it will not help us with reducing the number of minor page faults.
Making the faultaround ptes old results in a unixbench regression for some architectures [3][4]. But on some architectures like arm64 it is not found to cause any regression.
unixbench shell8 scores on arm64 v8.2 hardware with CONFIG_ARM64_HW_AFDBM enabled (5 runs min, max, avg):
Base: (741,748,744)
With this patch: (739,748,743)
So by default produce young ptes and provide a sysctl option to make the ptes old.
[1] http://lkml.kernel.org/r/1463488366-47723-1-git-send-email-kirill.shutemov@linux.intel.com
[2] https://lkml.kernel.org/r/[email protected]
[3] https://marc.info/?l=linux-kernel&m=146582237922378&w=2
[4] https://marc.info/?l=linux-mm&m=146589376909424&w=2
---
V3:
Fix the documentation (suggested by Kirill)
V2:
1. Removed the arch hook and want_old_faultaround_pte is made a sysctl
2. Renamed FAULT_FLAG_MKOLD to FAULT_FLAG_PREFAULT_OLD (suggested by Jan Kara)
3. Removed the saved fault address from vmf (suggested by Jan Kara)
Documentation/sysctl/vm.txt | 22 ++++++++++++++++++++++ include/linux/mm.h | 3 +++ kernel/sysctl.c | 9 +++++++++ mm/filemap.c | 10 ++++++++++ mm/memory.c | 4 ++++ 5 files changed, 48 insertions(+)
Documentation/sysctl/vm.txt +22 -0
@@ -63,6 +63,7 @@ Currently, these files are in /proc/sys/vm: - vfs_cache_pressure - watermark_scale_factor - zone_reclaim_mode +- want_old_faultaround_pte ==============================================================
@@ -887,4 +888,25 @@ Allowing regular swap effectively restricts allocations to the local node unless explicitly overridden by memory policies or cpuset configurations. +============================================================= + +want_old_faultaround_pte: + +By default faultaround code produces young pte. When want_old_faultaround_pte is +set to 1, faultaround produces old ptes. + +During sparse file access faultaround gets more pages mapped and when all of +them are young (default), under memory pressure, this makes vmscan swap out anon +pages instead, or to drop other page cache pages which otherwise stay resident. +Setting want_old_faultaround_pte to 1 avoids this. + +Making the faultaround ptes old can result in performance regression on some +architectures. This is due to cycles spent in micro-faults which would take page +walk to set young bit in the pte. One such known test that shows a regression on +x86 is unixbench shell8. Set want_old_faultaround_pte to 1 on architectures +which does not show this regression or if the workload shows overall performance +benefit with old faultaround ptes. + +The default value is 0. + ============ End of Document =================================
include/linux/mm.h +3 -0
@@ -302,6 +302,7 @@ extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *,#define FAULT_FLAG_USER 0x40/* The fault originated in userspace */ #define FAULT_FLAG_REMOTE 0x80/* faulting for non current tsk/mm */ #define FAULT_FLAG_INSTRUCTION 0x100/* The fault was during an instruction fetch */ +#define FAULT_FLAG_PREFAULT_OLD 0x200/* Make faultaround ptes old */ #define FAULT_FLAG_TRACE \ { FAULT_FLAG_WRITE, "WRITE" }, \
@@ -2676,5 +2677,7 @@ static inline bool page_is_guard(struct page *page)static inline void setup_nr_node_ids (void ) {}#endif +extern int want_old_faultaround_pte; +#endif /* __KERNEL__ */ #endif /* _LINUX_MM_H */
kernel/sysctl.c +9 -0
@@ -1343,6 +1343,15 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write, .extra1 = &zero, .extra2 = &one_hundred, }, + { + .procname = "want_old_faultaround_pte", + .data = &want_old_faultaround_pte, + .maxlen = sizeof(want_old_faultaround_pte), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = &zero, + .extra2 = &one, + }, #ifdef CONFIG_HUGETLB_PAGE { .procname = "nr_hugepages",
mm/filemap.c +10 -0
@@ -48,6 +48,8 @@#include <asm/mman.h> +int want_old_faultaround_pte; +/* * Shared mappings implemented 30.11.1994. It's not fully working yet, * though.
@@ -2677,6 +2679,14 @@ void filemap_map_pages(struct vm_fault *vmf,if (vmf->pte) vmf->pte += iter.index - last_pgoff; last_pgoff = iter.index; + +if (want_old_faultaround_pte) { +if (iter.index == vmf->pgoff) + vmf->flags &= ~FAULT_FLAG_PREFAULT_OLD ; +else + vmf->flags |=FAULT_FLAG_PREFAULT_OLD ; + } +if (alloc_set_pte (vmf,NULL , page)) goto unlock;unlock_page (page);
mm/memory.c +4 -0
@@ -3438,6 +3438,10 @@ int alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg, entry =mk_pte (page, vma->vm_page_prot);if (write) entry =maybe_mkwrite (pte_mkdirty (entry), vma); + +if (vmf->flags &FAULT_FLAG_PREFAULT_OLD ) + entry =pte_mkold (entry); +/* copy-on-write page */ if (write && !(vma->vm_flags &VM_SHARED )) {inc_mm_counter_fast (vma->vm_mm,MM_ANONPAGES );
Signature · 8 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation -- 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/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
[Please cc linux-api when proposing user interface]
Quoted 11 lines · Vinayak Menon
Based on Kirill's patch [1].
Currently, faultaround code produces young pte. This can screw up vmscan behaviour[2], as it makes vmscan think that these pages are hot and not push them out on first round.
During sparse file access faultaround gets more pages mapped and all of them are young. Under memory pressure, this makes vmscan swap out anon pages instead, or to drop other page cache pages which otherwise stay resident.
Quoted 6 lines
Modify faultaround to produce old ptes if sysctl '
want_old_faultaround_pte' is set, so they can easily be reclaimed under memory pressure.This can to some extend defeat the purpose of faultaround on machines without hardware accessed bit as it will not help us with reducing the number of minor page faults.
So we just want to add a knob to cripple the feature? Isn't it better to simply disable it than to have two distinct implementation which is rather non-intuitive and I would bet that most users will be clueless about how to set it or when to touch it at all. So we will end up with random cargo cult hints all over internet giving you your performance back...
I really dislike this new interface. If the fault around doesn't work for you then disable it.
Quoted 19 lines
Making the faultaround ptes old results in a unixbench regression for some architectures [3][4]. But on some architectures like arm64 it is not found to cause any regression.
unixbench shell8 scores on arm64 v8.2 hardware with
CONFIG_ARM64_HW_AFDBMenabled (5 runs min, max, avg):
Base: (741,748,744)
With this patch: (739,748,743)So by default produce young ptes and provide a sysctl option to make the ptes old.
[1] http://lkml.kernel.org/r/1463488366-47723-1-git-send-email-kirill.shutemov@linux.intel.com
[2] https://lkml.kernel.org/r/[email protected]
[3] https://marc.info/?l=linux-kernel&m=146582237922378&w=2
[4] https://marc.info/?l=linux-mm&m=146589376909424&w=2Signed-off-by Vinayak Menon <[email protected]>
Signature · 8 lines
Michal Hocko SUSE Labs -- 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/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 1 line · Michal Hocko
[Please cc linux-api when proposing user interface]
now for real...
Quoted 51 lines · Vinayak Menon
Quoted 11 lines
Based on Kirill's patch [1].
Currently, faultaround code produces young pte. This can screw up vmscan behaviour[2], as it makes vmscan think that these pages are hot and not push them out on first round.
During sparse file access faultaround gets more pages mapped and all of them are young. Under memory pressure, this makes vmscan swap out anon pages instead, or to drop other page cache pages which otherwise stay resident.
Quoted 6 lines
Modify faultaround to produce old ptes if sysctl '
want_old_faultaround_pte' is set, so they can easily be reclaimed under memory pressure.This can to some extend defeat the purpose of faultaround on machines without hardware accessed bit as it will not help us with reducing the number of minor page faults.
So we just want to add a knob to cripple the feature? Isn't it better to simply disable it than to have two distinct implementation which is rather non-intuitive and I would bet that most users will be clueless about how to set it or when to touch it at all. So we will end up with random cargo cult hints all over internet giving you your performance back...
I really dislike this new interface. If the fault around doesn't work for you then disable it.
Quoted 19 lines
Making the faultaround ptes old results in a unixbench regression for some architectures [3][4]. But on some architectures like arm64 it is not found to cause any regression.
unixbench shell8 scores on arm64 v8.2 hardware with
CONFIG_ARM64_HW_AFDBMenabled (5 runs min, max, avg):
Base: (741,748,744)
With this patch: (739,748,743)So by default produce young ptes and provide a sysctl option to make the ptes old.
[1] http://lkml.kernel.org/r/1463488366-47723-1-git-send-email-kirill.shutemov@linux.intel.com
[2] https://lkml.kernel.org/r/[email protected]
[3] https://marc.info/?l=linux-kernel&m=146582237922378&w=2
[4] https://marc.info/?l=linux-mm&m=146589376909424&w=2Signed-off-by Vinayak Menon <[email protected]>Signature · 2 lines
Michal Hocko SUSE Labs
Signature · 8 lines
Michal Hocko SUSE Labs -- 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/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 20 lines · Michal Hocko
[Please cc linux-api when proposing user interface]
Quoted 11 lines · Vinayak Menon
Based on Kirill's patch [1].
Currently, faultaround code produces young pte. This can screw up vmscan behaviour[2], as it makes vmscan think that these pages are hot and not push them out on first round.
During sparse file access faultaround gets more pages mapped and all of them are young. Under memory pressure, this makes vmscan swap out anon pages instead, or to drop other page cache pages which otherwise stay resident.
Quoted 6 lines
Modify faultaround to produce old ptes if sysctl '
want_old_faultaround_pte' is set, so they can easily be reclaimed under memory pressure.This can to some extend defeat the purpose of faultaround on machines without hardware accessed bit as it will not help us with reducing the number of minor page faults.
Quoted 6 lines
So we just want to add a knob to cripple the feature? Isn't it better to simply disable it than to have two distinct implementation which is rather non-intuitive and I would bet that most users will be clueless about how to set it or when to touch it at all. So we will end up with random cargo cult hints all over internet giving you your performance back...
If you are talking about non-HW access bit systems, then yes it would be better to disable faultaround when want_old_faultaround_pte is set to 1, like MInchan did here https://patchwork.kernel.org/patch/9115901/
I can submit a patch for that.
Quoted 2 lines
I really dislike this new interface. If the fault around doesn't work for you then disable it.
Faultaround works well for me on systems with HW access bit. But the benefit is reduced because of making the faultaround ptes young [2]. Ideally they should be old as they are speculatively mapped and not really accessed. But because of issues on certain architectures they need to be made young[3][4]. This patch is trying to help the other architectures which can tolerate old ptes, by fixing the vmscan behaviour. And this is not a theoretical problem that I am trying to fix. We have really seen the benefit of faultaround on arm mobile targets, but the problem is the vmscan behaviour due to the young pte workaround. And this patch helps in fixing that. Do you think something more needs to be added in the documentation to make things more clear on the flag usage ?
Quoted 13 lines
Quoted 13 lines
Making the faultaround ptes old results in a unixbench regression for some architectures [3][4]. But on some architectures like arm64 it is not found to cause any regression.
unixbench shell8 scores on arm64 v8.2 hardware with
CONFIG_ARM64_HW_AFDBMenabled (5 runs min, max, avg):
Base: (741,748,744)
With this patch: (739,748,743)So by default produce young ptes and provide a sysctl option to make the ptes old.
Quoted 7 lines
Quoted 7 lines
[1] http://lkml.kernel.org/r/1463488366-47723-1-git-send-email-kirill.shutemov@linux.intel.com
[2] https://lkml.kernel.org/r/[email protected]
[3] https://marc.info/?l=linux-kernel&m=146582237922378&w=2
[4] https://marc.info/?l=linux-mm&m=146589376909424&w=2Signed-off-by Vinayak Menon <[email protected]>
--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 39 lines · Vinayak Menon
Quoted 20 lines · Michal Hocko
[Please cc linux-api when proposing user interface]
Quoted 11 lines · Vinayak Menon
Based on Kirill's patch [1].
Currently, faultaround code produces young pte. This can screw up vmscan behaviour[2], as it makes vmscan think that these pages are hot and not push them out on first round.
During sparse file access faultaround gets more pages mapped and all of them are young. Under memory pressure, this makes vmscan swap out anon pages instead, or to drop other page cache pages which otherwise stay resident.
Quoted 6 lines
Modify faultaround to produce old ptes if sysctl '
want_old_faultaround_pte' is set, so they can easily be reclaimed under memory pressure.This can to some extend defeat the purpose of faultaround on machines without hardware accessed bit as it will not help us with reducing the number of minor page faults.
Quoted 6 lines
So we just want to add a knob to cripple the feature? Isn't it better to simply disable it than to have two distinct implementation which is rather non-intuitive and I would bet that most users will be clueless about how to set it or when to touch it at all. So we will end up with random cargo cult hints all over internet giving you your performance back...
If you are talking about non-HW access bit systems, then yes it would be better to disable faultaround when
want_old_faultaround_pteis set to 1, like MInchan did here https://patchwork.kernel.org/patch/9115901/
I can submit a patch for that.Quoted 2 lines
I really dislike this new interface. If the fault around doesn't work for you then disable it.
Quoted 12 lines
Faultaround works well for me on systems with HW access bit. But the benefit is reduced because of making the faultaround ptes young [2]. Ideally they should be old as they are speculatively mapped and not really accessed. But because of issues on certain architectures they need to be made young[3][4]. This patch is trying to help the other architectures which can tolerate old ptes, by fixing the vmscan behaviour. And this is not a theoretical problem that I am trying to fix. We have really seen the benefit of faultaround on arm mobile targets, but the problem is the vmscan behaviour due to the young pte workaround. And this patch helps in fixing that. Do you think something more needs to be added in the documentation to make things more clear on the flag usage ?
No, I would either prefer auto-tuning or document that fault around can lead to this behavior and recommend to disable it rather than add a new knob.
Signature · 8 lines
Michal Hocko SUSE Labs -- 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/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 49 lines · Michal Hocko
Quoted 36 lines · Vinayak Menon
Quoted 20 lines · Michal Hocko
[Please cc linux-api when proposing user interface]
Quoted 11 lines · Vinayak Menon
Based on Kirill's patch [1].
Currently, faultaround code produces young pte. This can screw up vmscan behaviour[2], as it makes vmscan think that these pages are hot and not push them out on first round.
During sparse file access faultaround gets more pages mapped and all of them are young. Under memory pressure, this makes vmscan swap out anon pages instead, or to drop other page cache pages which otherwise stay resident.
Quoted 6 lines
Modify faultaround to produce old ptes if sysctl '
want_old_faultaround_pte' is set, so they can easily be reclaimed under memory pressure.This can to some extend defeat the purpose of faultaround on machines without hardware accessed bit as it will not help us with reducing the number of minor page faults.
Quoted 6 lines
So we just want to add a knob to cripple the feature? Isn't it better to simply disable it than to have two distinct implementation which is rather non-intuitive and I would bet that most users will be clueless about how to set it or when to touch it at all. So we will end up with random cargo cult hints all over internet giving you your performance back...
If you are talking about non-HW access bit systems, then yes it would be better to disable faultaround when
want_old_faultaround_pteis set to 1, like MInchan did here https://patchwork.kernel.org/patch/9115901/
I can submit a patch for that.Quoted 2 lines
I really dislike this new interface. If the fault around doesn't work for you then disable it.
Quoted 12 lines
Faultaround works well for me on systems with HW access bit. But the benefit is reduced because of making the faultaround ptes young [2]. Ideally they should be old as they are speculatively mapped and not really accessed. But because of issues on certain architectures they need to be made young[3][4]. This patch is trying to help the other architectures which can tolerate old ptes, by fixing the vmscan behaviour. And this is not a theoretical problem that I am trying to fix. We have really seen the benefit of faultaround on arm mobile targets, but the problem is the vmscan behaviour due to the young pte workaround. And this patch helps in fixing that. Do you think something more needs to be added in the documentation to make things more clear on the flag usage ?
Quoted 3 lines
No, I would either prefer auto-tuning or document that fault around can lead to this behavior and recommend to disable it rather than add a new knob.
One of the objectives of making it a sysctl was to let user space tune it based on vmpressure [5]. But I am not sure how effective it would be. The vmpressure increase itself can be because of making faultaround ptes young [6] and it could be difficult to find a heuristic to enable/disable faultaround. And with the way vmpressure works, it can happen that vmpressure values don't indicate exact vmscan behavior always. Same is the case with auto-tuning based on vmpressure. Any other suggestions on how auto tuning can be implemented ?
Could you elaborate a bit on why you think sysctl is not a good option ? Is it because of the difficulty for the user to figure out how and when to use the interface ? If the document clearly explains what the knob is, wouldn't be easy for the user to just try the knob and see if his workload benefits or not. It's not just non-x86 devices that can benefit. There may be x86 workloads where the vmscan behavior masks the benefit of avoiding micro faults.
Or if you think sysctl is not the right place for such knobs, do you think it should be an expert level config option or a kernel command line param ?
Since there are lots of mobile and embedded devices that can get the full benefits of faultaround with such an option, I really don't think it is a good option to just document the problem and disable faultaround on those devices.
[5] https://www.spinics.net/lists/arm-kernel/msg622070.html
[6] https://lkml.org/lkml/2016/5/9/134
Thanks,
Vinayak
--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 56 lines · Vinayak Menon
Quoted 49 lines · Michal Hocko
Quoted 36 lines · Vinayak Menon
Quoted 20 lines · Michal Hocko
[Please cc linux-api when proposing user interface]
Quoted 11 lines · Vinayak Menon
Based on Kirill's patch [1].
Currently, faultaround code produces young pte. This can screw up vmscan behaviour[2], as it makes vmscan think that these pages are hot and not push them out on first round.
During sparse file access faultaround gets more pages mapped and all of them are young. Under memory pressure, this makes vmscan swap out anon pages instead, or to drop other page cache pages which otherwise stay resident.
Quoted 6 lines
Modify faultaround to produce old ptes if sysctl '
want_old_faultaround_pte' is set, so they can easily be reclaimed under memory pressure.This can to some extend defeat the purpose of faultaround on machines without hardware accessed bit as it will not help us with reducing the number of minor page faults.
Quoted 6 lines
So we just want to add a knob to cripple the feature? Isn't it better to simply disable it than to have two distinct implementation which is rather non-intuitive and I would bet that most users will be clueless about how to set it or when to touch it at all. So we will end up with random cargo cult hints all over internet giving you your performance back...
If you are talking about non-HW access bit systems, then yes it would be better to disable faultaround when
want_old_faultaround_pteis set to 1, like MInchan did here https://patchwork.kernel.org/patch/9115901/
I can submit a patch for that.Quoted 2 lines
I really dislike this new interface. If the fault around doesn't work for you then disable it.
Quoted 12 lines
Faultaround works well for me on systems with HW access bit. But the benefit is reduced because of making the faultaround ptes young [2]. Ideally they should be old as they are speculatively mapped and not really accessed. But because of issues on certain architectures they need to be made young[3][4]. This patch is trying to help the other architectures which can tolerate old ptes, by fixing the vmscan behaviour. And this is not a theoretical problem that I am trying to fix. We have really seen the benefit of faultaround on arm mobile targets, but the problem is the vmscan behaviour due to the young pte workaround. And this patch helps in fixing that. Do you think something more needs to be added in the documentation to make things more clear on the flag usage ?
Quoted 3 lines
No, I would either prefer auto-tuning or document that fault around can lead to this behavior and recommend to disable it rather than add a new knob.
Quoted 9 lines
One of the objectives of making it a sysctl was to let user space tune it based on vmpressure [5]. But I am not sure how effective it would be. The vmpressure increase itself can be because of making faultaround ptes young [6] and it could be difficult to find a heuristic to enable/disable faultaround. And with the way vmpressure works, it can happen that vmpressure values don't indicate exact vmscan behavior always. Same is the case with auto-tuning based on vmpressure. Any other suggestions on how auto tuning can be implemented ?
I would start simple. Just disable it on platforms which are known to suffer from this heuristic. Do not try to invent a sysctl nobody will know hot to setup.
Quoted 3 lines
Could you elaborate a bit on why you think sysctl is not a good option ? Is it because of the difficulty for the user to figure out how and when to use the interface ?
Absolutely. Not only that but the mere fact to realize that the fault around is the culprit is not something most users will be able/willing to do. So instead we will end up in yet another "disable THP because that solves all the problems in universe" cargo cult.
Quoted 5 lines
If the document clearly explains what the knob is, wouldn't be easy for the user to just try the knob and see if his workload benefits or not. It's not just non-x86 devices that can benefit. There may be x86 workloads where the vmscan behavior masks the benefit of avoiding micro faults.
Try to be more realistic. We have way too many sysctls. Some of them are really implementation specific and then it is not really trivial to get rid of them because people tend to (think they) depend on them. This is a user interface like any others and we do not add them without a due scrutiny. Moreover we do have an interface to suppress the effect of the faultaround. Instead you are trying to add another tunable for something that we can live without altogether. See my point?
Quoted 3 lines
Or if you think sysctl is not the right place for such knobs, do you think it should be an expert level config option or a kernel command line param ?
No it doesn't make much difference. It is still a user interface. Maybe one that is slightly easier to deprecate but just think about it. Do you really need a faultaround so much you really want to fiddle with such lowlevel stuff like old-vs-you pte bits?
Quoted 4 lines
Since there are lots of mobile and embedded devices that can get the full benefits of faultaround with such an option, I really don't think it is a good option to just document the problem and disable faultaround on those devices.
Could you point me to some numbers that prove that? Your unixbench doesn't sound overly convincing. And if this is really about some arches then change them to use old ptes in an arch specific code. Do not make it tunable.
Signature · 8 lines
Michal Hocko SUSE Labs -- 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/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 78 lines · Michal Hocko
Quoted 51 lines · Vinayak Menon
Quoted 46 lines · Michal Hocko
Quoted 33 lines · Vinayak Menon
Quoted 20 lines · Michal Hocko
[Please cc linux-api when proposing user interface]
Quoted 11 lines · Vinayak Menon
Based on Kirill's patch [1].
Currently, faultaround code produces young pte. This can screw up vmscan behaviour[2], as it makes vmscan think that these pages are hot and not push them out on first round.
During sparse file access faultaround gets more pages mapped and all of them are young. Under memory pressure, this makes vmscan swap out anon pages instead, or to drop other page cache pages which otherwise stay resident.
Quoted 6 lines
Modify faultaround to produce old ptes if sysctl '
want_old_faultaround_pte' is set, so they can easily be reclaimed under memory pressure.This can to some extend defeat the purpose of faultaround on machines without hardware accessed bit as it will not help us with reducing the number of minor page faults.
Quoted 6 lines
So we just want to add a knob to cripple the feature? Isn't it better to simply disable it than to have two distinct implementation which is rather non-intuitive and I would bet that most users will be clueless about how to set it or when to touch it at all. So we will end up with random cargo cult hints all over internet giving you your performance back...
If you are talking about non-HW access bit systems, then yes it would be better to disable faultaround when
want_old_faultaround_pteis set to 1, like MInchan did here https://patchwork.kernel.org/patch/9115901/
I can submit a patch for that.Quoted 2 lines
I really dislike this new interface. If the fault around doesn't work for you then disable it.
Quoted 12 lines
Faultaround works well for me on systems with HW access bit. But the benefit is reduced because of making the faultaround ptes young [2]. Ideally they should be old as they are speculatively mapped and not really accessed. But because of issues on certain architectures they need to be made young[3][4]. This patch is trying to help the other architectures which can tolerate old ptes, by fixing the vmscan behaviour. And this is not a theoretical problem that I am trying to fix. We have really seen the benefit of faultaround on arm mobile targets, but the problem is the vmscan behaviour due to the young pte workaround. And this patch helps in fixing that. Do you think something more needs to be added in the documentation to make things more clear on the flag usage ?
Quoted 3 lines
No, I would either prefer auto-tuning or document that fault around can lead to this behavior and recommend to disable it rather than add a new knob.
Quoted 9 lines
One of the objectives of making it a sysctl was to let user space tune it based on vmpressure [5]. But I am not sure how effective it would be. The vmpressure increase itself can be because of making faultaround ptes young [6] and it could be difficult to find a heuristic to enable/disable faultaround. And with the way vmpressure works, it can happen that vmpressure values don't indicate exact vmscan behavior always. Same is the case with auto-tuning based on vmpressure. Any other suggestions on how auto tuning can be implemented ?
I would start simple. Just disable it on platforms which are known to suffer from this heuristic. Do not try to invent a sysctl nobody will know hot to setup.
Quoted 3 lines
Could you elaborate a bit on why you think sysctl is not a good option ? Is it because of the difficulty for the user to figure out how and when to use the interface ?
Absolutely. Not only that but the mere fact to realize that the fault around is the culprit is not something most users will be able/willing to do. So instead we will end up in yet another "disable THP because that solves all the problems in universe" cargo cult.
Quoted 5 lines
If the document clearly explains what the knob is, wouldn't be easy for the user to just try the knob and see if his workload benefits or not. It's not just non-x86 devices that can benefit. There may be x86 workloads where the vmscan behavior masks the benefit of avoiding micro faults.
Quoted 7 lines
Try to be more realistic. We have way too many sysctls. Some of them are really implementation specific and then it is not really trivial to get rid of them because people tend to (think they) depend on them. This is a user interface like any others and we do not add them without a due scrutiny. Moreover we do have an interface to suppress the effect of the faultaround. Instead you are trying to add another tunable for something that we can live without altogether. See my point?
I agree on the sysctl part. But why should we disable faultaround and not find a way to make it useful ? I will try to put it this way. The original ideal behavior of ptes being old was reverted because of the unixbench regression. Isn't the current scenario similar to moving back to old ptes and document that architectures which observes a unixbench regression can disable faultaround ? Is it not better to find a way to fix the problem ? If not sysctl, why not a config or something like that ?
Quoted 7 lines
Quoted 3 lines
Or if you think sysctl is not the right place for such knobs, do you think it should be an expert level config option or a kernel command line param ?
No it doesn't make much difference. It is still a user interface. Maybe one that is slightly easier to deprecate but just think about it. Do you really need a faultaround so much you really want to fiddle with such lowlevel stuff like old-vs-you pte bits?
Yes. See below.
Quoted 6 lines
Quoted 4 lines
Since there are lots of mobile and embedded devices that can get the full benefits of faultaround with such an option, I really don't think it is a good option to just document the problem and disable faultaround on those devices.
Could you point me to some numbers that prove that? Your unixbench doesn't sound overly convincing.
The unixbench results were to show that there are devices that does not show a unixbench regression and can work well with old ptes.
Due to the vmscan behavior with faultaround, we were actually disabling the feature in our builds (Android). Recently it was noticed that faultaround can actually help in reducing the app launch times for apps which does a lot of library loading. Cases which I know about, 100-250ms of benefit in app launch time is seen with faultaround.
These are numbers for a tiny app like calculator.
A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A App Launch latency(ms) A A minor faults during the launch No faultaround (base)A A A A A A A A A A A A A A A A A 382A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A 35282 With FaultaroundA A A A A A A A A A A A A A A A A A A A A A A A A 322A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A 20114 With Fault around and new fixA A 325A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A 20848
The problem with faultaround starts when reclaim kicks in and that is described here https://lkml.org/lkml/2016/4/18/612
Quoted 3 lines
And if this is really about some arches
then change them to use old ptes in an arch specific code. Do not make it tunable.
This may not be actually specific to arch. Though the arm devices which I have tested on does not show any unixbench regression, there can be devices which may show because of micro architectural differences. And as I said earlier,A I think even x86 worloads can show benefits with old pte if the vmscan behaviour masks the faultaround advantage.
Thanks,
Vinayak
--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 1 line · Vinayak Menon
On 1/24/2018 3:08 PM, Michal Hocko wrote:
[...]
Quoted 10 lines
Quoted 7 lines
Try to be more realistic. We have way too many sysctls. Some of them are really implementation specific and then it is not really trivial to get rid of them because people tend to (think they) depend on them. This is a user interface like any others and we do not add them without a due scrutiny. Moreover we do have an interface to suppress the effect of the faultaround. Instead you are trying to add another tunable for something that we can live without altogether. See my point?
I agree on the sysctl part. But why should we disable faultaround and not find a way to make it useful ?
I didn't say that. Please read what I've written. I really hate your new sysctl, because that is not a solution. If you can find a different one than disabling it then go ahead. But do not try to put burden to users because they know what to set. Because they won't.
Signature · 8 lines
Michal Hocko SUSE Labs -- 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/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 10 lines · Michal Hocko
Quoted 1 line · Vinayak Menon
On 1/24/2018 3:08 PM, Michal Hocko wrote:
[...]
Quoted 7 lines
Quoted 7 lines
Try to be more realistic. We have way too many sysctls. Some of them are really implementation specific and then it is not really trivial to get rid of them because people tend to (think they) depend on them. This is a user interface like any others and we do not add them without a due scrutiny. Moreover we do have an interface to suppress the effect of the faultaround. Instead you are trying to add another tunable for something that we can live without altogether. See my point?
Quoted 6 lines
Quoted 2 lines
I agree on the sysctl part. But why should we disable faultaround and not find a way to make it useful ?
I didn't say that. Please read what I've written. I really hate your new sysctl, because that is not a solution. If you can find a different one than disabling it then go ahead. But do not try to put burden to users because they know what to set. Because they won't.
What about an expert level config option which is by default disabled ?
Whether to consider faultaround ptes as old or young is dependent on architectural details that can't be gathered at runtime by reading some system registers. This needs to be figured out by experiments, just like how a value for watermark_scale_factor is arrived at. So the user, in this case an engineer expert in this area decides whether the option can be enabled or not in the build.
I agree that it need not be a sysctl, but what is the problem that you see in making it a expert level config ? How is it a burden to a non-expert user ?
Thanks,
Vinayak
--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · Vinayak Menon
Quoted 10 lines · Michal Hocko
Quoted 1 line · Vinayak Menon
On 1/24/2018 3:08 PM, Michal Hocko wrote:
[...]
Quoted 7 lines
Quoted 7 lines
Try to be more realistic. We have way too many sysctls. Some of them are really implementation specific and then it is not really trivial to get rid of them because people tend to (think they) depend on them. This is a user interface like any others and we do not add them without a due scrutiny. Moreover we do have an interface to suppress the effect of the faultaround. Instead you are trying to add another tunable for something that we can live without altogether. See my point?
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
I agree on the sysctl part. But why should we disable faultaround and not find a way to make it useful ?
I didn't say that. Please read what I've written. I really hate your new sysctl, because that is not a solution. If you can find a different one than disabling it then go ahead. But do not try to put burden to users because they know what to set. Because they won't.
What about an expert level config option which is by default disabled ?
so we have way too many sysctls and it is hard for users to decide what to do and now you are suggesting a config option instead? How come this makes any sense?
Quoted 9 lines
Whether to consider faultaround ptes as old or young is dependent on architectural details that can't be gathered at runtime by reading some system registers. This needs to be figured out by experiments, just like how a value for
watermark_scale_factoris arrived at. So the user, in this case an engineer expert in this area decides whether the option can be enabled or not in the build.
I agree that it need not be a sysctl, but what is the problem that you see in making it a expert level config ? How is it a burden to a non-expert user ?
Our config space is immense. Adding more on top will not put a relief. Just imagine that you get a bug report about a strange reclaim behavior. Now you have a one more aspect to consider.
Seriously, if a heuristic fails on somebody then just make it more conservative. Maybe it is time to sit down and rethink how the fault around should be implemented. No shortcuts and fancy tunables to paper over those problems.
Signature · 8 lines
Michal Hocko SUSE Labs -- 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/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 14 lines · Michal Hocko
Quoted 13 lines · Vinayak Menon
Quoted 12 lines · Michal Hocko
Quoted 1 line · Vinayak Menon
On 1/24/2018 3:08 PM, Michal Hocko wrote:
[...]
Quoted 9 lines
Quoted 7 lines
Try to be more realistic. We have way too many sysctls. Some of them are really implementation specific and then it is not really trivial to get rid of them because people tend to (think they) depend on them. This is a user interface like any others and we do not add them without a due scrutiny. Moreover we do have an interface to suppress the effect of the faultaround. Instead you are trying to add another tunable for something that we can live without altogether. See my point?
I agree on the sysctl part. But why should we disable faultaround and not find a way to make it useful ?
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
I didn't say that. Please read what I've written. I really hate your new sysctl, because that is not a solution. If you can find a different one than disabling it then go ahead. But do not try to put burden to users because they know what to set. Because they won't.
What about an expert level config option which is by default disabled ?
so we have way too many sysctls and it is hard for users to decide what to do and now you are suggesting a config option instead? How come this makes any sense?
Because by making it a expert level config we are reducing the users exposed to the configuration.
Quoted 9 lines
Quoted 9 lines
Whether to consider faultaround ptes as old or young is dependent on architectural details that can't be gathered at runtime by reading some system registers. This needs to be figured out by experiments, just like how a value for
watermark_scale_factoris arrived at. So the user, in this case an engineer expert in this area decides whether the option can be enabled or not in the build.
I agree that it need not be a sysctl, but what is the problem that you see in making it a expert level config ? How is it a burden to a non-expert user ?
Quoted 8 lines
Our config space is immense. Adding more on top will not put a relief. Just imagine that you get a bug report about a strange reclaim behavior. Now you have a one more aspect to consider.
Seriously, if a heuristic fails on somebody then just make it more conservative. Maybe it is time to sit down and rethink how the fault around should be implemented. No shortcuts and fancy tunables to paper over those problems.
Not sure if this is a fault around problem, because without the arch workaround to make the ptes young, faultaround works well. But anyway let me see if I can do something to avoid tunables. Thanks.
--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>