Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp6784368imm; Wed, 27 Jun 2018 13:21:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIKrnYFNdk+ukSmXzwnv9XZFLQaKBKhjvD8QjQnTKv3fjbgA8PVg2IB2ESoZyRVLxguyRuy X-Received: by 2002:a17:902:d716:: with SMTP id w22-v6mr7532282ply.98.1530130871536; Wed, 27 Jun 2018 13:21:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530130871; cv=none; d=google.com; s=arc-20160816; b=S2b7gQbJ/OK6ndHCLqBEtDZeLj9NQB2qUZG8V3Qwzl4Uz/k1DCXZ4cr8neQ/6fNQoT KMsfmcQuQB2jYDQ+1pkgrvXGFqIG49ZYkns6rW41CdGZX25a9wp7g4sCSO+PMMg9qBj+ cHXn+XMP2jEikx67Cg0G+qYatuJNowUg/Zw8qML9HQrUlfwS2XGkaGoht3aJpB+PYQ6E qdiyLqJh6D+qbqoXqtqahrbbYhHbhhpFqh1j/t92vWU7ZNU7hBxvoInWWBNd/FQaSO9y fAhSNv7lXRsivzb025N9Ps+iqbISI5VvhMTYYYuBBMk4S6rCSElTyGk2mj4zWF33psbG 8pCA== 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=YS117XZUm2CTfRAj5aEges6EoNm1qyLdTt8lCnWpnKIMTDuNF7+39t2z/MKmlgLb6u CKSdGqBydc/IqAzorI8xT5LGwTyV8vSFY+TbuvP8FzN6lMGQtNPa8zfJY5irl5dIp5P1 2+vDQ/oHV3J6x1g7iYS/fvpeZZXuwvVVqQOgu8CoEQ8iOdEy6UqTz86BOCwSgim7GUt5 xUegzXPPmwF/43jJwGe2X9Ym+O2/bA8x+hjrV5ec7tePU939EUN/zgyJX+IQEPVvGWQ0 b7pT8WDT2Oep9I6KzOtk88Qz7g750RD9yTly+Q/P1fpaM0P64B9+s6T+fq9bxp5V3azx CR5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=h0p9MBWW; 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 x66-v6si4847684pfb.97.2018.06.27.13.20.57; Wed, 27 Jun 2018 13:21:11 -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=h0p9MBWW; 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 S965361AbeF0TJv (ORCPT + 99 others); Wed, 27 Jun 2018 15:09:51 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:37105 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932723AbeF0TJr (ORCPT ); Wed, 27 Jun 2018 15:09:47 -0400 Received: by mail-qt0-f195.google.com with SMTP id a18-v6so2629395qtj.4 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=JKMZBsA46GmGTKv8EksLDha0QUggczeKVcdXGdWwWdhaxMmKD2+yUafR01osJt8a9y cNMrL98LWH71p4U58VDVuv/DDRKTb/YI0tlMp920rTNYwHag0w/y55xmJBKYnj5YeDZW QoKMqAHC9Dw6yMd42ViusMRX43O5ws4Y3cc+V2kV1h/CkyxraApKrWYa0KIrS/wLzW2I Gt4wmIj0ukl6N6ZpQ7j67dhTVyDuhqd2EG/BuAwRyJwLvpwnn+D+FN1l7gS06/ATdz2W P+O7kl728akyVSuLs5cFjj/gunSwQIfZ7PGSz0sRVcBzPdtpX/MNNR54C7YmInBsTCQi kIaA== X-Gm-Message-State: APt69E1NdXquW+XXceGPDlXU2qHMx0Nt6ggmddBBh4lbQbZtZZMdDnu+ imGElPx/A3RyYouINBEvESniLv0N0NU= 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-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