From patchwork Tue May 29 21:17:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10437065 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 DBE40602BF for ; Tue, 29 May 2018 21:17:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB48528991 for ; Tue, 29 May 2018 21:17:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C02E62899C; Tue, 29 May 2018 21:17:35 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 520E128991 for ; Tue, 29 May 2018 21:17:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 185036B000A; Tue, 29 May 2018 17:17:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0E79D6B000C; Tue, 29 May 2018 17:17:32 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2FC06B000D; Tue, 29 May 2018 17:17:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f200.google.com (mail-qk0-f200.google.com [209.85.220.200]) by kanga.kvack.org (Postfix) with ESMTP id B76EA6B000A for ; Tue, 29 May 2018 17:17:31 -0400 (EDT) Received: by mail-qk0-f200.google.com with SMTP id s133-v6so6954908qke.21 for ; Tue, 29 May 2018 14:17:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=w+V6Y0XmRixRJvb8sQo73wwHLu/MDd0HUHM44FdMrq0=; b=F4cSNpxWKgvEHSreXCyGmjLg7LEoqSbTxVUuy5f0gGpgaX3ibSGn5lycarhRFlSk8C n4vJuqXHfdTBzXX8TU3mxrdV3YsPZfUuKvuoBdFCXY9/sRmLiH6fkpqkgL/fOYR1K/zT q0JCv1epzRWdWy2tiKaj4qmZ/GM6cnBWKUoGHZ7uK4sBYF0oaRpe9pzk43/+X/MZXxai s3EzhoOqAJceOoYpIjGoIYyLyB5clRCEjPbZ4NlfyUw8aBgeTjngmlvIf1wksnXd9cBF funW8TnTl4qT7eoJ3dms2Tbd1cH/nsZtgse20AgXpKCvUvJksDl0a1+mOEWCz/yLdgku dYtw== X-Gm-Message-State: APt69E2ss9exr46lwDRLomKAqhMViDEw9odrjio0jMGP+Voues8n3k1P 1FDSx9rUw65arwF53txgP+h3lmuDiI9sNW8bztBF+jBEG957qTuH2RNmGp01HW+Z/pTAGGnNpK2 6wTqi5SdT2Fl2iSmIB2RiF3kmHaeDjNO4ZMw9DZFTRWcGJtjO7WL98GNSshGiGVq8Fs6sczgkcz LgPJEeuKggI+otTOmCLRLNzXlFFF8YlWhyBj2eNz5d8CmfBn4uIIEOcGYaArXwecATAuIbDI39j ldCi3+ymeiUzRbsjc7Y87O/7B2AfIzUQ9cTsX0p8PcJhfiQotieDxicqW/Nee7K7m3PM2Pz9mZO CmAfmjLjNoXUFHH0XfjPHnw5e6Axs1jwtyEq4A4KrmSdN1KZ8rGRBIWOVLA+6jmO+FkoKbxvlFY 6 X-Received: by 2002:a37:a38c:: with SMTP id m134-v6mr70130qke.57.1527628651546; Tue, 29 May 2018 14:17:31 -0700 (PDT) X-Received: by 2002:a37:a38c:: with SMTP id m134-v6mr70102qke.57.1527628651029; Tue, 29 May 2018 14:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527628651; cv=none; d=google.com; s=arc-20160816; b=sM6msp/ynT8mtPvGI1G/LzoyQwreXnYR1bX4JK3mud5rJQ1myzh7wJXTUTBuiVyUzK ANmygyZQuAjpMzTY2nKR6+q4y871E1v94c2r27522/kdSwI/McvkRFuf9O42eMG1686Z 5Giz7DaqqCKu2nBCKjujd9qJmYpUP7ohtwVQCvx4Q+A+Vh8LMro/HQcJsxpQC1jQpym3 hybo+3pfYi+Qw2xAKTU7J+lJ8nhsEKqkZTmUVwwhx7zYihsy5LFZ5h0WWU8EQxR+RrHT PcIYCY9pRpIMk+ccaaf4MX8q/x/sBBNJIKr88UN0ZNT8ymOnICjS5Ive0ypxj8JhCffM 3a8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=w+V6Y0XmRixRJvb8sQo73wwHLu/MDd0HUHM44FdMrq0=; b=igGSpWV6ZUmrPYE4mj34oOBTDD5/odUUwS+ZpMD87lQ0bbE4s3fMtMYOLn3H/7OU+f Mg2BqXh1Irml2XS41YTN6FLxQwO96ilxC2lwa9HH7aK9k1vknqlqcMYu4jmqt50L6kz7 wlpKqbCM62YCzGlI1W3Xhjsw4kjI0faKKsxSmuSTDcUi6sZuV29Eo2tl91UGB7PwmpEf KvKmP9PIcMv5h0qL5FIOa6nwyfIXrz/7zvPzk7fiQI/f6UsVM6TZ14zsrTjES9B2Qh3F A/+2luK961AuLpPBYNyo52Wab5YkluaoJ2QHP8B+PpJAhUIs/4Iz2LM6hFeYPefJQ22H mf/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=CvE7ZL4z; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) smtp.mailfrom=josef@toxicpanda.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id w141-v6sor21481811qkw.68.2018.05.29.14.17.30 for (Google Transport Security); Tue, 29 May 2018 14:17:31 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=CvE7ZL4z; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) smtp.mailfrom=josef@toxicpanda.com 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=w+V6Y0XmRixRJvb8sQo73wwHLu/MDd0HUHM44FdMrq0=; b=CvE7ZL4z27L8o3CU6WKQy2Rf+/qLOWHnaFIiHfX5e6zJRxt2rra7hFtswkA2p8OqoB c0P/eHpXn5IrvCpCp+VrxERzJ1+FsPvWkQT8ZC3JX2DvvaQwwVJGlEfyUUUzxfo09PIm IIwmum9GvkAxhFC3NEJzHSHsMDOAGZD8u/YNd7ybknjOnulK33u3RGXlQOL4tfzS6KC+ TuJ3suQFTMDdC+WRuxz/X85tZohBl9Y7LZZjxWWdXTB087bYQE8rR18OJdjobNIymrwt lB7zB6Zh0GSs511FjQ0T2p96HB1DXskUo2wlPnYk4X05K1NhPOtz3lan27Dk0tWh0qVq 0H1Q== X-Google-Smtp-Source: ADUXVKIqDa7RcPW58D/9JRPCYrHQmzujbpwCT9iybMqnf12I4YdUjdbwFneEZT+mia0LT6gGbmR4NQ== X-Received: by 2002:a37:21de:: with SMTP id f91-v6mr40778qki.395.1527628650788; Tue, 29 May 2018 14:17:30 -0700 (PDT) Received: from localhost (cpe-2606-A000-4381-1201-225-22FF-FEB3-E51A.dyn6.twc.com. [2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id d2-v6sm8102982qto.71.2018.05.29.14.17.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 14:17:29 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, kernel-team@fb.com, linux-block@vger.kernel.org, akpm@linux-foundation.org, linux-mm@kvack.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, 29 May 2018 17:17:13 -0400 Message-Id: <20180529211724.4531-3-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180529211724.4531-1-josef@toxicpanda.com> References: <20180529211724.4531-1-josef@toxicpanda.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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