Skip to contentSkip to conversation

+ mm-vmscanc-use-div_round_up-for-calculation-of-zones-balance_gap-and-correct-comments.patch added to -mm tree

PATCH [email protected] 1 participant 1 message May 19, 2014

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

Subject: + mm-vmscanc-use-div_round_up-for-calculation-of-zones-balance_gap-and-correct-comments.patch added to -mm tree
To: [email protected],[email protected],[email protected]
From: [email protected]
Date: Mon, 19 May 2014 15:17:04 -0700

The patch titled
Subject: mm/vmscan.c: use DIV_ROUND_UP for calculation of zone's balance_gap and correct comments.
has been added to the -mm tree. Its filename is
mm-vmscanc-use-div_round_up-for-calculation-of-zones-balance_gap-and-correct-comments.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/mm-vmscanc-use-div_round_up-for-calculation-of-zones-balance_gap-and-correct-comments.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/mm-vmscanc-use-div_round_up-for-calculation-of-zones-balance_gap-and-correct-comments.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Jianyu Zhan <[email protected]>
Subject: mm/vmscan.c: use DIV_ROUND_UP for calculation of zone's balance_gap and correct comments.

Currently, we use (zone->managed_pages + KSWAPD_ZONE_BALANCE_GAP_RATIO-1) / KSWAPD_ZONE_BALANCE_GAP_RATIO to avoid a zero gap value. It's better to use DIV_ROUND_UP macro for neater code and clear meaning.

Besides, the gap value is calculated against the per-zone "managed pages", not "present pages". This patch also corrects the comment and do some rephrasing.

---

 include/linux/swap.h |    8 ++++----
 mm/vmscan.c          |   10 ++++------
 2 files changed, 8 insertions(+), 10 deletions(-)
include/linux/swap.h renamed from include/linux/swap.h~mm-vmscanc-use-div_round_up-for-calculation-of-zones-balance_gap-and-correct-comments +4 -4
diff -puN include/linux/swap.h~mm-vmscanc-use-div_round_up-for-calculation-of-zones-balance_gap-and-correct-comments include/linux/swap.h
@@ -166,10 +166,10 @@ enum {
 #define COMPACT_CLUSTER_MAX SWAP_CLUSTER_MAX
 
 /*
- * Ratio between the present memory in the zone and the "gap" that
- * we're allowing kswapd to shrink in addition to the per-zone high
- * wmark, even for zones that already have the high wmark satisfied,
- * in order to provide better per-zone lru behavior. We are ok to
+ * Ratio between zone->managed_pages and the "gap" that above the per-zone
+ * "high_wmark". While balancing nodes, We allow kswapd to shrink zones that
+ * do not meet the (high_wmark + gap) watermark, even which already met the
+ * high_wmark, in order to provide better per-zone lru behavior. We are ok to
  * spend not more than 1% of the memory for this zone balancing "gap".
  */
 #define KSWAPD_ZONE_BALANCE_GAP_RATIO 100
mm/vmscan.c renamed from mm/vmscan.c~mm-vmscanc-use-div_round_up-for-calculation-of-zones-balance_gap-and-correct-comments +4 -6
diff -puN mm/vmscan.c~mm-vmscanc-use-div_round_up-for-calculation-of-zones-balance_gap-and-correct-comments mm/vmscan.c
@@ -2298,9 +2298,8 @@ static inline bool compaction_ready(stru
 	 * there is a buffer of free pages available to give compaction
 	 * a reasonable chance of completing and allocating the page
 	 */
-	balance_gap = min(low_wmark_pages(zone),
-		(zone->managed_pages + KSWAPD_ZONE_BALANCE_GAP_RATIO-1) /
-			KSWAPD_ZONE_BALANCE_GAP_RATIO);
+	balance_gap = min(low_wmark_pages(zone), DIV_ROUND_UP(
+			zone->managed_pages, KSWAPD_ZONE_BALANCE_GAP_RATIO));
 	watermark = high_wmark_pages(zone) + balance_gap + (2UL << sc->order);
 	watermark_ok = zone_watermark_ok_safe(zone, 0, watermark, 0, 0);
 
@@ -2952,9 +2951,8 @@ static bool kswapd_shrink_zone(struct zo
 	 * high wmark plus a "gap" where the gap is either the low
 	 * watermark or 1% of the zone, whichever is smaller.
 	 */
-	balance_gap = min(low_wmark_pages(zone),
-		(zone->managed_pages + KSWAPD_ZONE_BALANCE_GAP_RATIO-1) /
-		KSWAPD_ZONE_BALANCE_GAP_RATIO);
+	balance_gap = min(low_wmark_pages(zone), DIV_ROUND_UP(
+			zone->managed_pages, KSWAPD_ZONE_BALANCE_GAP_RATIO));
 
 	/*
 	 * If there is no low memory pressure or the zone is balanced then no

_

Patches currently in -mm which might be from [email protected] are

origin.patch
mm-swapc-clean-up-lru_cache_add-functions.patch mm-swapc-introduce-put_refcounted_compound_page-helpers-for-spliting-put_compound_page.patch mm-swapc-split-put_compound_page-function.patch mm-introdule-compound_head_by_tail.patch mm-add-comment-for-__mod_zone_page_stat.patch mm-add-comment-for-__mod_zone_page_stat-checkpatch-fixes.patch mm-fold-mlocked_vma_newpage-into-its-only-call-site.patch mm-fold-mlocked_vma_newpage-into-its-only-call-site-checkpatch-fixes.patch mm-hugetlb-move-the-error-handle-logic-out-of-normal-code-path.patch mm-vmscanc-use-div_round_up-for-calculation-of-zones-balance_gap-and-correct-comments.patch linux-next.patch
mm-memcontrol-clean-up-memcg-zoneinfo-lookup.patch mm-memcontrol-remove-unnecessary-memcg-argument-from-soft-limit-functions.patch