From patchwork Wed Jun 27 19:09:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10492419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4623160325 for ; Wed, 27 Jun 2018 19:09:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5457829DA2 for ; Wed, 27 Jun 2018 19:09:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5228429D9A; Wed, 27 Jun 2018 19:09:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA4BF29DBA for ; Wed, 27 Jun 2018 19:09:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935046AbeF0TJu (ORCPT ); Wed, 27 Jun 2018 15:09:50 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:39573 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934905AbeF0TJr (ORCPT ); Wed, 27 Jun 2018 15:09:47 -0400 Received: by mail-qt0-f194.google.com with SMTP id b20-v6so2006195qtp.6 for ; Wed, 27 Jun 2018 12:09:47 -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=h0p9MBWWflX+NVWtEfoZfY7S1LnJxDMjCaSJl1g5Ple0W6kJAuc80sXc1mtLe1nWyn WvW0YYxtckVIhpEYLo0FpDKH7PkbHvQUXjNHT+A0rf+WxeOTunmZ/Iz2BNiEW4G3iUTx 8AUORA9FqYGZurTQRLhkIcXxIpNSkh4V8/CjdPlefrg0WcNiBVagzx5HR5Ig5mlg4vug Dd9rN3PN4cnKRPEfLQJoAy3ErrjWiw+8fcOIHftLfON494FRZ6z3w7pvoiOTJaIiTkOP mMbFSypkaTOyH2Dp8zq21H1xkgQz6vmVccUntywRrLDcvXPvS38PflxQquZQGTaJrSkP gOnA== 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=j5aVg6T0NQMpOsE64S3edmGvIQUYn26GF/C+BT3cEMrbYDma7+icplG4K1rR1wZdNN U/B+HpngWMtCXnyPn4QZv8z67fIpOJ3ySxsUkiY5KHPjZDok45OUt0Kzjoh8Imq6nf02 wSsObbptPVuK6Se5uSAUiWaC0km6ufHJgYxlRfeOo7GEq2VzJ4Fcu9o1FPggpbw3scbo G5kY+ZwWfIRhW46Y9094y/AZlfgFurDQLsrsNVJ52vSwmDZml+iSFg1S0KzcsiTHa/H/ GZBG4ZWPxJedYqK9REeUwge6FBgXQnWE2Ta6KYo4szg9ZmaGf6IwxSve7sQll962BwCi Irlw== X-Gm-Message-State: APt69E3UK8eCsTvXv3dHmcklSQsW7sNQh0ej6n8WyYIuhrFTFkPdTYsK iSbLjGx5VzKtkuhSl7qg+yAnNQ== X-Google-Smtp-Source: AAOMgpce1ju3hn1h6dl5bVpWVwjsr3WvLRmI3AFl+VcOfagaPsZtljDQhBWRSwt/vfXbCZ5K2W4IAg== X-Received: by 2002:a0c:83e5:: with SMTP id k92-v6mr6597335qva.88.1530126586802; Wed, 27 Jun 2018 12:09:46 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id t65-v6sm1478792qkg.18.2018.06.27.12.09.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Jun 2018 12:09:46 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, linux-block@vger.kernel.org, kernel-team@fb.com, akpm@linux-foundation.org, hannes@cmpxchg.org, tj@kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 02/14] block: introduce bio_issue_as_root_blkg Date: Wed, 27 Jun 2018 15:09:28 -0400 Message-Id: <20180627190940.4696-3-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180627190940.4696-1-josef@toxicpanda.com> References: <20180627190940.4696-1-josef@toxicpanda.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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