Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3812828imm; Tue, 29 May 2018 14:18:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIb4kiKFclmmXGtGIwplv22Lm3SPmej+SsmIJ8+iwp6cPEI57aurih4M34z3NhuzwSGn5r9 X-Received: by 2002:a17:902:b706:: with SMTP id d6-v6mr63557pls.105.1527628719723; Tue, 29 May 2018 14:18:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527628719; cv=none; d=google.com; s=arc-20160816; b=Xw4/KthcclPsKxmRvW8srDQT8ZpMy6T+xyeM4kWkbWQ5aFEGKEAHlCEBiFZRSo+PWw nhoXCUHosoVd8IK/0MS3umLMD1ZKm9pnDFkJpdtF2jzz9ow5JNv3t4r7MYvcu5Zcs39A 9POSbiSjmrgdjcsGU6xcrVdHCIcVCmBFVYjjiOJ9Mm+ytZj+ok3IolZj+s/3wEMs8+j4 8/N9/q4OTGr34BSMnkYgiXd5LGEKlmXn4p/hXtk5gRYyBNCrrHZlyq98DKpYQlrRJXlp QF5q+BTq0FyMXdJceXaFBdeOfYhYHBbRP8arvZ7wlYV2NOr5cpz4Z3NtEd0Z9WRW/HCg r7PQ== 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=w+V6Y0XmRixRJvb8sQo73wwHLu/MDd0HUHM44FdMrq0=; b=x+kLoUgyhxKipvH7KrzGF5g+J6Qc2wVkNrrfPZYt4qKuznYkghduRTcBlRk7lZt3by 7fW0OxcE4IKJ3vdrnvhi8+HStQqZDC0q7VxHRIOl1Gauu04fVAq863BzUlQObSRId/S/ YuSHrQCx/cHmkK7y+BGENTo/ATh5pkMVrwIVvSzlsxqo4T7p7CBZC6JSzcX5zoOjPngD R8lrpRsRKovgFb9is/AuiwoqA1sSc01OVW3SVkEEuYzrGeQkdQRKusbZ4hhKy17ohuUV k5iNx3cuQJ6nSUsnlC10BN8rK9kSthWUffHOE+10xPmEqWiujxtayJE/Qw3q4QMOuAJZ EuNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=CvE7ZL4z; 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 t7-v6si34201554pfa.170.2018.05.29.14.18.25; Tue, 29 May 2018 14:18:39 -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=CvE7ZL4z; 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 S967241AbeE2VRh (ORCPT + 99 others); Tue, 29 May 2018 17:17:37 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:46589 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966847AbeE2VRb (ORCPT ); Tue, 29 May 2018 17:17:31 -0400 Received: by mail-qk0-f196.google.com with SMTP id k86-v6so12702512qkh.13 for ; Tue, 29 May 2018 14:17:31 -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=w+V6Y0XmRixRJvb8sQo73wwHLu/MDd0HUHM44FdMrq0=; b=CvE7ZL4z27L8o3CU6WKQy2Rf+/qLOWHnaFIiHfX5e6zJRxt2rra7hFtswkA2p8OqoB c0P/eHpXn5IrvCpCp+VrxERzJ1+FsPvWkQT8ZC3JX2DvvaQwwVJGlEfyUUUzxfo09PIm IIwmum9GvkAxhFC3NEJzHSHsMDOAGZD8u/YNd7ybknjOnulK33u3RGXlQOL4tfzS6KC+ TuJ3suQFTMDdC+WRuxz/X85tZohBl9Y7LZZjxWWdXTB087bYQE8rR18OJdjobNIymrwt lB7zB6Zh0GSs511FjQ0T2p96HB1DXskUo2wlPnYk4X05K1NhPOtz3lan27Dk0tWh0qVq 0H1Q== 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=w+V6Y0XmRixRJvb8sQo73wwHLu/MDd0HUHM44FdMrq0=; b=H/f6HaN2+3wD987T/tkqR7hDAGwW0ykAFzmlbch8MHYN7ffkRIvux3xq7uZwYluzCe IEXNp+Jm9+EbzjyQd+LREwMu75ZRK2Zw60khrsy1GX7CWrEFcBDkcK3wLC24F/knoJ4A UYzPbGylNBDWHgZH6Mj8EEQQvKXUnXGxbyuX+nE85BB0GQvJF45uGYlLeFcaax99zfvG Ubg2RW4Wdo7LIKtohbDjPIAREeRmoFf9jl3kGdT/cciAobeLExrqk4arFRySHq2IQmwy b/o/9zWY4ygOVVXDdMfGusbQjg1+xBU8wlLRkf1zDH/e9qnzRzjjMktfcWxiwgdgDEw8 pIkQ== X-Gm-Message-State: APt69E154ZEJDF6aJw3qwOGRXFyzmzU8yRZ47qGcXaminDilcE9qRawj auUggxoM2YppfCMMCpk9wHQa9Q== 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> 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 --- 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