switch blk-cgroup to work on gendisk v2
Subsystems (9)
Hi all,
blk-cgroup works on only on live disks and "file system" I/O from bios. This all the information should be in the gendisk, and not the request_queue that also exists for pure passthrough request based devices.
Changes since v1:
- use the local disk variable in wbt_init instead of q->disk
- various spelling fixes
Diffstat:
block/bfq-cgroup.c | 18 ++-- block/bfq-iosched.c | 6 - block/blk-cgroup-rwstat.c | 2 block/blk-cgroup.c | 185 +++++++++++++++++++++------------------------- block/blk-cgroup.h | 41 ++++------ block/blk-iocost.c | 40 ++++----- block/blk-iolatency.c | 41 ++++------ block/blk-ioprio.c | 6 - block/blk-mq-debugfs.c | 10 -- block/blk-rq-qos.c | 67 ++++++++++++++++ block/blk-rq-qos.h | 66 +--------------- block/blk-stat.c | 3 block/blk-sysfs.c | 4 block/blk-throttle.c | 31 ++++--- block/blk-wbt.c | 39 ++++----- block/blk-wbt.h | 12 +- block/genhd.c | 17 ++-- include/linux/blkdev.h | 10 +- include/linux/sched.h | 2 kernel/fork.c | 2 mm/swapfile.c | 2 21 files changed, 292 insertions(+), 312 deletions(-)
PATCH 1/15 blk-cgroup: don't defer blkg_free to a workqueue
Now that blk_put_queue can be called from process context, there is no need for the asynchronous execution.
This effectively reverts commit d578c770c85233af592e54537f93f3831bde7e9a.
--- block/blk-cgroup.c | 32 ++++++++++---------------------- block/blk-cgroup.h | 5 +---- 2 files changed, 11 insertions(+), 26 deletions(-)
block/blk-cgroup.c +10 -22
@@ -114,12 +114,19 @@ static bool blkcg_policy_enabled(struct request_queue *q,return pol &&test_bit (pol->plid, q->blkcg_pols); } -static void blkg_free_workfn (struct work_struct *work) +/** +* blkg_free - free a blkg +* @blkg: blkg to free +* +* Free @blkg which may be partially allocated. +*/ +static void blkg_free (struct blkcg_gq *blkg) { - struct blkcg_gq *blkg = container_of(work, struct blkcg_gq, - free_work);int i; +if (!blkg) +return ; +for (i =0 ; i <BLKCG_MAX_POLS ; i++)if (blkg->pd[i]) blkcg_policy[i]->pd_free_fn (blkg->pd[i]);
@@ -131,25 +138,6 @@ static void blkg_free_workfn(struct work_struct *work)kfree (blkg); } -/** -* blkg_free - free a blkg -* @blkg: blkg to free -* -* Free @blkg which may be partially allocated. -*/ -static void blkg_free (struct blkcg_gq *blkg) -{ -if (!blkg) -return ; - -/* -* Both ->pd_free_fn() and request queue's release handler may -* sleep, so free us by scheduling one work func -*/ -INIT_WORK (&blkg->free_work, blkg_free_workfn); -schedule_work (&blkg->free_work); -} -static void __blkg_release (struct rcu_head *rcu) { struct blkcg_gq *blkg = container_of(rcu, struct blkcg_gq, rcu_head);
block/blk-cgroup.h +1 -4
@@ -75,10 +75,7 @@ struct blkcg_gq {spinlock_t async_bio_lock;struct bio_list async_bios; -union { -struct work_struct async_bio_work; -struct work_struct free_work; - }; +struct work_struct async_bio_work;atomic_t use_delay;atomic64_t delay_nsec;
Signature · 1 line
2.39.0
Re: [PATCH 01/15] blk-cgroup: don't defer blkg_free to a workqueue
Quoted 7 lines · Christoph Hellwig
Now that
blk_put_queuecan be called from process context, there is no need for the asynchronous execution.This effectively reverts commit
d578c770c85233af592e54537f93f3831bde7e9a.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Andreas Herrmann <[email protected]>
Signature · 1 line
tejun
Re: [PATCH 01/15] blk-cgroup: don't defer blkg_free to a workqueue
In reply to Christoph HellwigQuoted 1 line · Christoph Hellwig
Now that
blk_put_queuecan be called from process context, there is no
s/process/atomic?
Quoted 3 lines
need for the asynchronous execution.
This effectively reverts commit
d578c770c85233af592e54537f93f3831bde7e9a.
blkg_free() can be called with ->queue_lock, and:
- del_timer_sync(&tg->service_queue.pending_timer) is called from throtl_pd_free().
- queue_lock is required by throtl_pending_timer_fn
So there is deadlock risk if the above commit is reverted.
Thanks,
Ming
Tejun Heo
maintainerRe: [PATCH 01/15] blk-cgroup: don't defer blkg_free to a workqueue
Quoted 9 lines · Ming Lei
Quoted 1 line · Christoph Hellwig
Now that
blk_put_queuecan be called from process context, there is nos/process/atomic?
Quoted 3 lines
need for the asynchronous execution.
This effectively reverts commit
d578c770c85233af592e54537f93f3831bde7e9a.
Quoted 7 lines
blkg_free()can be called with ->queue_lock, and:-
del_timer_sync(&tg->service_queue.pending_timer)is called fromthrotl_pd_free().-
queue_lockis required bythrotl_pending_timer_fnSo there is deadlock risk if the above commit is reverted.
Ah, good catch. Looks like we'd have to leave this async.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 01/15] blk-cgroup: don't defer blkg_free to a workqueue
In reply to Christoph HellwigHi, Christoph,
ÔÚ 2023/01/24 14:57, Christoph Hellwig дµÀ:
Quoted 4 lines
Now that
blk_put_queuecan be called from process context, there is no need for the asynchronous execution.This effectively reverts commit
d578c770c85233af592e54537f93f3831bde7e9a.
blkg_free() can be called from rcu callback, and my patch
blk-cgroup: synchronize pd_free_fn() from blkg_free_workfn() and blkcg_deactivate_policy()
will hold a mutex in blkg_free_workfn(), I think it's better not do such thing in rcu callback, right?
Thanks,
Kuai
PATCH 2/15 block: don't call blk_throtl_stat_add for non-READ/WRITE commands
In reply to Christoph Hellwigblk_throtl_stat_add is called from blk_stat_add explicitly, unlike the other stats that go through q->stats->callbacks. To prepare for cgroup data moving to the gendisk, ensure blk_throtl_stat_add is only called for the plain READ and WRITE commands that it actually handles internally, as blk_stat_add can also be called for passthrough commands on queues that do not have a gendisk associated with them.
--- block/blk-stat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-stat.c +2 -1
@@ -58,7 +58,8 @@ void blk_stat_add(struct request *rq, u64 now) value = (now >= rq->io_start_time_ns) ? now - rq->io_start_time_ns :0 ; -blk_throtl_stat_add (rq, value); +if (req_op (rq) ==REQ_OP_READ ||req_op (rq) ==REQ_OP_WRITE ) +blk_throtl_stat_add (rq, value);rcu_read_lock (); cpu =get_cpu ();
Signature · 1 line
2.39.0
PATCH 3/15 blk-cgroup: delay blk-cgroup initialization until add_disk
In reply to Christoph HellwigThere is no need to initialize the group code before the disk is marked live. Moving the cgroup initialization earlier will help to have a fully initialized struct device in the gendisk for the cgroup code to use in the future. Similarly tear the cgroup information down in del_gendisk to be symmetric and because none of the cgroup tracking is needed once non-passthrough I/O stops.
--- block/genhd.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
block/genhd.c +9 -8
@@ -466,10 +466,14 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,*/ pm_runtime_set_memalloc_noio (ddev, true); - ret =blk_integrity_add (disk); + ret =blkcg_init_disk (disk);if (ret) goto out_del_block_link; + ret =blk_integrity_add (disk); +if (ret) + goto out_blkcg_exit; + disk->part0->bd_holder_dir =kobject_create_and_add ("holders" , &ddev->kobj);if (!disk->part0->bd_holder_dir) {
@@ -534,6 +538,8 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,kobject_put (disk->part0->bd_holder_dir); out_del_integrity:blk_integrity_del (disk); +out_blkcg_exit: +blkcg_exit_disk (disk); out_del_block_link:if (!sysfs_deprecated)sysfs_remove_link (block_depr,dev_name (ddev));
@@ -662,6 +668,8 @@ void del_gendisk(struct gendisk *disk)rq_qos_exit (q);blk_mq_unquiesce_queue (q); +blkcg_exit_disk (disk); +/* * If the disk does not own the queue, allow using passthrough requests * again. Else leave the queue frozen to fail all I/O.
@@ -1171,8 +1179,6 @@ static void disk_release(struct device *dev) !test_bit(GD_ADDED, &disk->state))blk_mq_exit_queue (disk->queue); -blkcg_exit_disk (disk); -bioset_exit (&disk->bio_split);disk_release_events (disk);
@@ -1385,9 +1391,6 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,if (xa_insert (&disk->part_tbl,0 , disk->part0,GFP_KERNEL )) goto out_destroy_part_tbl; -if (blkcg_init_disk (disk)) - goto out_erase_part0; -rand_initialize_disk (disk);disk_to_dev (disk)->class = &block_class;disk_to_dev (disk)->type = &disk_type;
@@ -1400,8 +1403,6 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,#endif return disk; -out_erase_part0: -xa_erase (&disk->part_tbl,0 ); out_destroy_part_tbl:xa_destroy (&disk->part_tbl); disk->part0->bd_disk =NULL ;
Signature · 1 line
2.39.0
Tejun Heo
maintainerRe: [PATCH 03/15] blk-cgroup: delay blk-cgroup initialization until add_disk
Quoted 1 line · Christoph Hellwig
There is no need to initialize the group code before the disk is marked
^ cgroup
Signature · 1 line
tejun
PATCH 4/15 blk-cgroup: pin the gendisk in struct blkcg_gq
In reply to Christoph HellwigCurrently each blkcg_gq holds a request_queue reference, which is what is used in the policies. But a lot of these interfaces will move over to use a gendisk, so store a disk in struct blkcg_gq and hold a reference to it.
--- block/bfq-cgroup.c | 6 +++--- block/blk-cgroup-rwstat.c | 2 +- block/blk-cgroup.c | 29 +++++++++++++---------------- block/blk-cgroup.h | 11 +++++------ block/blk-iocost.c | 2 +- block/blk-iolatency.c | 4 ++-- block/blk-throttle.c | 4 ++-- 7 files changed, 27 insertions(+), 31 deletions(-)
block/bfq-cgroup.c +3 -3
@@ -407,7 +407,7 @@ static void bfqg_stats_xfer_dead(struct bfq_group *bfqg) parent =bfqg_parent (bfqg); -lockdep_assert_held (&bfqg_to_blkg (bfqg)->q->queue_lock); +lockdep_assert_held (&bfqg_to_blkg (bfqg)->disk->queue->queue_lock);if (unlikely (!parent))return ;
@@ -538,7 +538,7 @@ static void bfq_pd_init(struct blkg_policy_data *pd) {struct blkcg_gq *blkg =pd_to_blkg (pd);struct bfq_group *bfqg =blkg_to_bfqg (blkg); -struct bfq_data *bfqd = blkg->q->elevator->elevator_data; +struct bfq_data *bfqd = blkg->disk->queue->elevator->elevator_data;struct bfq_entity *entity = &bfqg->entity;struct bfq_group_data *d =blkcg_to_bfqgd (blkg->blkcg);
@@ -1203,7 +1203,7 @@ static u64 bfqg_prfill_stat_recursive(struct seq_file *sf,struct cgroup_subsys_state *pos_css;u64 sum =0 ; -lockdep_assert_held (&blkg->q->queue_lock); +lockdep_assert_held (&blkg->disk->queue->queue_lock);rcu_read_lock ();blkg_for_each_descendant_pre (pos_blkg, pos_css, blkg) {
block/blk-cgroup-rwstat.c +1 -1
@@ -107,7 +107,7 @@ void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol,struct cgroup_subsys_state *pos_css;unsigned int i; -lockdep_assert_held (&blkg->q->queue_lock); +lockdep_assert_held (&blkg->disk->queue->queue_lock);memset (sum,0 ,sizeof (*sum));rcu_read_lock ();
block/blk-cgroup.c +13 -16
@@ -131,8 +131,8 @@ static void blkg_free(struct blkcg_gq *blkg)if (blkg->pd[i]) blkcg_policy[i]->pd_free_fn (blkg->pd[i]); -if (blkg->q) -blk_put_queue (blkg->q); +if (blkg->disk) +put_disk (blkg->disk);free_percpu (blkg->iostat_cpu);percpu_ref_exit (&blkg->refcnt);kfree (blkg);
@@ -245,10 +245,9 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,if (!blkg->iostat_cpu) goto err_free; -if (!blk_get_queue (disk->queue)) - goto err_free; +get_device (disk_to_dev (disk)); - blkg->q = disk->queue; + blkg->disk = disk;INIT_LIST_HEAD (&blkg->q_node);spin_lock_init (&blkg->async_bio_lock);bio_list_init (&blkg->async_bios);
@@ -443,7 +442,7 @@ static void blkg_destroy(struct blkcg_gq *blkg)struct blkcg *blkcg = blkg->blkcg;int i; -lockdep_assert_held (&blkg->q->queue_lock); +lockdep_assert_held (&blkg->disk->queue->queue_lock);lockdep_assert_held (&blkcg->lock);/* Something wrong if we are trying to remove same group twice */
@@ -459,7 +458,7 @@ static void blkg_destroy(struct blkcg_gq *blkg) blkg->online = false; -radix_tree_delete (&blkcg->blkg_tree, blkg->q->id); +radix_tree_delete (&blkcg->blkg_tree, blkg->disk->queue->id);list_del_init (&blkg->q_node);hlist_del_init_rcu (&blkg->blkcg_node);
@@ -547,9 +546,7 @@ static int blkcg_reset_stats(struct cgroup_subsys_state *css,const char *blkg_dev_name (struct blkcg_gq *blkg) { -if (!blkg->q->disk || !blkg->q->disk->bdi->dev) -return NULL ; -return bdi_dev_name (blkg->q->disk->bdi); +return bdi_dev_name (blkg->disk->bdi); }/**
@@ -581,10 +578,10 @@ void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg,rcu_read_lock ();hlist_for_each_entry_rcu (blkg, &blkcg->blkg_list, blkcg_node) { -spin_lock_irq (&blkg->q->queue_lock); -if (blkcg_policy_enabled (blkg->q, pol)) +spin_lock_irq (&blkg->disk->queue->queue_lock); +if (blkcg_policy_enabled (blkg->disk->queue, pol)) total +=prfill (sf, blkg->pd[pol->plid], data); -spin_unlock_irq (&blkg->q->queue_lock); +spin_unlock_irq (&blkg->disk->queue->queue_lock); }rcu_read_unlock ();
@@ -1008,9 +1005,9 @@ static int blkcg_print_stat(struct seq_file *sf, void *v)rcu_read_lock ();hlist_for_each_entry_rcu (blkg, &blkcg->blkg_list, blkcg_node) { -spin_lock_irq (&blkg->q->queue_lock); +spin_lock_irq (&blkg->disk->queue->queue_lock);blkcg_print_one_stat (blkg, sf); -spin_unlock_irq (&blkg->q->queue_lock); +spin_unlock_irq (&blkg->disk->queue->queue_lock); }rcu_read_unlock ();return 0 ;
@@ -1080,7 +1077,7 @@ static void blkcg_destroy_blkgs(struct blkcg *blkcg)while (!hlist_empty (&blkcg->blkg_list)) {struct blkcg_gq *blkg =hlist_entry (blkcg->blkg_list.first, struct blkcg_gq, blkcg_node); -struct request_queue *q = blkg->q; +struct request_queue *q = blkg->disk->queue;if (need_resched () || !spin_trylock (&q->queue_lock)) {/*
block/blk-cgroup.h +5 -6
@@ -53,8 +53,7 @@ struct blkg_iostat_set {/* association between a blk cgroup and a request queue */ struct blkcg_gq { -/* Pointer to the associated request_queue */ -struct request_queue *q; +struct gendisk *disk;struct list_head q_node;struct hlist_node blkcg_node;struct blkcg *blkcg;
@@ -251,11 +250,11 @@ static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg,return q->root_blkg; blkg =rcu_dereference (blkcg->blkg_hint); -if (blkg && blkg->q == q) +if (blkg && blkg->disk->queue == q)return blkg; blkg =radix_tree_lookup (&blkcg->blkg_tree, q->id); -if (blkg && blkg->q != q) +if (blkg && blkg->disk->queue != q) blkg =NULL ;return blkg; }
@@ -355,7 +354,7 @@ static inline void blkg_put(struct blkcg_gq *blkg)#define blkg_for_each_descendant_pre (d_blkg, pos_css, p_blkg) \ css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css) \ if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \ - (p_blkg)->q))) + (p_blkg)->disk->queue)))/** * blkg_for_each_descendant_post - post-order walk of a blkg's descendants
@@ -370,7 +369,7 @@ static inline void blkg_put(struct blkcg_gq *blkg)#define blkg_for_each_descendant_post (d_blkg, pos_css, p_blkg) \ css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css) \ if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \ - (p_blkg)->q))) + (p_blkg)->disk->queue)))bool __blkcg_punt_bio_submit (struct bio *bio);
block/blk-iocost.c +1 -1
@@ -2953,7 +2953,7 @@ static void ioc_pd_init(struct blkg_policy_data *pd) {struct ioc_gq *iocg =pd_to_iocg (pd);struct blkcg_gq *blkg =pd_to_blkg (&iocg->pd); -struct ioc *ioc =q_to_ioc (blkg->q); +struct ioc *ioc =q_to_ioc (blkg->disk->queue);struct ioc_now now;struct blkcg_gq *tblkg;unsigned long flags;
block/blk-iolatency.c +2 -2
@@ -974,12 +974,12 @@ static void iolatency_pd_init(struct blkg_policy_data *pd) {struct iolatency_grp *iolat =pd_to_lat (pd);struct blkcg_gq *blkg =lat_to_blkg (iolat); -struct rq_qos *rqos =blkcg_rq_qos (blkg->q); +struct rq_qos *rqos =blkcg_rq_qos (blkg->disk->queue);struct blk_iolatency *blkiolat =BLKIOLATENCY (rqos);u64 now =ktime_to_ns (ktime_get ());int cpu; -if (blk_queue_nonrot (blkg->q)) +if (blk_queue_nonrot (blkg->disk->queue)) iolat->ssd = true;else iolat->ssd = false;
block/blk-throttle.c +2 -2
@@ -388,7 +388,7 @@ static void throtl_pd_init(struct blkg_policy_data *pd) {struct throtl_grp *tg =pd_to_tg (pd);struct blkcg_gq *blkg =tg_to_blkg (tg); -struct throtl_data *td = blkg->q->td; +struct throtl_data *td = blkg->disk->queue->td;struct throtl_service_queue *sq = &tg->service_queue;/*
@@ -1175,7 +1175,7 @@ static void throtl_pending_timer_fn(struct timer_list *t)/* throtl_data may be gone, so figure out request queue by blkg */ if (tg) - q = tg->pd.blkg->q; + q = tg->pd.blkg->disk->queue;else q = td->queue;
Signature · 1 line
2.39.0
Tejun Heo
maintainerRe: [PATCH 04/15] blk-cgroup: pin the gendisk in struct blkcg_gq
Hello,
block/blk-cgroup.c static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk, · line 248
Quoted 7 lines · Christoph Hellwig
block/blk-cgroup.c +1
-2@@ -245,10 +245,9 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,if (!blkg->iostat_cpu) goto err_free; -if (!blk_get_queue (disk->queue)) - goto err_free; +get_device (disk_to_dev (disk));
We lose the blk_queue_dying() test here. It'd be great if the patch description explains why this is safe.
block/blk-cgroup.c static int blkcg_reset_stats(struct cgroup_subsys_state *css, · line 549
Quoted 8 lines
block/blk-cgroup.c +1
-3@@ -547,9 +546,7 @@ static int blkcg_reset_stats(struct cgroup_subsys_state *css,const char *blkg_dev_name (struct blkcg_gq *blkg) { -if (!blkg->q->disk || !blkg->q->disk->bdi->dev) -return NULL ; -return bdi_dev_name (blkg->q->disk->bdi); +return bdi_dev_name (blkg->disk->bdi);
This isn't completely trivial like other conversions. Maybe worth mentioning in the description too?
Thanks.
Signature · 1 line
tejun
PATCH 5/15 blk-cgroup: store a gendisk to throttle in struct task_struct
In reply to Christoph HellwigSwitch from a request_queue pointer and reference to a gendisk once for the throttle information in struct task_struct.
Move the check for the dead disk to the latest place now that is is unbundled from the reference grab.
--- block/blk-cgroup.c | 37 +++++++++++++++++++------------------ include/linux/sched.h | 2 +- kernel/fork.c | 2 +- mm/swapfile.c | 2 +- 4 files changed, 22 insertions(+), 21 deletions(-)
block/blk-cgroup.c +19 -18
@@ -1334,9 +1334,9 @@ static void blkcg_bind(struct cgroup_subsys_state *root_css)static void blkcg_exit (struct task_struct *tsk) { -if (tsk->throttle_queue) -blk_put_queue (tsk->throttle_queue); - tsk->throttle_queue =NULL ; +if (tsk->throttle_disk) +put_disk (tsk->throttle_disk); + tsk->throttle_disk =NULL ; }struct cgroup_subsys io_cgrp_subsys = {
@@ -1778,29 +1778,32 @@ static void blkcg_maybe_throttle_blkg(struct blkcg_gq *blkg, bool use_memdelay)* * This is only called if we've been marked with set_notify_resume(). Obviously * we can be set_notify_resume() for reasons other than blkcg throttling, so we -* check to see if current->throttle_queue is set and if not this doesn't do +* check to see if current->throttle_disk is set and if not this doesn't do * anything. This should only ever be called by the resume code, it's not meant * to be called by people willy-nilly as it will actually do the work to * throttle the task if it is setup for throttling. */ void blkcg_maybe_throttle_current (void ) { -struct request_queue *q = current->throttle_queue; +struct gendisk *disk = current->throttle_disk;struct blkcg *blkcg;struct blkcg_gq *blkg;bool use_memdelay = current->use_memdelay; -if (!q) +if (!disk)return ; - current->throttle_queue =NULL ; + current->throttle_disk =NULL ; current->use_memdelay = false; +if (test_bit (GD_DEAD , &disk->state)) + goto out_put_disk; +rcu_read_lock (); blkcg =css_to_blkcg (blkcg_css ());if (!blkcg) goto out; - blkg =blkg_lookup (blkcg, q); + blkg =blkg_lookup (blkcg, disk->queue);if (!blkg) goto out;if (!blkg_tryget (blkg))
@@ -1809,11 +1812,12 @@ void blkcg_maybe_throttle_current(void)blkcg_maybe_throttle_blkg (blkg, use_memdelay);blkg_put (blkg); -blk_put_queue (q); +put_disk (disk);return ; out:rcu_read_unlock (); -blk_put_queue (q); +out_put_disk: +put_disk (disk); }/**
@@ -1835,18 +1839,15 @@ void blkcg_maybe_throttle_current(void)*/ void blkcg_schedule_throttle (struct gendisk *disk,bool use_memdelay) { -struct request_queue *q = disk->queue; -if (unlikely (current->flags &PF_KTHREAD ))return ; -if (current->throttle_queue != q) { -if (!blk_get_queue (q)) -return ; +if (current->throttle_disk != disk) { +get_device (disk_to_dev (disk)); -if (current->throttle_queue) -blk_put_queue (current->throttle_queue); - current->throttle_queue = q; +if (current->throttle_disk) +put_disk (current->throttle_disk); + current->throttle_disk = disk; }if (use_memdelay)
include/linux/sched.h +1 -1
@@ -1436,7 +1436,7 @@ struct task_struct {#endif #ifdef CONFIG_BLK_CGROUP -struct request_queue *throttle_queue; +struct gendisk *throttle_disk;#endif #ifdef CONFIG_UPROBES
kernel/fork.c +1 -1
@@ -1044,7 +1044,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)#endif #ifdef CONFIG_BLK_CGROUP - tsk->throttle_queue =NULL ; + tsk->throttle_disk =NULL ; tsk->use_memdelay =0 ;#endif
mm/swapfile.c +1 -1
@@ -3642,7 +3642,7 @@ void __cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask)* We've already scheduled a throttle, avoid taking the global swap * lock. */ -if (current->throttle_queue) +if (current->throttle_disk)return ;spin_lock (&swap_avail_lock);
Signature · 1 line
2.39.0
Tejun Heo
maintainerRe: [PATCH 05/15] blk-cgroup: store a gendisk to throttle in struct task_struct
Quoted 18 lines · Christoph Hellwig
void
blkcg_maybe_throttle_current(void)
{block/blk-cgroup.c +5
-3-struct request_queue *q = current->throttle_queue; +struct gendisk *disk = current->throttle_disk;struct blkcg *blkcg;struct blkcg_gq *blkg;bool use_memdelay = current->use_memdelay; -if (!q) +if (!disk)return ; - current->throttle_queue =NULL ; + current->throttle_disk =NULL ; current->use_memdelay = false; +if (test_bit (GD_DEAD , &disk->state)) + goto out_put_disk;
...
Quoted 4 lines
block/blk-cgroup.c +0
-0@@ -1835,18 +1839,15 @@ void blkcg_maybe_throttle_current(void)*/ void blkcg_schedule_throttle (struct gendisk *disk,bool use_memdelay) {
block/blk-cgroup.c void blkcg_maybe_throttle_current(void) · line 1846
Quoted 10 lines
block/blk-cgroup.c +2
-5-struct request_queue *q = disk->queue; -if (unlikely (current->flags &PF_KTHREAD ))return ; -if (current->throttle_queue != q) { -if (!blk_get_queue (q)) -return ; +if (current->throttle_disk != disk) { +get_device (disk_to_dev (disk));
So, we're shifting the dead test from schedule to the actual throttle path, which makes sense but I think this should at least be mentioned in the description if not put in its own patch.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 05/15] blk-cgroup: store a gendisk to throttle in struct task_struct
Quoted 3 lines · Tejun Heo
So, we're shifting the dead test from schedule to the actual throttle path, which makes sense but I think this should at least be mentioned in the description if not put in its own patch.
That's what I tried to say with:
"Move the check for the dead disk to the latest place now that is is
unbundled from the reference grab."
what else would you want me to write?
Tejun Heo
maintainerRe: [PATCH 05/15] blk-cgroup: store a gendisk to throttle in struct task_struct
Sorry about late reply.
Quoted 11 lines · Christoph Hellwig
Quoted 3 lines · Tejun Heo
So, we're shifting the dead test from schedule to the actual throttle path, which makes sense but I think this should at least be mentioned in the description if not put in its own patch.
That's what I tried to say with:
"Move the check for the dead disk to the latest place now that is is
unbundled from the reference grab."what else would you want me to write?
It'd be better if the paragraph actually said where that change is being made along with why and whether it causes any behavior difference.
This seems safe to me but I can't tell why it's being moved. Maybe it's better because that's "latest" but that's a lot hanging on that single word. If this is better because we're testing it later instead of to accomodate other changes being made, this should be a separate patch, right? It's a subtle behavior change which is buried with a bunch of other mechanical changes.
Thanks.
Signature · 1 line
tejun
PATCH 6/15 blk-wbt: pass a gendisk to wbt_{enable,disable}_default
In reply to Christoph HellwigPass a gendisk to wbt_enable_default and wbt_disable_default to prepare for phasing out usage of the request_queue in the blk-cgroup code.
--- block/bfq-iosched.c | 4 ++-- block/blk-iocost.c | 4 ++-- block/blk-sysfs.c | 2 +- block/blk-wbt.c | 7 ++++--- block/blk-wbt.h | 8 ++++---- 5 files changed, 13 insertions(+), 12 deletions(-)
block/bfq-iosched.c +2 -2
@@ -7165,7 +7165,7 @@ static void bfq_exit_queue(struct elevator_queue *e)blk_stat_disable_accounting (bfqd->queue);clear_bit (ELEVATOR_FLAG_DISABLE_WBT , &e->flags); -wbt_enable_default (bfqd->queue); +wbt_enable_default (bfqd->queue->disk);kfree (bfqd); }
@@ -7354,7 +7354,7 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)blk_queue_flag_set (QUEUE_FLAG_SQ_SCHED , q);set_bit (ELEVATOR_FLAG_DISABLE_WBT , &eq->flags); -wbt_disable_default (q); +wbt_disable_default (q->disk);blk_stat_enable_accounting (q);return 0 ;
block/blk-iocost.c +2 -2
@@ -3285,11 +3285,11 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input,blk_stat_enable_accounting (disk->queue);blk_queue_flag_set (QUEUE_FLAG_RQ_ALLOC_TIME , disk->queue); ioc->enabled = true; -wbt_disable_default (disk->queue); +wbt_disable_default (disk); }else {blk_queue_flag_clear (QUEUE_FLAG_RQ_ALLOC_TIME , disk->queue); ioc->enabled = false; -wbt_enable_default (disk->queue); +wbt_enable_default (disk); }if (user) {
block/blk-sysfs.c +1 -1
@@ -826,7 +826,7 @@ int blk_register_queue(struct gendisk *disk) goto out_elv_unregister;blk_queue_flag_set (QUEUE_FLAG_REGISTERED , q); -wbt_enable_default (q); +wbt_enable_default (disk);blk_throtl_register (disk);/* Now everything is ready and send out KOBJ_ADD uevent */
block/blk-wbt.c +4 -3
@@ -650,8 +650,9 @@ void wbt_set_write_cache(struct request_queue *q, bool write_cache_on)/* * Enable wbt if defaults are configured that way */ -void wbt_enable_default (struct request_queue *q) +void wbt_enable_default (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct rq_qos *rqos;bool disable_flag = q->elevator &&test_bit (ELEVATOR_FLAG_DISABLE_WBT , &q->elevator->flags);
@@ -718,9 +719,9 @@ static void wbt_exit(struct rq_qos *rqos)/* * Disable wbt, if enabled by default. */ -void wbt_disable_default (struct request_queue *q) +void wbt_disable_default (struct gendisk *disk) { -struct rq_qos *rqos =wbt_rq_qos (q); +struct rq_qos *rqos =wbt_rq_qos (disk->queue);struct rq_wb *rwb;if (!rqos)return ;
block/blk-wbt.h +4 -4
@@ -91,8 +91,8 @@ static inline unsigned int wbt_inflight(struct rq_wb *rwb)#ifdef CONFIG_BLK_WBT int wbt_init (struct request_queue *); -void wbt_disable_default (struct request_queue *); -void wbt_enable_default (struct request_queue *); +void wbt_disable_default (struct gendisk *disk); +void wbt_enable_default (struct gendisk *disk);u64 wbt_get_min_lat (struct request_queue *q);void wbt_set_min_lat (struct request_queue *q,u64 val);
@@ -108,10 +108,10 @@ static inline int wbt_init(struct request_queue *q) {return -EINVAL ; } -static inline void wbt_disable_default (struct request_queue *q) +static inline void wbt_disable_default (struct gendisk *disk) { } -static inline void wbt_enable_default (struct request_queue *q) +static inline void wbt_enable_default (struct gendisk *disk) { }static inline void wbt_set_write_cache (struct request_queue *q,bool wc)
Signature · 1 line
2.39.0
PATCH 7/15 blk-wbt: pass a gendisk to wbt_init
In reply to Christoph HellwigPass a gendisk to wbt_init to prepare for phasing out usage of the request_queue in the blk-cgroup code.
--- block/blk-sysfs.c | 2 +- block/blk-wbt.c | 5 +++-- block/blk-wbt.h | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-)
block/blk-sysfs.c +1 -1
@@ -500,7 +500,7 @@ static ssize_t queue_wb_lat_store(struct request_queue *q, const char *page, rqos =wbt_rq_qos (q);if (!rqos) { - ret =wbt_init (q); + ret =wbt_init (q->disk);if (ret)return ret; }
block/blk-wbt.c +3 -2
@@ -671,7 +671,7 @@ void wbt_enable_default(struct gendisk *disk)return ;if (queue_is_mq (q) && !disable_flag) -wbt_init (q); +wbt_init (disk); }EXPORT_SYMBOL_GPL (wbt_enable_default);
@@ -835,8 +835,9 @@ static struct rq_qos_ops wbt_rqos_ops = {#endif }; -int wbt_init (struct request_queue *q) +int wbt_init (struct gendisk *disk) { +struct request_queue *q = disk->queue;struct rq_wb *rwb;int i;int ret;
block/blk-wbt.h +2 -2
@@ -90,7 +90,7 @@ static inline unsigned int wbt_inflight(struct rq_wb *rwb)#ifdef CONFIG_BLK_WBT -int wbt_init (struct request_queue *); +int wbt_init (struct gendisk *disk);void wbt_disable_default (struct gendisk *disk);void wbt_enable_default (struct gendisk *disk);
@@ -104,7 +104,7 @@ u64 wbt_default_latency_nsec(struct request_queue *);#else -static inline int wbt_init (struct request_queue *q) +static inline int wbt_init (struct gendisk *disk) {return -EINVAL ; }
Signature · 1 line
2.39.0
PATCH 8/15 blk-wbt: open code wbt_queue_depth_changed in wbt_update_limits
In reply to Christoph HellwigNo real need to all the method here, so open code to it to prepare for some paramter passing changes.
--- block/blk-wbt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/blk-wbt.c +2 -2
@@ -863,9 +863,9 @@ int wbt_init(struct gendisk *disk) rwb->enable_state =WBT_STATE_ON_DEFAULT ; rwb->wc =test_bit (QUEUE_FLAG_WC , &q->queue_flags); rwb->rq_depth.default_depth =RWB_DEF_DEPTH ; + rwb->rq_depth.queue_depth =blk_queue_depth (q); rwb->min_lat_nsec =wbt_default_latency_nsec (q); - -wbt_queue_depth_changed (&rwb->rqos); +wbt_update_limits (rwb);/* * Assign rwb and add the stats callback.
Signature · 1 line
2.39.0
Tejun Heo
maintainerRe: [PATCH 08/15] blk-wbt: open code wbt_queue_depth_changed in wbt_update_limits
Quoted 1 line · Christoph Hellwig
No real need to all the method here, so open code to it to prepare
I might be being slow but can't understand what the first sentence is saying. I think making the descriptions a bit more detailed would be generally helpful.
Thanks.
Signature · 1 line
tejun
PATCH 9/15 blk-rq-qos: make rq_qos_add and rq_qos_del more useful
In reply to Christoph HellwigSwitch to passing a gendisk, and make rq_qos_add initialize all required fields and drop the not required q argument from rq_qos_del. Also move the code out of line given how large it is.
--- block/blk-iocost.c | 13 ++------- block/blk-iolatency.c | 14 +++------ block/blk-rq-qos.c | 67 +++++++++++++++++++++++++++++++++++++++++++ block/blk-rq-qos.h | 62 ++------------------------------------- block/blk-wbt.c | 5 +--- 5 files changed, 78 insertions(+), 83 deletions(-)
block/blk-iocost.c +3 -10
@@ -2843,9 +2843,7 @@ static struct rq_qos_ops ioc_rqos_ops = {static int blk_iocost_init (struct gendisk *disk) { -struct request_queue *q = disk->queue;struct ioc *ioc; -struct rq_qos *rqos;int i, cpu, ret; ioc =kzalloc (sizeof (*ioc),GFP_KERNEL );
@@ -2868,11 +2866,6 @@ static int blk_iocost_init(struct gendisk *disk)local64_set (&ccs->rq_wait_ns,0 ); } - rqos = &ioc->rqos; - rqos->id =RQ_QOS_COST ; - rqos->ops = &ioc_rqos_ops; - rqos->q = q; -spin_lock_init (&ioc->lock);timer_setup (&ioc->timer, ioc_timer_fn,0 );INIT_LIST_HEAD (&ioc->active_iocgs);
@@ -2896,17 +2889,17 @@ static int blk_iocost_init(struct gendisk *disk)* called before policy activation completion, can't assume that the * target bio has an iocg associated and need to test for NULL iocg. */ - ret =rq_qos_add (q, rqos); + ret =rq_qos_add (&ioc->rqos, disk,RQ_QOS_COST , &ioc_rqos_ops);if (ret) goto err_free_ioc; - ret =blkcg_activate_policy (q, &blkcg_policy_iocost); + ret =blkcg_activate_policy (disk->queue, &blkcg_policy_iocost);if (ret) goto err_del_qos;return 0 ; err_del_qos: -rq_qos_del (q, rqos); +rq_qos_del (&ioc->rqos); err_free_ioc:free_percpu (ioc->pcpu_stat);kfree (ioc);
block/blk-iolatency.c +4 -10
@@ -757,24 +757,18 @@ static void blkiolatency_enable_work_fn(struct work_struct *work)int blk_iolatency_init (struct gendisk *disk) { -struct request_queue *q = disk->queue;struct blk_iolatency *blkiolat; -struct rq_qos *rqos;int ret; blkiolat =kzalloc (sizeof (*blkiolat),GFP_KERNEL );if (!blkiolat)return -ENOMEM ; - rqos = &blkiolat->rqos; - rqos->id =RQ_QOS_LATENCY ; - rqos->ops = &blkcg_iolatency_ops; - rqos->q = q; - - ret =rq_qos_add (q, rqos); + ret =rq_qos_add (&blkiolat->rqos, disk,RQ_QOS_LATENCY , + &blkcg_iolatency_ops);if (ret) goto err_free; - ret =blkcg_activate_policy (q, &blkcg_policy_iolatency); + ret =blkcg_activate_policy (disk->queue, &blkcg_policy_iolatency);if (ret) goto err_qos_del;
@@ -784,7 +778,7 @@ int blk_iolatency_init(struct gendisk *disk)return 0 ; err_qos_del: -rq_qos_del (q, rqos); +rq_qos_del (&blkiolat->rqos); err_free:kfree (blkiolat);return ret;
block/blk-rq-qos.c +67 -0
70 lines not on this page · raw message
block/blk-rq-qos.h +3 -59
68 lines not on this page · raw message
block/blk-wbt.c +1 -4
@@ -855,9 +855,6 @@ int wbt_init(struct gendisk *disk)for (i =0 ; i <WBT_NUM_RWQ ; i++)rq_wait_init (&rwb->rq_wait[i]); - rwb->rqos.id =RQ_QOS_WBT ; - rwb->rqos.ops = &wbt_rqos_ops; - rwb->rqos.q = q; rwb->last_comp = rwb->last_issue = jiffies; rwb->win_nsec =RWB_WINDOW_NSEC ; rwb->enable_state =WBT_STATE_ON_DEFAULT ;
@@ -870,7 +867,7 @@ int wbt_init(struct gendisk *disk)/* * Assign rwb and add the stats callback. */ - ret =rq_qos_add (q, &rwb->rqos); + ret =rq_qos_add (&rwb->rqos, disk,RQ_QOS_WBT , &wbt_rqos_ops);if (ret) goto err_free;
Signature · 1 line
2.39.0
Tejun Heo
maintainerRe: [PATCH 09/15] blk-rq-qos: make rq_qos_add and rq_qos_del more useful
Quoted 3 lines · Christoph Hellwig
Switch to passing a gendisk, and make
rq_qos_addinitialize all required fields and drop the not required q argument fromrq_qos_del. Also move the code out of line given how large it is.
Sorry about all the nit picks but can you please separate out the uninlining into its own patch? Code move + small changes in the same patch can be error prone.
Thanks.
Signature · 1 line
tejun
PATCH 10/15 blk-rq-qos: constify rq_qos_ops
In reply to Christoph HellwigThese op vectors are constant, so mark them const.
--- block/blk-iocost.c | 2 +- block/blk-iolatency.c | 2 +- block/blk-rq-qos.c | 2 +- block/blk-rq-qos.h | 4 ++-- block/blk-wbt.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-)
block/blk-iocost.c +1 -1
@@ -2832,7 +2832,7 @@ static void ioc_rqos_exit(struct rq_qos *rqos)kfree (ioc); } -static struct rq_qos_ops ioc_rqos_ops = { +static const struct rq_qos_ops ioc_rqos_ops = { .throttle = ioc_rqos_throttle, .merge = ioc_rqos_merge, .done_bio = ioc_rqos_done_bio,
block/blk-iolatency.c +1 -1
@@ -650,7 +650,7 @@ static void blkcg_iolatency_exit(struct rq_qos *rqos)kfree (blkiolat); } -static struct rq_qos_ops blkcg_iolatency_ops = { +static const struct rq_qos_ops blkcg_iolatency_ops = { .throttle = blkcg_iolatency_throttle, .done_bio = blkcg_iolatency_done_bio, .exit = blkcg_iolatency_exit,
block/blk-rq-qos.c +1 -1
@@ -296,7 +296,7 @@ void rq_qos_exit(struct request_queue *q) }int rq_qos_add (struct rq_qos *rqos,struct gendisk *disk,enum rq_qos_id id, -struct rq_qos_ops *ops) +const struct rq_qos_ops *ops) {struct request_queue *q = disk->queue;
block/blk-rq-qos.h +2 -2
@@ -25,7 +25,7 @@ struct rq_wait { };struct rq_qos { -struct rq_qos_ops *ops; +const struct rq_qos_ops *ops;struct request_queue *q;enum rq_qos_id id;struct rq_qos *next;
@@ -86,7 +86,7 @@ static inline void rq_wait_init(struct rq_wait *rq_wait) }int rq_qos_add (struct rq_qos *rqos,struct gendisk *disk,enum rq_qos_id id, -struct rq_qos_ops *ops); +const struct rq_qos_ops *ops);void rq_qos_del (struct rq_qos *rqos);typedef bool (acquire_inflight_cb_t )(struct rq_wait *rqw,void *private_data);
block/blk-wbt.c +1 -1
@@ -821,7 +821,7 @@ static const struct blk_mq_debugfs_attr wbt_debugfs_attrs[] = { };#endif -static struct rq_qos_ops wbt_rqos_ops = { +static const struct rq_qos_ops wbt_rqos_ops = { .throttle = wbt_wait, .issue = wbt_issue, .track = wbt_track,
Signature · 1 line
2.39.0
PATCH 11/15 blk-rq-qos: store a gendisk instead of request_queue in struct rq_qos
In reply to Christoph HellwigThis is what about half of the users already want, and it's only going to grow more.
--- block/blk-iocost.c | 12 ++++++------ block/blk-iolatency.c | 14 +++++++------- block/blk-mq-debugfs.c | 10 ++++------ block/blk-rq-qos.c | 4 ++-- block/blk-rq-qos.h | 2 +- block/blk-wbt.c | 16 +++++++--------- 6 files changed, 27 insertions(+), 31 deletions(-)
block/blk-iocost.c +6 -6
@@ -669,7 +669,7 @@ static struct ioc *q_to_ioc(struct request_queue *q)static const char __maybe_unused *ioc_name (struct ioc *ioc) { -struct gendisk *disk = ioc->rqos.q->disk; +struct gendisk *disk = ioc->rqos.disk;if (!disk)return "<unknown>" ;
@@ -808,11 +808,11 @@ static int ioc_autop_idx(struct ioc *ioc)u64 now_ns;/* rotational? */ -if (!blk_queue_nonrot (ioc->rqos.q)) +if (!blk_queue_nonrot (ioc->rqos.disk->queue))return AUTOP_HDD ;/* handle SATA SSDs w/ broken NCQ */ -if (blk_queue_depth (ioc->rqos.q) ==1 ) +if (blk_queue_depth (ioc->rqos.disk->queue) ==1 )return AUTOP_SSD_QD1 ;/* use one of the normal ssd sets */
@@ -2649,7 +2649,7 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)if (use_debt) {iocg_incur_debt (iocg, abs_cost, &now);if (iocg_kick_delay (iocg, &now)) -blkcg_schedule_throttle (rqos->q->disk, +blkcg_schedule_throttle (rqos->disk, (bio->bi_opf &REQ_SWAP ) ==REQ_SWAP );iocg_unlock (iocg, ioc_locked, &flags);return ;
@@ -2750,7 +2750,7 @@ static void ioc_rqos_merge(struct rq_qos *rqos, struct request *rq,if (likely (!list_empty (&iocg->active_list))) {iocg_incur_debt (iocg, abs_cost, &now);if (iocg_kick_delay (iocg, &now)) -blkcg_schedule_throttle (rqos->q->disk, +blkcg_schedule_throttle (rqos->disk, (bio->bi_opf &REQ_SWAP ) ==REQ_SWAP ); }else {iocg_commit_bio (iocg, bio, abs_cost, cost);
@@ -2821,7 +2821,7 @@ static void ioc_rqos_exit(struct rq_qos *rqos) {struct ioc *ioc =rqos_to_ioc (rqos); -blkcg_deactivate_policy (rqos->q, &blkcg_policy_iocost); +blkcg_deactivate_policy (rqos->disk->queue, &blkcg_policy_iocost);spin_lock_irq (&ioc->lock); ioc->running =IOC_STOP ;
block/blk-iolatency.c +7 -7
@@ -292,7 +292,7 @@ static void __blkcg_iolatency_throttle(struct rq_qos *rqos,unsigned use_delay =atomic_read (&lat_to_blkg (iolat)->use_delay);if (use_delay) -blkcg_schedule_throttle (rqos->q->disk, use_memdelay); +blkcg_schedule_throttle (rqos->disk, use_memdelay);/* * To avoid priority inversions we want to just take a slot if we are
@@ -330,7 +330,7 @@ static void scale_cookie_change(struct blk_iolatency *blkiolat, struct child_latency_info *lat_info, bool up) { -unsigned long qd = blkiolat->rqos.q->nr_requests; +unsigned long qd = blkiolat->rqos.disk->queue->nr_requests;unsigned long scale =scale_amount (qd, up);unsigned long old =atomic_read (&lat_info->scale_cookie);unsigned long max_scale = qd <<1 ;
@@ -372,7 +372,7 @@ static void scale_cookie_change(struct blk_iolatency *blkiolat,*/ static void scale_change (struct iolatency_grp *iolat,bool up) { -unsigned long qd = iolat->blkiolat->rqos.q->nr_requests; +unsigned long qd = iolat->blkiolat->rqos.disk->queue->nr_requests;unsigned long scale =scale_amount (qd, up);unsigned long old = iolat->max_depth;
@@ -646,7 +646,7 @@ static void blkcg_iolatency_exit(struct rq_qos *rqos)timer_shutdown_sync (&blkiolat->timer);flush_work (&blkiolat->enable_work); -blkcg_deactivate_policy (rqos->q, &blkcg_policy_iolatency); +blkcg_deactivate_policy (rqos->disk->queue, &blkcg_policy_iolatency);kfree (blkiolat); }
@@ -665,7 +665,7 @@ static void blkiolatency_timer_fn(struct timer_list *t)rcu_read_lock ();blkg_for_each_descendant_pre (blkg, pos_css, - blkiolat->rqos.q->root_blkg) { + blkiolat->rqos.disk->queue->root_blkg) {struct iolatency_grp *iolat;struct child_latency_info *lat_info;unsigned long flags;
@@ -749,9 +749,9 @@ static void blkiolatency_enable_work_fn(struct work_struct *work)*/ enabled =atomic_read (&blkiolat->enable_cnt);if (enabled != blkiolat->enabled) { -blk_mq_freeze_queue (blkiolat->rqos.q); +blk_mq_freeze_queue (blkiolat->rqos.disk->queue); blkiolat->enabled = enabled; -blk_mq_unfreeze_queue (blkiolat->rqos.q); +blk_mq_unfreeze_queue (blkiolat->rqos.disk->queue); } }
block/blk-mq-debugfs.c +4 -6
@@ -813,9 +813,9 @@ static const char *rq_qos_id_to_name(enum rq_qos_id id)void blk_mq_debugfs_unregister_rqos (struct rq_qos *rqos) { -lockdep_assert_held (&rqos->q->debugfs_mutex); +lockdep_assert_held (&rqos->disk->queue->debugfs_mutex); -if (!rqos->q->debugfs_dir) +if (!rqos->disk->queue->debugfs_dir)return ;debugfs_remove_recursive (rqos->debugfs_dir); rqos->debugfs_dir =NULL ;
@@ -823,7 +823,7 @@ void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos)void blk_mq_debugfs_register_rqos (struct rq_qos *rqos) { -struct request_queue *q = rqos->q; +struct request_queue *q = rqos->disk->queue;const char *dir_name =rq_qos_id_to_name (rqos->id);lockdep_assert_held (&q->debugfs_mutex);
@@ -835,9 +835,7 @@ void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) q->rqos_debugfs_dir =debugfs_create_dir ("rqos" , q->debugfs_dir); - rqos->debugfs_dir =debugfs_create_dir (dir_name, - rqos->q->rqos_debugfs_dir); - + rqos->debugfs_dir =debugfs_create_dir (dir_name, q->rqos_debugfs_dir);debugfs_create_files (rqos->debugfs_dir, rqos, rqos->ops->debugfs_attrs); }
block/blk-rq-qos.c +2 -2
@@ -300,7 +300,7 @@ int rq_qos_add(struct rq_qos *rqos, struct gendisk *disk, enum rq_qos_id id, {struct request_queue *q = disk->queue; - rqos->q = q; + rqos->disk = disk; rqos->id = id; rqos->ops = ops;
@@ -337,7 +337,7 @@ int rq_qos_add(struct rq_qos *rqos, struct gendisk *disk, enum rq_qos_id id,void rq_qos_del (struct rq_qos *rqos) { -struct request_queue *q = rqos->q; +struct request_queue *q = rqos->disk->queue;struct rq_qos **cur;/*
block/blk-rq-qos.h +1 -1
@@ -26,7 +26,7 @@ struct rq_wait {struct rq_qos {const struct rq_qos_ops *ops; -struct request_queue *q; +struct gendisk *disk;enum rq_qos_id id;struct rq_qos *next;#ifdef CONFIG_BLK_DEBUG_FS
block/blk-wbt.c +7 -9
@@ -98,7 +98,7 @@ 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.q->disk->bdi->wb; +struct bdi_writeback *wb = &rwb->rqos.disk->bdi->wb;return time_before (jiffies, wb->dirty_sleep +HZ ); }
@@ -235,7 +235,7 @@ enum {static int latency_exceeded (struct rq_wb *rwb,struct blk_rq_stat *stat) { -struct backing_dev_info *bdi = rwb->rqos.q->disk->bdi; +struct backing_dev_info *bdi = rwb->rqos.disk->bdi;struct rq_depth *rqd = &rwb->rq_depth;u64 thislat;
@@ -288,7 +288,7 @@ static int latency_exceeded(struct rq_wb *rwb, struct blk_rq_stat *stat)static void rwb_trace_step (struct rq_wb *rwb,const char *msg) { -struct backing_dev_info *bdi = rwb->rqos.q->disk->bdi; +struct backing_dev_info *bdi = rwb->rqos.disk->bdi;struct rq_depth *rqd = &rwb->rq_depth; trace_wbt_step(bdi, msg, rqd->scale_step, rwb->cur_win_nsec,
@@ -358,13 +358,12 @@ static void wb_timer_fn(struct blk_stat_callback *cb)unsigned int inflight =wbt_inflight (rwb);int status; -if (!rwb->rqos.q->disk) +if (!rwb->rqos.disk)return ; status =latency_exceeded (rwb, cb->stat); -trace_wbt_timer (rwb->rqos.q->disk->bdi, status, rqd->scale_step, - inflight); +trace_wbt_timer (rwb->rqos.disk->bdi, status, rqd->scale_step, inflight);/* * If we exceeded the latency target, step down. If we did not,
@@ -702,16 +701,15 @@ static int wbt_data_dir(const struct request *rq)static void wbt_queue_depth_changed (struct rq_qos *rqos) { -RQWB (rqos)->rq_depth.queue_depth =blk_queue_depth (rqos->q); +RQWB (rqos)->rq_depth.queue_depth =blk_queue_depth (rqos->disk->queue);wbt_update_limits (RQWB (rqos)); }static void wbt_exit (struct rq_qos *rqos) {struct rq_wb *rwb =RQWB (rqos); -struct request_queue *q = rqos->q; -blk_stat_remove_callback (q, rwb->cb); +blk_stat_remove_callback (rqos->disk->queue, rwb->cb);blk_stat_free_callback (rwb->cb);kfree (rwb); }
Signature · 1 line
2.39.0
PATCH 12/15 blk-cgroup: pass a gendisk to blkcg_{de,}activate_policy
In reply to Christoph HellwigPrepare for storing the blkcg information in the gendisk instead of the request_queue.
--- block/bfq-cgroup.c | 2 +- block/bfq-iosched.c | 2 +- block/blk-cgroup.c | 21 +++++++++++---------- block/blk-cgroup.h | 9 ++++----- block/blk-iocost.c | 4 ++-- block/blk-iolatency.c | 4 ++-- block/blk-ioprio.c | 4 ++-- block/blk-throttle.c | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-)
block/bfq-cgroup.c +1 -1
@@ -1293,7 +1293,7 @@ struct bfq_group *bfq_create_group_hierarchy(struct bfq_data *bfqd, int node) {int ret; - ret =blkcg_activate_policy (bfqd->queue, &blkcg_policy_bfq); + ret =blkcg_activate_policy (bfqd->queue->disk, &blkcg_policy_bfq);if (ret)return NULL ;
block/bfq-iosched.c +1 -1
@@ -7155,7 +7155,7 @@ static void bfq_exit_queue(struct elevator_queue *e)bfqg_and_blkg_put (bfqd->root_group);#ifdef CONFIG_BFQ_GROUP_IOSCHED -blkcg_deactivate_policy (bfqd->queue, &blkcg_policy_bfq); +blkcg_deactivate_policy (bfqd->queue->disk, &blkcg_policy_bfq);#else spin_lock_irq (&bfqd->lock);bfq_put_async_queues (bfqd, bfqd->root_group);
block/blk-cgroup.c +11 -10
@@ -1362,14 +1362,14 @@ struct cgroup_subsys io_cgrp_subsys = {EXPORT_SYMBOL_GPL (io_cgrp_subsys);/** -* blkcg_activate_policy - activate a blkcg policy on a request_queue -* @q: request_queue of interest +* blkcg_activate_policy - activate a blkcg policy on a gendisk +* @disk: gendisk of interest * @pol: blkcg policy to activate * -* Activate @pol on @q. Requires %GFP_KERNEL context. @q goes through +* Activate @pol on @disk. Requires %GFP_KERNEL context. @disk goes through * bypass mode to populate its blkgs with policy_data for @pol. * -* Activation happens with @q bypassed, so nobody would be accessing blkgs +* Activation happens with @disk bypassed, so nobody would be accessing blkgs * from IO path. Update of each blkg is protected by both queue and blkcg * locks so that holding either lock and testing blkcg_policy_enabled() is * always enough for dereferencing policy data.
@@ -1377,9 +1377,9 @@ EXPORT_SYMBOL_GPL(io_cgrp_subsys);* The caller is responsible for synchronizing [de]activations and policy * [un]registerations. Returns 0 on success, -errno on failure. */ -int blkcg_activate_policy (struct request_queue *q, -const struct blkcg_policy *pol) +int blkcg_activate_policy (struct gendisk *disk,const struct blkcg_policy *pol) { +struct request_queue *q = disk->queue;struct blkg_policy_data *pd_prealloc =NULL ;struct blkcg_gq *blkg, *pinned_blkg =NULL ;int ret;
@@ -1473,16 +1473,17 @@ int blkcg_activate_policy(struct request_queue *q,EXPORT_SYMBOL_GPL (blkcg_activate_policy);/** -* blkcg_deactivate_policy - deactivate a blkcg policy on a request_queue -* @q: request_queue of interest +* blkcg_deactivate_policy - deactivate a blkcg policy on a gendisk +* @disk: gendisk of interest * @pol: blkcg policy to deactivate * -* Deactivate @pol on @q. Follows the same synchronization rules as +* Deactivate @pol on @disk. Follows the same synchronization rules as * blkcg_activate_policy(). */ -void blkcg_deactivate_policy (struct request_queue *q, +void blkcg_deactivate_policy (struct gendisk *disk,const struct blkcg_policy *pol) { +struct request_queue *q = disk->queue;struct blkcg_gq *blkg;if (!blkcg_policy_enabled (q, pol))
block/blk-cgroup.h +4 -5
@@ -190,9 +190,8 @@ void blkcg_exit_disk(struct gendisk *disk);/* Blkio controller policy registration */ int blkcg_policy_register (struct blkcg_policy *pol);void blkcg_policy_unregister (struct blkcg_policy *pol); -int blkcg_activate_policy (struct request_queue *q, -const struct blkcg_policy *pol); -void blkcg_deactivate_policy (struct request_queue *q, +int blkcg_activate_policy (struct gendisk *disk,const struct blkcg_policy *pol); +void blkcg_deactivate_policy (struct gendisk *disk,const struct blkcg_policy *pol);const char *blkg_dev_name (struct blkcg_gq *blkg);
@@ -491,9 +490,9 @@ static inline int blkcg_init_disk(struct gendisk *disk) { return 0; }static inline void blkcg_exit_disk (struct gendisk *disk) { }static inline int blkcg_policy_register (struct blkcg_policy *pol) {return 0 ; }static inline void blkcg_policy_unregister (struct blkcg_policy *pol) { } -static inline int blkcg_activate_policy (struct request_queue *q, +static inline int blkcg_activate_policy (struct gendisk *disk,const struct blkcg_policy *pol) {return 0 ; } -static inline void blkcg_deactivate_policy (struct request_queue *q, +static inline void blkcg_deactivate_policy (struct gendisk *disk,const struct blkcg_policy *pol) { } static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
block/blk-iocost.c +2 -2
@@ -2821,7 +2821,7 @@ static void ioc_rqos_exit(struct rq_qos *rqos) {struct ioc *ioc =rqos_to_ioc (rqos); -blkcg_deactivate_policy (rqos->disk->queue, &blkcg_policy_iocost); +blkcg_deactivate_policy (rqos->disk, &blkcg_policy_iocost);spin_lock_irq (&ioc->lock); ioc->running =IOC_STOP ;
@@ -2893,7 +2893,7 @@ static int blk_iocost_init(struct gendisk *disk)if (ret) goto err_free_ioc; - ret =blkcg_activate_policy (disk->queue, &blkcg_policy_iocost); + ret =blkcg_activate_policy (disk, &blkcg_policy_iocost);if (ret) goto err_del_qos;return 0 ;
block/blk-iolatency.c +2 -2
@@ -646,7 +646,7 @@ static void blkcg_iolatency_exit(struct rq_qos *rqos)timer_shutdown_sync (&blkiolat->timer);flush_work (&blkiolat->enable_work); -blkcg_deactivate_policy (rqos->disk->queue, &blkcg_policy_iolatency); +blkcg_deactivate_policy (rqos->disk, &blkcg_policy_iolatency);kfree (blkiolat); }
@@ -768,7 +768,7 @@ int blk_iolatency_init(struct gendisk *disk) &blkcg_iolatency_ops);if (ret) goto err_free; - ret =blkcg_activate_policy (disk->queue, &blkcg_policy_iolatency); + ret =blkcg_activate_policy (disk, &blkcg_policy_iolatency);if (ret) goto err_qos_del;
block/blk-ioprio.c +2 -2
@@ -204,12 +204,12 @@ void blkcg_set_ioprio(struct bio *bio)void blk_ioprio_exit (struct gendisk *disk) { -blkcg_deactivate_policy (disk->queue, &ioprio_policy); +blkcg_deactivate_policy (disk, &ioprio_policy); }int blk_ioprio_init (struct gendisk *disk) { -return blkcg_activate_policy (disk->queue, &ioprio_policy); +return blkcg_activate_policy (disk, &ioprio_policy); }static int __init ioprio_init (void )
block/blk-throttle.c +2 -2
@@ -2395,7 +2395,7 @@ int blk_throtl_init(struct gendisk *disk) td->low_downgrade_time = jiffies;/* activate policy */ - ret =blkcg_activate_policy (q, &blkcg_policy_throtl); + ret =blkcg_activate_policy (disk, &blkcg_policy_throtl);if (ret) {free_percpu (td->latency_buckets[READ ]);free_percpu (td->latency_buckets[WRITE ]);
@@ -2411,7 +2411,7 @@ void blk_throtl_exit(struct gendisk *disk)BUG_ON (!q->td);del_timer_sync (&q->td->service_queue.pending_timer);throtl_shutdown_wq (q); -blkcg_deactivate_policy (q, &blkcg_policy_throtl); +blkcg_deactivate_policy (disk, &blkcg_policy_throtl);free_percpu (q->td->latency_buckets[READ ]);free_percpu (q->td->latency_buckets[WRITE ]);kfree (q->td);
Signature · 1 line
2.39.0
PATCH 13/15 blk-cgroup: pass a gendisk to pd_alloc_fn
In reply to Christoph HellwigNo need to the request_queue here, pass a gendisk and extract the node ids from that.
--- block/bfq-cgroup.c | 6 +++--- block/blk-cgroup.c | 10 +++++----- block/blk-cgroup.h | 4 ++-- block/blk-iocost.c | 7 ++++--- block/blk-iolatency.c | 7 +++---- block/blk-ioprio.c | 2 +- block/blk-throttle.c | 7 +++---- 7 files changed, 21 insertions(+), 22 deletions(-)
block/bfq-cgroup.c +3 -3
@@ -515,12 +515,12 @@ static void bfq_cpd_free(struct blkcg_policy_data *cpd)kfree (cpd_to_bfqgd (cpd)); } -static struct blkg_policy_data *bfq_pd_alloc (gfp_t gfp,struct request_queue *q, -struct blkcg *blkcg) +static struct blkg_policy_data *bfq_pd_alloc (struct gendisk *disk, +struct blkcg *blkcg,gfp_t gfp) {struct bfq_group *bfqg; - bfqg =kzalloc_node (sizeof (*bfqg), gfp, q->node); + bfqg =kzalloc_node (sizeof (*bfqg), gfp, disk->node_id);if (!bfqg)return NULL ;
block/blk-cgroup.c +5 -5
@@ -268,7 +268,7 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,continue ;/* alloc per-policy data and attach it to blkg */ - pd = pol->pd_alloc_fn (gfp_mask, disk->queue, blkcg); + pd = pol->pd_alloc_fn (disk, blkcg, gfp_mask);if (!pd) goto err_free;
@@ -1404,8 +1404,8 @@ int blkcg_activate_policy(struct gendisk *disk, const struct blkcg_policy *pol) pd = pd_prealloc; pd_prealloc =NULL ; }else { - pd = pol->pd_alloc_fn (GFP_NOWAIT | __GFP_NOWARN, q, - blkg->blkcg); + pd = pol->pd_alloc_fn (disk, blkg->blkcg, +GFP_NOWAIT | __GFP_NOWARN); }if (!pd) {
@@ -1422,8 +1422,8 @@ int blkcg_activate_policy(struct gendisk *disk, const struct blkcg_policy *pol)if (pd_prealloc) pol->pd_free_fn (pd_prealloc); - pd_prealloc = pol->pd_alloc_fn (GFP_KERNEL , q, - blkg->blkcg); + pd_prealloc = pol->pd_alloc_fn (disk, blkg->blkcg, +GFP_KERNEL );if (pd_prealloc) goto retry;else
block/blk-cgroup.h +2 -2
@@ -150,8 +150,8 @@ typedef struct blkcg_policy_data *(blkcg_pol_alloc_cpd_fn)(gfp_t gfp);typedef void (blkcg_pol_init_cpd_fn )(struct blkcg_policy_data *cpd);typedef void (blkcg_pol_free_cpd_fn )(struct blkcg_policy_data *cpd);typedef void (blkcg_pol_bind_cpd_fn )(struct blkcg_policy_data *cpd); -typedef struct blkg_policy_data *(blkcg_pol_alloc_pd_fn )(gfp_t gfp, -struct request_queue *q,struct blkcg *blkcg); +typedef struct blkg_policy_data *(blkcg_pol_alloc_pd_fn )(struct gendisk *disk, +struct blkcg *blkcg,gfp_t gfp);typedef void (blkcg_pol_init_pd_fn )(struct blkg_policy_data *pd);typedef void (blkcg_pol_online_pd_fn )(struct blkg_policy_data *pd);typedef void (blkcg_pol_offline_pd_fn )(struct blkg_policy_data *pd);
block/blk-iocost.c +4 -3
@@ -2923,13 +2923,14 @@ static void ioc_cpd_free(struct blkcg_policy_data *cpd)kfree (container_of(cpd ,struct ioc_cgrp ,cpd )); } -static struct blkg_policy_data *ioc_pd_alloc (gfp_t gfp,struct request_queue *q, -struct blkcg *blkcg) +static struct blkg_policy_data *ioc_pd_alloc (struct gendisk *disk, +struct blkcg *blkcg,gfp_t gfp) {int levels = blkcg->css.cgroup->level +1 ;struct ioc_gq *iocg; - iocg =kzalloc_node (struct_size (iocg, ancestors, levels), gfp, q->node); + iocg =kzalloc_node (struct_size (iocg, ancestors, levels), gfp, + disk->node_id);if (!iocg)return NULL ;
block/blk-iolatency.c +3 -4
@@ -946,13 +946,12 @@ static void iolatency_pd_stat(struct blkg_policy_data *pd, struct seq_file *s) iolat->max_depth, avg_lat, cur_win); } -static struct blkg_policy_data *iolatency_pd_alloc (gfp_t gfp, -struct request_queue *q, -struct blkcg *blkcg) +static struct blkg_policy_data *iolatency_pd_alloc (struct gendisk *disk, +struct blkcg *blkcg,gfp_t gfp) {struct iolatency_grp *iolat; - iolat =kzalloc_node (sizeof (*iolat), gfp, q->node); + iolat =kzalloc_node (sizeof (*iolat), gfp, disk->node_id);if (!iolat)return NULL ; iolat->stats = __alloc_percpu_gfp(sizeof(struct latency_stat),
block/blk-ioprio.c +1 -1
@@ -116,7 +116,7 @@ static ssize_t ioprio_set_prio_policy(struct kernfs_open_file *of, char *buf, }static struct blkg_policy_data * -ioprio_alloc_pd (gfp_t gfp,struct request_queue *q,struct blkcg *blkcg) +ioprio_alloc_pd (struct gendisk *disk,struct blkcg *blkcg,gfp_t gfp) {struct ioprio_blkg *ioprio_blkg;
block/blk-throttle.c +3 -4
@@ -335,14 +335,13 @@ static void throtl_service_queue_init(struct throtl_service_queue *sq)timer_setup (&sq->pending_timer, throtl_pending_timer_fn,0 ); } -static struct blkg_policy_data *throtl_pd_alloc (gfp_t gfp, -struct request_queue *q, -struct blkcg *blkcg) +static struct blkg_policy_data *throtl_pd_alloc (struct gendisk *disk, +struct blkcg *blkcg,gfp_t gfp) {struct throtl_grp *tg;int rw; - tg =kzalloc_node (sizeof (*tg), gfp, q->node); + tg =kzalloc_node (sizeof (*tg), gfp, disk->node_id);if (!tg)return NULL ;
Signature · 1 line
2.39.0
PATCH 14/15 blk-cgroup: pass a gendisk to blkg_lookup
In reply to Christoph HellwigPass a gendisk to blkg_lookup and use that to find the match as part of phasing out usage of the request_queue in the blk-cgroup code.
--- block/blk-cgroup.c | 16 ++++++++-------- block/blk-cgroup.h | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-)
block/blk-cgroup.c +8 -8
@@ -320,7 +320,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, struct gendisk *disk,/* link parent */ if (blkcg_parent (blkcg)) { - blkg->parent =blkg_lookup (blkcg_parent (blkcg), disk->queue); + blkg->parent =blkg_lookup (blkcg_parent (blkcg), disk);if (WARN_ON_ONCE (!blkg->parent)) { ret = -ENODEV ; goto err_put_css;
@@ -389,12 +389,12 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,WARN_ON_ONCE (!rcu_read_lock_held ()); - blkg =blkg_lookup (blkcg, q); + blkg =blkg_lookup (blkcg, disk);if (blkg)return blkg;spin_lock_irqsave (&q->queue_lock, flags); - blkg =blkg_lookup (blkcg, q); + blkg =blkg_lookup (blkcg, disk);if (blkg) {if (blkcg != &blkcg_root && blkg !=rcu_dereference (blkcg->blkg_hint))
@@ -413,7 +413,7 @@ static struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,struct blkcg_gq *ret_blkg = q->root_blkg;while (parent) { - blkg =blkg_lookup (parent, q); + blkg =blkg_lookup (parent, disk);if (blkg) {/* remember closest blkg */ ret_blkg = blkg;
@@ -692,7 +692,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, goto fail_unlock; } - blkg =blkg_lookup (blkcg, q); + blkg =blkg_lookup (blkcg, disk);if (blkg) goto success;
@@ -706,7 +706,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,struct blkcg_gq *new_blkg; parent =blkcg_parent (blkcg); -while (parent && !blkg_lookup (parent, q)) { +while (parent && !blkg_lookup (parent, disk)) { pos = parent; parent =blkcg_parent (parent); }
@@ -736,7 +736,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, goto fail_preloaded; } - blkg =blkg_lookup (pos, q); + blkg =blkg_lookup (pos, disk);if (blkg) {blkg_free (new_blkg); }else {
@@ -1804,7 +1804,7 @@ void blkcg_maybe_throttle_current(void) blkcg =css_to_blkcg (blkcg_css ());if (!blkcg) goto out; - blkg =blkg_lookup (blkcg, disk->queue); + blkg =blkg_lookup (blkcg, disk);if (!blkg) goto out;if (!blkg_tryget (blkg))
block/blk-cgroup.h +10 -10
@@ -230,30 +230,30 @@ static inline bool bio_issue_as_root_blkg(struct bio *bio) }/** -* blkg_lookup - lookup blkg for the specified blkcg - q pair +* blkg_lookup - lookup blkg for the specified blkcg - disk pair * @blkcg: blkcg of interest -* @q: request_queue of interest +* @disk: gendisk of interest * -* Lookup blkg for the @blkcg - @q pair. +* Lookup blkg for the @blkcg - @disk pair. * Must be called in a RCU critical section. */ static inline struct blkcg_gq *blkg_lookup (struct blkcg *blkcg, -struct request_queue *q) +struct gendisk *disk) {struct blkcg_gq *blkg;WARN_ON_ONCE (!rcu_read_lock_held ());if (blkcg == &blkcg_root) -return q->root_blkg; +return disk->queue->root_blkg; blkg =rcu_dereference (blkcg->blkg_hint); -if (blkg && blkg->disk->queue == q) +if (blkg && blkg->disk == disk)return blkg; - blkg =radix_tree_lookup (&blkcg->blkg_tree, q->id); -if (blkg && blkg->disk->queue != q) + blkg =radix_tree_lookup (&blkcg->blkg_tree, disk->queue->id); +if (blkg && blkg->disk != disk) blkg =NULL ;return blkg; }
@@ -353,7 +353,7 @@ static inline void blkg_put(struct blkcg_gq *blkg)#define blkg_for_each_descendant_pre (d_blkg, pos_css, p_blkg) \ css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css) \ if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \ - (p_blkg)->disk->queue))) + (p_blkg)->disk)))/** * blkg_for_each_descendant_post - post-order walk of a blkg's descendants
@@ -368,7 +368,7 @@ static inline void blkg_put(struct blkcg_gq *blkg)#define blkg_for_each_descendant_post (d_blkg, pos_css, p_blkg) \ css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css) \ if (((d_blkg) = blkg_lookup(css_to_blkcg(pos_css), \ - (p_blkg)->disk->queue))) + (p_blkg)->disk)))bool __blkcg_punt_bio_submit (struct bio *bio);
Signature · 1 line
2.39.0
PATCH 15/15 blk-cgroup: move the cgroup information to struct gendisk
In reply to Christoph Hellwigcgroup information only makes sense on a live gendisk that allows file system I/O (which includes the raw block device). So move over the cgroup related members.
--- block/bfq-cgroup.c | 4 ++-- block/blk-cgroup.c | 48 +++++++++++++++++++++--------------------- block/blk-cgroup.h | 2 +- block/blk-iolatency.c | 2 +- block/blk-throttle.c | 16 ++++++++------ include/linux/blkdev.h | 10 ++++----- 6 files changed, 43 insertions(+), 39 deletions(-)
block/bfq-cgroup.c +2 -2
@@ -1003,7 +1003,7 @@ void bfq_end_wr_async(struct bfq_data *bfqd) {struct blkcg_gq *blkg; -list_for_each_entry (blkg, &bfqd->queue->blkg_list, q_node) { +list_for_each_entry (blkg, &bfqd->queue->disk->blkg_list, q_node) {struct bfq_group *bfqg =blkg_to_bfqg (blkg);bfq_end_wr_async_queues (bfqd, bfqg);
@@ -1297,7 +1297,7 @@ struct bfq_group *bfq_create_group_hierarchy(struct bfq_data *bfqd, int node)if (ret)return NULL ; -return blkg_to_bfqg (bfqd->queue->root_blkg); +return blkg_to_bfqg (bfqd->queue->disk->root_blkg); }struct blkcg_policy blkcg_policy_bfq = {
block/blk-cgroup.c +24 -24
173 lines not on this page · raw message
block/blk-cgroup.h +1 -1
@@ -246,7 +246,7 @@ static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg,WARN_ON_ONCE (!rcu_read_lock_held ());if (blkcg == &blkcg_root) -return disk->queue->root_blkg; +return disk->root_blkg; blkg =rcu_dereference (blkcg->blkg_hint);if (blkg && blkg->disk == disk)
block/blk-iolatency.c +1 -1
@@ -665,7 +665,7 @@ static void blkiolatency_timer_fn(struct timer_list *t)rcu_read_lock ();blkg_for_each_descendant_pre (blkg, pos_css, - blkiolat->rqos.disk->queue->root_blkg) { + blkiolat->rqos.disk->root_blkg) {struct iolatency_grp *iolat;struct child_latency_info *lat_info;unsigned long flags;
block/blk-throttle.c +10 -6
@@ -451,7 +451,8 @@ static void blk_throtl_update_limit_valid(struct throtl_data *td)bool low_valid = false;rcu_read_lock (); -blkg_for_each_descendant_post (blkg, pos_css, td->queue->root_blkg) { +blkg_for_each_descendant_post (blkg, pos_css, + td->queue->disk->root_blkg) {struct throtl_grp *tg =blkg_to_tg (blkg); if (tg->bps[READ][LIMIT_LOW] || tg->bps[WRITE][LIMIT_LOW] ||
@@ -1180,7 +1181,7 @@ static void throtl_pending_timer_fn(struct timer_list *t)spin_lock_irq (&q->queue_lock); -if (!q->root_blkg) +if (!q->disk->root_blkg) goto out_unlock;if (throtl_can_upgrade (td,NULL ))
@@ -1322,7 +1323,8 @@ static void tg_conf_updated(struct throtl_grp *tg, bool global)* blk-throttle. */ blkg_for_each_descendant_pre (blkg, pos_css, - global ? tg->td->queue->root_blkg :tg_to_blkg (tg)) { + global ? tg->td->queue->disk->root_blkg : +tg_to_blkg (tg)) {struct throtl_grp *this_tg =blkg_to_tg (blkg);struct throtl_grp *parent_tg;
@@ -1717,7 +1719,7 @@ void blk_throtl_cancel_bios(struct gendisk *disk)* path need RCU protection and to prevent warning from lockdep. */ rcu_read_lock (); -blkg_for_each_descendant_post (blkg, pos_css, q->root_blkg) { +blkg_for_each_descendant_post (blkg, pos_css, disk->root_blkg) {struct throtl_grp *tg =blkg_to_tg (blkg);struct throtl_service_queue *sq = &tg->service_queue;
@@ -1871,7 +1873,8 @@ static bool throtl_can_upgrade(struct throtl_data *td,return false;rcu_read_lock (); -blkg_for_each_descendant_post (blkg, pos_css, td->queue->root_blkg) { +blkg_for_each_descendant_post (blkg, pos_css, + td->queue->disk->root_blkg) {struct throtl_grp *tg =blkg_to_tg (blkg);if (tg == this_tg)
@@ -1917,7 +1920,8 @@ static void throtl_upgrade_state(struct throtl_data *td) td->low_upgrade_time = jiffies; td->scale =0 ;rcu_read_lock (); -blkg_for_each_descendant_post (blkg, pos_css, td->queue->root_blkg) { +blkg_for_each_descendant_post (blkg, pos_css, + td->queue->disk->root_blkg) {struct throtl_grp *tg =blkg_to_tg (blkg);struct throtl_service_queue *sq = &tg->service_queue;
include/linux/blkdev.h +5 -5
@@ -163,6 +163,11 @@ struct gendisk {struct timer_rand_state *random;atomic_t sync_io;/* RAID */ struct disk_events *ev; +#ifdef CONFIG_BLK_CGROUP +DECLARE_BITMAP (blkcg_pols,BLKCG_MAX_POLS ); +struct blkcg_gq *root_blkg; +struct list_head blkg_list; +#endif #ifdef CONFIG_BLK_DEV_INTEGRITY struct kobject integrity_kobj;#endif /* CONFIG_BLK_DEV_INTEGRITY */
@@ -481,11 +486,6 @@ struct request_queue {struct blk_mq_tags *sched_shared_tags;struct list_head icq_list; -#ifdef CONFIG_BLK_CGROUP -DECLARE_BITMAP (blkcg_pols,BLKCG_MAX_POLS ); -struct blkcg_gq *root_blkg; -struct list_head blkg_list; -#endif struct queue_limits limits;
Signature · 1 line
2.39.0
Tejun Heo
maintainerRe: [PATCH 15/15] blk-cgroup: move the cgroup information to struct gendisk
Quoted 6 lines · Christoph Hellwig
cgroup information only makes sense on a live gendisk that allows file system I/O (which includes the raw block device). So move over the cgroup related members.
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Andreas Herrmann <[email protected]>
The series looks fine to me other than the nits.
Thanks.
Signature · 1 line
tejun