blkcg: revert blkcg cleanups series
Subsystems (12)
PATCH 1/1 blkcg: revert blkcg cleanups series
This reverts a series committed earlier due to null pointer exception bug report in [1]. It seems there are edge case interactions that I did not consider and will need some time to understand what causes the adverse interactions.
The original series can be found in [2] with a follow up series in [3].
[1] https://www.spinics.net/lists/cgroups/msg20719.html
[2] https://lore.kernel.org/lkml/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/
This reverts the following commits:d459d853c2ed, b2c3fa546705, 101246ec02b5, b3b9f24f5fcc, e2b0989954ae, f0fcb3ec89f3, c839e7a03f92, bdc2491708c4, 74b7c02a9bc1, 5bf9a1f3b4ef, a7b39b4e961c, 07b05bcc3213, 49f4c2dc2b50, 27e6fa996c53
--- Documentation/admin-guide/cgroup-v2.rst | 8 +- block/bfq-cgroup.c | 4 +- block/bfq-iosched.c | 2 +- block/bio.c | 174 +++++++----------------- block/blk-cgroup.c | 123 ++++++----------- block/blk-core.c | 1 - block/blk-iolatency.c | 26 +++- block/blk-throttle.c | 13 +- block/bounce.c | 4 +- block/cfq-iosched.c | 4 +- drivers/block/loop.c | 5 +- drivers/md/raid0.c | 2 +- fs/buffer.c | 10 +- fs/ext4/page-io.c | 2 +- include/linux/bio.h | 26 ++-- include/linux/blk-cgroup.h | 145 ++++++-------------- include/linux/blk_types.h | 1 + include/linux/cgroup.h | 2 - include/linux/writeback.h | 5 +- kernel/cgroup/cgroup.c | 48 ++----- kernel/trace/blktrace.c | 4 +- mm/page_io.c | 2 +- 22 files changed, 208 insertions(+), 403 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +3 -5
@@ -1857,10 +1857,8 @@ following two functions. wbc_init_bio(@wbc, @bio) Should be called for each bio carrying writeback data and - associates the bio with the inode's owner cgroup and the - corresponding request queue. This must be called after - a queue (device) has been associated with the bio and - before submission. + associates the bio with the inode's owner cgroup. Can be + called anytime between bio allocation and submission. wbc_account_io(@wbc, @page, @bytes) Should be called for each data segment being written out.
@@ -1879,7 +1877,7 @@ the configuration, the bio may be executed at a lower priority and if the writeback session is holding shared resources, e.g. a journal entry, may lead to priority inversion. There is no one easy solution for the problem. Filesystems can try to work around specific problem -cases by skipping wbc_init_bio() or using bio_associate_create_blkg() +cases by skipping wbc_init_bio() or using bio_associate_blkcg() directly.
block/bfq-cgroup.c +2 -2
@@ -642,7 +642,7 @@ void bfq_bic_update_cgroup(struct bfq_io_cq *bic, struct bio *bio)uint64_t serial_nr;rcu_read_lock (); - serial_nr =__bio_blkcg (bio)->css.serial_nr; + serial_nr =bio_blkcg (bio)->css.serial_nr;/* * Check whether blkcg has changed. The condition may trigger
@@ -651,7 +651,7 @@ void bfq_bic_update_cgroup(struct bfq_io_cq *bic, struct bio *bio)if (unlikely (!bfqd) ||likely (bic->blkcg_serial_nr == serial_nr)) goto out; - bfqg =__bfq_bic_change_cgroup (bfqd, bic,__bio_blkcg (bio)); + bfqg =__bfq_bic_change_cgroup (bfqd, bic,bio_blkcg (bio));/* * Update blkg_path for bfq_log_* functions. We cache this * path, and update it here, for the following
block/bfq-iosched.c +1 -1
@@ -4384,7 +4384,7 @@ static struct bfq_queue *bfq_get_queue(struct bfq_data *bfqd,rcu_read_lock (); - bfqg =bfq_find_set_group (bfqd,__bio_blkcg (bio)); + bfqg =bfq_find_set_group (bfqd,bio_blkcg (bio));if (!bfqg) { bfqq = &bfqd->oom_bfqq; goto out;
block/bio.c +47 -127
229 lines not on this page · raw message
block/blk-cgroup.c +38 -85
203 lines not on this page · raw message
block/blk-core.c +0 -1
@@ -2433,7 +2433,6 @@ blk_qc_t generic_make_request(struct bio *bio)if (q)blk_queue_exit (q); q = bio->bi_disk->queue; -bio_reassociate_blkg (q, bio); flags =0 ;if (bio->bi_opf &REQ_NOWAIT ) flags =BLK_MQ_REQ_NOWAIT ;
block/blk-iolatency.c +24 -2
@@ -480,12 +480,34 @@ static void blkcg_iolatency_throttle(struct rq_qos *rqos, struct bio *bio, spinlock_t *lock) {struct blk_iolatency *blkiolat =BLKIOLATENCY (rqos); -struct blkcg_gq *blkg = bio->bi_blkg; +struct blkcg *blkcg; +struct blkcg_gq *blkg; +struct request_queue *q = rqos->q;bool issue_as_root =bio_issue_as_root_blkg (bio);if (!blk_iolatency_enabled (blkiolat))return ; +rcu_read_lock (); + blkcg =bio_blkcg (bio); +bio_associate_blkcg (bio, &blkcg->css); + blkg =blkg_lookup (blkcg, q); +if (unlikely (!blkg)) { +if (!lock) +spin_lock_irq (q->queue_lock); + blkg =blkg_lookup_create (blkcg, q); +if (IS_ERR (blkg)) + blkg =NULL ; +if (!lock) +spin_unlock_irq (q->queue_lock); + } +if (!blkg) + goto out; + +bio_issue_init (&bio->bi_issue,bio_sectors (bio)); +bio_associate_blkg (bio, blkg); +out: +rcu_read_unlock ();while (blkg && blkg->parent) {struct iolatency_grp *iolat =blkg_to_lat (blkg);if (!iolat) {
@@ -706,7 +728,7 @@ static void blkiolatency_timer_fn(struct timer_list *t)* We could be exiting, don't access the pd unless we have a * ref on the blkg. */ -if (!blkg_tryget (blkg)) +if (!blkg_try_get (blkg))continue ; iolat =blkg_to_lat (blkg);
block/blk-throttle.c +12 -1
@@ -2115,11 +2115,21 @@ static inline void throtl_update_latency_buckets(struct throtl_data *td) }#endif +static void blk_throtl_assoc_bio (struct throtl_grp *tg,struct bio *bio) +{ +#ifdef CONFIG_BLK_DEV_THROTTLING_LOW +/* fallback to root_blkg if we fail to get a blkg ref */ +if (bio->bi_css && (bio_associate_blkg (bio,tg_to_blkg (tg)) == -ENODEV )) +bio_associate_blkg (bio, bio->bi_disk->queue->root_blkg); +bio_issue_init (&bio->bi_issue,bio_sectors (bio)); +#endif +} +bool blk_throtl_bio (struct request_queue *q,struct blkcg_gq *blkg,struct bio *bio) {struct throtl_qnode *qn =NULL ; -struct throtl_grp *tg =blkg_to_tg (blkg); +struct throtl_grp *tg =blkg_to_tg (blkg ?: q->root_blkg);struct throtl_service_queue *sq;bool rw =bio_data_dir (bio);bool throttled = false;
@@ -2138,6 +2148,7 @@ bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,if (unlikely (blk_queue_bypass (q))) goto out_unlock; +blk_throtl_assoc_bio (tg, bio);blk_throtl_update_idletime (tg); sq = &tg->service_queue;
block/bounce.c +1 -3
@@ -276,9 +276,7 @@ static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask, } } -bio_clone_blkg_association (bio, bio_src); - -blkcg_bio_issue_init (bio); +bio_clone_blkcg_association (bio, bio_src);return bio; }
block/cfq-iosched.c +2 -2
@@ -3759,7 +3759,7 @@ static void check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio)uint64_t serial_nr;rcu_read_lock (); - serial_nr =__bio_blkcg (bio)->css.serial_nr; + serial_nr =bio_blkcg (bio)->css.serial_nr;rcu_read_unlock ();/*
@@ -3824,7 +3824,7 @@ cfq_get_queue(struct cfq_data *cfqd, bool is_sync, struct cfq_io_cq *cic,struct cfq_group *cfqg;rcu_read_lock (); - cfqg =cfq_lookup_cfqg (cfqd,__bio_blkcg (bio)); + cfqg =cfq_lookup_cfqg (cfqd,bio_blkcg (bio));if (!cfqg) { cfqq = &cfqd->oom_cfqq; goto out;
drivers/block/loop.c +2 -3
@@ -77,7 +77,6 @@#include <linux/falloc.h> #include <linux/uio.h> #include <linux/ioprio.h> -#include <linux/blk-cgroup.h> #include "loop.h"
@@ -1761,8 +1760,8 @@ static blk_status_t loop_queue_rq(struct blk_mq_hw_ctx *hctx,/* always use the first bio's css */ #ifdef CONFIG_BLK_CGROUP -if (cmd->use_aio && rq->bio && rq->bio->bi_blkg) { - cmd->css = &bio_blkcg (rq->bio)->css; +if (cmd->use_aio && rq->bio && rq->bio->bi_css) { + cmd->css = rq->bio->bi_css;css_get (cmd->css); } else#endif
drivers/md/raid0.c +1 -1
@@ -542,7 +542,7 @@ static void raid0_handle_discard(struct mddev *mddev, struct bio *bio) !discard_bio)continue ;bio_chain (discard_bio, bio); -bio_clone_blkg_association (discard_bio, bio); +bio_clone_blkcg_association (discard_bio, bio);if (mddev->gendisk) trace_block_bio_remap(bdev_get_queue(rdev->bdev), discard_bio, disk_devt(mddev->gendisk),
fs/buffer.c +5 -5
@@ -3060,6 +3060,11 @@ static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,*/ bio =bio_alloc (GFP_NOIO ,1 ); +if (wbc) { +wbc_init_bio (wbc, bio); +wbc_account_io (wbc, bh->b_page, bh->b_size); + } + bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >>9 );bio_set_dev (bio, bh->b_bdev); bio->bi_write_hint = write_hint;
@@ -3079,11 +3084,6 @@ static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh, op_flags |=REQ_PRIO ;bio_set_op_attrs (bio, op, op_flags); -if (wbc) { -wbc_init_bio (wbc, bio); -wbc_account_io (wbc, bh->b_page, bh->b_size); - } -submit_bio (bio);return 0 ; }
fs/ext4/page-io.c +1 -1
@@ -374,13 +374,13 @@ static int io_submit_init_bio(struct ext4_io_submit *io, bio =bio_alloc (GFP_NOIO ,BIO_MAX_PAGES );if (!bio)return -ENOMEM ; +wbc_init_bio (io->io_wbc, bio); bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >>9 );bio_set_dev (bio, bh->b_bdev); bio->bi_end_io = ext4_end_bio; bio->bi_private =ext4_get_io_end (io->io_end); io->io_bio = bio; io->io_next_block = bh->b_blocknr; -wbc_init_bio (io->io_wbc, bio);return 0 ; }
include/linux/bio.h +9 -17
@@ -503,31 +503,23 @@ do { \ disk_devt((bio)->bi_disk)#if defined(CONFIG_MEMCG ) && defined(CONFIG_BLK_CGROUP ) -int bio_associate_blkg_from_page (struct bio *bio,struct page *page); +int bio_associate_blkcg_from_page (struct bio *bio,struct page *page);#else -static inline int bio_associate_blkg_from_page (struct bio *bio, -struct page *page) {return 0 ; } +static inline int bio_associate_blkcg_from_page (struct bio *bio, +struct page *page) {return 0 ; }#endif #ifdef CONFIG_BLK_CGROUP +int bio_associate_blkcg (struct bio *bio,struct cgroup_subsys_state *blkcg_css);int bio_associate_blkg (struct bio *bio,struct blkcg_gq *blkg); -int bio_associate_blkg_from_css (struct bio *bio, -struct cgroup_subsys_state *css); -int bio_associate_create_blkg (struct request_queue *q,struct bio *bio); -int bio_reassociate_blkg (struct request_queue *q,struct bio *bio);void bio_disassociate_task (struct bio *bio); -void bio_clone_blkg_association (struct bio *dst,struct bio *src); +void bio_clone_blkcg_association (struct bio *dst,struct bio *src);#else /* CONFIG_BLK_CGROUP */ -static inline int bio_associate_blkg_from_css (struct bio *bio, -struct cgroup_subsys_state *css) -{return 0 ; } -static inline int bio_associate_create_blkg (struct request_queue *q, -struct bio *bio) {return 0 ; } -static inline int bio_reassociate_blkg (struct request_queue *q,struct bio *bio) -{return 0 ; } +static inline int bio_associate_blkcg (struct bio *bio, +struct cgroup_subsys_state *blkcg_css) {return 0 ; }static inline void bio_disassociate_task (struct bio *bio) { } -static inline void bio_clone_blkg_association (struct bio *dst, -struct bio *src) { } +static inline void bio_clone_blkcg_association (struct bio *dst, +struct bio *src) { }#endif /* CONFIG_BLK_CGROUP */ #ifdef CONFIG_HIGHMEM
include/linux/blk-cgroup.h +45 -100
245 lines not on this page · raw message
include/linux/blk_types.h +1 -0
@@ -178,6 +178,7 @@ struct bio {* release. Read comment on top of bio_associate_current(). */ struct io_context *bi_ioc; +struct cgroup_subsys_state *bi_css;struct blkcg_gq *bi_blkg;struct bio_issue bi_issue;#endif
include/linux/cgroup.h +0 -2
@@ -93,8 +93,6 @@ extern struct css_set init_css_set;bool css_has_online_children (struct cgroup_subsys_state *css);struct cgroup_subsys_state *css_from_id (int id,struct cgroup_subsys *ss); -struct cgroup_subsys_state *cgroup_e_css (struct cgroup *cgroup, -struct cgroup_subsys *ss);struct cgroup_subsys_state *cgroup_get_e_css (struct cgroup *cgroup,struct cgroup_subsys *ss); struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry,
include/linux/writeback.h +2 -3
@@ -246,8 +246,7 @@ static inline void wbc_attach_fdatawrite_inode(struct writeback_control *wbc,* * @bio is a part of the writeback in progress controlled by @wbc. Perform * writeback specific initialization. This is used to apply the cgroup -* writeback context. Must be called after the bio has been associated with -* a device. +* writeback context. */ static inline void wbc_init_bio (struct writeback_control *wbc,struct bio *bio) {
@@ -258,7 +257,7 @@ static inline void wbc_init_bio(struct writeback_control *wbc, struct bio *bio)* regular writeback instead of writing things out itself. */ if (wbc->wb) - bio_associate_blkg_from_css(bio, wbc->wb->blkcg_css); + bio_associate_blkcg(bio, wbc->wb->blkcg_css); }#else /* CONFIG_CGROUP_WRITEBACK */
kernel/cgroup/cgroup.c +9 -39
84 lines not on this page · raw message
kernel/trace/blktrace.c +2 -2
@@ -764,9 +764,9 @@ blk_trace_bio_get_cgid(struct request_queue *q, struct bio *bio)if (!bt || !(blk_tracer_flags.val &TRACE_BLK_OPT_CGROUP ))return NULL ; -if (!bio->bi_blkg) +if (!bio->bi_css)return NULL ; -return cgroup_get_kernfs_id (bio_blkcg (bio)->css.cgroup); +return cgroup_get_kernfs_id (bio->bi_css->cgroup); }#else static union kernfs_node_id *
mm/page_io.c +1 -1
@@ -339,7 +339,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, goto out; } bio->bi_opf =REQ_OP_WRITE |REQ_SWAP |wbc_to_write_flags (wbc); -bio_associate_blkg_from_page (bio, page); +bio_associate_blkcg_from_page (bio, page);count_swpout_vm_event (page);set_page_writeback (page);unlock_page (page);
Signature · 1 line
2.17.1
Jens Axboe
maintainerQuoted 7 lines · Dennis Zhou
This reverts a series committed earlier due to null pointer exception bug report in [1]. It seems there are edge case interactions that I did not consider and will need some time to understand what causes the adverse interactions.
The original series can be found in [2] with a follow up series in [3].
Quoted 8 lines
[1] https://www.spinics.net/lists/cgroups/msg20719.html
[2] https://lore.kernel.org/lkml/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/This reverts the following commits:
d459d853c2ed,b2c3fa546705,101246ec02b5,b3b9f24f5fcc,e2b0989954ae,f0fcb3ec89f3,c839e7a03f92,bdc2491708c4,74b7c02a9bc1,5bf9a1f3b4ef,a7b39b4e961c,07b05bcc3213,49f4c2dc2b50,27e6fa996c53
Thanks Dennis, I think this is the best way forward. Then you can work on getting the stacked setups working correctly for 4.21.
Signature · 1 line
Jens Axboe