diff options
author | Peng Hao <flyingpeng@tencent.com> | 2024-07-23 11:55:13 +0800 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2024-09-01 20:25:45 -0700 |
commit | c39542732a3d84e851a0ab8ff3106ed3138174a0 (patch) | |
tree | 3579156c50ad6bf85eecf400a2f31880c9fb4638 /mm/damon | |
parent | c2a967f6ab0ec896648c0497d3dc15d8f136b148 (diff) |
mm/damon/lru_sort: adjust local variable to dynamic allocation
When KASAN is enabled and built with clang:
mm/damon/lru_sort.c:199:12: error: stack frame size (2328) exceeds
limit (2048) in 'damon_lru_sort_apply_parameters' [-Werror,-Wframe-larger-than]
static int damon_lru_sort_apply_parameters(void)
^
1 error generated.
This is because damon_lru_sort_quota contains a large array, and
assigning this variable to a local variable causes a large amount of
stack space to be occupied.
So adjust local variable to dynamic allocation.
Link: https://lkml.kernel.org/r/20240723035513.20153-1-flyingpeng@tencent.com
Signed-off-by: Peng Hao <flyingpeng@tencent.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/damon')
-rw-r--r-- | mm/damon/lru_sort.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 4af8fd4a390b..0b35bd5fb659 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -148,12 +148,17 @@ static struct damon_target *target; static struct damos *damon_lru_sort_new_scheme( struct damos_access_pattern *pattern, enum damos_action action) { - struct damos_quota quota = damon_lru_sort_quota; + struct damos *damos; + struct damos_quota *quota = kmemdup(&damon_lru_sort_quota, + sizeof(damon_lru_sort_quota), GFP_KERNEL); + + if (!quota) + return NULL; /* Use half of total quota for hot/cold pages sorting */ - quota.ms = quota.ms / 2; + quota->ms = quota->ms / 2; - return damon_new_scheme( + damos = damon_new_scheme( /* find the pattern, and */ pattern, /* (de)prioritize on LRU-lists */ @@ -161,10 +166,12 @@ static struct damos *damon_lru_sort_new_scheme( /* for each aggregation interval */ 0, /* under the quota. */ - "a, + quota, /* (De)activate this according to the watermarks. */ &damon_lru_sort_wmarks, NUMA_NO_NODE); + kfree(quota); + return damos; } /* Create a DAMON-based operation scheme for hot memory regions */ |