Message ID | 20230805110711.2975149-8-shikemeng@huaweicloud.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Fixes and cleanups to compaction | expand |
On 8/5/2023 7:07 PM, Kemeng Shi wrote: > We always do zone_watermark_ok check and compaction_suitable check > together to test if compaction for target order should be runned. > Factor these code out for preparation to remove repeat code. > > Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> > --- > mm/compaction.c | 42 +++++++++++++++++++++++++++++------------- > 1 file changed, 29 insertions(+), 13 deletions(-) > > diff --git a/mm/compaction.c b/mm/compaction.c > index b5a699ed526b..26787ebb0297 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -2365,6 +2365,30 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, > return false; > } > > +/* > + * Should we do compaction for target allocation order. > + * Return COMPACT_SUCCESS if allocation for target order can be already > + * satisfied > + * Return COMPACT_SKIPPED if compaction for target order is likely to fail > + * Return COMPACT_CONTINUE if compaction for target order should be runned > + */ > +static inline enum compact_result > +compaction_suit_allocation_order(struct zone *zone, unsigned int order, > + int highest_zoneidx, unsigned int alloc_flags) > +{ > + unsigned long watermark; > + > + watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK); IIUC, the watermark used in patch 8 and patch 9 is different, right? Have you measured the impact of modifying this watermark? > + if (zone_watermark_ok(zone, order, watermark, highest_zoneidx, > + alloc_flags)) > + return COMPACT_SUCCESS; > + > + if (!compaction_suitable(zone, order, highest_zoneidx)) > + return COMPACT_SKIPPED; > + > + return COMPACT_CONTINUE; > +} > + > static enum compact_result > compact_zone(struct compact_control *cc, struct capture_control *capc) > { > @@ -2390,19 +2414,11 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) > cc->migratetype = gfp_migratetype(cc->gfp_mask); > > if (compaction_with_allocation_order(cc->order)) { > - unsigned long watermark; > - > - /* Allocation can already succeed, nothing to do */ > - watermark = wmark_pages(cc->zone, > - cc->alloc_flags & ALLOC_WMARK_MASK); > - if (zone_watermark_ok(cc->zone, cc->order, watermark, > - cc->highest_zoneidx, cc->alloc_flags)) > - return COMPACT_SUCCESS; > - > - /* Compaction is likely to fail */ > - if (!compaction_suitable(cc->zone, cc->order, > - cc->highest_zoneidx)) > - return COMPACT_SKIPPED; > + ret = compaction_suit_allocation_order(cc->zone, cc->order, > + cc->highest_zoneidx, > + cc->alloc_flags); > + if (ret != COMPACT_CONTINUE) > + return ret; > } > > /*
on 8/15/2023 4:53 PM, Baolin Wang wrote: > > > On 8/5/2023 7:07 PM, Kemeng Shi wrote: >> We always do zone_watermark_ok check and compaction_suitable check >> together to test if compaction for target order should be runned. >> Factor these code out for preparation to remove repeat code. >> >> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> >> --- >> mm/compaction.c | 42 +++++++++++++++++++++++++++++------------- >> 1 file changed, 29 insertions(+), 13 deletions(-) >> >> diff --git a/mm/compaction.c b/mm/compaction.c >> index b5a699ed526b..26787ebb0297 100644 >> --- a/mm/compaction.c >> +++ b/mm/compaction.c >> @@ -2365,6 +2365,30 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, >> return false; >> } >> +/* >> + * Should we do compaction for target allocation order. >> + * Return COMPACT_SUCCESS if allocation for target order can be already >> + * satisfied >> + * Return COMPACT_SKIPPED if compaction for target order is likely to fail >> + * Return COMPACT_CONTINUE if compaction for target order should be runned >> + */ >> +static inline enum compact_result >> +compaction_suit_allocation_order(struct zone *zone, unsigned int order, >> + int highest_zoneidx, unsigned int alloc_flags) >> +{ >> + unsigned long watermark; >> + >> + watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK); > > IIUC, the watermark used in patch 8 and patch 9 is different, right? Have you measured the impact of modifying this watermark? > Actually, there is no functional change intended. Consider wmark_pages with alloc_flags = 0 is equivalent to min_wmark_pages, patch 8 and patch 9 still use original watermark. >> + if (zone_watermark_ok(zone, order, watermark, highest_zoneidx, >> + alloc_flags)) >> + return COMPACT_SUCCESS; >> + >> + if (!compaction_suitable(zone, order, highest_zoneidx)) >> + return COMPACT_SKIPPED; >> + >> + return COMPACT_CONTINUE; >> +} >> + >> static enum compact_result >> compact_zone(struct compact_control *cc, struct capture_control *capc) >> { >> @@ -2390,19 +2414,11 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) >> cc->migratetype = gfp_migratetype(cc->gfp_mask); >> if (compaction_with_allocation_order(cc->order)) { >> - unsigned long watermark; >> - >> - /* Allocation can already succeed, nothing to do */ >> - watermark = wmark_pages(cc->zone, >> - cc->alloc_flags & ALLOC_WMARK_MASK); >> - if (zone_watermark_ok(cc->zone, cc->order, watermark, >> - cc->highest_zoneidx, cc->alloc_flags)) >> - return COMPACT_SUCCESS; >> - >> - /* Compaction is likely to fail */ >> - if (!compaction_suitable(cc->zone, cc->order, >> - cc->highest_zoneidx)) >> - return COMPACT_SKIPPED; >> + ret = compaction_suit_allocation_order(cc->zone, cc->order, >> + cc->highest_zoneidx, >> + cc->alloc_flags); >> + if (ret != COMPACT_CONTINUE) >> + return ret; >> } >> /* > >
On 8/15/2023 8:10 PM, Kemeng Shi wrote: > > > on 8/15/2023 4:53 PM, Baolin Wang wrote: >> >> >> On 8/5/2023 7:07 PM, Kemeng Shi wrote: >>> We always do zone_watermark_ok check and compaction_suitable check >>> together to test if compaction for target order should be runned. >>> Factor these code out for preparation to remove repeat code. >>> >>> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> >>> --- >>> mm/compaction.c | 42 +++++++++++++++++++++++++++++------------- >>> 1 file changed, 29 insertions(+), 13 deletions(-) >>> >>> diff --git a/mm/compaction.c b/mm/compaction.c >>> index b5a699ed526b..26787ebb0297 100644 >>> --- a/mm/compaction.c >>> +++ b/mm/compaction.c >>> @@ -2365,6 +2365,30 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, >>> return false; >>> } >>> +/* >>> + * Should we do compaction for target allocation order. >>> + * Return COMPACT_SUCCESS if allocation for target order can be already >>> + * satisfied >>> + * Return COMPACT_SKIPPED if compaction for target order is likely to fail >>> + * Return COMPACT_CONTINUE if compaction for target order should be runned >>> + */ >>> +static inline enum compact_result >>> +compaction_suit_allocation_order(struct zone *zone, unsigned int order, >>> + int highest_zoneidx, unsigned int alloc_flags) >>> +{ >>> + unsigned long watermark; >>> + >>> + watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK); >> >> IIUC, the watermark used in patch 8 and patch 9 is different, right? Have you measured the impact of modifying this watermark? >> > Actually, there is no functional change intended. Consider wmark_pages with > alloc_flags = 0 is equivalent to min_wmark_pages, patch 8 and patch 9 still > use original watermark. Can you use ALLOC_WMARK_MIN macro to make it more clear? And I think patch 8 and patch 9 should be squashed into patch 7 to convert all at once. >>> + if (zone_watermark_ok(zone, order, watermark, highest_zoneidx, >>> + alloc_flags)) >>> + return COMPACT_SUCCESS; >>> + >>> + if (!compaction_suitable(zone, order, highest_zoneidx)) >>> + return COMPACT_SKIPPED; >>> + >>> + return COMPACT_CONTINUE; >>> +} >>> + >>> static enum compact_result >>> compact_zone(struct compact_control *cc, struct capture_control *capc) >>> { >>> @@ -2390,19 +2414,11 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) >>> cc->migratetype = gfp_migratetype(cc->gfp_mask); >>> if (compaction_with_allocation_order(cc->order)) { >>> - unsigned long watermark; >>> - >>> - /* Allocation can already succeed, nothing to do */ >>> - watermark = wmark_pages(cc->zone, >>> - cc->alloc_flags & ALLOC_WMARK_MASK); >>> - if (zone_watermark_ok(cc->zone, cc->order, watermark, >>> - cc->highest_zoneidx, cc->alloc_flags)) >>> - return COMPACT_SUCCESS; >>> - >>> - /* Compaction is likely to fail */ >>> - if (!compaction_suitable(cc->zone, cc->order, >>> - cc->highest_zoneidx)) >>> - return COMPACT_SKIPPED; >>> + ret = compaction_suit_allocation_order(cc->zone, cc->order, >>> + cc->highest_zoneidx, >>> + cc->alloc_flags); >>> + if (ret != COMPACT_CONTINUE) >>> + return ret; >>> } >>> /* >> >>
on 8/19/2023 8:27 PM, Baolin Wang wrote: > > > On 8/15/2023 8:10 PM, Kemeng Shi wrote: >> >> >> on 8/15/2023 4:53 PM, Baolin Wang wrote: >>> >>> >>> On 8/5/2023 7:07 PM, Kemeng Shi wrote: >>>> We always do zone_watermark_ok check and compaction_suitable check >>>> together to test if compaction for target order should be runned. >>>> Factor these code out for preparation to remove repeat code. >>>> >>>> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> >>>> --- >>>> mm/compaction.c | 42 +++++++++++++++++++++++++++++------------- >>>> 1 file changed, 29 insertions(+), 13 deletions(-) >>>> >>>> diff --git a/mm/compaction.c b/mm/compaction.c >>>> index b5a699ed526b..26787ebb0297 100644 >>>> --- a/mm/compaction.c >>>> +++ b/mm/compaction.c >>>> @@ -2365,6 +2365,30 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, >>>> return false; >>>> } >>>> +/* >>>> + * Should we do compaction for target allocation order. >>>> + * Return COMPACT_SUCCESS if allocation for target order can be already >>>> + * satisfied >>>> + * Return COMPACT_SKIPPED if compaction for target order is likely to fail >>>> + * Return COMPACT_CONTINUE if compaction for target order should be runned >>>> + */ >>>> +static inline enum compact_result >>>> +compaction_suit_allocation_order(struct zone *zone, unsigned int order, >>>> + int highest_zoneidx, unsigned int alloc_flags) >>>> +{ >>>> + unsigned long watermark; >>>> + >>>> + watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK); >>> >>> IIUC, the watermark used in patch 8 and patch 9 is different, right? Have you measured the impact of modifying this watermark? >>> >> Actually, there is no functional change intended. Consider wmark_pages with >> alloc_flags = 0 is equivalent to min_wmark_pages, patch 8 and patch 9 still >> use original watermark. > > Can you use ALLOC_WMARK_MIN macro to make it more clear? Sorry, I can't quite follow this. The watermark should differ with different alloc_flags instead of WMARK_MIN hard-coded. Patch 8 and patch 9 use watermark with WMARK_MIN as they get alloc_flags = 0. > > And I think patch 8 and patch 9 should be squashed into patch 7 to convert all at once. Sure, i could do this in next version. > >>>> + if (zone_watermark_ok(zone, order, watermark, highest_zoneidx, >>>> + alloc_flags)) >>>> + return COMPACT_SUCCESS; >>>> + >>>> + if (!compaction_suitable(zone, order, highest_zoneidx)) >>>> + return COMPACT_SKIPPED; >>>> + >>>> + return COMPACT_CONTINUE; >>>> +} >>>> + >>>> static enum compact_result >>>> compact_zone(struct compact_control *cc, struct capture_control *capc) >>>> { >>>> @@ -2390,19 +2414,11 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) >>>> cc->migratetype = gfp_migratetype(cc->gfp_mask); >>>> if (compaction_with_allocation_order(cc->order)) { >>>> - unsigned long watermark; >>>> - >>>> - /* Allocation can already succeed, nothing to do */ >>>> - watermark = wmark_pages(cc->zone, >>>> - cc->alloc_flags & ALLOC_WMARK_MASK); >>>> - if (zone_watermark_ok(cc->zone, cc->order, watermark, >>>> - cc->highest_zoneidx, cc->alloc_flags)) >>>> - return COMPACT_SUCCESS; >>>> - >>>> - /* Compaction is likely to fail */ >>>> - if (!compaction_suitable(cc->zone, cc->order, >>>> - cc->highest_zoneidx)) >>>> - return COMPACT_SKIPPED; >>>> + ret = compaction_suit_allocation_order(cc->zone, cc->order, >>>> + cc->highest_zoneidx, >>>> + cc->alloc_flags); >>>> + if (ret != COMPACT_CONTINUE) >>>> + return ret; >>>> } >>>> /* >>> >>> > >
On 8/22/2023 9:57 AM, Kemeng Shi wrote: > > > on 8/19/2023 8:27 PM, Baolin Wang wrote: >> >> >> On 8/15/2023 8:10 PM, Kemeng Shi wrote: >>> >>> >>> on 8/15/2023 4:53 PM, Baolin Wang wrote: >>>> >>>> >>>> On 8/5/2023 7:07 PM, Kemeng Shi wrote: >>>>> We always do zone_watermark_ok check and compaction_suitable check >>>>> together to test if compaction for target order should be runned. >>>>> Factor these code out for preparation to remove repeat code. >>>>> >>>>> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> >>>>> --- >>>>> mm/compaction.c | 42 +++++++++++++++++++++++++++++------------- >>>>> 1 file changed, 29 insertions(+), 13 deletions(-) >>>>> >>>>> diff --git a/mm/compaction.c b/mm/compaction.c >>>>> index b5a699ed526b..26787ebb0297 100644 >>>>> --- a/mm/compaction.c >>>>> +++ b/mm/compaction.c >>>>> @@ -2365,6 +2365,30 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, >>>>> return false; >>>>> } >>>>> +/* >>>>> + * Should we do compaction for target allocation order. >>>>> + * Return COMPACT_SUCCESS if allocation for target order can be already >>>>> + * satisfied >>>>> + * Return COMPACT_SKIPPED if compaction for target order is likely to fail >>>>> + * Return COMPACT_CONTINUE if compaction for target order should be runned >>>>> + */ >>>>> +static inline enum compact_result >>>>> +compaction_suit_allocation_order(struct zone *zone, unsigned int order, >>>>> + int highest_zoneidx, unsigned int alloc_flags) >>>>> +{ >>>>> + unsigned long watermark; >>>>> + >>>>> + watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK); >>>> >>>> IIUC, the watermark used in patch 8 and patch 9 is different, right? Have you measured the impact of modifying this watermark? >>>> >>> Actually, there is no functional change intended. Consider wmark_pages with >>> alloc_flags = 0 is equivalent to min_wmark_pages, patch 8 and patch 9 still >>> use original watermark. >> >> Can you use ALLOC_WMARK_MIN macro to make it more clear? > Sorry, I can't quite follow this. The watermark should differ with different > alloc_flags instead of WMARK_MIN hard-coded. > Patch 8 and patch 9 use watermark with WMARK_MIN as they get alloc_flags = 0. I mean you can pass 'alloc_flags=ALLOC_WMARK_MIN' instead of a magic number 0 when calling compaction_suit_allocation_order() in patch 8 and patch 9. >> And I think patch 8 and patch 9 should be squashed into patch 7 to convert all at once. > Sure, i could do this in next version. >> >>>>> + if (zone_watermark_ok(zone, order, watermark, highest_zoneidx, >>>>> + alloc_flags)) >>>>> + return COMPACT_SUCCESS; >>>>> + >>>>> + if (!compaction_suitable(zone, order, highest_zoneidx)) >>>>> + return COMPACT_SKIPPED; >>>>> + >>>>> + return COMPACT_CONTINUE; >>>>> +} >>>>> + >>>>> static enum compact_result >>>>> compact_zone(struct compact_control *cc, struct capture_control *capc) >>>>> { >>>>> @@ -2390,19 +2414,11 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) >>>>> cc->migratetype = gfp_migratetype(cc->gfp_mask); >>>>> if (compaction_with_allocation_order(cc->order)) { >>>>> - unsigned long watermark; >>>>> - >>>>> - /* Allocation can already succeed, nothing to do */ >>>>> - watermark = wmark_pages(cc->zone, >>>>> - cc->alloc_flags & ALLOC_WMARK_MASK); >>>>> - if (zone_watermark_ok(cc->zone, cc->order, watermark, >>>>> - cc->highest_zoneidx, cc->alloc_flags)) >>>>> - return COMPACT_SUCCESS; >>>>> - >>>>> - /* Compaction is likely to fail */ >>>>> - if (!compaction_suitable(cc->zone, cc->order, >>>>> - cc->highest_zoneidx)) >>>>> - return COMPACT_SKIPPED; >>>>> + ret = compaction_suit_allocation_order(cc->zone, cc->order, >>>>> + cc->highest_zoneidx, >>>>> + cc->alloc_flags); >>>>> + if (ret != COMPACT_CONTINUE) >>>>> + return ret; >>>>> } >>>>> /* >>>> >>>> >> >>
on 8/24/2023 10:25 AM, Baolin Wang wrote: > > > On 8/22/2023 9:57 AM, Kemeng Shi wrote: >> >> >> on 8/19/2023 8:27 PM, Baolin Wang wrote: >>> >>> >>> On 8/15/2023 8:10 PM, Kemeng Shi wrote: >>>> >>>> >>>> on 8/15/2023 4:53 PM, Baolin Wang wrote: >>>>> >>>>> >>>>> On 8/5/2023 7:07 PM, Kemeng Shi wrote: >>>>>> We always do zone_watermark_ok check and compaction_suitable check >>>>>> together to test if compaction for target order should be runned. >>>>>> Factor these code out for preparation to remove repeat code. >>>>>> >>>>>> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> >>>>>> --- >>>>>> mm/compaction.c | 42 +++++++++++++++++++++++++++++------------- >>>>>> 1 file changed, 29 insertions(+), 13 deletions(-) >>>>>> >>>>>> diff --git a/mm/compaction.c b/mm/compaction.c >>>>>> index b5a699ed526b..26787ebb0297 100644 >>>>>> --- a/mm/compaction.c >>>>>> +++ b/mm/compaction.c >>>>>> @@ -2365,6 +2365,30 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, >>>>>> return false; >>>>>> } >>>>>> +/* >>>>>> + * Should we do compaction for target allocation order. >>>>>> + * Return COMPACT_SUCCESS if allocation for target order can be already >>>>>> + * satisfied >>>>>> + * Return COMPACT_SKIPPED if compaction for target order is likely to fail >>>>>> + * Return COMPACT_CONTINUE if compaction for target order should be runned >>>>>> + */ >>>>>> +static inline enum compact_result >>>>>> +compaction_suit_allocation_order(struct zone *zone, unsigned int order, >>>>>> + int highest_zoneidx, unsigned int alloc_flags) >>>>>> +{ >>>>>> + unsigned long watermark; >>>>>> + >>>>>> + watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK); >>>>> >>>>> IIUC, the watermark used in patch 8 and patch 9 is different, right? Have you measured the impact of modifying this watermark? >>>>> >>>> Actually, there is no functional change intended. Consider wmark_pages with >>>> alloc_flags = 0 is equivalent to min_wmark_pages, patch 8 and patch 9 still >>>> use original watermark. >>> >>> Can you use ALLOC_WMARK_MIN macro to make it more clear? >> Sorry, I can't quite follow this. The watermark should differ with different >> alloc_flags instead of WMARK_MIN hard-coded. >> Patch 8 and patch 9 use watermark with WMARK_MIN as they get alloc_flags = 0. > > I mean you can pass 'alloc_flags=ALLOC_WMARK_MIN' instead of a magic number 0 when calling compaction_suit_allocation_order() in patch 8 and patch 9. > Thanks for explain and this do make it better. I will do this in next version. >>> And I think patch 8 and patch 9 should be squashed into patch 7 to convert all at once. >> Sure, i could do this in next version. >>> >>>>>> + if (zone_watermark_ok(zone, order, watermark, highest_zoneidx, >>>>>> + alloc_flags)) >>>>>> + return COMPACT_SUCCESS; >>>>>> + >>>>>> + if (!compaction_suitable(zone, order, highest_zoneidx)) >>>>>> + return COMPACT_SKIPPED; >>>>>> + >>>>>> + return COMPACT_CONTINUE; >>>>>> +} >>>>>> + >>>>>> static enum compact_result >>>>>> compact_zone(struct compact_control *cc, struct capture_control *capc) >>>>>> { >>>>>> @@ -2390,19 +2414,11 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) >>>>>> cc->migratetype = gfp_migratetype(cc->gfp_mask); >>>>>> if (compaction_with_allocation_order(cc->order)) { >>>>>> - unsigned long watermark; >>>>>> - >>>>>> - /* Allocation can already succeed, nothing to do */ >>>>>> - watermark = wmark_pages(cc->zone, >>>>>> - cc->alloc_flags & ALLOC_WMARK_MASK); >>>>>> - if (zone_watermark_ok(cc->zone, cc->order, watermark, >>>>>> - cc->highest_zoneidx, cc->alloc_flags)) >>>>>> - return COMPACT_SUCCESS; >>>>>> - >>>>>> - /* Compaction is likely to fail */ >>>>>> - if (!compaction_suitable(cc->zone, cc->order, >>>>>> - cc->highest_zoneidx)) >>>>>> - return COMPACT_SKIPPED; >>>>>> + ret = compaction_suit_allocation_order(cc->zone, cc->order, >>>>>> + cc->highest_zoneidx, >>>>>> + cc->alloc_flags); >>>>>> + if (ret != COMPACT_CONTINUE) >>>>>> + return ret; >>>>>> } >>>>>> /* >>>>> >>>>> >>> >>> >
diff --git a/mm/compaction.c b/mm/compaction.c index b5a699ed526b..26787ebb0297 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2365,6 +2365,30 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, return false; } +/* + * Should we do compaction for target allocation order. + * Return COMPACT_SUCCESS if allocation for target order can be already + * satisfied + * Return COMPACT_SKIPPED if compaction for target order is likely to fail + * Return COMPACT_CONTINUE if compaction for target order should be runned + */ +static inline enum compact_result +compaction_suit_allocation_order(struct zone *zone, unsigned int order, + int highest_zoneidx, unsigned int alloc_flags) +{ + unsigned long watermark; + + watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK); + if (zone_watermark_ok(zone, order, watermark, highest_zoneidx, + alloc_flags)) + return COMPACT_SUCCESS; + + if (!compaction_suitable(zone, order, highest_zoneidx)) + return COMPACT_SKIPPED; + + return COMPACT_CONTINUE; +} + static enum compact_result compact_zone(struct compact_control *cc, struct capture_control *capc) { @@ -2390,19 +2414,11 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) cc->migratetype = gfp_migratetype(cc->gfp_mask); if (compaction_with_allocation_order(cc->order)) { - unsigned long watermark; - - /* Allocation can already succeed, nothing to do */ - watermark = wmark_pages(cc->zone, - cc->alloc_flags & ALLOC_WMARK_MASK); - if (zone_watermark_ok(cc->zone, cc->order, watermark, - cc->highest_zoneidx, cc->alloc_flags)) - return COMPACT_SUCCESS; - - /* Compaction is likely to fail */ - if (!compaction_suitable(cc->zone, cc->order, - cc->highest_zoneidx)) - return COMPACT_SKIPPED; + ret = compaction_suit_allocation_order(cc->zone, cc->order, + cc->highest_zoneidx, + cc->alloc_flags); + if (ret != COMPACT_CONTINUE) + return ret; } /*
We always do zone_watermark_ok check and compaction_suitable check together to test if compaction for target order should be runned. Factor these code out for preparation to remove repeat code. Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> --- mm/compaction.c | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-)