mm/damon/sysfs-schemes: add timeout for update_schemes_tried_regions
authorSeongJae Park <sj@kernel.org>
Fri, 24 Nov 2023 21:38:40 +0000 (21:38 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 7 Dec 2023 00:12:48 +0000 (16:12 -0800)
commit7d6fa31a2fd7072376b3c8be66bf8527b2c8208c
treea9f2cdfe69df6c7ab9cb791f422c80169227a517
parent854f2764b5771e450b44e6a5fddb6872deb5bb56
mm/damon/sysfs-schemes: add timeout for update_schemes_tried_regions

If a scheme is set to not applied to any monitoring target region for any
reasons including the target access pattern, quota, filters, or
watermarks, writing 'update_schemes_tried_regions' to 'state' DAMON sysfs
file can indefinitely hang.  Fix the case by implementing a timeout for
the operation.  The time limit is two apply intervals of each scheme.

Link: https://lkml.kernel.org/r/20231124213840.39157-1-sj@kernel.org
Fixes: 4d4e41b68299 ("mm/damon/sysfs-schemes: do not update tried regions more than one DAMON snapshot")
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/sysfs-schemes.c