hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9935 -------------------------------- Hide dpool related files if dpagelist is not enabled. Fixes: 118813b0a079 ("[Huawei] mm/dpool: add dpool.show to show meminfo") Signed-off-by: Wupeng Ma <mawupeng1@huawei.com> --- mm/dynamic_pool.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/mm/dynamic_pool.c b/mm/dynamic_pool.c index cc553982d85f2..c5a45b1d34841 100644 --- a/mm/dynamic_pool.c +++ b/mm/dynamic_pool.c @@ -1386,13 +1386,30 @@ static struct dynamic_pool_ops hugetlb_dpool_ops = { .restore_pool = dpool_merge_all, }; -/* If dynamic pool is disabled, hide the interface */ +/* + * Determines whether to hide dynamic pool control files based on + * cross-hiding logic. + * + * Cross-hiding behavior: + * - When enable_dpagelist is ON, hide dhugetlb files + * - When enable_dhugetlb is ON, hide dpagelist files + * + * Prevents conflicts when both features could interfere. + */ bool dynamic_pool_hide_files(struct cftype *cft) { - if (dpool_enabled && enable_dhugetlb) + bool is_dhugetlb_file = !!strstr(cft->name, "dhugetlb"); + bool is_dpagelist_file = !!strstr(cft->name, "dpool"); + /* Non-related files are never hidden */ + if (!is_dhugetlb_file && !is_dpagelist_file) return false; - return !!strstr(cft->name, "dhugetlb"); + /* Hide all related files when the dynamic pool feature is disabled */ + if (!dpool_enabled) + return true; + + return (enable_dpagelist && is_dhugetlb_file) || + (enable_dhugetlb && is_dpagelist_file); } int dynamic_pool_add_memory(struct mem_cgroup *memcg, int nid, -- 2.43.0