linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: axboe@kernel.dk, kernel-team@fb.com, linux-block@vger.kernel.org,
	akpm@linux-foundation.org, hannes@cmpxchg.org, tj@kernel.org,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: Josef Bacik <jbacik@fb.com>
Subject: [PATCH 02/14] block: introduce bio_issue_as_root_blkg
Date: Fri, 29 Jun 2018 15:25:30 -0400	[thread overview]
Message-ID: <20180629192542.26649-3-josef@toxicpanda.com> (raw)
In-Reply-To: <20180629192542.26649-1-josef@toxicpanda.com>

From: Josef Bacik <jbacik@fb.com>

Instead of forcing all file systems to get the right context on their
bio's, simply check for REQ_META to see if we need to issue as the root
blkg.  We don't want to force all bio's to have the root blkg associated
with them if REQ_META is set, as some controllers (blk-iolatency) need
to know who the originating cgroup is so it can backcharge them for the
work they are doing.  This helper will make sure that the controllers do
the proper thing wrt the IO priority and backcharging.

Signed-off-by: Josef Bacik <jbacik@fb.com>
Acked-by: Tejun Heo <tj@kernel.org>
---
 include/linux/blk-cgroup.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h
index 6c666fd7de3c..69aa71dc0c04 100644
--- a/include/linux/blk-cgroup.h
+++ b/include/linux/blk-cgroup.h
@@ -238,6 +238,22 @@ static inline struct blkcg *bio_blkcg(struct bio *bio)
 	return css_to_blkcg(task_css(current, io_cgrp_id));
 }
 
+/**
+ * bio_issue_as_root_blkg - see if this bio needs to be issued as root blkg
+ * @return: true if this bio needs to be submitted with the root blkg context.
+ *
+ * In order to avoid priority inversions we sometimes need to issue a bio as if
+ * it were attached to the root blkg, and then backcharge to the actual owning
+ * blkg.  The idea is we do bio_blkcg() to look up the actual context for the
+ * bio and attach the appropriate blkg to the bio.  Then we call this helper and
+ * if it is true run with the root blkg for that queue and then do any
+ * backcharging to the originating cgroup once the io is complete.
+ */
+static inline bool bio_issue_as_root_blkg(struct bio *bio)
+{
+	return (bio->bi_opf & REQ_META);
+}
+
 /**
  * blkcg_parent - get the parent of a blkcg
  * @blkcg: blkcg of interest
-- 
2.14.3

  parent reply	other threads:[~2018-06-29 19:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-29 19:25 [PATCH 00/14][V5] Introduce io.latency io controller for cgroups Josef Bacik
2018-06-29 19:25 ` [PATCH 01/14] block: add bi_blkg to the bio " Josef Bacik
2018-06-29 19:25 ` Josef Bacik [this message]
2018-06-29 19:25 ` [PATCH 03/14] blk-cgroup: allow controllers to output their own stats Josef Bacik
2018-07-02 21:06   ` Tejun Heo
2018-06-29 19:25 ` [PATCH 04/14] blk: introduce REQ_SWAP Josef Bacik
2018-07-02 21:47   ` Jens Axboe
2018-06-29 19:25 ` [PATCH 05/14] swap,blkcg: issue swap io with the appropriate context Josef Bacik
2018-06-29 19:25 ` [PATCH 06/14] blkcg: add generic throttling mechanism Josef Bacik
2018-06-29 19:25 ` [PATCH 07/14] memcontrol: schedule throttling if we are congested Josef Bacik
2018-06-29 19:25 ` [PATCH 08/14] blk-stat: export helpers for modifying blk_rq_stat Josef Bacik
2018-06-29 19:25 ` [PATCH 09/14] blk-rq-qos: refactor out common elements of blk-wbt Josef Bacik
2018-06-29 19:25 ` [PATCH 10/14] block: remove external dependency on wbt_flags Josef Bacik
2018-06-29 19:25 ` [PATCH 11/14] rq-qos: introduce dio_bio callback Josef Bacik
2018-06-29 19:25 ` [PATCH 12/14] block: introduce blk-iolatency io controller Josef Bacik
2018-07-02 21:47   ` Tejun Heo
2018-06-29 19:25 ` [PATCH 13/14] Documentation: add a doc for blk-iolatency Josef Bacik
2018-07-02 21:49   ` Tejun Heo
2018-06-29 19:25 ` [PATCH 14/14] skip readahead if the cgroup is congested Josef Bacik
2018-07-02 21:13   ` Tejun Heo
2018-07-02 21:26 ` [PATCH 00/14][V5] Introduce io.latency io controller for cgroups Andrew Morton
2018-07-02 21:38   ` Josef Bacik
2018-07-02 21:41   ` Jens Axboe
2018-07-02 21:47     ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2018-07-03 15:14 [PATCH 0/14][V6] " Josef Bacik
2018-07-03 15:14 ` [PATCH 02/14] block: introduce bio_issue_as_root_blkg Josef Bacik
2018-06-27 19:09 [PATCH 00/14][V4] Introduce io.latency io controller for cgroups Josef Bacik
2018-06-27 19:09 ` [PATCH 02/14] block: introduce bio_issue_as_root_blkg Josef Bacik

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=20180629192542.26649-3-josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=hannes@cmpxchg.org \
    --cc=jbacik@fb.com \
    --cc=kernel-team@fb.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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).