switch blk-cgroup to work on gendisk v4
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 v3:
- improve a commit log
- drop a change to not acquire a pointless disk reference
Changes since v2:
- drop the patch to revert the async blkg freeing
- simplify error unwinding when failing to allocate a blkg
- add back the dead queue/disk check in blkg_alloc
- split two patches to better document the changes
- add another blk-wbt cleanup patch
- rewrite a commit log
- another typo fix
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 | 226 +++++++++++++++++++++------------------------- block/blk-cgroup.h | 38 +++---- 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-settings.c | 1 block/blk-stat.c | 3 block/blk-sysfs.c | 5 - block/blk-throttle.c | 31 +++--- block/blk-wbt.c | 116 +++++++++++++++++++---- block/blk-wbt.h | 98 +------------------ block/genhd.c | 17 +-- include/linux/blkdev.h | 12 +- include/linux/sched.h | 2 kernel/fork.c | 2 mm/swapfile.c | 2 22 files changed, 391 insertions(+), 418 deletions(-)
PATCH 1/19 block: don't call blk_throtl_stat_add for non-READ/WRITE commands
blk_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 2/19 blk-cgroup: delay blk-cgroup initialization until add_disk
In reply to Christoph HellwigThere is no need to initialize the cgroup 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
PATCH 3/19 blk-cgroup: improve error unwinding in blkg_alloc
In reply to Christoph HellwigUnwind only the previous initialization steps that happened in blkg_alloc using goto based unwinding. This avoids the need for the !queue special case in blkg_free and thus ensures that any blkg seens outside of blkg_alloc is always fully constructed.
--- block/blk-cgroup.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
block/blk-cgroup.c +19 -20
@@ -128,22 +128,16 @@ static void blkg_free_workfn(struct work_struct *work)* blkcg_mutex is used to synchronize blkg_free_workfn() and * blkcg_deactivate_policy(). */ -if (q) -mutex_lock (&q->blkcg_mutex); - +mutex_lock (&q->blkcg_mutex);for (i =0 ; i <BLKCG_MAX_POLS ; i++)if (blkg->pd[i]) blkcg_policy[i]->pd_free_fn (blkg->pd[i]); -if (blkg->parent)blkg_put (blkg->parent); +list_del_init (&blkg->q_node); +mutex_unlock (&q->blkcg_mutex); -if (q) { -list_del_init (&blkg->q_node); -mutex_unlock (&q->blkcg_mutex); -blk_put_queue (q); - } - +blk_put_queue (q);free_percpu (blkg->iostat_cpu);percpu_ref_exit (&blkg->refcnt);kfree (blkg);
@@ -265,16 +259,13 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk, blkg =kzalloc_node (sizeof (*blkg), gfp_mask, disk->queue->node);if (!blkg)return NULL ; -if (percpu_ref_init (&blkg->refcnt, blkg_release,0 , gfp_mask)) - goto err_free; - + goto out_free_blkg; blkg->iostat_cpu = alloc_percpu_gfp(struct blkg_iostat_set, gfp_mask);if (!blkg->iostat_cpu) - goto err_free; - + goto out_exit_refcnt;if (!blk_get_queue (disk->queue)) - goto err_free; + goto out_free_iostat; blkg->q = disk->queue;INIT_LIST_HEAD (&blkg->q_node);
@@ -299,8 +290,7 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,/* alloc per-policy data and attach it to blkg */ pd = pol->pd_alloc_fn (gfp_mask, disk->queue, blkcg);if (!pd) - goto err_free; - + goto out_free_pds; blkg->pd[i] = pd; pd->blkg = blkg; pd->plid = i;
@@ -309,8 +299,17 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,return blkg; -err_free: -blkg_free (blkg); +out_free_pds: +while (--i >=0 ) +if (blkg->pd[i]) + blkcg_policy[i]->pd_free_fn (blkg->pd[i]); +blk_put_queue (disk->queue); +out_free_iostat: +free_percpu (blkg->iostat_cpu); +out_exit_refcnt: +percpu_ref_exit (&blkg->refcnt); +out_free_blkg: +kfree (blkg);return NULL ; }
Signature · 1 line
2.39.0
PATCH 4/19 blk-cgroup: simplify blkg freeing from initialization failure paths
In reply to Christoph HellwigThere is no need to delay freeing a blkg to a workqueue when freeing it after an initialization failure.
--- block/blk-cgroup.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-)
block/blk-cgroup.c +7 -20
@@ -114,10 +114,8 @@ 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) +static void blkg_free (struct blkcg_gq *blkg) { - struct blkcg_gq *blkg = container_of(work, struct blkcg_gq, - free_work);struct request_queue *q = blkg->q;int i;
@@ -143,23 +141,9 @@ 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) +static void blkg_free_workfn (struct work_struct *work) { -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); +blkg_free (container_of(work ,struct blkcg_gq ,free_work )); }static void __blkg_release (struct rcu_head *rcu)
@@ -170,7 +154,10 @@ static void __blkg_release(struct rcu_head *rcu)/* release the blkcg and parent blkg refs this blkg has been holding */ css_put (&blkg->blkcg->css); -blkg_free (blkg); + +/* ->pd_free_fn() may sleep, so free from a work queue */ +INIT_WORK (&blkg->free_work, blkg_free_workfn); +schedule_work (&blkg->free_work); }/*
Signature · 1 line
2.39.0
PATCH 5/19 blk-cgroup: remove the !bdi->dev check in blkg_dev_name
In reply to Christoph Hellwigbdi_dev_name already performs the same check.
--- block/blk-cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-cgroup.c +1 -1
@@ -572,7 +572,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) +if (!blkg->q->disk)return NULL ;return bdi_dev_name (blkg->q->disk->bdi); }
Signature · 1 line
2.39.0
PATCH 6/19 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 | 35 +++++++++++++++++------------------ block/blk-cgroup.h | 11 +++++------ block/blk-iocost.c | 2 +- block/blk-iolatency.c | 4 ++-- block/blk-throttle.c | 4 ++-- 7 files changed, 31 insertions(+), 33 deletions(-)
block/bfq-cgroup.c +3 -3
@@ -405,7 +405,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 ;
@@ -536,7 +536,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);
@@ -1201,7 +1201,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 +17 -18
@@ -116,7 +116,6 @@ static bool blkcg_policy_enabled(struct request_queue *q,static void blkg_free (struct blkcg_gq *blkg) { -struct request_queue *q = blkg->q;int i;/*
@@ -126,16 +125,16 @@ static void blkg_free(struct blkcg_gq *blkg)* blkcg_mutex is used to synchronize blkg_free_workfn() and * blkcg_deactivate_policy(). */ -mutex_lock (&q->blkcg_mutex); +mutex_lock (&blkg->disk->queue->blkcg_mutex);for (i =0 ; i <BLKCG_MAX_POLS ; i++)if (blkg->pd[i]) blkcg_policy[i]->pd_free_fn (blkg->pd[i]);if (blkg->parent)blkg_put (blkg->parent);list_del_init (&blkg->q_node); -mutex_unlock (&q->blkcg_mutex); +mutex_unlock (&blkg->disk->queue->blkcg_mutex); -blk_put_queue (q); +put_disk (blkg->disk);free_percpu (blkg->iostat_cpu);percpu_ref_exit (&blkg->refcnt);kfree (blkg);
@@ -251,10 +250,12 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk, blkg->iostat_cpu = alloc_percpu_gfp(struct blkg_iostat_set, gfp_mask);if (!blkg->iostat_cpu) goto out_exit_refcnt; -if (!blk_get_queue (disk->queue)) + +if (test_bit (GD_DEAD , &disk->state)) goto out_free_iostat; +get_device (disk_to_dev (disk)); + blkg->disk = disk; - blkg->q = disk->queue;INIT_LIST_HEAD (&blkg->q_node);spin_lock_init (&blkg->async_bio_lock);bio_list_init (&blkg->async_bios);
@@ -290,7 +291,7 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,while (--i >=0 )if (blkg->pd[i]) blkcg_policy[i]->pd_free_fn (blkg->pd[i]); -blk_put_queue (disk->queue); +put_disk (blkg->disk); out_free_iostat:free_percpu (blkg->iostat_cpu); out_exit_refcnt:
@@ -461,7 +462,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);/*
@@ -485,7 +486,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);hlist_del_init_rcu (&blkg->blkcg_node);/*
@@ -572,9 +573,7 @@ static int blkcg_reset_stats(struct cgroup_subsys_state *css,const char *blkg_dev_name (struct blkcg_gq *blkg) { -if (!blkg->q->disk) -return NULL ; -return bdi_dev_name (blkg->q->disk->bdi); +return bdi_dev_name (blkg->disk->bdi); }/**
@@ -606,10 +605,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 ();
@@ -1033,9 +1032,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 ;
@@ -1105,7 +1104,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;
@@ -255,11 +254,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; }
@@ -359,7 +358,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
@@ -374,7 +373,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
PATCH 7/19 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.
--- block/blk-cgroup.c | 32 +++++++++++++++----------------- include/linux/sched.h | 2 +- kernel/fork.c | 2 +- mm/swapfile.c | 2 +- 4 files changed, 18 insertions(+), 20 deletions(-)
block/blk-cgroup.c +15 -17
@@ -1362,9 +1362,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 = {
@@ -1815,29 +1815,29 @@ 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;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))
@@ -1846,11 +1846,10 @@ 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); }/**
@@ -1872,18 +1871,17 @@ 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)) +if (current->throttle_disk != disk) { +if (test_bit (GD_DEAD , &disk->state))return ; +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
PATCH 8/19 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
@@ -7156,7 +7156,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); }
@@ -7344,7 +7344,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 9/19 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 10/19 blk-wbt: move private information from blk-wbt.h to blk-wbt.c
In reply to Christoph HellwigA large part of blk-wbt.h is only used in blk-wbt.c, so move it there.
--- block/blk-settings.c | 1 + block/blk-sysfs.c | 1 + block/blk-wbt.c | 77 +++++++++++++++++++++++++++++++++++++++ block/blk-wbt.h | 86 -------------------------------------------- 4 files changed, 79 insertions(+), 86 deletions(-)
block/blk-settings.c +1 -0
@@ -16,6 +16,7 @@#include <linux/dma-mapping.h> #include "blk.h" +#include "blk-rq-qos.h" #include "blk-wbt.h" void blk_queue_rq_timeout (struct request_queue *q,unsigned int timeout)
block/blk-sysfs.c +1 -0
@@ -16,6 +16,7 @@#include "blk-mq.h" #include "blk-mq-debugfs.h" #include "blk-mq-sched.h" +#include "blk-rq-qos.h" #include "blk-wbt.h" #include "blk-cgroup.h" #include "blk-throttle.h"
block/blk-wbt.c +77 -0
95 lines not on this page · raw message
block/blk-wbt.h +0 -86
92 lines not on this page · raw message
Signature · 1 line
2.39.0
PATCH 11/19 blk-wbt: open code wbt_queue_depth_changed in wbt_init
In reply to Christoph Hellwigwbt_queue_depth_changed just updates a field and calls another function. Open code it in wbt_init, so that the local queue variable can be used instead of the one stored in the rq_qos. This will allow delaying that rq_qos->queue assignment in a subsequent patch.
--- block/blk-wbt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/blk-wbt.c +2 -2
@@ -941,8 +941,8 @@ int wbt_init(struct gendisk *disk) rwb->wc =test_bit (QUEUE_FLAG_WC , &q->queue_flags); rwb->rq_depth.default_depth =RWB_DEF_DEPTH ; rwb->min_lat_nsec =wbt_default_latency_nsec (q); - -wbt_queue_depth_changed (&rwb->rqos); + rwb->rq_depth.queue_depth =blk_queue_depth (q); +wbt_update_limits (rwb);/* * Assign rwb and add the stats callback.
Signature · 1 line
2.39.0
PATCH 12/19 blk-rq-qos: move rq_qos_add and rq_qos_del out of line
In reply to Christoph HellwigThese two functions are rather larger and not in a fast path, so move them out of line.
--- block/blk-rq-qos.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ block/blk-rq-qos.h | 61 ++-------------------------------------------- 2 files changed, 62 insertions(+), 59 deletions(-)
block/blk-rq-qos.c +60 -0
@@ -294,3 +294,63 @@ void rq_qos_exit(struct request_queue *q) rqos->ops->exit (rqos); } } + +int rq_qos_add (struct request_queue *q,struct rq_qos *rqos) +{ +/* +* No IO can be in-flight when adding rqos, so freeze queue, which +* is fine since we only support rq_qos for blk-mq queue. +* +* Reuse ->queue_lock for protecting against other concurrent +* rq_qos adding/deleting +*/ +blk_mq_freeze_queue (q); + +spin_lock_irq (&q->queue_lock); +if (rq_qos_id (q, rqos->id)) + goto ebusy; + rqos->next = q->rq_qos; + q->rq_qos = rqos; +spin_unlock_irq (&q->queue_lock); + +blk_mq_unfreeze_queue (q); + +if (rqos->ops->debugfs_attrs) { +mutex_lock (&q->debugfs_mutex); +blk_mq_debugfs_register_rqos (rqos); +mutex_unlock (&q->debugfs_mutex); + } + +return 0 ; +ebusy: +spin_unlock_irq (&q->queue_lock); +blk_mq_unfreeze_queue (q); +return -EBUSY ; + +} + +void rq_qos_del (struct request_queue *q,struct rq_qos *rqos) +{ +struct rq_qos **cur; + +/* +* See comment in rq_qos_add() about freezing queue & using +* ->queue_lock. +*/ +blk_mq_freeze_queue (q); + +spin_lock_irq (&q->queue_lock); +for (cur = &q->rq_qos; *cur; cur = &(*cur)->next) { +if (*cur == rqos) { + *cur = rqos->next; +break ; + } + } +spin_unlock_irq (&q->queue_lock); + +blk_mq_unfreeze_queue (q); + +mutex_lock (&q->debugfs_mutex); +blk_mq_debugfs_unregister_rqos (rqos); +mutex_unlock (&q->debugfs_mutex); +}
block/blk-rq-qos.h +2 -59
67 lines not on this page · raw message
Signature · 1 line
2.39.0
PATCH 13/19 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.
--- block/blk-iocost.c | 13 +++---------- block/blk-iolatency.c | 14 ++++---------- block/blk-rq-qos.c | 13 ++++++++++--- block/blk-rq-qos.h | 5 +++-- block/blk-wbt.c | 5 +---- 5 files changed, 21 insertions(+), 29 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 +10 -3
@@ -295,8 +295,15 @@ void rq_qos_exit(struct request_queue *q) } } -int rq_qos_add (struct request_queue *q,struct rq_qos *rqos) +int rq_qos_add (struct rq_qos *rqos,struct gendisk *disk,enum rq_qos_id id, +struct rq_qos_ops *ops) { +struct request_queue *q = disk->queue; + + rqos->q = q; + rqos->id = id; + rqos->ops = ops; +/* * No IO can be in-flight when adding rqos, so freeze queue, which * is fine since we only support rq_qos for blk-mq queue.
@@ -326,11 +333,11 @@ int rq_qos_add(struct request_queue *q, struct rq_qos *rqos)spin_unlock_irq (&q->queue_lock);blk_mq_unfreeze_queue (q);return -EBUSY ; - } -void rq_qos_del (struct request_queue *q,struct rq_qos *rqos) +void rq_qos_del (struct rq_qos *rqos) { +struct request_queue *q = rqos->q;struct rq_qos **cur;/*
block/blk-rq-qos.h +3 -2
@@ -85,8 +85,9 @@ static inline void rq_wait_init(struct rq_wait *rq_wait)init_waitqueue_head (&rq_wait->wait); } -int rq_qos_add (struct request_queue *q,struct rq_qos *rqos); -void rq_qos_del (struct request_queue *q,struct rq_qos *rqos); +int rq_qos_add (struct rq_qos *rqos,struct gendisk *disk,enum rq_qos_id id, +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);typedef void (cleanup_cb_t )(struct rq_wait *rqw,void *private_data);
block/blk-wbt.c +1 -4
@@ -932,9 +932,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 ;
@@ -947,7 +944,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
PATCH 14/19 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
@@ -898,7 +898,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 15/19 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
@@ -165,7 +165,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 ); }
@@ -312,7 +312,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;
@@ -365,7 +365,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,
@@ -435,13 +435,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,
@@ -779,16 +778,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 16/19 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
@@ -1291,7 +1291,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
@@ -7146,7 +7146,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
@@ -1390,14 +1390,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.
@@ -1405,9 +1405,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;
@@ -1508,16 +1508,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
@@ -194,9 +194,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);
@@ -495,9 +494,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 17/19 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
@@ -513,12 +513,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
@@ -276,7 +276,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 out_free_pds; blkg->pd[i] = pd;
@@ -1432,8 +1432,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) {
@@ -1450,8 +1450,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
@@ -154,8 +154,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 18/19 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
@@ -337,7 +337,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;
@@ -409,12 +409,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))
@@ -433,7 +433,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;
@@ -719,7 +719,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;
@@ -733,7 +733,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); }
@@ -763,7 +763,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 {
@@ -1838,7 +1838,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
@@ -234,30 +234,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; }
@@ -357,7 +357,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
@@ -372,7 +372,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 19/19 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 | 66 +++++++++++++++++++++--------------------- block/blk-cgroup.h | 4 +-- block/blk-iolatency.c | 2 +- block/blk-throttle.c | 16 ++++++---- include/linux/blkdev.h | 12 ++++---- 6 files changed, 54 insertions(+), 50 deletions(-)
block/bfq-cgroup.c +2 -2
@@ -1001,7 +1001,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, entry) {struct bfq_group *bfqg =blkg_to_bfqg (blkg);bfq_end_wr_async_queues (bfqd, bfqg);
@@ -1295,7 +1295,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 +33 -33
223 lines not on this page · raw message
block/blk-cgroup.h +2 -2
@@ -54,7 +54,7 @@ struct blkg_iostat_set {/* association between a blk cgroup and a request queue */ struct blkcg_gq {struct gendisk *disk; -struct list_head q_node; +struct list_head entry;struct hlist_node blkcg_node;struct blkcg *blkcg;
@@ -250,7 +250,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 +6 -6
@@ -163,6 +163,12 @@ 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; +struct mutex blkcg_mutex; +#endif /* CONFIG_BLK_CGROUP */ #ifdef CONFIG_BLK_DEV_INTEGRITY struct kobject integrity_kobj;#endif /* CONFIG_BLK_DEV_INTEGRITY */
@@ -481,12 +487,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; -struct mutex blkcg_mutex; -#endif struct queue_limits limits;
Signature · 1 line
2.39.0
Quoted 10 lines · Christoph Hellwig
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_queuethat also exists for pure passthrough request based devices.Changes since v3:
- improve a commit log
- drop a change to not acquire a pointless disk reference[...]
Applied, thanks!
[01/19] block: don't call blk_throtl_stat_add for non-READ/WRITE commands
commit: a886001c2da8dd02357d0d336ddb021903347f89
[02/19] blk-cgroup: delay blk-cgroup initialization until add_disk
commit: 178fa7d49815ea8001f43ade37a22072829fd8ab
[03/19] blk-cgroup: improve error unwinding in blkg_alloc
commit: 0b6f93bdf07e52620f725f721e547408e0d04c9d
[04/19] blk-cgroup: simplify blkg freeing from initialization failure paths
commit: 27b642b07a4a5eb44dffa94a5171ce468bdc46f9
[05/19] blk-cgroup: remove the !bdi->dev check in blkg_dev_name
commit: 180b04d450a7137270c12dbb6bebf1d5e6c0a6f2
[06/19] blk-cgroup: pin the gendisk in struct blkcg_gq
commit: 84d7d462b16dd5f0bf7c7ca9254bf81db2c952a2
[07/19] blk-cgroup: store a gendisk to throttle in struct task_struct
commit: f05837ed73d0c73e950b2d9f2612febb0d3d451e
[08/19] blk-wbt: pass a gendisk to wbt_{enable,disable}_default
commit: 04aad37be1a88de6a1919996a615437ac74de479
[09/19] blk-wbt: pass a gendisk to wbt_init
commit: 958f29654747a54f2272eb478e493eb97f492e06
[10/19] blk-wbt: move private information from blk-wbt.h to blk-wbt.c
commit: 0bc65bd41dfd2f75b9f38812326d767db5cd0663
[11/19] blk-wbt: open code wbt_queue_depth_changed in wbt_init
commit: 4e1d91ae876bd12f327340f11a16a1278985e7e1
[12/19] blk-rq-qos: move rq_qos_add and rq_qos_del out of line
commit: b494f9c566ba5fe2cc8abe67fdeb0332c6b48d4b
[13/19] blk-rq-qos: make rq_qos_add and rq_qos_del more useful
commit: ce57b558604e68277d31ca5ce49ec4579a8618c5
[14/19] blk-rq-qos: constify rq_qos_ops
commit: 3963d84df7974b6687cb34bce3b9e0b2686f839c
[15/19] blk-rq-qos: store a gendisk instead of request_queue in struct rq_qos
commit: ba91c849fa50dbc6519cf7808177b3a9b7f6bc97
[16/19] blk-cgroup: pass a gendisk to blkcg_{de,}activate_policy
commit: 40e4996ec099a301083eb7e29095ebdfc31443da
[17/19] blk-cgroup: pass a gendisk to pd_alloc_fn
commit: 0a0b4f79db2e6e745672aa3852cf5fdf7af14a0f
[18/19] blk-cgroup: pass a gendisk to blkg_lookup
commit: 479664cee14d8452d3d76f8d0b7fccd0cbe4ed49
[19/19] blk-cgroup: move the cgroup information to struct gendisk
commit: 3f13ab7c80fdb0ada86a8e3e818960bc1ccbaa59Best regards,
Signature · 1 line
Jens Axboe