linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shaohua Li <shli@kernel.org>
To: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org
Cc: tj@kernel.org, gregkh@linuxfoundation.org, hch@lst.de,
	axboe@fb.com, rostedt@goodmis.org, lizefan@huawei.com,
	Kernel-team@fb.com, Shaohua Li <shli@fb.com>
Subject: [PATCH V2 09/12] block: always attach cgroup info into bio
Date: Wed, 14 Jun 2017 09:12:07 -0700	[thread overview]
Message-ID: <9936601782742e092ed3c0e30e983daf3d866c1d.1497455937.git.shli@fb.com> (raw)
In-Reply-To: <cover.1497455937.git.shli@fb.com>
In-Reply-To: <cover.1497455937.git.shli@fb.com>

From: Shaohua Li <shli@fb.com>

blkcg_bio_issue_check() already gets blkcg for a BIO.
bio_associate_blkcg() uses a percpu refcounter, so it's a very cheap
operation. There is no point we don't attach the cgroup info into bio at
blkcg_bio_issue_check. This also makes blktrace outputs correct cgroup
info.

Signed-off-by: Shaohua Li <shli@fb.com>
---
 block/blk-throttle.c       | 7 +------
 include/linux/blk-cgroup.h | 3 +++
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index a7285bf..a6ebd2b 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -2104,14 +2104,9 @@ static inline void throtl_update_latency_buckets(struct throtl_data *td)
 static void blk_throtl_assoc_bio(struct throtl_grp *tg, struct bio *bio)
 {
 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
-	int ret;
-
-	ret = bio_associate_current(bio);
-	if (ret == 0 || ret == -EBUSY)
+	if (bio->bi_css)
 		bio->bi_cg_private = tg;
 	blk_stat_set_issue(&bio->bi_issue_stat, bio_sectors(bio));
-#else
-	bio_associate_current(bio);
 #endif
 }
 
diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h
index 01b62e7..fe10b85 100644
--- a/include/linux/blk-cgroup.h
+++ b/include/linux/blk-cgroup.h
@@ -691,6 +691,9 @@ static inline bool blkcg_bio_issue_check(struct request_queue *q,
 	rcu_read_lock();
 	blkcg = bio_blkcg(bio);
 
+	/* associate blkcg if bio hasn't attached one */
+	bio_associate_blkcg(bio, &blkcg->css);
+
 	blkg = blkg_lookup(blkcg, q);
 	if (unlikely(!blkg)) {
 		spin_lock_irq(q->queue_lock);
-- 
2.9.3

  parent reply	other threads:[~2017-06-14 16:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-14 16:11 [PATCH V2 00/12]blktrace: output cgroup info Shaohua Li
2017-06-14 16:11 ` [PATCH V2 01/12] kernfs: implement i_generation Shaohua Li
2017-06-14 16:12 ` [PATCH V2 02/12] kernfs: use idr instead of ida to manage inode number Shaohua Li
2017-06-14 16:12 ` [PATCH V2 03/12] kernfs: add an API to get kernfs node from " Shaohua Li
2017-06-14 16:12 ` [PATCH V2 04/12] kernfs: don't set dentry->d_fsdata Shaohua Li
2017-06-14 16:12 ` [PATCH V2 05/12] kernfs: introduce kernfs_node_id Shaohua Li
2017-06-15 20:14   ` kbuild test robot
2017-06-14 16:12 ` [PATCH V2 06/12] kernfs: add exportfs operations Shaohua Li
2017-06-14 16:12 ` [PATCH V2 07/12] cgroup: export fhandle info for a cgroup Shaohua Li
2017-06-14 16:12 ` [PATCH V2 08/12] blktrace: export cgroup info in trace Shaohua Li
2017-06-14 16:12 ` Shaohua Li [this message]
2017-06-14 16:12 ` [PATCH V2 10/12] block: call __bio_free in bio_endio Shaohua Li
2017-06-14 16:12 ` [PATCH V2 11/12] blktrace: add an option to allow displying cgroup path Shaohua Li
2017-06-14 16:12 ` [PATCH V2 12/12] block: use standard blktrace API to output cgroup info for debug notes Shaohua Li
2017-06-15 13:56   ` kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9936601782742e092ed3c0e30e983daf3d866c1d.1497455937.git.shli@fb.com \
    --to=shli@kernel.org \
    --cc=Kernel-team@fb.com \
    --cc=axboe@fb.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=rostedt@goodmis.org \
    --cc=shli@fb.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).