Re: [RFC PATCH 1/3] mm/damon/core: error damos_commit_quota_goal() for zero target_value

[email protected]
Newsgroups dev.linux.lists.damon
Message-ID <[email protected]>
> If a DAMOS scheme has a damos_quota_goal of zero target_value,
> damos_quota_goal() could trigger division-by-zero error.  Hence each
> DAMON API callers should do the zero target_value validation.  It is
> easy to make mistakes.  Actually such bugs in DAMON_LRU_SORT and
> DAMON_SAMPLE_MTIER were found and fixed [1].
> 
> It is better to handle the corner case only once in the core layer,
> instead of multiple places in all DAMON API callers.  One
> straightforward option is using an alternative denominator for the
> corner case in the damos_quota_goal().  However, the zero target_value
> is meaningless.  In this case, the quota goal is always evaluated as
> achieved or over-achieved.  The quota will only keep being reduced.
> 
> Simply avoid using zero target_value by adding a check in the core layer
> DAMOS quota goal parameters validation/commit path,
> damos_commit_quota_goal().  Update it to return an error in the case.
> Also update its caller to propagate the error.
> 
> [1] https://lore.kernel.org/[email protected]
> 
> Signed-off-by: SJ Park <[email protected]>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.