aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoonsoo Kim <iamjoonsoo.kim@lge.com>2018-04-10 19:30:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-11 13:28:32 -0400
commitd3cda2337bbc9edd2a26b83cb00eaa8c048ff274 (patch)
tree96e2745e71e23f92a7ce96b6a6b1eec3b69cd779
parent94723aafb9e76414fada7c1c198733a86f01ea8f (diff)
mm/page_alloc: don't reserve ZONE_HIGHMEM for ZONE_MOVABLE request
Freepage on ZONE_HIGHMEM doesn't work for kernel memory so it's not that important to reserve. When ZONE_MOVABLE is used, this problem would theorectically cause to decrease usable memory for GFP_HIGHUSER_MOVABLE allocation request which is mainly used for page cache and anon page allocation. So, fix it by setting 0 to sysctl_lowmem_reserve_ratio[ZONE_HIGHMEM]. And, defining sysctl_lowmem_reserve_ratio array by MAX_NR_ZONES - 1 size makes code complex. For example, if there is highmem system, following reserve ratio is activated for *NORMAL ZONE* which would be easyily misleading people. #ifdef CONFIG_HIGHMEM 32 #endif This patch also fixes this situation by defining sysctl_lowmem_reserve_ratio array by MAX_NR_ZONES and place "#ifdef" to right place. Link: http://lkml.kernel.org/r/1504672525-17915-1-git-send-email-iamjoonsoo.kim@lge.com Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Tested-by: Tony Lindgren <tony@atomide.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.vnet.ibm.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Rik van Riel <riel@redhat.com> Cc: Laura Abbott <lauraa@codeaurora.org> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Michal Nazarewicz <mina86@mina86.com> Cc: Russell King <linux@armlinux.org.uk> Cc: Will Deacon <will.deacon@arm.com> Cc: <linux-api@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--Documentation/sysctl/vm.txt5
-rw-r--r--include/linux/mmzone.h2
-rw-r--r--mm/page_alloc.c25
3 files changed, 17 insertions, 15 deletions
diff --git a/Documentation/sysctl/vm.txt b/Documentation/sysctl/vm.txt
index ff234d229cbb..17256f2ad919 100644
--- a/Documentation/sysctl/vm.txt
+++ b/Documentation/sysctl/vm.txt
@@ -312,8 +312,6 @@ The lowmem_reserve_ratio is an array. You can see them by reading this file.
312% cat /proc/sys/vm/lowmem_reserve_ratio 312% cat /proc/sys/vm/lowmem_reserve_ratio
313256 256 32 313256 256 32
314- 314-
315Note: # of this elements is one fewer than number of zones. Because the highest
316 zone's value is not necessary for following calculation.
317 315
318But, these values are not used directly. The kernel calculates # of protection 316But, these values are not used directly. The kernel calculates # of protection
319pages for each zones from them. These are shown as array of protection pages 317pages for each zones from them. These are shown as array of protection pages
@@ -364,7 +362,8 @@ As above expression, they are reciprocal number of ratio.
364pages of higher zones on the node. 362pages of higher zones on the node.
365 363
366If you would like to protect more pages, smaller values are effective. 364If you would like to protect more pages, smaller values are effective.
367The minimum value is 1 (1/1 -> 100%). 365The minimum value is 1 (1/1 -> 100%). The value less than 1 completely
366disables protection of the pages.
368 367
369============================================================== 368==============================================================
370 369
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index a0c9e45a859a..32699b2dc52a 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -885,7 +885,7 @@ int min_free_kbytes_sysctl_handler(struct ctl_table *, int,
885 void __user *, size_t *, loff_t *); 885 void __user *, size_t *, loff_t *);
886int watermark_scale_factor_sysctl_handler(struct ctl_table *, int, 886int watermark_scale_factor_sysctl_handler(struct ctl_table *, int,
887 void __user *, size_t *, loff_t *); 887 void __user *, size_t *, loff_t *);
888extern int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1]; 888extern int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES];
889int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *, int, 889int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *, int,
890 void __user *, size_t *, loff_t *); 890 void __user *, size_t *, loff_t *);
891int percpu_pagelist_fraction_sysctl_handler(struct ctl_table *, int, 891int percpu_pagelist_fraction_sysctl_handler(struct ctl_table *, int,
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b04667848375..34a4c12d2675 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -205,17 +205,18 @@ static void __free_pages_ok(struct page *page, unsigned int order);
205 * TBD: should special case ZONE_DMA32 machines here - in those we normally 205 * TBD: should special case ZONE_DMA32 machines here - in those we normally
206 * don't need any ZONE_NORMAL reservation 206 * don't need any ZONE_NORMAL reservation
207 */ 207 */
208int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = { 208int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES] = {
209#ifdef CONFIG_ZONE_DMA 209#ifdef CONFIG_ZONE_DMA
210 256, 210 [ZONE_DMA] = 256,
211#endif 211#endif
212#ifdef CONFIG_ZONE_DMA32 212#ifdef CONFIG_ZONE_DMA32
213 256, 213 [ZONE_DMA32] = 256,
214#endif 214#endif
215 [ZONE_NORMAL] = 32,
215#ifdef CONFIG_HIGHMEM 216#ifdef CONFIG_HIGHMEM
216 32, 217 [ZONE_HIGHMEM] = 0,
217#endif 218#endif
218 32, 219 [ZONE_MOVABLE] = 0,
219}; 220};
220 221
221EXPORT_SYMBOL(totalram_pages); 222EXPORT_SYMBOL(totalram_pages);
@@ -7132,13 +7133,15 @@ static void setup_per_zone_lowmem_reserve(void)
7132 struct zone *lower_zone; 7133 struct zone *lower_zone;
7133 7134
7134 idx--; 7135 idx--;
7135
7136 if (sysctl_lowmem_reserve_ratio[idx] < 1)
7137 sysctl_lowmem_reserve_ratio[idx] = 1;
7138
7139 lower_zone = pgdat->node_zones + idx; 7136 lower_zone = pgdat->node_zones + idx;
7140 lower_zone->lowmem_reserve[j] = managed_pages / 7137
7141 sysctl_lowmem_reserve_ratio[idx]; 7138 if (sysctl_lowmem_reserve_ratio[idx] < 1) {
7139 sysctl_lowmem_reserve_ratio[idx] = 0;
7140 lower_zone->lowmem_reserve[j] = 0;
7141 } else {
7142 lower_zone->lowmem_reserve[j] =
7143 managed_pages / sysctl_lowmem_reserve_ratio[idx];
7144 }
7142 managed_pages += lower_zone->managed_pages; 7145 managed_pages += lower_zone->managed_pages;
7143 } 7146 }
7144 } 7147 }