Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1273718imm; Tue, 3 Jul 2018 08:21:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLNx4juTaCot1n1N7xqlSG8Q4Mtig/dzMS1UOiAfGqbBhzou8AcqGPVGoQhRrPXRelWurlM X-Received: by 2002:a63:bd51:: with SMTP id d17-v6mr26750278pgp.42.1530631265134; Tue, 03 Jul 2018 08:21:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530631265; cv=none; d=google.com; s=arc-20160816; b=yfJIb1ZPgF4BAS4vzL8di5paCD4FN4nhBrK12ptkld7nnZusaUBtPFrE0rcWnaeV+0 sqEZuRIox4wqjHBxlIxyP2nGZmsmovVfBHvdeGWfCFqtsN0Ihdv/dWAfr5FoJpySBlQt vdRuH8GKGwWn8Hazlt0uTPJ8Oy1YrcZhi46NVA2yl7r4xBSPztIkLoaMszmuOiEMnzDl xSk0cpx10qcEWwdZhq25rfy/+ENk2b7qeaYol2NgtO1qR2jIpWYf2rH91Y380fzhcNEd zXFqIp5hXtXkkyBQRyq/mDqetMB3dcCj9TORWNdDK4BtBeziSRvCF26dcPFWGYDOGxde QVOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=gkdJSYLh9LN7Ss8j0Rn9mX3g9Rqhn9vecXPFB0z5w9o=; b=MmlOvH3oYsg4yn8PB88o2IWmDBryvLsuGKOE/O714S7BpUAMrBDARDkAlWiFEh1IdH ioEGtDfv7NkgwUGbWu93u5ahduC4XYYUdpFjCuH/BR4CSebJLRejsrBEK8BYh3haN6tx kC6oDMpBJSFgzwyVI8DvLZEdLxJldMytbkWcP1s1KfIOs/cHP2MZPcjh8qfARvLkgPbz DoxvNrHGa7g4Cj1A1NG81EYVWIQuLrpjfnDzTFQNESh9E109EyWqAiq6fh3cybj95pfb IYdJLIaGaT7mlJ3nzdJuIwNH3Ef2SCyrSZGQHBl7G+h+xloiMC9Hskgqg1j3s4JZ9XFP QB1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=rrJkMw9t; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i62-v6si1310987pfc.255.2018.07.03.08.20.50; Tue, 03 Jul 2018 08:21:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=rrJkMw9t; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933781AbeGCPTm (ORCPT + 99 others); Tue, 3 Jul 2018 11:19:42 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:35565 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933954AbeGCPPK (ORCPT ); Tue, 3 Jul 2018 11:15:10 -0400 Received: by mail-qt0-f196.google.com with SMTP id z6-v6so1874910qti.2 for ; Tue, 03 Jul 2018 08:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gkdJSYLh9LN7Ss8j0Rn9mX3g9Rqhn9vecXPFB0z5w9o=; b=rrJkMw9td3K4lUzUDyX2Al0CdqoicFVk+1YE+PqsAkvDgs5eN40uLaF7U9xzx0/Hql WtfifV7wvs6WKR2wFcjO+XbMdo2NDSqi9eCLZrI3ZvoAHzhqLuogxL02+x+NPm2uNgFC GoHnSuQ3D5hx5h9Pls5eAfYIwzdlv7l5cWX4WQGxri3/YPsYH6oYYhKBLubVO43BYkUZ mzB+A46Di5VPYe9wcveeVoz+q/9WSBbRNAwfg/o+ftXc85VHd8wMrYs5HbIlcZelMljh JimjPvW5cth+MGoOlVcD8r/+oe4WLm0bE0/cqcnS4QYRhacZDw3O2oNEm3Jv413ewNPw e83g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gkdJSYLh9LN7Ss8j0Rn9mX3g9Rqhn9vecXPFB0z5w9o=; b=Sk1yTssC1K4vWAh6iRMW2Wk/FtzGAGa/YEauJ5iCFJFf4lF36U2Wcz5dzcyDam/xnL 070sPgukCgmszgmlxLgaZVKea1irK0ktN0kUFK8on3xo7y3mzFLFODJj1KGKB6fBL+7L 2W7thtPl/B4EefwqICSFol2dwjk8VU13DK9NRxIQum+MYBZnGNtO/z7EADaQ4gxCiChq ypmI5fnAUnxF97b0jFCcz/kjY6HWPj2ZFYp6kZHSU/U9iVz231dyhrds/D0WpHG9Ir+1 YE89Gf4WGAnxaBKnwJ46xyxrXrUu6+bu5XmGM6uiUOjWSwmbe+onQ43WTkJ7wMu2USd+ t5FQ== X-Gm-Message-State: APt69E0Y/xIkW6iH2WGsJKGght5N37EDkNTmoc1gPx5OZzz50hA46v+4 gnictpRNmoQeD+bVyJiOnKXHUw== X-Received: by 2002:ac8:3274:: with SMTP id y49-v6mr16177950qta.194.1530630909327; Tue, 03 Jul 2018 08:15:09 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id y131-v6sm773495qka.30.2018.07.03.08.15.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jul 2018 08:15:08 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, hannes@cmpxchg.org, tj@kernel.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, kernel-team@fb.com Cc: Josef Bacik Subject: [PATCH 02/14] block: introduce bio_issue_as_root_blkg Date: Tue, 3 Jul 2018 11:14:51 -0400 Message-Id: <20180703151503.2549-3-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180703151503.2549-1-josef@toxicpanda.com> References: <20180703151503.2549-1-josef@toxicpanda.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josef Bacik 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 Acked-by: Tejun Heo --- 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