提交 042cecca 编写于 作者: X Xu Yu 提交者: Caspar Zhang

alinux: mm: kidled: fix frame-larger-than build warning

This fix the following build warning:

mm/memcontrol.c: In function 'mem_cgroup_idle_page_stats_show':
mm/memcontrol.c:3866:1: warning: the frame size of 2160 bytes is larger than 2048 bytes [-Wframe-larger-than=]

The root cause is that "mem_cgroup_idle_page_stats_show" has two
"struct idle_page_stats" variables, each of which is 1056 bytes in
size, on the stack, thus exceeding the 2048 max frame size.

This fix the build warning by dynamically allocating memory to these two
variables with kmalloc.

Fixes: f55ac551 ("alinux: mm: Support kidled")
Signed-off-by: NXu Yu <xuyu@linux.alibaba.com>
Reviewed-by: NXunlei Pang <xlpang@linux.alibaba.com>
上级 78c5482c
...@@ -3560,20 +3560,25 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v) ...@@ -3560,20 +3560,25 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v)
{ {
struct mem_cgroup *iter, *memcg = mem_cgroup_from_css(seq_css(m)); struct mem_cgroup *iter, *memcg = mem_cgroup_from_css(seq_css(m));
struct kidled_scan_period scan_period, period; struct kidled_scan_period scan_period, period;
struct idle_page_stats stats, cache; struct idle_page_stats *stats, *cache;
unsigned long scans; unsigned long scans;
bool has_hierarchy = kidled_use_hierarchy(); bool has_hierarchy = kidled_use_hierarchy();
bool no_buckets = false; bool no_buckets = false;
int i, j, t; int i, j, t;
stats = kmalloc(sizeof(struct idle_page_stats) * 2, GFP_KERNEL);
if (!stats)
return -ENOMEM;
cache = stats + 1;
down_read(&memcg->idle_stats_rwsem); down_read(&memcg->idle_stats_rwsem);
stats = memcg->idle_stats[memcg->idle_stable_idx]; *stats = memcg->idle_stats[memcg->idle_stable_idx];
scans = memcg->idle_scans; scans = memcg->idle_scans;
scan_period = memcg->scan_period; scan_period = memcg->scan_period;
up_read(&memcg->idle_stats_rwsem); up_read(&memcg->idle_stats_rwsem);
/* Nothing will be outputed with invalid buckets */ /* Nothing will be outputed with invalid buckets */
if (KIDLED_IS_BUCKET_INVALID(stats.buckets)) { if (KIDLED_IS_BUCKET_INVALID(stats->buckets)) {
no_buckets = true; no_buckets = true;
scans = 0; scans = 0;
goto output; goto output;
...@@ -3581,7 +3586,7 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v) ...@@ -3581,7 +3586,7 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v)
/* Zeroes will be output with mismatched scan period */ /* Zeroes will be output with mismatched scan period */
if (!kidled_is_scan_period_equal(&scan_period)) { if (!kidled_is_scan_period_equal(&scan_period)) {
memset(&stats.count, 0, sizeof(stats.count)); memset(&stats->count, 0, sizeof(stats->count));
scan_period = kidled_get_current_scan_period(); scan_period = kidled_get_current_scan_period();
scans = 0; scans = 0;
goto output; goto output;
...@@ -3594,7 +3599,7 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v) ...@@ -3594,7 +3599,7 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v)
continue; continue;
down_read(&iter->idle_stats_rwsem); down_read(&iter->idle_stats_rwsem);
cache = iter->idle_stats[iter->idle_stable_idx]; *cache = iter->idle_stats[iter->idle_stable_idx];
period = memcg->scan_period; period = memcg->scan_period;
up_read(&iter->idle_stats_rwsem); up_read(&iter->idle_stats_rwsem);
...@@ -3603,7 +3608,7 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v) ...@@ -3603,7 +3608,7 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v)
* or buckets are invalid. * or buckets are invalid.
*/ */
if (!kidled_is_scan_period_equal(&period) || if (!kidled_is_scan_period_equal(&period) ||
KIDLED_IS_BUCKET_INVALID(cache.buckets)) KIDLED_IS_BUCKET_INVALID(cache->buckets))
continue; continue;
/* /*
...@@ -3616,13 +3621,14 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v) ...@@ -3616,13 +3621,14 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v)
*/ */
for (i = 0; i < NUM_KIDLED_BUCKETS; i++) { for (i = 0; i < NUM_KIDLED_BUCKETS; i++) {
for (j = 0; j < NUM_KIDLED_BUCKETS - 1; j++) { for (j = 0; j < NUM_KIDLED_BUCKETS - 1; j++) {
if (cache.buckets[i] <= if (cache->buckets[i] <=
stats.buckets[j]) stats->buckets[j])
break; break;
} }
for (t = 0; t < KIDLE_NR_TYPE; t++) for (t = 0; t < KIDLE_NR_TYPE; t++)
stats.count[t][j] += cache.count[t][i]; stats->count[t][j] +=
cache->count[t][i];
} }
} }
} }
...@@ -3636,14 +3642,14 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v) ...@@ -3636,14 +3642,14 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v)
seq_puts(m, "# buckets: "); seq_puts(m, "# buckets: ");
if (no_buckets) { if (no_buckets) {
seq_puts(m, "no valid bucket available\n"); seq_puts(m, "no valid bucket available\n");
return 0; goto out;
} }
for (i = 0; i < NUM_KIDLED_BUCKETS; i++) { for (i = 0; i < NUM_KIDLED_BUCKETS; i++) {
seq_printf(m, "%d", stats.buckets[i]); seq_printf(m, "%d", stats->buckets[i]);
if ((i == NUM_KIDLED_BUCKETS - 1) || if ((i == NUM_KIDLED_BUCKETS - 1) ||
!stats.buckets[i + 1]) { !stats->buckets[i + 1]) {
seq_puts(m, "\n"); seq_puts(m, "\n");
j = i + 1; j = i + 1;
break; break;
...@@ -3664,11 +3670,11 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v) ...@@ -3664,11 +3670,11 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v)
if (i == j - 1) { if (i == j - 1) {
snprintf(region, sizeof(region), "[%d,+inf)", snprintf(region, sizeof(region), "[%d,+inf)",
stats.buckets[i]); stats->buckets[i]);
} else { } else {
snprintf(region, sizeof(region), "[%d,%d)", snprintf(region, sizeof(region), "[%d,%d)",
stats.buckets[i], stats->buckets[i],
stats.buckets[i + 1]); stats->buckets[i + 1]);
} }
seq_printf(m, " %14s", region); seq_printf(m, " %14s", region);
...@@ -3687,12 +3693,14 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v) ...@@ -3687,12 +3693,14 @@ static int mem_cgroup_idle_page_stats_show(struct seq_file *m, void *v)
for (i = 0; i < j; i++) { for (i = 0; i < j; i++) {
seq_printf(m, " %14lu", seq_printf(m, " %14lu",
stats.count[t][i] << PAGE_SHIFT); stats->count[t][i] << PAGE_SHIFT);
} }
seq_puts(m, "\n"); seq_puts(m, "\n");
} }
out:
kfree(stats);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册