Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp920661imm; Tue, 5 Jun 2018 06:35:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIlavxXR096wy/3eDrqR6cGaOUCM5WWrFkGr6Ncdn5BovUVeunYL+qnMRNxuU37HY6WZGDr X-Received: by 2002:a17:902:8308:: with SMTP id bd8-v6mr9957980plb.329.1528205714188; Tue, 05 Jun 2018 06:35:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528205714; cv=none; d=google.com; s=arc-20160816; b=rxZbrrKIsLAQ/YOAYhIBF8BhenbbxvqUnfPL/0JILPYEBvZzRyMrea3ue9EfKgqvS3 k5Wh4GhjdvwwNKzTupEyOAHgXbyI34qR7o5VlWUJnMDEPRRoAygtQa1lKekDh/3cxjVZ wMMvNPAdIEzZKZhntBnqxbU9zkh8pqaG2Wjz2adAEpF6qEqmhTTcEa5FLOx0wWPynstR aGTNW7oX7lvPAu2V7G/JWT+RRQjpLPsZQ/P6ZgtLWhj23CJE2DazJv6VlOQD4Sh4HLNP Qbn16w5C0g1dSxsZirnNQ3AZ49/j2blCD3FT5yq5O9NdB+3x7nq1EMPlZra/XN0BT36E /05g== 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=BGE+HQNs8d+GRAzmg7M3pRMutgsylry9v9EwcfvF9hK1j2mUXOqLacERHhVEkJ/pTp aln9Fwb3XLZDx67w5kj1VjP5/UdjXO+KiYa9TGw4Gfnk6F3AGmlDawtw2BqEmp7hq+ZW yhrkrWuE5ruo0OLkvGocIg2ybHMXLoCyq2M9AitEr3D1QcXPLHGGYbZ4aQr6Mrrsurhi RqHeEddkdcFI02EMiJW8wDS4BguPVDa4kSsDN058r7hAs2UpQpN8W8gquzGwXG9x0N/7 autjiNjjejKN3P8N0TeBj0IpHgpsUeAxtgMG7D/Tkmr/T/Z3RSB6bHCa1sn6Q2jxT+5a bB6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=g/aypdOH; 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 w10-v6si2367766pfk.14.2018.06.05.06.35.00; Tue, 05 Jun 2018 06:35:14 -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=g/aypdOH; 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 S1751838AbeFEN35 (ORCPT + 99 others); Tue, 5 Jun 2018 09:29:57 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:34123 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751940AbeFEN3y (ORCPT ); Tue, 5 Jun 2018 09:29:54 -0400 Received: by mail-qk0-f195.google.com with SMTP id q70-v6so1482135qke.1 for ; Tue, 05 Jun 2018 06:29:53 -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=g/aypdOHZxY0xlgmHhuhe0N2q2D6PHEZVM71ZhH3IECmNYDpGhMw1pK6yhvLD5E/Cr bm3+GVvFec3xrJvJ76ZBz6NvSqlGPxAWyXfXeohpSsZ3lAsmOTlHS54M3RPVV2sZb4kt r8Ov7KQxWoKUVkZ8tGH/Y6WSBP0F+iI92HhxZDQAw2w4K+J945c3FDzc2ZsMN7SrxPzL 0FWXJqEID2h1gAgyXfNO3oHI3sHmaBkph6waG45JGbWBwYJb6XOy7koWhGQWC/OQZJWJ AXmzIwL2Y7SC0jbdaN+MSBn26URGfIckJZ3hAq/Hi1z02lnhrRaAkXAV6ovu52ZgJNzt tmqA== 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=je3we29sYgk5Qj/0AbD4XKI9tmt0zREfT7bAfXHaoA/7wZIzjzWwKP9S28PCAkKfEX yGLKEcc5RowsVWZBYUFzCiOAFV1jDpdpl992wjR6jv233iz+WU0EqMtsuhhW3duNtO65 5HvcYsIzfj53tfqGSZ+0Z+OdITmvCb5IBFmBdLVrwQLKyRmnKVRwMOSAopf18OrX3T5/ AZ6IjTbKqf/ISOkPRFIJvlLniDaIXkkIIcitn3ygFA5RkVrgyDK+0qzYHlJuceaDaI3o aHbZEXRH1dFdQIz9ZLJAnP20ZVan8d/spXwm8M1pdiOwZLTKOZ0rKHtq0ekBRg+UiSub drBw== X-Gm-Message-State: APt69E1DpXewy+95RJYsWjAmpjuTEUXzoHzf6AeGqvhixqVWgmx97ygK AJT5vJuXB/hq1AqjS9XttmcILA== X-Received: by 2002:a37:c551:: with SMTP id p78-v6mr22895053qki.184.1528205393572; Tue, 05 Jun 2018 06:29:53 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id t184-v6sm35297617qkc.6.2018.06.05.06.29.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jun 2018 06:29:53 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, kernel-team@fb.com, linux-block@vger.kernel.org, akpm@linux-foundation.org, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, tj@kernel.org, linux-fsdevel@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 02/13] block: introduce bio_issue_as_root_blkg Date: Tue, 5 Jun 2018 09:29:37 -0400 Message-Id: <20180605132948.1664-3-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180605132948.1664-1-josef@toxicpanda.com> References: <20180605132948.1664-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