From patchwork Tue Sep 17 15:13:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 11148971 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF42D16B1 for ; Tue, 17 Sep 2019 15:13:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AEEC02189D for ; Tue, 17 Sep 2019 15:13:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568733193; bh=z4CPOtHs6ihvYRKspJKvZFgoWbkRkqOf+ArxEH2TfdQ=; h=Date:From:To:Cc:Subject:List-ID:From; b=xB0nfLkNyMEst0Oavgvy4g+58sh6F6knllj2+5Fr3Cwqb+YyBYfHAmzAL3FfR1MtL 4I1skZvcmCMvXgebFs8oA7HFwidEGkg5ExLn1tFLrIz45OsG3Yvly09fh323AFRhS/ JD3d+h5urEZbDgeYK5Amc0goKs5HpX16sTmQ+nf8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729224AbfIQPNN (ORCPT ); Tue, 17 Sep 2019 11:13:13 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:37035 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727454AbfIQPNM (ORCPT ); Tue, 17 Sep 2019 11:13:12 -0400 Received: by mail-qk1-f195.google.com with SMTP id u184so4399043qkd.4; Tue, 17 Sep 2019 08:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=2BszFrJE5DhvvCqO6dnoH5rt4IlU+zqhXXHVu1J4dUQ=; b=BdxsZV3xdouTBb85ev20LScZzJk9sHxCTS804kLTi4P+4cxV14+mdM/5k/CTfY7KYy QlIbcCNUMrm97b8uLRopqvPVyRIZWzE4h3GKMdK+b6Nxzijp/EzTlas3mw8Jc7C0q03Q z0GMOTss3RH52FWcirpt0t+ETLAx/ycrt2r6PRYvRj8iyP8tB0BjGNEuMdQ5TNGKvxz/ HTJ5cTOptNPgmHGUkpqBjYcghQgHxfCvtUfOYAruMsjfvSNevICznZAXEw8Kv/MQLGxt z8h7yk2O4Y3phH9s8yE0gpXzECURVyKfHMKJyN+dW/wo7vWayo9UMyNkA6H/5LUhqKYc OKzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mime-version:content-disposition:user-agent; bh=2BszFrJE5DhvvCqO6dnoH5rt4IlU+zqhXXHVu1J4dUQ=; b=EJNh6spvPJXb6KZaFRQ+ZVhjZXiXgmAnJVpDmVS1L+4ygo/EHeK8zpO3IwrJtxsy/6 tOweanzqv8zb4V+kQnIX7K9avzW39jTHEW7jBut5bZpRtOckHHquKPLBrcQoghFeAIY4 zf7Imjgm4HX8u/Qsn8mNYTiyJ9kiAYJcSkSkPTdDmY+VTDpGaWrjlf0AbeT0HruAexaj GCeEn65m9ROxmx8RPdYLV8y5BsNvIk1/CzrQeNqkwXPF3nNr3lzHfKzgq+gb8wKqlKa9 3T9BUQMZn8QLh84Lb5BXNMW608SQT2BByswNkYzd8cKYhLBTueaA91veLEnO94u+eS2y f55w== X-Gm-Message-State: APjAAAW8XGnxOxMeQkJzJl36RnlFfpJ3MIXCARDCURBuJgmDVaY9j/zS eIemTDvNHJo3nlLTofjIa/Q= X-Google-Smtp-Source: APXvYqzbnXW2dyx9T1bmuFxvPhQjaNDo4H3H8poIc8cpF3BPdAICYHUB7s5ADRNkkXNPrDoMGqJVfA== X-Received: by 2002:a37:7bc7:: with SMTP id w190mr4467178qkc.215.1568733190659; Tue, 17 Sep 2019 08:13:10 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::8d29]) by smtp.gmail.com with ESMTPSA id r7sm1365774qkb.82.2019.09.17.08.13.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Sep 2019 08:13:10 -0700 (PDT) Date: Tue, 17 Sep 2019 08:13:08 -0700 From: Tejun Heo To: Jens Axboe , Paolo Valente Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: [PATCH 1/2] blkcg: Export blkcg_conf_prep/finish() for bfq Message-ID: <20190917151308.GH3084169@devbig004.ftw2.facebook.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org bfq module build is currently broken due to these two functions. Fix it by export them. Signed-off-by: Tejun Heo Cc: Paolo Valente --- block/blk-cgroup.c | 2 ++ 1 file changed, 2 insertions(+) --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -900,6 +900,7 @@ fail: } return ret; } +EXPORT_SYMBOL_GPL(blkg_conf_prep); /** * blkg_conf_finish - finish up per-blkg config update @@ -915,6 +916,7 @@ void blkg_conf_finish(struct blkg_conf_c rcu_read_unlock(); put_disk_and_module(ctx->disk); } +EXPORT_SYMBOL_GPL(blkg_conf_finish); static int blkcg_print_stat(struct seq_file *sf, void *v) { From patchwork Tue Sep 17 15:13:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 11148973 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5280E112B for ; Tue, 17 Sep 2019 15:13:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 27ECF218AE for ; Tue, 17 Sep 2019 15:13:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568733220; bh=75NKTbm6AlKFfHiPs8m0sb7Njjn9TZwX86bp7dIG3TY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=iOSsdnd9hDNFvQChHbcRIBNtJTtaVtGZpX8MWG+fdzwgFxtYd3llHBkikTc11kNz4 Qy2tj5BcyNUcVZRiAgUsE/9OIhAzsf8VjBg6r7DCSW5osNVKTN3sC7i1rJwfrsEElW 7s3r9Wgi1Ahgom8cOGyAZpbCeGSPtTTf8O3KZCSw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727635AbfIQPNj (ORCPT ); Tue, 17 Sep 2019 11:13:39 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:33036 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727454AbfIQPNj (ORCPT ); Tue, 17 Sep 2019 11:13:39 -0400 Received: by mail-qk1-f195.google.com with SMTP id x134so4421388qkb.0; Tue, 17 Sep 2019 08:13:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wSF64Sv9YEZzkU5NW2nI/DUGXcru3f1vbdKzb0+xRjU=; b=GNanJicUsDiZTH0ZLVbbKfVFv7WpneUpk1FZW61z0QwC9nf0hr47iaAKlTd0qYXlaA GGSTyI4cxc2fyRbsVHfxDmhyaHM0rvA+1TL9GOuNBp+XZcClMl8HuvxVdDQWJSUc2uw4 /fUeFlWL/MZ0BpvtTy/Xxyk2z6K+f3lo59sypfs2MJux8eo3ms4Mi0f6pnyOcjQlZdQV OxfXCDBQGiUuy6BHf1lzVL7eh/Kr8IO4MI63f2jvc3q4r00BtvT/znjgHyyaXNklNO+M CTLFQl8pxiErsUvPwWX0aKV9GqQasY3VJY6OEOXGmLww3uWDTUTzDTYbZii+PyrjgY0M YmIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=wSF64Sv9YEZzkU5NW2nI/DUGXcru3f1vbdKzb0+xRjU=; b=iyUgA3x5RQsT/EGTowKjA1OXlkrM3CMjofAqmcDj6k8a1KtwLCwxrcKHln/xACeKWY 6LymtYe6FMnE0v7SG7qvWyB+S1mk/DnN5iSu7tXQFwBY3Xt1v3GAsfiTd9nwxDS9R8hz wbEKRPwl9FoaRVOXe+66mao/mN/TLSiYFojD+j9PPtYBWlY6ujmCHay+dx/bMKHQIOmA d4exGrazb+wfkWrNMjyrfxTyrCTRR1JjFwC1nLT2kY2fndzdH5P1r9p/bK/+cu5zppj1 I+E8fEcDr5SecxFQoIOwU5d74Qs95YmiaRtF6kro8aMCQH5oR8yf0ogRVzFdrBuSdKnk tTfQ== X-Gm-Message-State: APjAAAWfGgTdCiwDK+lKCKswBCuxgg/YbGTZJ+8Cd7eJbhSKXX4kV58D AJpIrtdKweeBjiOFQ2IlbdU= X-Google-Smtp-Source: APXvYqyWNEGuBCTeeYqe2xBxQKmG1RCeKN/0s2/BxV/xsm5ht5VKaDYN28tfPyxujy9FGmauCf5ebg== X-Received: by 2002:a37:a00f:: with SMTP id j15mr4206395qke.335.1568733217440; Tue, 17 Sep 2019 08:13:37 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::8d29]) by smtp.gmail.com with ESMTPSA id e7sm1368545qtb.94.2019.09.17.08.13.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Sep 2019 08:13:36 -0700 (PDT) Date: Tue, 17 Sep 2019 08:13:34 -0700 From: Tejun Heo To: Jens Axboe , Paolo Valente Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: [PATCH 2/2] blkcg: Make bfq disable iocost when enabled Message-ID: <20190917151334.GI3084169@devbig004.ftw2.facebook.com> References: <20190917151308.GH3084169@devbig004.ftw2.facebook.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190917151308.GH3084169@devbig004.ftw2.facebook.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Both iocost and bfq implement weight based IO control. Currently, bfq is using io.bfq prefix but wants to drop the bfq part. To avoid interface conflict, make bfq disable iocost when it's selected as the IO scheduler for any block device on the system. iocost is only re-enabled when bfq is built as a module and unloaded. Signed-off-by: Tejun Heo Cc: Paolo Valente --- Documentation/admin-guide/cgroup-v2.rst | 8 +++++--- block/bfq-cgroup.c | 2 ++ block/bfq-iosched.c | 32 ++++++++++++++++++++++++++++++++ block/blk-iocost.c | 5 ++--- include/linux/blk-cgroup.h | 5 +++++ kernel/cgroup/cgroup.c | 2 ++ 6 files changed, 48 insertions(+), 6 deletions(-) --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1406,9 +1406,11 @@ IO The "io" controller regulates the distribution of IO resources. This controller implements both weight based and absolute bandwidth or IOPS -limit distribution; however, weight based distribution is available -only if cfq-iosched is in use and neither scheme is available for -blk-mq devices. +limit distribution. Weight based distribution is implemented by +either iocost controller or bfq IO scheduler. When bfq is selected as +the IO scheduler for any block device, iocost is disabled and bfq's +implementation overrides for all devices. If bfq is built as a kernel +module, unloading it re-enables iocost. IO Interface Files --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -1194,7 +1194,9 @@ struct bfq_group *bfq_create_group_hiera } struct blkcg_policy blkcg_policy_bfq = { +#ifndef CONFIG_BLK_CGROUP_IOCOST .dfl_cftypes = bfq_blkg_files, +#endif .legacy_cftypes = bfq_blkcg_legacy_files, .cpd_alloc_fn = bfq_cpd_alloc, --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -6365,6 +6365,36 @@ static void bfq_init_root_group(struct b root_group->sched_data.bfq_class_idle_last_service = jiffies; } +#if defined(CONFIG_BFQ_GROUP_IOSCHED) && defined(CONFIG_BLK_CGROUP_IOCOST) +static bool bfq_enabled = false; + +static void bfq_enable(void) +{ + static DEFINE_MUTEX(bfq_enable_mutex); + + mutex_lock(&bfq_enable_mutex); + if (!bfq_enabled) { + pr_info("bfq-iosched: Overriding iocost\n"); + blkcg_policy_unregister(&blkcg_policy_iocost); + cgroup_add_dfl_cftypes(&io_cgrp_subsys, bfq_blkg_files); + bfq_enabled = true; + } + mutex_unlock(&bfq_enable_mutex); +} + +static void __exit bfq_disable(void) +{ + if (bfq_enabled) { + pr_info("bfq-iosched: Restoring iocost\n"); + cgroup_rm_cftypes(bfq_blkg_files); + blkcg_policy_register(&blkcg_policy_iocost); + } +} +#else +static void bfq_enable(void) {} +static void __exit bfq_disable(void) {} +#endif + static int bfq_init_queue(struct request_queue *q, struct elevator_type *e) { struct bfq_data *bfqd; @@ -6489,6 +6519,7 @@ static int bfq_init_queue(struct request bfq_init_entity(&bfqd->oom_bfqq.entity, bfqd->root_group); wbt_disable_default(q); + bfq_enable(); return 0; out_free: @@ -6806,6 +6837,7 @@ static void __exit bfq_exit(void) blkcg_policy_unregister(&blkcg_policy_bfq); #endif bfq_slab_kill(); + bfq_disable(); } module_init(bfq_init); --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -605,8 +605,6 @@ static u32 vrate_adj_pct[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 16 }; -static struct blkcg_policy blkcg_policy_iocost; - /* accessors and helpers */ static struct ioc *rqos_to_ioc(struct rq_qos *rqos) { @@ -2434,7 +2432,7 @@ static struct cftype ioc_files[] = { {} }; -static struct blkcg_policy blkcg_policy_iocost = { +struct blkcg_policy blkcg_policy_iocost = { .dfl_cftypes = ioc_files, .cpd_alloc_fn = ioc_cpd_alloc, .cpd_free_fn = ioc_cpd_free, @@ -2442,6 +2440,7 @@ static struct blkcg_policy blkcg_policy_ .pd_init_fn = ioc_pd_init, .pd_free_fn = ioc_pd_free, }; +EXPORT_SYMBOL_GPL(blkcg_policy_iocost); static int __init ioc_init(void) { --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -815,6 +815,11 @@ static inline void blkcg_clear_delay(str void blkcg_add_delay(struct blkcg_gq *blkg, u64 now, u64 delta); void blkcg_schedule_throttle(struct request_queue *q, bool use_memdelay); void blkcg_maybe_throttle_current(void); + +#ifdef CONFIG_BLK_CGROUP_IOCOST +extern struct blkcg_policy blkcg_policy_iocost; +#endif + #else /* CONFIG_BLK_CGROUP */ struct blkcg { --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -4059,6 +4059,7 @@ int cgroup_rm_cftypes(struct cftype *cft mutex_unlock(&cgroup_mutex); return ret; } +EXPORT_SYMBOL_GPL(cgroup_rm_cftypes); /** * cgroup_add_cftypes - add an array of cftypes to a subsystem @@ -4115,6 +4116,7 @@ int cgroup_add_dfl_cftypes(struct cgroup cft->flags |= __CFTYPE_ONLY_ON_DFL; return cgroup_add_cftypes(ss, cfts); } +EXPORT_SYMBOL_GPL(cgroup_add_dfl_cftypes); /** * cgroup_add_legacy_cftypes - add an array of cftypes for legacy hierarchies