summaryrefslogtreecommitdiffstats
path: root/mm/vmscan.c
diff options
context:
space:
mode:
authorGreg Thelen <gthelen@google.com>2018-08-17 18:45:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-08-17 19:20:28 -0400
commitbb451fdf3d058dfecee1c0b965342d344e7d8317 (patch)
tree2930abe7aef27e391d5400d19070e747c681ba3f /mm/vmscan.c
parent10ed63415223b16d7e80ba528556500231814232 (diff)
mm/vmscan.c: condense scan_control
Use smaller scan_control fields for order, priority, and reclaim_idx. Convert fields from int => s8. All easily fit within a byte: - allocation order range: 0..MAX_ORDER(64?) - priority range: 0..12(DEF_PRIORITY) - reclaim_idx range: 0..6(__MAX_NR_ZONES) Since 6538b8ea886e ("x86_64: expand kernel stack to 16K") x86_64 stack overflows are not an issue. But it's inefficient to use ints. Use s8 (signed byte) rather than u8 to allow for loops like: do { ... } while (--sc.priority >= 0); Add BUILD_BUG_ON to verify that s8 is capable of storing max values. This reduces sizeof(struct scan_control): - 96 => 80 bytes (x86_64) - 68 => 56 bytes (i386) scan_control structure field order is changed to utilize padding. After this patch there is 1 bit of scan_control padding. akpm: makes my vmscan.o's .text 572 bytes smaller as well. Link: http://lkml.kernel.org/r/20180530061212.84915-1-gthelen@google.com Signed-off-by: Greg Thelen <gthelen@google.com> Suggested-by: Matthew Wilcox <willy@infradead.org> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/vmscan.c')
-rw-r--r--mm/vmscan.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 03822f86f288..a00d94530e57 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -65,12 +65,6 @@ struct scan_control {
65 /* How many pages shrink_list() should reclaim */ 65 /* How many pages shrink_list() should reclaim */
66 unsigned long nr_to_reclaim; 66 unsigned long nr_to_reclaim;
67 67
68 /* This context's GFP mask */
69 gfp_t gfp_mask;
70
71 /* Allocation order */
72 int order;
73
74 /* 68 /*
75 * Nodemask of nodes allowed by the caller. If NULL, all nodes 69 * Nodemask of nodes allowed by the caller. If NULL, all nodes
76 * are scanned. 70 * are scanned.
@@ -83,12 +77,6 @@ struct scan_control {
83 */ 77 */
84 struct mem_cgroup *target_mem_cgroup; 78 struct mem_cgroup *target_mem_cgroup;
85 79
86 /* Scan (total_size >> priority) pages at once */
87 int priority;
88
89 /* The highest zone to isolate pages for reclaim from */
90 enum zone_type reclaim_idx;
91
92 /* Writepage batching in laptop mode; RECLAIM_WRITE */ 80 /* Writepage batching in laptop mode; RECLAIM_WRITE */
93 unsigned int may_writepage:1; 81 unsigned int may_writepage:1;
94 82
@@ -111,6 +99,18 @@ struct scan_control {
111 /* One of the zones is ready for compaction */ 99 /* One of the zones is ready for compaction */
112 unsigned int compaction_ready:1; 100 unsigned int compaction_ready:1;
113 101
102 /* Allocation order */
103 s8 order;
104
105 /* Scan (total_size >> priority) pages at once */
106 s8 priority;
107
108 /* The highest zone to isolate pages for reclaim from */
109 s8 reclaim_idx;
110
111 /* This context's GFP mask */
112 gfp_t gfp_mask;
113
114 /* Incremented by the number of inactive pages that were scanned */ 114 /* Incremented by the number of inactive pages that were scanned */
115 unsigned long nr_scanned; 115 unsigned long nr_scanned;
116 116
@@ -3064,6 +3064,14 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
3064 }; 3064 };
3065 3065
3066 /* 3066 /*
3067 * scan_control uses s8 fields for order, priority, and reclaim_idx.
3068 * Confirm they are large enough for max values.
3069 */
3070 BUILD_BUG_ON(MAX_ORDER > S8_MAX);
3071 BUILD_BUG_ON(DEF_PRIORITY > S8_MAX);
3072 BUILD_BUG_ON(MAX_NR_ZONES > S8_MAX);
3073
3074 /*
3067 * Do not enter reclaim if fatal signal was delivered while throttled. 3075 * Do not enter reclaim if fatal signal was delivered while throttled.
3068 * 1 is returned so that the page allocator does not OOM kill at this 3076 * 1 is returned so that the page allocator does not OOM kill at this
3069 * point. 3077 * point.