Message ID | 20220628144921.2190275-2-yanaijie@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | blk-cgroup: duplicated code refactor | expand |
On 6/28/22 8:49 AM, Jason Yan wrote: > To reduce some duplicated code, factor out blkcg_iostat_update(). No > functional change. > > Signed-off-by: Jason Yan <yanaijie@huawei.com> > --- > block/blk-cgroup.c | 37 ++++++++++++++++++++----------------- > 1 file changed, 20 insertions(+), 17 deletions(-) > > diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c > index 764e740b0c0f..60d205ec213e 100644 > --- a/block/blk-cgroup.c > +++ b/block/blk-cgroup.c > @@ -846,6 +846,21 @@ static void blkg_iostat_sub(struct blkg_iostat *dst, struct blkg_iostat *src) > } > } > > +static inline void blkcg_iostat_update(struct blkcg_gq *blkg, > + struct blkg_iostat *cur, struct blkg_iostat *last) > +{ > + struct blkg_iostat delta; > + unsigned long flags; > + > + /* propagate percpu delta to global */ > + flags = u64_stats_update_begin_irqsave(&blkg->iostat.sync); > + blkg_iostat_set(&delta, cur); > + blkg_iostat_sub(&delta, last); > + blkg_iostat_add(&blkg->iostat.cur, &delta); > + blkg_iostat_add(last, &delta); > + u64_stats_update_end_irqrestore(&blkg->iostat.sync, flags); > +} > + Please kill the inline.
On 2022/6/28 22:45, Jens Axboe wrote: > On 6/28/22 8:49 AM, Jason Yan wrote: >> To reduce some duplicated code, factor out blkcg_iostat_update(). No >> functional change. >> >> Signed-off-by: Jason Yan <yanaijie@huawei.com> >> --- >> block/blk-cgroup.c | 37 ++++++++++++++++++++----------------- >> 1 file changed, 20 insertions(+), 17 deletions(-) >> >> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c >> index 764e740b0c0f..60d205ec213e 100644 >> --- a/block/blk-cgroup.c >> +++ b/block/blk-cgroup.c >> @@ -846,6 +846,21 @@ static void blkg_iostat_sub(struct blkg_iostat *dst, struct blkg_iostat *src) >> } >> } >> >> +static inline void blkcg_iostat_update(struct blkcg_gq *blkg, >> + struct blkg_iostat *cur, struct blkg_iostat *last) >> +{ >> + struct blkg_iostat delta; >> + unsigned long flags; >> + >> + /* propagate percpu delta to global */ >> + flags = u64_stats_update_begin_irqsave(&blkg->iostat.sync); >> + blkg_iostat_set(&delta, cur); >> + blkg_iostat_sub(&delta, last); >> + blkg_iostat_add(&blkg->iostat.cur, &delta); >> + blkg_iostat_add(last, &delta); >> + u64_stats_update_end_irqrestore(&blkg->iostat.sync, flags); >> +} >> + > > Please kill the inline. > OK. Thanks.
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 764e740b0c0f..60d205ec213e 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -846,6 +846,21 @@ static void blkg_iostat_sub(struct blkg_iostat *dst, struct blkg_iostat *src) } } +static inline void blkcg_iostat_update(struct blkcg_gq *blkg, + struct blkg_iostat *cur, struct blkg_iostat *last) +{ + struct blkg_iostat delta; + unsigned long flags; + + /* propagate percpu delta to global */ + flags = u64_stats_update_begin_irqsave(&blkg->iostat.sync); + blkg_iostat_set(&delta, cur); + blkg_iostat_sub(&delta, last); + blkg_iostat_add(&blkg->iostat.cur, &delta); + blkg_iostat_add(last, &delta); + u64_stats_update_end_irqrestore(&blkg->iostat.sync, flags); +} + static void blkcg_rstat_flush(struct cgroup_subsys_state *css, int cpu) { struct blkcg *blkcg = css_to_blkcg(css); @@ -860,8 +875,7 @@ static void blkcg_rstat_flush(struct cgroup_subsys_state *css, int cpu) hlist_for_each_entry_rcu(blkg, &blkcg->blkg_list, blkcg_node) { struct blkcg_gq *parent = blkg->parent; struct blkg_iostat_set *bisc = per_cpu_ptr(blkg->iostat_cpu, cpu); - struct blkg_iostat cur, delta; - unsigned long flags; + struct blkg_iostat cur; unsigned int seq; /* fetch the current per-cpu values */ @@ -870,23 +884,12 @@ static void blkcg_rstat_flush(struct cgroup_subsys_state *css, int cpu) blkg_iostat_set(&cur, &bisc->cur); } while (u64_stats_fetch_retry(&bisc->sync, seq)); - /* propagate percpu delta to global */ - flags = u64_stats_update_begin_irqsave(&blkg->iostat.sync); - blkg_iostat_set(&delta, &cur); - blkg_iostat_sub(&delta, &bisc->last); - blkg_iostat_add(&blkg->iostat.cur, &delta); - blkg_iostat_add(&bisc->last, &delta); - u64_stats_update_end_irqrestore(&blkg->iostat.sync, flags); + blkcg_iostat_update(blkg, &cur, &bisc->last); /* propagate global delta to parent (unless that's root) */ - if (parent && parent->parent) { - flags = u64_stats_update_begin_irqsave(&parent->iostat.sync); - blkg_iostat_set(&delta, &blkg->iostat.cur); - blkg_iostat_sub(&delta, &blkg->iostat.last); - blkg_iostat_add(&parent->iostat.cur, &delta); - blkg_iostat_add(&blkg->iostat.last, &delta); - u64_stats_update_end_irqrestore(&parent->iostat.sync, flags); - } + if (parent && parent->parent) + blkcg_iostat_update(parent, &blkg->iostat.cur, + &blkg->iostat.last); } rcu_read_unlock();
To reduce some duplicated code, factor out blkcg_iostat_update(). No functional change. Signed-off-by: Jason Yan <yanaijie@huawei.com> --- block/blk-cgroup.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-)