Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1243530imm; Fri, 29 Jun 2018 14:12:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfK3QR1ZLE26oY0IoHE+Yq9vAhIjzHw35etbLbXms7yaaRT+KKAw45eyWhUxuekWfBA4Qxf X-Received: by 2002:aa7:86d7:: with SMTP id h23-v6mr12244513pfo.132.1530306779044; Fri, 29 Jun 2018 14:12:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530306779; cv=none; d=google.com; s=arc-20160816; b=ySpeQh3cm+jz77bTOmCR/VWWXdCIy2yU5aj7jT86DPAmmSPi/BsMKJujizKlQ0CsSA 6a2vjLUR5cVdVA0xRSb4X9pgKrXaUE2Q4yWT6QvaPQ+8kIdmoqHdaXF8XX8t82UNrveP kJDYG8P4nRF4r1fDctglPx74sSS7BZJu1+43aaSIYeJ1H3gPWcci/48bunHi4V5C3wrU b5z3b2gqXeCvPjBlbR3bQNyIatVzzmPzX9MUJkvDqM+z7J7tjFdzxLA6cMdWoroynU9w wf7F6RABfnOmFJkaMbS9FEdsIrE/MaReA/GxNKjVDByUMC+YFAjdLV59lTs0yo4uXD91 PbUw== 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=YOuOC0CvJ+EBV4QYnfempVSTTJyAasZg2kvxab1x+YCZFzNL8QBzPeN0tipNA/jHy2 9sRSPJbghsX696EGPD/jjatX9wDuCsuYImApMd+ul0hSi+klANndRmYoDjGkm/lZPEti BWTgL9RZ7llXV20qK91JmBpcusIzlRivAC8PYZ9cHpWJMaa8GXSYEn1rIkoPGA4z7LCU UaZ3EazBiB1tQwjztfBidvOGBOAs2xfhmys1l4fpkqITD4aTfc+9rbspYuE/EqqVHjiy yW9/oUn/tz66ZLeRc7D50TQBe80JYwo/UGOPpN3j2pkB1wLc/765hqizyWsfhZhfOkfC yNQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=lvUbPMbc; 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 n5-v6si9816640pfi.360.2018.06.29.14.12.44; Fri, 29 Jun 2018 14:12:59 -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=lvUbPMbc; 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 S936968AbeF2T3o (ORCPT + 99 others); Fri, 29 Jun 2018 15:29:44 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:34276 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934465AbeF2TZs (ORCPT ); Fri, 29 Jun 2018 15:25:48 -0400 Received: by mail-qt0-f196.google.com with SMTP id m13-v6so2005574qth.1 for ; Fri, 29 Jun 2018 12:25:48 -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=lvUbPMbc+sZ/5s4o0FACiGm2SVguhyOZvDPVCUu5DqDNjS4hp0cxAu4OsI4dVpAXIt fY37AGYKv7uKaxUx97B+1hXrDDahup3fJutWuVVH6y3stcdiBAYW9We7mUsrtpmsbW8L HvKYDOysSQrsavvzeTjJG+2wiVFaJQ7ArTCuBV9qxJ4F4hP5rYEOMLuldCei5w8A2hZK vxVLebXBPrRwStAq1HVI02th/m845ixb6kdu0NjCeDsK8Htbmz5RdgGRLcclvadwOCx7 8ETyL6hfiXCd2PhcOoYvYh62U/o90IQjEPTDt4Ck92o2aI3iL+RHIlEYFM7InYimU1OI rI/g== 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=pCg+murop6fpsFTlXR8nF6rqpbre4UQqKu3KrCgBjTBHbfN4giUbLVVp1HCtyUHJ6h +hgZzruJ7Z6ec6hHkEKzGqK5+ZRw6N30CXx70T6c6Pe1ZT3wJzcD/dZdty/pVGuqOLVQ f8mkq3WJMmrFnGwl1GKzHjOHXxm6CXtA5lE2WlyVp/hShbsUTgZEPXWZwZXrZRWuWbQv s2GwEgSgwDlmDp7/zJN/KgVGHrDJ5SgKuEg9q3fvGNLUiRci43iLYqns9HfJPWLKkqyH kgK4OlNBR/YnDRuDNI7hGp5pMNsuDepckeLzvWH4kWyN7SHUU8uz1H46ltaIQFlmMqcp 5yEg== X-Gm-Message-State: APt69E2vT/+Q4SNFp8u3H9RDAwhm/bAOO2c8TIGK6aN+oYhpEpEAYxq4 Nmgpsy+uDdkK3uG4evqxP+VPRg== X-Received: by 2002:ac8:317b:: with SMTP id h56-v6mr15316109qtb.191.1530300347945; Fri, 29 Jun 2018 12:25:47 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id d192-v6sm7178406qkb.46.2018.06.29.12.25.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Jun 2018 12:25:47 -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, 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: Fri, 29 Jun 2018 15:25:30 -0400 Message-Id: <20180629192542.26649-3-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180629192542.26649-1-josef@toxicpanda.com> References: <20180629192542.26649-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