Skip to content

Commit

Permalink
mm: fix arithmetic for bdi min_ratio
Browse files Browse the repository at this point in the history
Since now bdi->min_ratio is part per million, fix the wrong arithmetic. 
Otherwise it will fail with -EINVAL when setting a reasonable min_ratio,
as it tries to set min_ratio to (min_ratio * BDI_RATIO_SCALE) in
percentage unit, which exceeds 100% anyway.

    # cat /sys/class/bdi/253\:0/min_ratio
    0
    # cat /sys/class/bdi/253\:0/max_ratio
    100
    # echo 1 > /sys/class/bdi/253\:0/min_ratio
    -bash: echo: write error: Invalid argument

Link: https://lkml.kernel.org/r/[email protected]
Fixes: 8021fb3 ("mm: split off __bdi_set_min_ratio() function")
Signed-off-by: Jingbo Xu <[email protected]>
Reported-by: Joseph Qi <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Stefan Roesch <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
lostjeffle authored and akpm00 committed Dec 29, 2023
1 parent efa7df3 commit e0646b7
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion mm/page-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,6 @@ static int __bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ra

if (min_ratio > 100 * BDI_RATIO_SCALE)
return -EINVAL;
min_ratio *= BDI_RATIO_SCALE;

spin_lock_bh(&bdi_lock);
if (min_ratio > bdi->max_ratio) {
Expand Down

0 comments on commit e0646b7

Please sign in to comment.