mm, page_alloc: don't check cpuset allowed twice in fast-path
Subsystems (2)
PATCH 1/1 mm, page_alloc: don't check cpuset allowed twice in fast-path
Since commit 682a3385e773 ("mm, page_alloc: inline the fast path of the zonelist iterator") we replace a NULL nodemask with cpuset_current_mems_allowed in the fast path, so that get_page_from_freelist() filters nodes allowed by the cpuset via for_next_zone_zonelist_nodemask(). In that case it's pointless to also check __cpuset_zone_allowed(), which we can avoid by not using ALLOC_CPUSET in that scenario.
--- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/page_alloc.c +2 -1
@@ -3754,9 +3754,10 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,if (cpusets_enabled ()) { alloc_mask |= __GFP_HARDWALL; - alloc_flags |=ALLOC_CPUSET ;if (!ac.nodemask) ac.nodemask = &cpuset_current_mems_allowed; +else + alloc_flags |=ALLOC_CPUSET ; } gfp_mask &= gfp_allowed_mask;
Signature · 7 lines
2.11.0 -- 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 6 lines · Vlastimil Babka
Since commit
682a3385e773("mm,page_alloc: inline the fast path of the zonelist iterator") we replace a NULL nodemask withcpuset_current_mems_allowedin the fast path, so thatget_page_from_freelist()filters nodes allowed by the cpuset viafor_next_zone_zonelist_nodemask(). In that case it's pointless to also check__cpuset_zone_allowed(), which we can avoid by not usingALLOC_CPUSETin that scenario.
OK, this seems to be really worth it as most allocations go via __alloc_pages so we can save __cpuset_zone_allowed in the fast path.
I was about to object how fragile this might be wrt. other ALLOC_CPUSET checks but then I've realized this is only for the hotpath as the slowpath goes through gfp_to_alloc_flags() which sets it back on.
Maybe all that could be added to the changelog?
Quoted 1 line
Signed-off-by Vlastimil Babka <[email protected]>
Quoted 28 lines
--- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)mm/page_alloc.c +2
-1@@ -3754,9 +3754,10 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,if (cpusets_enabled ()) { alloc_mask |= __GFP_HARDWALL; - alloc_flags |=ALLOC_CPUSET ;if (!ac.nodemask) ac.nodemask = &cpuset_current_mems_allowed; +else + alloc_flags |=ALLOC_CPUSET ; } gfp_mask &= gfp_allowed_mask;Signature · 7 lines
2.11.0 -- 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>
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 6 lines · Vlastimil Babka
Since commit
682a3385e773("mm,page_alloc: inline the fast path of the zonelist iterator") we replace a NULL nodemask withcpuset_current_mems_allowedin the fast path, so thatget_page_from_freelist()filters nodes allowed by the cpuset viafor_next_zone_zonelist_nodemask(). In that case it's pointless to also check__cpuset_zone_allowed(), which we can avoid by not usingALLOC_CPUSETin that scenario.OK, this seems to be really worth it as most allocations go via
__alloc_pagesso we can save__cpuset_zone_allowedin the fast path.
Well the "really fast path" assumes that there are no cpusets (except the root one), which is done using static key check in cpusets_enabled(). But we can still do better even if they are enabled.
Quoted 5 lines
I was about to object how fragile this might be wrt. other
ALLOC_CPUSETchecks but then I've realized this is only for the hotpath as the slowpath goes throughgfp_to_alloc_flags()which sets it back on.Maybe all that could be added to the changelog?
OK, will do after collecting more feedback.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Vlastimil Babka <[email protected]>Acked-by Michal Hocko <[email protected]>
Thanks!
Quoted 24 lines
Quoted 24 lines
--- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)mm/page_alloc.c +2
-1@@ -3754,9 +3754,10 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,if (cpusets_enabled ()) { alloc_mask |= __GFP_HARDWALL; - alloc_flags |=ALLOC_CPUSET ;if (!ac.nodemask) ac.nodemask = &cpuset_current_mems_allowed; +else + alloc_flags |=ALLOC_CPUSET ; } gfp_mask &= gfp_allowed_mask;Signature · 1 line
2.11.0
Quoted 6 lines
Quoted 5 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/ .
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Anshuman Khandual
Reviewed-byQuoted 8 lines · Michal Hocko
Quoted 6 lines · Vlastimil Babka
Since commit
682a3385e773("mm,page_alloc: inline the fast path of the zonelist iterator") we replace a NULL nodemask withcpuset_current_mems_allowedin the fast path, so thatget_page_from_freelist()filters nodes allowed by the cpuset viafor_next_zone_zonelist_nodemask(). In that case it's pointless to also check__cpuset_zone_allowed(), which we can avoid by not usingALLOC_CPUSETin that scenario.
Quoted 8 lines
OK, this seems to be really worth it as most allocations go via
__alloc_pagesso we can save__cpuset_zone_allowedin the fast path.I was about to object how fragile this might be wrt. other
ALLOC_CPUSETchecks but then I've realized this is only for the hotpath as the slowpath goes throughgfp_to_alloc_flags()which sets it back on.Maybe all that could be added to the changelog?
Agreed, all these should be added into the change log as the effect of cpuset based nodemask during fast path and slow path is little bit confusing.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Vlastimil Babka <[email protected]>Acked-by Michal Hocko <[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>