iocost: fix infinite loop bug in adjust_inuse_and_calc_cost()
Tejun Heo authored
adjust_inuse_and_calc_cost() is responsible for reducing the amount of
donated weights dynamically in period as the budget runs low. Because we
don't want to do full donation calculation in period, we keep latching up
inuse by INUSE_ADJ_STEP_PCT of the active weight of the cgroup until the
resulting hweight_inuse is satisfactory.

Unfortunately, the adj_step calculation was reading the active weight before
acquiring ioc->lock. Because the current thread could have lost race to
activate the iocg to another thread before entering this function, it may
read the active weight as zero before acquiring ioc->lock. When this
happens, the adj_step is calculated as zero and the incremental adjustment
loop becomes an infinite one.

Fix it by fetching the active weight after acquiring ioc->lock.

Fixes: b0853ab4

 ("blk-iocost: revamp in-period donation snapbacks")
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
aa67db24
Name Last commit Last update
Documentation Documentation/filesystems/locking.rst: remove an incorrect sentence
LICENSES LICENSES: Rename other to deprecated
arch Merge tag 'x86-urgent-2020-08-30' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
block iocost: fix infinite loop bug in adjust_inuse_and_calc_cost()
certs .gitignore: add SPDX License Identifier
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
drivers bcache: use part_[begin|end]_io_acct instead of disk_[begin|end]_io_acct
fs block: remove check_disk_change
include block: introduce part_[begin|end]_io_acct
init Merge tag 'for-linus' of git://github.com/openrisc/linux
ipc treewide: Use fallthrough pseudo-keyword
kernel blktrace: make function blk_trace_bio_get_cgid() static
lib lib: Revert use of fallthrough pseudo-keyword in lib/
mm Merge tag 'powerpc-5.9-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
net Merge tag 'nfsd-5.9-1' of git://git.linux-nfs.org/projects/cel/cel-2.6
samples treewide: Use fallthrough pseudo-keyword
scripts kconfig: qconf: replace deprecated QString::sprintf() with QTextStream
security treewide: Use fallthrough pseudo-keyword
sound treewide: Use fallthrough pseudo-keyword
tools blk-iocost: update iocost_monitor.py
usr Merge branch 'work.fdpic' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
virt Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
.clang-format block: add bio_for_each_bvec_all()
.cocciconfig scripts: add Linux .cocciconfig for coccinelle
.get_maintainer.ignore Opt out of scripts/get_maintainer.pl
.gitattributes .gitattributes: use 'dts' diff driver for dts files
.gitignore .gitignore: Add ZSTD-compressed files
.mailmap Merge branch 'akpm' (patches from Andrew)
COPYING COPYING: state that all contributions really are covered by this file
CREDITS CREDITS: Replace HTTP links with HTTPS ones
Kbuild kbuild: rename hostprogs-y/always to hostprogs/always-y
Kconfig kbuild: ensure full rebuild when the compiler is updated
MAINTAINERS Merge tag 'x86-urgent-2020-08-30' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Makefile Linux 5.9-rc3
README Drop all 00-INDEX files from Documentation/
Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.