Skip to content

Commit

Permalink
blkcg: remove blkcg->id
Browse files Browse the repository at this point in the history
blkcg->id is a unique id given to each blkcg; however, the
cgroup_subsys_state which each blkcg embeds already has ->serial_nr
which can be used for the same purpose.  Drop blkcg->id and replace
its uses with blkcg->css.serial_nr.  Rename cfq_cgroup->blkcg_id to
->blkcg_serial_nr and @id in check_blkcg_changed() to @serial_nr for
consistency.

Signed-off-by: Tejun Heo <[email protected]>
Acked-by: Vivek Goyal <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
htejun authored and axboe committed Sep 8, 2014
1 parent 55872c5 commit f4da807
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 0 additions & 2 deletions block/blk-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,6 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
static struct cgroup_subsys_state *
blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
{
static atomic64_t id_seq = ATOMIC64_INIT(0);
struct blkcg *blkcg;

if (!parent_css) {
Expand All @@ -836,7 +835,6 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)

blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
done:
spin_lock_init(&blkcg->lock);
INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
Expand Down
3 changes: 0 additions & 3 deletions block/blk-cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ struct blkcg {
struct blkcg_gq *blkg_hint;
struct hlist_head blkg_list;

/* for policies to test whether associated blkcg has changed */
uint64_t id;

/* TODO: per-policy storage in blkcg */
unsigned int cfq_weight; /* belongs to cfq */
unsigned int cfq_leaf_weight;
Expand Down
10 changes: 5 additions & 5 deletions block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ struct cfq_io_cq {
struct cfq_ttime ttime;
int ioprio; /* the current ioprio */
#ifdef CONFIG_CFQ_GROUP_IOSCHED
uint64_t blkcg_id; /* the current blkcg ID */
uint64_t blkcg_serial_nr; /* the current blkcg serial */
#endif
};

Expand Down Expand Up @@ -3534,17 +3534,17 @@ static void check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio)
{
struct cfq_data *cfqd = cic_to_cfqd(cic);
struct cfq_queue *sync_cfqq;
uint64_t id;
uint64_t serial_nr;

rcu_read_lock();
id = bio_blkcg(bio)->id;
serial_nr = bio_blkcg(bio)->css.serial_nr;
rcu_read_unlock();

/*
* Check whether blkcg has changed. The condition may trigger
* spuriously on a newly created cic but there's no harm.
*/
if (unlikely(!cfqd) || likely(cic->blkcg_id == id))
if (unlikely(!cfqd) || likely(cic->blkcg_serial_nr == serial_nr))
return;

sync_cfqq = cic_to_cfqq(cic, 1);
Expand All @@ -3558,7 +3558,7 @@ static void check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio)
cfq_put_queue(sync_cfqq);
}

cic->blkcg_id = id;
cic->blkcg_serial_nr = serial_nr;
}
#else
static inline void check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio) { }
Expand Down

0 comments on commit f4da807

Please sign in to comment.