Commit 15d827f5 authored by SeongJae Park's avatar SeongJae Park Committed by Matthias Maennich
Browse files

UPSTREAM: mm/damon/sysfs: remove requested targets when online-commit inputs

damon_sysfs_set_targets(), which updates the targets of the context for
online commitment, do not remove targets that removed from the
corresponding sysfs files.  As a result, more than intended targets of the
context can exist and hence consume memory and monitoring CPU resource
more than expected.

Fix it by removing all targets of the context and fill up again using the
user input.  This could cause unnecessary memory dealloc and realloc
operations, but this is not a hot code path.  Also, note that damon_target
is stateless, and hence no data is lost.

[sj@kernel.org: fix unnecessary monitoring results removal]
  Link: https://lkml.kernel.org/r/20231028213353.45397-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20231022210735.46409-2-sj@kernel.org


Fixes: da878780 ("mm/damon/sysfs: support online inputs update")
Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
Cc: Brendan Higgins <brendanhiggins@google.com>
Cc: <stable@vger.kernel.org>	[5.19.x]
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 19467a95)

Bug: 300502883
Bug: 325146881
Change-Id: Icf094f138e6810182d23d2c412fbabe3ecd960fe
Signed-off-by: default avatarcui yangpei <cuiyangpei@xiaomi.com>
parent bd3f6ba4
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment