From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Jan Kara <jack@suse.cz>, Jens Axboe <axboe@kernel.dk>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.1 59/71] blk-wbt: Fix detection of dirty-throttled tasks
Date: Wed, 13 Mar 2024 12:39:45 -0400 [thread overview]
Message-ID: <20240313163957.615276-60-sashal@kernel.org> (raw)
In-Reply-To: <20240313163957.615276-1-sashal@kernel.org>
From: Jan Kara <jack@suse.cz>
[ Upstream commit f814bdda774c183b0cc15ec8f3b6e7c6f4527ba5 ]
The detection of dirty-throttled tasks in blk-wbt has been subtly broken
since its beginning in 2016. Namely if we are doing cgroup writeback and
the throttled task is not in the root cgroup, balance_dirty_pages() will
set dirty_sleep for the non-root bdi_writeback structure. However
blk-wbt checks dirty_sleep only in the root cgroup bdi_writeback
structure. Thus detection of recently throttled tasks is not working in
this case (we noticed this when we switched to cgroup v2 and suddently
writeback was slow).
Since blk-wbt has no easy way to get to proper bdi_writeback and
furthermore its intention has always been to work on the whole device
rather than on individual cgroups, just move the dirty_sleep timestamp
from bdi_writeback to backing_dev_info. That fixes the checking for
recently throttled task and saves memory for everybody as a bonus.
CC: stable@vger.kernel.org
Fixes: b57d74aff9ab ("writeback: track if we're sleeping on progress in balance_dirty_pages()")
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20240123175826.21452-1-jack@suse.cz
[axboe: fixup indentation errors]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
block/blk-wbt.c | 4 ++--
include/linux/backing-dev-defs.h | 7 +++++--
mm/backing-dev.c | 2 +-
mm/page-writeback.c | 2 +-
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index e9206b1406e76..fcacdff8af93b 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -98,9 +98,9 @@ static void wb_timestamp(struct rq_wb *rwb, unsigned long *var)
*/
static bool wb_recent_wait(struct rq_wb *rwb)
{
- struct bdi_writeback *wb = &rwb->rqos.disk->bdi->wb;
+ struct backing_dev_info *bdi = rwb->rqos.disk->bdi;
- return time_before(jiffies, wb->dirty_sleep + HZ);
+ return time_before(jiffies, bdi->last_bdp_sleep + HZ);
}
static inline struct rq_wait *get_rq_wait(struct rq_wb *rwb,
diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h
index ae12696ec492c..2ad261082bba5 100644
--- a/include/linux/backing-dev-defs.h
+++ b/include/linux/backing-dev-defs.h
@@ -141,8 +141,6 @@ struct bdi_writeback {
struct delayed_work dwork; /* work item used for writeback */
struct delayed_work bw_dwork; /* work item used for bandwidth estimate */
- unsigned long dirty_sleep; /* last wait */
-
struct list_head bdi_node; /* anchored at bdi->wb_list */
#ifdef CONFIG_CGROUP_WRITEBACK
@@ -179,6 +177,11 @@ struct backing_dev_info {
* any dirty wbs, which is depended upon by bdi_has_dirty().
*/
atomic_long_t tot_write_bandwidth;
+ /*
+ * Jiffies when last process was dirty throttled on this bdi. Used by
+ * blk-wbt.
+ */
+ unsigned long last_bdp_sleep;
struct bdi_writeback wb; /* the root writeback info for this bdi */
struct list_head wb_list; /* list of all wbs */
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index bf5525c2e561a..c070ff9ef9cf3 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -305,7 +305,6 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
INIT_LIST_HEAD(&wb->work_list);
INIT_DELAYED_WORK(&wb->dwork, wb_workfn);
INIT_DELAYED_WORK(&wb->bw_dwork, wb_update_bandwidth_workfn);
- wb->dirty_sleep = jiffies;
err = fprop_local_init_percpu(&wb->completions, gfp);
if (err)
@@ -793,6 +792,7 @@ int bdi_init(struct backing_dev_info *bdi)
INIT_LIST_HEAD(&bdi->bdi_list);
INIT_LIST_HEAD(&bdi->wb_list);
init_waitqueue_head(&bdi->wb_waitq);
+ bdi->last_bdp_sleep = jiffies;
return cgwb_bdi_init(bdi);
}
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index d3e9d12860b9f..9046d1f1b408e 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1809,7 +1809,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb,
break;
}
__set_current_state(TASK_KILLABLE);
- wb->dirty_sleep = now;
+ bdi->last_bdp_sleep = jiffies;
io_schedule_timeout(pause);
current->dirty_paused_when = now + pause;
--
2.43.0
next prev parent reply other threads:[~2024-03-13 16:41 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 16:38 [PATCH 6.1 00/71] 6.1.82-rc1 review Sasha Levin
2024-03-13 16:38 ` [PATCH 6.1 01/71] ceph: switch to corrected encoding of max_xattr_size in mdsmap Sasha Levin
2024-03-13 16:38 ` [PATCH 6.1 02/71] net: lan78xx: fix runtime PM count underflow on link stop Sasha Levin
2024-03-13 16:38 ` [PATCH 6.1 03/71] ixgbe: {dis, en}able irqs in ixgbe_txrx_ring_{dis, en}able Sasha Levin
2024-03-13 16:38 ` [PATCH 6.1 04/71] i40e: disable NAPI right after disabling irqs when handling xsk_pool Sasha Levin
2024-03-13 16:38 ` [PATCH 6.1 05/71] ice: reorder disabling IRQ and NAPI in ice_qp_dis Sasha Levin
2024-03-13 16:38 ` [PATCH 6.1 06/71] tracing/net_sched: Fix tracepoints that save qdisc_dev() as a string Sasha Levin
2024-03-13 16:38 ` [PATCH 6.1 07/71] geneve: make sure to pull inner header in geneve_rx() Sasha Levin
2024-03-13 16:38 ` [PATCH 6.1 08/71] net: sparx5: Fix use after free inside sparx5_del_mact_entry Sasha Levin
2024-03-13 16:38 ` [PATCH 6.1 09/71] ice: virtchnl: stop pretending to support RSS over AQ or registers Sasha Levin
2024-03-13 16:38 ` [PATCH 6.1 10/71] net: ice: Fix potential NULL pointer dereference in ice_bridge_setlink() Sasha Levin
2024-03-13 16:38 ` [PATCH 6.1 11/71] igc: avoid returning frame twice in XDP_REDIRECT Sasha Levin
2024-03-13 16:38 ` [PATCH 6.1 12/71] net/ipv6: avoid possible UAF in ip6_route_mpath_notify() Sasha Levin
2024-03-13 16:38 ` [PATCH 6.1 13/71] cpumap: Zero-initialise xdp_rxq_info struct before running XDP program Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 14/71] net: dsa: microchip: fix register write order in ksz8_ind_write8() Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 15/71] net/rds: fix WARNING in rds_conn_connect_if_down Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 16/71] netfilter: nft_ct: fix l3num expectations with inet pseudo family Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 17/71] netfilter: nf_conntrack_h323: Add protection for bmp length out of range Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 18/71] erofs: apply proper VMA alignment for memory mapped files on THP Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 19/71] netrom: Fix a data-race around sysctl_netrom_default_path_quality Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 20/71] netrom: Fix a data-race around sysctl_netrom_obsolescence_count_initialiser Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 21/71] netrom: Fix data-races around sysctl_netrom_network_ttl_initialiser Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 22/71] netrom: Fix a data-race around sysctl_netrom_transport_timeout Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 23/71] netrom: Fix a data-race around sysctl_netrom_transport_maximum_tries Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 24/71] netrom: Fix a data-race around sysctl_netrom_transport_acknowledge_delay Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 25/71] netrom: Fix a data-race around sysctl_netrom_transport_busy_delay Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 26/71] netrom: Fix a data-race around sysctl_netrom_transport_requested_window_size Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 27/71] netrom: Fix a data-race around sysctl_netrom_transport_no_activity_timeout Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 28/71] netrom: Fix a data-race around sysctl_netrom_routing_control Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 29/71] netrom: Fix a data-race around sysctl_netrom_link_fails_count Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 30/71] netrom: Fix data-races around sysctl_net_busy_read Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 31/71] KVM: s390: add stat counter for shadow gmap events Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 32/71] KVM: s390: vsie: fix race during shadow creation Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 33/71] ASoC: codecs: wcd938x: fix headphones volume controls Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 34/71] drm/amd/display: Fix uninitialized variable usage in core_link_ 'read_dpcd() & write_dpcd()' functions Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 35/71] nfp: flower: add goto_chain_index for ct entry Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 36/71] nfp: flower: add hardware offload check for post " Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 37/71] readahead: avoid multiple marked readahead pages Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 38/71] selftests/mm: switch to bash from sh Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 39/71] selftests: mm: fix map_hugetlb failure on 64K page size systems Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 40/71] xhci: process isoc TD properly when there was a transaction error mid TD Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 41/71] xhci: handle isoc Babble and Buffer Overrun events properly Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 42/71] drm/amdgpu: Reset IH OVERFLOW_CLEAR bit Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 43/71] x86/mmio: Disable KVM mitigation when X86_FEATURE_CLEAR_CPU_BUF is set Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 44/71] Documentation/hw-vuln: Add documentation for RFDS Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 45/71] x86/rfds: Mitigate Register File Data Sampling (RFDS) Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 46/71] KVM/x86: Export RFDS_NO and RFDS_CLEAR to guests Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 47/71] selftests: mptcp: decrease BW in simult flows Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 48/71] blk-iocost: disable writeback throttling Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 49/71] elevator: remove redundant code in elv_unregister_queue() Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 50/71] blk-wbt: remove unnecessary check in wbt_enable_default() Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 51/71] elevator: add new field flags in struct elevator_queue Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 52/71] blk-wbt: don't enable throttling if default elevator is bfq Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 53/71] blk-wbt: pass a gendisk to wbt_{enable,disable}_default Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 54/71] blk-wbt: pass a gendisk to wbt_init Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 55/71] blk-rq-qos: move rq_qos_add and rq_qos_del out of line Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 56/71] blk-rq-qos: make rq_qos_add and rq_qos_del more useful Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 57/71] blk-rq-qos: constify rq_qos_ops Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 58/71] blk-rq-qos: store a gendisk instead of request_queue in struct rq_qos Sasha Levin
2024-03-13 16:39 ` Sasha Levin [this message]
2024-03-13 16:39 ` [PATCH 6.1 60/71] drm/amd/display: Wrong colorimetry workaround Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 61/71] drm/amd/display: Fix MST Null Ptr for RV Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 62/71] getrusage: add the "signal_struct *sig" local variable Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 63/71] getrusage: move thread_group_cputime_adjusted() outside of lock_task_sighand() Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 64/71] getrusage: use __for_each_thread() Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 65/71] getrusage: use sig->stats_lock rather than lock_task_sighand() Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 66/71] fs/proc: do_task_stat: use __for_each_thread() Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 67/71] fs/proc: do_task_stat: use sig->stats_lock to gather the threads/children stats Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 68/71] exit: wait_task_zombie: kill the no longer necessary spin_lock_irq(siglock) Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 69/71] blk-wbt: fix that wbt can't be disabled by default Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 70/71] blk-iocost: Pass gendisk to ioc_refresh_params Sasha Levin
2024-03-13 16:39 ` [PATCH 6.1 71/71] Linux 6.1.82-rc1 Sasha Levin
2024-03-13 20:04 ` [PATCH 6.1 00/71] 6.1.82-rc1 review Pavel Machek
2024-03-13 20:13 ` Mateusz Jończyk
2024-03-13 21:27 ` Mateusz Jończyk
2024-03-14 21:12 ` Mateusz Jończyk
2024-03-14 22:04 ` Jens Axboe
2024-03-14 22:35 ` Sasha Levin
2024-03-14 22:40 ` Jens Axboe
2024-03-15 12:14 ` Sasha Levin
2024-03-15 14:42 ` Sasha Levin
2024-03-15 14:49 ` Jens Axboe
2024-03-15 19:31 ` Ron Economos
2024-03-14 14:43 ` Naresh Kamboju
2024-03-14 20:45 ` Florian Fainelli
2024-03-15 10:37 ` Shreeya Patel
2024-03-15 15:34 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240313163957.615276-60-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=axboe@kernel.dk \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox