From patchwork Mon Nov 19 10:34:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10688447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD0A113B5 for ; Mon, 19 Nov 2018 10:34:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDB8C287F8 for ; Mon, 19 Nov 2018 10:34:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1CD2296A0; Mon, 19 Nov 2018 10:34:45 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E98BA2964C for ; Mon, 19 Nov 2018 10:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728118AbeKSU5x (ORCPT ); Mon, 19 Nov 2018 15:57:53 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43073 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727993AbeKSU5w (ORCPT ); Mon, 19 Nov 2018 15:57:52 -0500 Received: by mail-wr1-f67.google.com with SMTP id r10so13898073wrs.10 for ; Mon, 19 Nov 2018 02:34:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LmkQD0tbtsZAukIf+hDcnldAyNR4PdixWTebwHtfE1o=; b=AaxJv2p3JFx65im37SGV+IZMjQz1PPfDkb8OcXtv8JDpUPSwtJZtW84/AKZepCQe+C N6ByZWMq30fbYPq9WLjLvcq+3L+10BQzWw1OW1Pt/d9MWCFPc6NjMm4cKoRYnUAPMnD9 s0GJUK1te5M31nWFXEdF1uRlg/3TqiSkMp1y0= 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=LmkQD0tbtsZAukIf+hDcnldAyNR4PdixWTebwHtfE1o=; b=BYFCkf3+o55vsV7+WhIXXuqEvrPCg12qUCgIUD7j97t65g4v5hewXlMj3J0F2WFne9 OwKuUh7UcURhkohWcq8BTDC7PmuzP1eELLF0lWzuZiiBO57RSCOTjnPFkY7MTdXMqjDy gCh+yxImyqvDSnjrf1wGSZ7kQ0eoBO1LZJ4lYKS4DcKpYWdQKnGKD7UPsf8Su5U9tcCt nFNaJ5Dc+XKg3Bf7Y1wfN4AVvUCf70HtpbB6eliiGx7iRpo2BWSlhfhvM/C5Gsxqa0zp OX0WwRAK0ZgBoIdWGZoZpUegTrlnwIGwl1QuHC/GqylYS2IHe3wFomJ3zVDjdxwpzWjs jnXg== X-Gm-Message-State: AA+aEWbkNPrPq3Oz/MIhjbP9PwaY+qayrwwnlxBLiU7fw31aKr6UFd/h sP+lWpW4Y2J2HDx31QI5C1nQ4g== X-Google-Smtp-Source: AFSGD/VCCSlfW7s2cTUeUYGwoWoJPMb3TpI+ymkX4bkzm+sqlXypUQzp38a5WThphA2RbFy/Gh6k5g== X-Received: by 2002:adf:a743:: with SMTP id e3mr4979481wrd.56.1542623677866; Mon, 19 Nov 2018 02:34:37 -0800 (PST) Received: from localhost.localdomain ([37.162.18.180]) by smtp.gmail.com with ESMTPSA id e9sm14973298wro.16.2018.11.19.02.34.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 02:34:37 -0800 (PST) From: Paolo Valente To: Jens Axboe , Greg Kroah-Hartman , Tejun Heo , Li Zefan , Angelo Ruocco , Dennis Zhou , Josef Bacik , Liu Bo , Bart Van Assche , Johannes Weiner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Paolo Valente Subject: [PATCH V2 01/10] cgroup: add hook seq_show_cft with also the owning cftype as parameter Date: Mon, 19 Nov 2018 11:34:15 +0100 Message-Id: <20181119103424.3853-2-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181119103424.3853-1-paolo.valente@linaro.org> References: <20181119103424.3853-1-paolo.valente@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current implementation of the seq_show hook in the cftype struct has only, as parameters, the seq_file to write to and the arguments passed by the command line. Thus, the only way to retrieve the cftype that owns an instance of such hook function is by using the accessor in the seq_file itself. But in a future scenario where the same file may be shared by multiple cftypes, this accessor will point only to the first of the cftypes linked to the seq_file. It will then be impossible to access the cftype owning the seq_show function within the seq_show itself, unless such cftype is the first one. This commit adds an additional seq_show_cft hook that has as a formal parameter also the cftype that owns the function. Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- include/linux/cgroup-defs.h | 3 ++- kernel/cgroup/cgroup.c | 15 +++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 5e1694fe035b..7841db6e7fb3 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -543,8 +543,9 @@ struct cftype { */ s64 (*read_s64)(struct cgroup_subsys_state *css, struct cftype *cft); - /* generic seq_file read interface */ + /* generic seq_file read interfaces*/ int (*seq_show)(struct seq_file *sf, void *v); + int (*seq_show_cft)(struct seq_file *sf, struct cftype *cft, void *v); /* optional ops, implement all or none */ void *(*seq_start)(struct seq_file *sf, loff_t *ppos); diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 6aaf5dd5383b..9d0993dd68fe 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -1418,7 +1418,8 @@ static umode_t cgroup_file_mode(const struct cftype *cft) { umode_t mode = 0; - if (cft->read_u64 || cft->read_s64 || cft->seq_show) + if (cft->read_u64 || cft->read_s64 || cft->seq_show || + cft->seq_show_cft) mode |= S_IRUGO; if (cft->write_u64 || cft->write_s64 || cft->write) { @@ -3519,17 +3520,19 @@ static int cgroup_seqfile_show(struct seq_file *m, void *arg) { struct cftype *cft = seq_cft(m); struct cgroup_subsys_state *css = seq_css(m); + int ret = 0; if (cft->seq_show) - return cft->seq_show(m, arg); - - if (cft->read_u64) + ret = cft->seq_show(m, arg); + else if (cft->seq_show_cft) + ret = cft->seq_show_cft(m, cft, arg); + else if (cft->read_u64) seq_printf(m, "%llu\n", cft->read_u64(css, cft)); else if (cft->read_s64) seq_printf(m, "%lld\n", cft->read_s64(css, cft)); else - return -EINVAL; - return 0; + ret = -EINVAL; + return ret; } static struct kernfs_ops cgroup_kf_single_ops = { From patchwork Mon Nov 19 10:34:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10688465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67EEC13B5 for ; Mon, 19 Nov 2018 10:35:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58488294C4 for ; Mon, 19 Nov 2018 10:35:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4439D296A0; Mon, 19 Nov 2018 10:35:58 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F7422964C for ; Mon, 19 Nov 2018 10:35:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728130AbeKSU54 (ORCPT ); Mon, 19 Nov 2018 15:57:56 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:54301 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728102AbeKSU5z (ORCPT ); Mon, 19 Nov 2018 15:57:55 -0500 Received: by mail-wm1-f66.google.com with SMTP id r63-v6so4759168wma.4 for ; Mon, 19 Nov 2018 02:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xE31UGISHMijh6BWsEpclRZoNNImo7FAKtEIn5NIV0A=; b=SU4gX9UrHxz7m4v1tXtIXnFVKBC85SmHhU3WWiQYYH5YJWdQrx77/09MmnpPILr2Gv PCbKmtQgB2koGowWyZFjNRJlKJFv9udeNRVF/Tx2HHxFCDZQhXGe45I/uov9rCuAnB50 t7iYiiNqnQaObo/r0EtTj0WBdzrK0QxzCGtFc= 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=xE31UGISHMijh6BWsEpclRZoNNImo7FAKtEIn5NIV0A=; b=LnATcvH5vl/RMePygnhBj6j+MWELpFWKVGWI8weikTG/QvOreGgnrflUqqXvjqcW8G JD1lO+llt4uuetLiEvOMW3J/LXJLkrOu7IbDLVUi6HWc9LFINy1evf706HUEQZQXN5JJ qBNfrhwgwq2VFEBJw8pdEpwpR+GXto8kjzn0ebxXtG0KXhWGcGrLVg0m8uB/Fgszt6x2 cWSU97o6v68wz8/J6GyLoOQmjvUv5oEd2p86Ul4zP5RmdHXwtvuay3aBfDjpBgkYDOj0 zXAD1Dt4jIm0IbtUS0gUIb67cMo1n3Q/5Z+wqKWIE+idvka+uA6rhI5WAIkjiZzft5SX 3Pjw== X-Gm-Message-State: AA+aEWbVHYvJVU9AAinmYG35c8cVEijQ+VzFWpEUvIhj6GKzucHcUd8O AwBhmNUvP6bFVZu6CETlFa7zBQ== X-Google-Smtp-Source: AJdET5ePbdKRB70yuXm+nYTaN5hJuUM29xs9xF7/e6SHKoDCwG1a+m1b34Np/Qb+SAwhNgZdAROnFg== X-Received: by 2002:a1c:ce0e:: with SMTP id e14mr4785626wmg.53.1542623680540; Mon, 19 Nov 2018 02:34:40 -0800 (PST) Received: from localhost.localdomain ([37.162.18.180]) by smtp.gmail.com with ESMTPSA id e9sm14973298wro.16.2018.11.19.02.34.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 02:34:40 -0800 (PST) From: Paolo Valente To: Jens Axboe , Greg Kroah-Hartman , Tejun Heo , Li Zefan , Angelo Ruocco , Dennis Zhou , Josef Bacik , Liu Bo , Bart Van Assche , Johannes Weiner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Paolo Valente Subject: [PATCH V2 02/10] block, cgroup: pass cftype to functions that need to use it Date: Mon, 19 Nov 2018 11:34:16 +0100 Message-Id: <20181119103424.3853-3-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181119103424.3853-1-paolo.valente@linaro.org> References: <20181119103424.3853-1-paolo.valente@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some seq_show functions need to access the cftype they belong to, for retrieving the data to show. These functions get their cftype by using the seq_cft accessor for the seq_file. This solution is no longer viable in case a seq_file is shared among more than one cftype, because the accessor always returns (only) the first of the cftypes sharing the seq_file. This commit enables these seq_show functions to be passed their cftype, by replacing their prototype with that of the newly defined seq_show_cft hook, and by invoking these functions through this new hook. Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- block/bfq-cgroup.c | 54 ++++++++++++++++++++++++---------------------- block/blk-cgroup.c | 22 ++++++++++++------- block/blk-throttle.c | 8 +++---- include/linux/blk-cgroup.h | 10 +++++---- 4 files changed, 52 insertions(+), 42 deletions(-) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index a7a1712632b0..038e418fa64f 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -918,17 +918,17 @@ static ssize_t bfq_io_set_weight(struct kernfs_open_file *of, } #ifdef CONFIG_DEBUG_BLK_CGROUP -static int bfqg_print_stat(struct seq_file *sf, void *v) +static int bfqg_print_stat(struct seq_file *sf, struct cftype *cft, void *v) { blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), blkg_prfill_stat, - &blkcg_policy_bfq, seq_cft(sf)->private, false); + &blkcg_policy_bfq, cft->private, false); return 0; } -static int bfqg_print_rwstat(struct seq_file *sf, void *v) +static int bfqg_print_rwstat(struct seq_file *sf, struct cftype *cft, void *v) { blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), blkg_prfill_rwstat, - &blkcg_policy_bfq, seq_cft(sf)->private, true); + &blkcg_policy_bfq, cft->private, true); return 0; } @@ -949,19 +949,21 @@ static u64 bfqg_prfill_rwstat_recursive(struct seq_file *sf, return __blkg_prfill_rwstat(sf, pd, &sum); } -static int bfqg_print_stat_recursive(struct seq_file *sf, void *v) +static int bfqg_print_stat_recursive(struct seq_file *sf, struct cftype *cft, + void *v) { blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), bfqg_prfill_stat_recursive, &blkcg_policy_bfq, - seq_cft(sf)->private, false); + cft->private, false); return 0; } -static int bfqg_print_rwstat_recursive(struct seq_file *sf, void *v) +static int bfqg_print_rwstat_recursive(struct seq_file *sf, struct cftype *cft, + void *v) { blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), bfqg_prfill_rwstat_recursive, &blkcg_policy_bfq, - seq_cft(sf)->private, true); + cft->private, true); return 0; } @@ -1063,18 +1065,18 @@ struct cftype bfq_blkcg_legacy_files[] = { { .name = "bfq.io_service_bytes", .private = (unsigned long)&blkcg_policy_bfq, - .seq_show = blkg_print_stat_bytes, + .seq_show_cft = blkg_print_stat_bytes, }, { .name = "bfq.io_serviced", .private = (unsigned long)&blkcg_policy_bfq, - .seq_show = blkg_print_stat_ios, + .seq_show_cft = blkg_print_stat_ios, }, #ifdef CONFIG_DEBUG_BLK_CGROUP { .name = "bfq.time", .private = offsetof(struct bfq_group, stats.time), - .seq_show = bfqg_print_stat, + .seq_show_cft = bfqg_print_stat, }, { .name = "bfq.sectors", @@ -1083,22 +1085,22 @@ struct cftype bfq_blkcg_legacy_files[] = { { .name = "bfq.io_service_time", .private = offsetof(struct bfq_group, stats.service_time), - .seq_show = bfqg_print_rwstat, + .seq_show_cft = bfqg_print_rwstat, }, { .name = "bfq.io_wait_time", .private = offsetof(struct bfq_group, stats.wait_time), - .seq_show = bfqg_print_rwstat, + .seq_show_cft = bfqg_print_rwstat, }, { .name = "bfq.io_merged", .private = offsetof(struct bfq_group, stats.merged), - .seq_show = bfqg_print_rwstat, + .seq_show_cft = bfqg_print_rwstat, }, { .name = "bfq.io_queued", .private = offsetof(struct bfq_group, stats.queued), - .seq_show = bfqg_print_rwstat, + .seq_show_cft = bfqg_print_rwstat, }, #endif /* CONFIG_DEBUG_BLK_CGROUP */ @@ -1106,18 +1108,18 @@ struct cftype bfq_blkcg_legacy_files[] = { { .name = "bfq.io_service_bytes_recursive", .private = (unsigned long)&blkcg_policy_bfq, - .seq_show = blkg_print_stat_bytes_recursive, + .seq_show_cft = blkg_print_stat_bytes_recursive, }, { .name = "bfq.io_serviced_recursive", .private = (unsigned long)&blkcg_policy_bfq, - .seq_show = blkg_print_stat_ios_recursive, + .seq_show_cft = blkg_print_stat_ios_recursive, }, #ifdef CONFIG_DEBUG_BLK_CGROUP { .name = "bfq.time_recursive", .private = offsetof(struct bfq_group, stats.time), - .seq_show = bfqg_print_stat_recursive, + .seq_show_cft = bfqg_print_stat_recursive, }, { .name = "bfq.sectors_recursive", @@ -1126,22 +1128,22 @@ struct cftype bfq_blkcg_legacy_files[] = { { .name = "bfq.io_service_time_recursive", .private = offsetof(struct bfq_group, stats.service_time), - .seq_show = bfqg_print_rwstat_recursive, + .seq_show_cft = bfqg_print_rwstat_recursive, }, { .name = "bfq.io_wait_time_recursive", .private = offsetof(struct bfq_group, stats.wait_time), - .seq_show = bfqg_print_rwstat_recursive, + .seq_show_cft = bfqg_print_rwstat_recursive, }, { .name = "bfq.io_merged_recursive", .private = offsetof(struct bfq_group, stats.merged), - .seq_show = bfqg_print_rwstat_recursive, + .seq_show_cft = bfqg_print_rwstat_recursive, }, { .name = "bfq.io_queued_recursive", .private = offsetof(struct bfq_group, stats.queued), - .seq_show = bfqg_print_rwstat_recursive, + .seq_show_cft = bfqg_print_rwstat_recursive, }, { .name = "bfq.avg_queue_size", @@ -1150,22 +1152,22 @@ struct cftype bfq_blkcg_legacy_files[] = { { .name = "bfq.group_wait_time", .private = offsetof(struct bfq_group, stats.group_wait_time), - .seq_show = bfqg_print_stat, + .seq_show_cft = bfqg_print_stat, }, { .name = "bfq.idle_time", .private = offsetof(struct bfq_group, stats.idle_time), - .seq_show = bfqg_print_stat, + .seq_show_cft = bfqg_print_stat, }, { .name = "bfq.empty_time", .private = offsetof(struct bfq_group, stats.empty_time), - .seq_show = bfqg_print_stat, + .seq_show_cft = bfqg_print_stat, }, { .name = "bfq.dequeue", .private = offsetof(struct bfq_group, stats.dequeue), - .seq_show = bfqg_print_stat, + .seq_show_cft = bfqg_print_stat, }, #endif /* CONFIG_DEBUG_BLK_CGROUP */ { } /* terminate */ diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 63d226a084cd..772d32bbecae 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -565,15 +565,16 @@ static u64 blkg_prfill_rwstat_field(struct seq_file *sf, /** * blkg_print_stat_bytes - seq_show callback for blkg->stat_bytes * @sf: seq_file to print to + * @cft: cftype holding the data * @v: unused * * To be used as cftype->seq_show to print blkg->stat_bytes. * cftype->private must be set to the blkcg_policy. */ -int blkg_print_stat_bytes(struct seq_file *sf, void *v) +int blkg_print_stat_bytes(struct seq_file *sf, struct cftype *cft, void *v) { blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), - blkg_prfill_rwstat_field, (void *)seq_cft(sf)->private, + blkg_prfill_rwstat_field, (void *)cft->private, offsetof(struct blkcg_gq, stat_bytes), true); return 0; } @@ -582,15 +583,16 @@ EXPORT_SYMBOL_GPL(blkg_print_stat_bytes); /** * blkg_print_stat_bytes - seq_show callback for blkg->stat_ios * @sf: seq_file to print to + * @cft: cftype holding the data * @v: unused * * To be used as cftype->seq_show to print blkg->stat_ios. cftype->private * must be set to the blkcg_policy. */ -int blkg_print_stat_ios(struct seq_file *sf, void *v) +int blkg_print_stat_ios(struct seq_file *sf, struct cftype *cft, void *v) { blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), - blkg_prfill_rwstat_field, (void *)seq_cft(sf)->private, + blkg_prfill_rwstat_field, (void *)cft->private, offsetof(struct blkcg_gq, stat_ios), true); return 0; } @@ -608,13 +610,15 @@ static u64 blkg_prfill_rwstat_field_recursive(struct seq_file *sf, /** * blkg_print_stat_bytes_recursive - recursive version of blkg_print_stat_bytes * @sf: seq_file to print to + * @cft: cftype holding the data * @v: unused */ -int blkg_print_stat_bytes_recursive(struct seq_file *sf, void *v) +int blkg_print_stat_bytes_recursive(struct seq_file *sf, struct cftype *cft, + void *v) { blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), blkg_prfill_rwstat_field_recursive, - (void *)seq_cft(sf)->private, + (void *)cft->private, offsetof(struct blkcg_gq, stat_bytes), true); return 0; } @@ -623,13 +627,15 @@ EXPORT_SYMBOL_GPL(blkg_print_stat_bytes_recursive); /** * blkg_print_stat_ios_recursive - recursive version of blkg_print_stat_ios * @sf: seq_file to print to + * @cft: cftype holding the data * @v: unused */ -int blkg_print_stat_ios_recursive(struct seq_file *sf, void *v) +int blkg_print_stat_ios_recursive(struct seq_file *sf, struct cftype *cft, + void *v) { blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), blkg_prfill_rwstat_field_recursive, - (void *)seq_cft(sf)->private, + (void *)cft->private, offsetof(struct blkcg_gq, stat_ios), true); return 0; } diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 8f0a104770ee..6bfdaac53b6f 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1493,22 +1493,22 @@ static struct cftype throtl_legacy_files[] = { { .name = "throttle.io_service_bytes", .private = (unsigned long)&blkcg_policy_throtl, - .seq_show = blkg_print_stat_bytes, + .seq_show_cft = blkg_print_stat_bytes, }, { .name = "throttle.io_service_bytes_recursive", .private = (unsigned long)&blkcg_policy_throtl, - .seq_show = blkg_print_stat_bytes_recursive, + .seq_show_cft = blkg_print_stat_bytes_recursive, }, { .name = "throttle.io_serviced", .private = (unsigned long)&blkcg_policy_throtl, - .seq_show = blkg_print_stat_ios, + .seq_show_cft = blkg_print_stat_ios, }, { .name = "throttle.io_serviced_recursive", .private = (unsigned long)&blkcg_policy_throtl, - .seq_show = blkg_print_stat_ios_recursive, + .seq_show_cft = blkg_print_stat_ios_recursive, }, { } /* terminate */ }; diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index a9e2e2037129..770b59e0d35f 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -207,10 +207,12 @@ u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, u64 blkg_prfill_stat(struct seq_file *sf, struct blkg_policy_data *pd, int off); u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, int off); -int blkg_print_stat_bytes(struct seq_file *sf, void *v); -int blkg_print_stat_ios(struct seq_file *sf, void *v); -int blkg_print_stat_bytes_recursive(struct seq_file *sf, void *v); -int blkg_print_stat_ios_recursive(struct seq_file *sf, void *v); +int blkg_print_stat_bytes(struct seq_file *sf, struct cftype *cft, void *v); +int blkg_print_stat_ios(struct seq_file *sf, struct cftype *cft, void *v); +int blkg_print_stat_bytes_recursive(struct seq_file *sf, struct cftype *cft, + void *v); +int blkg_print_stat_ios_recursive(struct seq_file *sf, struct cftype *cft, + void *v); u64 blkg_stat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol, int off); From patchwork Mon Nov 19 10:34:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10688449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8425714BD for ; Mon, 19 Nov 2018 10:34:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70CCE287F8 for ; Mon, 19 Nov 2018 10:34:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64F422964C; Mon, 19 Nov 2018 10:34:48 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0E96287F8 for ; Mon, 19 Nov 2018 10:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728157AbeKSU57 (ORCPT ); Mon, 19 Nov 2018 15:57:59 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43091 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbeKSU56 (ORCPT ); Mon, 19 Nov 2018 15:57:58 -0500 Received: by mail-wr1-f68.google.com with SMTP id r10so13898438wrs.10 for ; Mon, 19 Nov 2018 02:34:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=x0Itf0ZxI+Oxy7a9zO1EZJNmqUfunAWUlaUx3OwJfXE=; b=ZY9L6xbrDMh2HjcNz0YOjsrYk0Kmtklvb60AEmHSjiJI/Pk+YMBYPF0O31vnW8uYNA c9mhYofxWkWb+nOOBKPvdgFBpZSiuq0Z0Cb090oHVsvuIymAZOAd3UGEwStIpuBuMv3h 6BZEXTJWgLYIrrgwNuGx/H/HnMh1Ym7GLwhns= 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=x0Itf0ZxI+Oxy7a9zO1EZJNmqUfunAWUlaUx3OwJfXE=; b=BDXgwW13Hw4w8CKFuGt31oOqJ8mc8rGw6Ug+vOn8M2fUj23auTikbqLgkCv45uUqes KgjyfKn5luhATmnAwchcgKMrwO9HlXLH87t7DkEgHzLcqyFCktekjrVlkOjrVuTh79fa G+f3d6GlSU5Gz1Ob1xrLiAU6dUBEiZCaf0ZS41XXtksxXDrUgP1af8Fa18nzZoQqztFB V8JhNpZKcPxHkSnuVIQF2bm0QQc8G9AobUM7YLCLX5jCDmu0IpdbhVg7BZuLOfUNEG8H WzM16pVaFdCEjiSZKCOO7LEIj78/KGSgFAdhmq8IsPlmEwVo518eWQLkd0EeP/GDw7UI pwUw== X-Gm-Message-State: AGRZ1gKDWYJY+XX+BOQ+iw1h2A1kZdwgozumx1bX047UeWuxZn3S+Uwe RzcRK0FXMItXjZB1QCYZKx+1jQ== X-Google-Smtp-Source: AJdET5fXw0qKxltdCvOTqRUWYOz39k9i/6Dbg6sQgUh6yuV+I1LQ+XJzInDrAA/rwPSZrkrvF0SJ6g== X-Received: by 2002:a5d:4acb:: with SMTP id y11mr17334824wrs.281.1542623683215; Mon, 19 Nov 2018 02:34:43 -0800 (PST) Received: from localhost.localdomain ([37.162.18.180]) by smtp.gmail.com with ESMTPSA id e9sm14973298wro.16.2018.11.19.02.34.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 02:34:42 -0800 (PST) From: Paolo Valente To: Jens Axboe , Greg Kroah-Hartman , Tejun Heo , Li Zefan , Angelo Ruocco , Dennis Zhou , Josef Bacik , Liu Bo , Bart Van Assche , Johannes Weiner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Paolo Valente Subject: [PATCH V2 03/10] cgroup: link cftypes of the same subsystem with the same name Date: Mon, 19 Nov 2018 11:34:17 +0100 Message-Id: <20181119103424.3853-4-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181119103424.3853-1-paolo.valente@linaro.org> References: <20181119103424.3853-1-paolo.valente@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Angelo Ruocco Two entities, of any kind, are not able to create a cgroup file with the same name in the same folder: if an entity tries to create a file that has the same name as a file created by another entity, the cgroup core stops it, warns the user about the error, and then proceeds to delete all the files created by the last entity. However, in some specific situations, it may be useful for two or more entities to use a common file, e.g., the I/O schedulers bfq and cfq had the same "weight" attribute, that changed the behavior of the two schedulers in a similar way. This commit prepares the interface that allows two entities to share files. It adds a flag CFTYPE_SHARE_FILE for cftypes, flag that allows cftypes to be linked together if they are part of the same subsystem and have the same name. There is a limitation for a cftype that wants to share a file: it can't have the hooks seq_start/next/stop. The reason is that there is no consistent way to show portions of a file once multiple cftypes are attached to it, and thus more than one seq_show() is invoked: there are neither an univocal start point, nor univocal "next" and "stop" operations. Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- include/linux/cgroup-defs.h | 9 ++++++ kernel/cgroup/cgroup.c | 78 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 7841db6e7fb3..d659763c7221 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -93,6 +93,8 @@ enum { CFTYPE_NO_PREFIX = (1 << 3), /* (DON'T USE FOR NEW FILES) no subsys prefix */ CFTYPE_WORLD_WRITABLE = (1 << 4), /* (DON'T USE FOR NEW FILES) S_IWUGO */ + CFTYPE_SHARES_FILE = (1 << 5), /* shares file w/ other cfts */ + /* internal flags, do not use outside cgroup core proper */ __CFTYPE_ONLY_ON_DFL = (1 << 16), /* only on default hierarchy */ __CFTYPE_NOT_ON_DFL = (1 << 17), /* not on default hierarchy */ @@ -528,6 +530,13 @@ struct cftype { */ struct cgroup_subsys *ss; /* NULL for cgroup core files */ struct list_head node; /* anchored at ss->cfts */ + + /* + * List of cftypes that are sharing the same file. It allows the hook + * functions of the cftypes in the list to be called together. + */ + struct list_head share_node; + struct kernfs_ops *kf_ops; int (*open)(struct kernfs_open_file *of); diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 9d0993dd68fe..61eafd69e2fd 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -1549,11 +1549,15 @@ struct cgroup *cgroup_kn_lock_live(struct kernfs_node *kn, bool drain_offline) return NULL; } -static void cgroup_rm_file(struct cgroup *cgrp, const struct cftype *cft) +static void cgroup_rm_file(struct cgroup *cgrp, struct cftype *cft) { char name[CGROUP_FILE_NAME_MAX]; + struct kernfs_node *kn = kernfs_find_and_get(cgrp->kn, + cgroup_file_name(cgrp, cft, name)); + struct cftype *cfts = kn->priv; lockdep_assert_held(&cgroup_mutex); + kernfs_put(kn); if (cft->file_offset) { struct cgroup_subsys_state *css = cgroup_css(cgrp, cft->ss); @@ -1566,7 +1570,19 @@ static void cgroup_rm_file(struct cgroup *cgrp, const struct cftype *cft) del_timer_sync(&cfile->notify_timer); } - kernfs_remove_by_name(cgrp->kn, cgroup_file_name(cgrp, cft, name)); + /* Delete the file only if it's used by one cftype */ + if (list_empty(&cft->share_node) || atomic_read(&kn->count) == 1) { + kernfs_remove(kn); + } else { + /* + * Update the "priv" pointer of the kernfs_node if the cftype + * that first created the file is removed. + */ + if (cft == cfts) + kn->priv = list_next_entry(cft, share_node); + + kernfs_put(kn); + } } /** @@ -3437,6 +3453,7 @@ static int cgroup_file_open(struct kernfs_open_file *of) { struct cftype *cft = of->kn->priv; + if (cft->open) return cft->open(of); return 0; @@ -3585,6 +3602,22 @@ static int cgroup_add_file(struct cgroup_subsys_state *css, struct cgroup *cgrp, #ifdef CONFIG_DEBUG_LOCK_ALLOC key = &cft->lockdep_key; #endif + + if (cft->flags & CFTYPE_SHARES_FILE) { + /* kn->count keeps track of how many cftypes share kn */ + kn = kernfs_find_and_get(cgrp->kn, + cgroup_file_name(cgrp, cft, name)); + if (kn) { + struct cftype *cfts = kn->priv; + + if (cfts->flags & CFTYPE_SHARES_FILE) + goto out_set_cfile; + else + kernfs_put(kn); + + } + } + kn = __kernfs_create_file(cgrp->kn, cgroup_file_name(cgrp, cft, name), cgroup_file_mode(cft), GLOBAL_ROOT_UID, GLOBAL_ROOT_GID, @@ -3599,6 +3632,7 @@ static int cgroup_add_file(struct cgroup_subsys_state *css, struct cgroup *cgrp, return ret; } +out_set_cfile: if (cft->file_offset) { struct cgroup_file *cfile = (void *)css + cft->file_offset; @@ -3696,11 +3730,46 @@ static void cgroup_exit_cftypes(struct cftype *cfts) cft->kf_ops = NULL; cft->ss = NULL; + list_del(&cft->share_node); + /* revert flags set by cgroup core while adding @cfts */ cft->flags &= ~(__CFTYPE_ONLY_ON_DFL | __CFTYPE_NOT_ON_DFL); } } +/* + * Link a cftype that wants to share a file to the list of cftypes that are + * using it. + * + * The conditions for a cftype to be put in an existing list of cftypes and + * thus start to share a file are: + * - to have the flag CFTYPE_SHARES_FILE set; + * - to have all flags coincide with the flags of the other cftypes in the + * list; + * - to not have a seq_start hook: there is no consistent way to show + * portions of a file once multiple cftypes are attached to it, and thus + * more than one seq_show() is invoked. + * + * Once two or more cftypes are linked together, the file only points + * to the first of them. + */ +static void cgroup_link_cftype(struct cgroup_subsys *ss, struct cftype *cft) +{ + struct cftype *cfts; + + list_for_each_entry(cfts, &ss->cfts, node) { + struct cftype *c; + + for (c = cfts; c->name[0] != '\0'; c++) + if (c != cft && !(c->flags ^ cft->flags) && + !(c->seq_start || cft->seq_start) && + !strcmp(c->name, cft->name)) { + list_add(&cft->share_node, &c->share_node); + return; + } + } +} + static int cgroup_init_cftypes(struct cgroup_subsys *ss, struct cftype *cfts) { struct cftype *cft; @@ -3730,6 +3799,11 @@ static int cgroup_init_cftypes(struct cgroup_subsys *ss, struct cftype *cfts) cft->kf_ops = kf_ops; cft->ss = ss; + + INIT_LIST_HEAD(&cft->share_node); + + if (cft->flags & CFTYPE_SHARES_FILE) + cgroup_link_cftype(ss, cft); } return 0; From patchwork Mon Nov 19 10:34:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10688451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5255213B5 for ; Mon, 19 Nov 2018 10:34:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40BC7287F8 for ; Mon, 19 Nov 2018 10:34:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3413A2964C; Mon, 19 Nov 2018 10:34:51 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 036DF287F8 for ; Mon, 19 Nov 2018 10:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727760AbeKSU6A (ORCPT ); Mon, 19 Nov 2018 15:58:00 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33376 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728128AbeKSU6A (ORCPT ); Mon, 19 Nov 2018 15:58:00 -0500 Received: by mail-wm1-f65.google.com with SMTP id 79so2404334wmo.0 for ; Mon, 19 Nov 2018 02:34:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ixCco3tkgOz6XOnATIyg3v7JG+fMVyFH/i6hN9+7LbE=; b=kKp2I6yh/orVyEouSJpVWokRdAT9xO+g+kCnqgaaTzcRgXwvj2mzpvsQeI/fL870j/ FWJpkmfYHVEX994JHS9HKt3nipa3xeLHvXCMO6b7u5kQXIhAGjuRJ+Y8HyG2lb5f+Ag9 5/O6i7rXVsv45I3wffJr69woHSqCdtIyD3Cxw= 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=ixCco3tkgOz6XOnATIyg3v7JG+fMVyFH/i6hN9+7LbE=; b=YItD4pChOaXNVIAEvlQEvq3QnR825QYG8rvxepPtD1RG/Y9tI/HLWhbTqSfL5iaBq/ HsUo6AwxnVMLuWqfqOwhMeaSDDlIMM/Ahuqx77XkH724xxzkG5kC0BRpnEUoWtQ94HdE X3n/UUTrX+8b93tbpngnChPVl0qn4k3OR1r3J7mVNxOmSorepiy4mLVAbEa4RKQDJoOD kklLexFF7AyWfXTvQo5yj1Y0r6MFDe4eYsdnE5g9rZsLi0ODqEr353jiX7sotClwPNlY ZT5CTm6WkRlYyyOTEujn1N4zXSZvHfjUZNuJpUQHfcGFqOC68ykMoCDleZaUJhLxGXo0 /IHg== X-Gm-Message-State: AA+aEWZ/ybcLu4+OvfZi6fEXzBf6qiAlswYTL3DOnCyg2KYclO27V0ob oeMDJ6I65rTo0z6jjQkFBxKuCg== X-Google-Smtp-Source: AFSGD/XQN0bxurfeBwqVhi42PyrkCx7YpUAfDxlfoSPjxaAmOF+536pj4Jx/EI2aSgzxGuXsLZUQ4w== X-Received: by 2002:a1c:2b45:: with SMTP id r66-v6mr6662149wmr.128.1542623686156; Mon, 19 Nov 2018 02:34:46 -0800 (PST) Received: from localhost.localdomain ([37.162.18.180]) by smtp.gmail.com with ESMTPSA id e9sm14973298wro.16.2018.11.19.02.34.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 02:34:45 -0800 (PST) From: Paolo Valente To: Jens Axboe , Greg Kroah-Hartman , Tejun Heo , Li Zefan , Angelo Ruocco , Dennis Zhou , Josef Bacik , Liu Bo , Bart Van Assche , Johannes Weiner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Paolo Valente Subject: [PATCH V2 04/10] cgroup: add owner name to cftypes Date: Mon, 19 Nov 2018 11:34:18 +0100 Message-Id: <20181119103424.3853-5-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181119103424.3853-1-paolo.valente@linaro.org> References: <20181119103424.3853-1-paolo.valente@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Angelo Ruocco The piece of information "who created a certain cftype" is not stored anywhere, thus a cftype is not able to know who is its owner. This commit addresses this problem by adding a new field in the cftype structure that enables the name of its owner to be explicitly set. Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- include/linux/cgroup-defs.h | 2 ++ include/linux/cgroup.h | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index d659763c7221..6e31f478c6e1 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -36,6 +36,7 @@ struct seq_file; #define MAX_CGROUP_TYPE_NAMELEN 32 #define MAX_CGROUP_ROOT_NAMELEN 64 #define MAX_CFTYPE_NAME 64 +#define MAX_OWNER_NAME 64 /* define the enumeration of all cgroup subsystems */ #define SUBSYS(_x) _x ## _cgrp_id, @@ -505,6 +506,7 @@ struct cftype { * end of cftype array. */ char name[MAX_CFTYPE_NAME]; + char owner_name[MAX_OWNER_NAME]; unsigned long private; /* diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 9d12757a65b0..267153bd898a 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -291,6 +291,19 @@ void css_task_iter_end(struct css_task_iter *it); ; \ else +/** + * list_for_each_cft - walk circular list of cftypes linked together + * @cft: cftype from where to start + * @n: cftype used as a temporary storage + * + * A cftype pointed by a file may be part of a circular list of cftypes, this + * macro walks the circular list starting from any given cftype. Unlike the + * "list_for_each_entry" macro, the first element is included in the iteration. + */ +#define list_for_each_cft(cft, n) \ + for (n = NULL; cft != n; n = (n == NULL) ? cft : n, \ + cft = list_next_entry(cft, share_node)) + /* * Inline functions. */ From patchwork Mon Nov 19 10:34:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10688463 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F71114BD for ; Mon, 19 Nov 2018 10:35:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E6FD287F8 for ; Mon, 19 Nov 2018 10:35:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4281B2964C; Mon, 19 Nov 2018 10:35:30 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9445287F8 for ; Mon, 19 Nov 2018 10:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728245AbeKSU6F (ORCPT ); Mon, 19 Nov 2018 15:58:05 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37690 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728237AbeKSU6D (ORCPT ); Mon, 19 Nov 2018 15:58:03 -0500 Received: by mail-wr1-f66.google.com with SMTP id j10so17214820wru.4 for ; Mon, 19 Nov 2018 02:34:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=X5boqJ0UbdeKGVE+FnIPUcIjT6rvSPY3NTZlqHlp7eY=; b=cOaOohdKAX6mJq3wr2E6Hwafuweehz68ABx+2oXHJV0TZuvr4qoCBxK2dufKJTVwOI pIuCn8YJgCmgtwHWw/Bhfhh2VvhLRaaHj0AkzG5SpAmKlDJQv+8kIIsF2MoREcj+qMIQ C2MBBTrmNvoV9HHeYBNRnb8XIcdxNvnBM7qSs= 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=X5boqJ0UbdeKGVE+FnIPUcIjT6rvSPY3NTZlqHlp7eY=; b=eoi1kXwuy0MgULilGwx4tHhw8NvCspzTuzusII27+zdDTzzIuJ0lNdRvZ+mUkA97Ss APNxukmC3RFd4z2g6ZjjbEmtmk2Swez0KM7ofCIEHHAGsx7Y5xs5V42zuxaT+VFL3sOY RAyXwKCdN8uC5wQoqn54XZn1aWn62q5FlpbWx7HpMnFwKMWFdGvx4XmZj2/7Vo+OztpU lgO0oxfDGKdleea4ab7a5aHTXwPjg9T5gH2o6BgplaTcJgE7wE12zY0Vi0dqx4zJFGkS yav41AZ0nXp9F7H5FQhlEGKveXibj2ooeJravxfzzQrmk4POrtS13qnPnWs63/iX4PbG XiTw== X-Gm-Message-State: AGRZ1gL3YYctKnqDGQmqq3dJumQKUct+gz2tpHd/R6+7bm/u2raWuKAy thdcm4oS5ichfdhbHA66U/NBYw== X-Google-Smtp-Source: AJdET5dlidO4F2+Oc57hof7n9lzgBTwrCKQE7wMlAYyJLDMl0bDi14Nwu5lkSVkH9OvaTIOR3d0voQ== X-Received: by 2002:a5d:6187:: with SMTP id j7mr17824022wru.300.1542623689487; Mon, 19 Nov 2018 02:34:49 -0800 (PST) Received: from localhost.localdomain ([37.162.18.180]) by smtp.gmail.com with ESMTPSA id e9sm14973298wro.16.2018.11.19.02.34.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 02:34:49 -0800 (PST) From: Paolo Valente To: Jens Axboe , Greg Kroah-Hartman , Tejun Heo , Li Zefan , Angelo Ruocco , Dennis Zhou , Josef Bacik , Liu Bo , Bart Van Assche , Johannes Weiner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Paolo Valente Subject: [PATCH V2 05/10] block, bfq: align min and default weights with the old cfq default Date: Mon, 19 Nov 2018 11:34:19 +0100 Message-Id: <20181119103424.3853-6-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181119103424.3853-1-paolo.valente@linaro.org> References: <20181119103424.3853-1-paolo.valente@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Angelo Ruocco bfq exposes a cgroup attribute, weight, with the same meaning as that exposed by cfq. This commit changes bfq default and min weights to match the ones set by cfq (before legacy blk was removed). Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- block/bfq-iosched.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 77651d817ecd..249d8128d3ee 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -22,13 +22,13 @@ #define BFQ_IOPRIO_CLASSES 3 #define BFQ_CL_IDLE_TIMEOUT (HZ/5) -#define BFQ_MIN_WEIGHT 1 +#define BFQ_MIN_WEIGHT 10 #define BFQ_MAX_WEIGHT 1000 #define BFQ_WEIGHT_CONVERSION_COEFF 10 #define BFQ_DEFAULT_QUEUE_IOPRIO 4 -#define BFQ_WEIGHT_LEGACY_DFL 100 +#define BFQ_WEIGHT_LEGACY_DFL 500 #define BFQ_DEFAULT_GRP_IOPRIO 0 #define BFQ_DEFAULT_GRP_CLASS IOPRIO_CLASS_BE From patchwork Mon Nov 19 10:34:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10688453 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 676CD13B5 for ; Mon, 19 Nov 2018 10:34:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54432287F8 for ; Mon, 19 Nov 2018 10:34:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45AF72964C; Mon, 19 Nov 2018 10:34:59 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96682287F8 for ; Mon, 19 Nov 2018 10:34:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728238AbeKSU6J (ORCPT ); Mon, 19 Nov 2018 15:58:09 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36364 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728283AbeKSU6H (ORCPT ); Mon, 19 Nov 2018 15:58:07 -0500 Received: by mail-wr1-f68.google.com with SMTP id t3so1231272wrr.3 for ; Mon, 19 Nov 2018 02:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U4mx1fsW9hQVbmr4//R68r7KKVwetfXIYfE3uWdN0BA=; b=WmfejyvwiqglaM7h5Ev4Z0FCeNcqTiYIIExPQ4Tm4odYSIRRi7BQKPz60lpr5NxKUn Ql1cG2nTKWLNdExnpTToG1ROtic9FG/wQtE4SiV+z7fwdjnpxuYSE5pHUn2+EKlQHGQg sT2nPkqTp2x2oDyuhu8iBxzs0ALZZ7E508z78= 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=U4mx1fsW9hQVbmr4//R68r7KKVwetfXIYfE3uWdN0BA=; b=XExmMux9dWTmrBQeDa6MAno71+E20FXOfbXw3a58SPaSKOVw5/xoxgJPD+iYn5U3PN pO3bruE9bk1236yp+MmJot/cMBime49RYiU76jjUaopUV0njTkNZGbwkqLx2J8RvoXiR ReWT4keJgKa7jia6adIn+UmLGvC2Y/45DXiHxUx7C4lcqxlSbk+Dx8Kxvxy5iyyAYvSs cUMdZZk5w3+Qf0S87ui7ewYKjUB3CxvVZQCik1rHAWEJT4dONhv0mihbTfJ11Hc+/TIk kH3Uancu/IOVeDfBYNLTdijA270iRFBy9WuSpuZHaqeR14jDnweSKYOgycPvT1ifSC5v Gw2Q== X-Gm-Message-State: AA+aEWa4Su8BkV4WpOeaToJW+sYuArpfU/T3luJux2Fk31DinKiPBNNz 7Nuir808ftDKnMVBZSwMHv59DQ== X-Google-Smtp-Source: AFSGD/W2mi6KsjsMrtNGYj62KHvXQ8q32ubp7k6R4iPvkIGZteTn9oJGijRQQtIMchc92nXrQQ0Ntg== X-Received: by 2002:a5d:410e:: with SMTP id l14mr9321492wrp.61.1542623692598; Mon, 19 Nov 2018 02:34:52 -0800 (PST) Received: from localhost.localdomain ([37.162.18.180]) by smtp.gmail.com with ESMTPSA id e9sm14973298wro.16.2018.11.19.02.34.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 02:34:52 -0800 (PST) From: Paolo Valente To: Jens Axboe , Greg Kroah-Hartman , Tejun Heo , Li Zefan , Angelo Ruocco , Dennis Zhou , Josef Bacik , Liu Bo , Bart Van Assche , Johannes Weiner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Paolo Valente Subject: [PATCH V2 06/10] cgroup: make all functions of all cftypes be invoked Date: Mon, 19 Nov 2018 11:34:20 +0100 Message-Id: <20181119103424.3853-7-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181119103424.3853-1-paolo.valente@linaro.org> References: <20181119103424.3853-1-paolo.valente@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Angelo Ruocco When two or more entities (of any kind) share a file, their respective cftypes are linked together. The allowed operations on those files are: open, release, write and show, mapped to the functions defined in the cftypes. This commit makes the cgroup core invoke, whenever one of those operations is requested, the respective function of all the cftypes linked together. Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- kernel/cgroup/cgroup.c | 181 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 132 insertions(+), 49 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 61eafd69e2fd..9bf6b0b5a0ca 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -3452,66 +3452,107 @@ static int cgroup_cpu_pressure_show(struct seq_file *seq, void *v) static int cgroup_file_open(struct kernfs_open_file *of) { struct cftype *cft = of->kn->priv; + struct cftype *n; + int ret = 0; + list_for_each_cft(cft, n) { + if (cft->open) + ret = cft->open(of); + /* + * If there has been an error with the open function of one of + * the cft associated with the file, we call the release + * function of all the cftype associated to cft whose open + * function succeded. + */ + if (ret) { + struct cftype *c = of->kn->priv; + struct cftype *n; + + list_for_each_cft(c, n) { + if (cft == c) + break; + if (c->release) + c->release(of); + } + break; + } + } - if (cft->open) - return cft->open(of); - return 0; + return ret; } static void cgroup_file_release(struct kernfs_open_file *of) { struct cftype *cft = of->kn->priv; + struct cftype *n; - if (cft->release) - cft->release(of); + list_for_each_cft(cft, n) + if (cft->release) + cft->release(of); } +/* + * Call all the write functions of the cftypes associated with the file. + * + * When a write fails, don't keep trying to write into the file via the write + * functions of the other cftypes associated with it. + */ static ssize_t cgroup_file_write(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off) { struct cgroup_namespace *ns = current->nsproxy->cgroup_ns; struct cgroup *cgrp = of->kn->parent->priv; struct cftype *cft = of->kn->priv; + struct cftype *n; struct cgroup_subsys_state *css; - int ret; + int ret = 0; - /* - * If namespaces are delegation boundaries, disallow writes to - * files in an non-init namespace root from inside the namespace - * except for the files explicitly marked delegatable - - * cgroup.procs and cgroup.subtree_control. - */ - if ((cgrp->root->flags & CGRP_ROOT_NS_DELEGATE) && - !(cft->flags & CFTYPE_NS_DELEGATABLE) && - ns != &init_cgroup_ns && ns->root_cset->dfl_cgrp == cgrp) - return -EPERM; + list_for_each_cft(cft, n) { + /* + * If namespaces are delegation boundaries, disallow writes to + * files in an non-init namespace root from inside the + * namespace except for the files explicitly marked + * delegatable - cgroup.procs and cgroup.subtree_control. + */ + if ((cgrp->root->flags & CGRP_ROOT_NS_DELEGATE) && + !(cft->flags & CFTYPE_NS_DELEGATABLE) && + ns != &init_cgroup_ns && ns->root_cset->dfl_cgrp == cgrp) + return -EPERM; - if (cft->write) - return cft->write(of, buf, nbytes, off); + if (cft->write) { + ret = cft->write(of, buf, nbytes, off); - /* - * kernfs guarantees that a file isn't deleted with operations in - * flight, which means that the matching css is and stays alive and - * doesn't need to be pinned. The RCU locking is not necessary - * either. It's just for the convenience of using cgroup_css(). - */ - rcu_read_lock(); - css = cgroup_css(cgrp, cft->ss); - rcu_read_unlock(); + if (ret) + break; + continue; + } - if (cft->write_u64) { - unsigned long long v; - ret = kstrtoull(buf, 0, &v); - if (!ret) - ret = cft->write_u64(css, cft, v); - } else if (cft->write_s64) { - long long v; - ret = kstrtoll(buf, 0, &v); - if (!ret) - ret = cft->write_s64(css, cft, v); - } else { - ret = -EINVAL; + /* + * kernfs guarantees that a file isn't deleted with operations + * in flight, which means that the matching css is and stays + * alive and doesn't need to be pinned. The RCU locking is not + * necessary either. It's just for the convenience of using + * cgroup_css(). + */ + rcu_read_lock(); + css = cgroup_css(cgrp, cft->ss); + rcu_read_unlock(); + + if (cft->write_u64) { + unsigned long long v; + + ret = kstrtoull(buf, 0, &v); + if (!ret) + ret = cft->write_u64(css, cft, v); + } else if (cft->write_s64) { + long long v; + + ret = kstrtoll(buf, 0, &v); + if (!ret) + ret = cft->write_s64(css, cft, v); + } else { + return -EINVAL; + } } return ret ?: nbytes; @@ -3533,22 +3574,64 @@ static void cgroup_seqfile_stop(struct seq_file *seq, void *v) seq_cft(seq)->seq_stop(seq, v); } +/* + * A file shared by more cftypes may be showing different values. In that case + * call all the show functions and print the name of the owner that defined + * them. + */ static int cgroup_seqfile_show(struct seq_file *m, void *arg) { struct cftype *cft = seq_cft(m); + struct cftype *n; struct cgroup_subsys_state *css = seq_css(m); + char *first_seqshow_str = NULL; + size_t first_str_size = 0; + size_t current_str_size = 0; int ret = 0; - if (cft->seq_show) - ret = cft->seq_show(m, arg); - else if (cft->seq_show_cft) - ret = cft->seq_show_cft(m, cft, arg); - else if (cft->read_u64) - seq_printf(m, "%llu\n", cft->read_u64(css, cft)); - else if (cft->read_s64) - seq_printf(m, "%lld\n", cft->read_s64(css, cft)); - else - ret = -EINVAL; + list_for_each_cft(cft, n) { + if (cft->seq_show) { + ret = cft->seq_show(m, arg); + if (ret) + break; + } else if (cft->seq_show_cft) { + ret = cft->seq_show_cft(m, cft, arg); + if (ret) + break; + } else if (cft->read_u64) { + seq_printf(m, "%llu\n", cft->read_u64(css, cft)); + } else if (cft->read_s64) { + seq_printf(m, "%lld\n", cft->read_s64(css, cft)); + } else { + ret = -EINVAL; + break; + } + current_str_size = m->count - current_str_size; + + if (first_seqshow_str == NULL) { + first_seqshow_str = kmalloc(m->size, GFP_KERNEL); + first_str_size = m->count; + strcpy(first_seqshow_str, m->buf); + first_str_size = m->count; + } else if (strcmp(first_seqshow_str, + m->buf + m->count - current_str_size)) { + first_str_size = -1; + } + + if (current_str_size) { + seq_printf(m, " - %s\n", cft->owner_name); + current_str_size = m->count; + } + } + + /* + * If all the cft->seqfile_show/read are equal, truncate the + * output of the seqfile to the length of the first string. + */ + if (first_str_size != -1) + m->count = first_str_size; + + kfree(first_seqshow_str); return ret; } From patchwork Mon Nov 19 10:34:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10688455 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED33313B5 for ; Mon, 19 Nov 2018 10:35:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD0EB287F8 for ; Mon, 19 Nov 2018 10:35:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D10222964C; Mon, 19 Nov 2018 10:35:00 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42935287F8 for ; Mon, 19 Nov 2018 10:35:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728285AbeKSU6K (ORCPT ); Mon, 19 Nov 2018 15:58:10 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39984 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728342AbeKSU6K (ORCPT ); Mon, 19 Nov 2018 15:58:10 -0500 Received: by mail-wr1-f68.google.com with SMTP id p4so22274523wrt.7 for ; Mon, 19 Nov 2018 02:34:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hWUit/vYiH26YHlA9buP+oQITDwnzmUPMPxq3d9LPkE=; b=YfU6dTeTHM5A73Tg5BMA4Dw8e7o9lmuB/XXB5c23ILL9CwfpTx7baLDS9fcxsc4otQ h+tJUzNJjWWpTo+fcsVP95Nv2im3yghKNLInHuZODRvbKsDeb2XPU70gXHTWu30bsKH+ nOdzVt5hy9oioZwEv6JpXsY9wqtsNzerY764E= 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=hWUit/vYiH26YHlA9buP+oQITDwnzmUPMPxq3d9LPkE=; b=G39A/XOZapKRKjAkWYq3CfTo8FbrFnZF4JwzPiy433iCb9fp6XKyUz2b+fzqeB+zKL Nv5SnwIOzYx3Qazx4HNyrRUSnEZ3JfF3P5bR2B3X/LRMP4nwwWS6pyD2178QWHKRxE1E Tp8PHbst5/pU1zXt4QcMbdS2uOrd4IE3RZuNOXmtdfLg88qomvLZwqL7vu1aBEUYFKw/ IIvXjXuAY3VLLzUECIJezKFezwLwK6AHRVGw68VVn+zsorF4OIwMQhOG4P82b7gQCjSp RoqmYdWqr4YZdZLh2bNGDJVpCcZI7QNQgwa3GPh9+Q/y31d0LUH8xcq+5wHLl/Yf0SLC F/3g== X-Gm-Message-State: AGRZ1gLbRNRtUydKiAx9mil4XiJiORND/slJcxDNlyc6BF+ErzPBy/BT nwegEgoweF/JsCIV8EjrZOCOEw== X-Google-Smtp-Source: AJdET5fCheLXk7HslibEJh72wzIBDKuwOox1n0FqTi3WVYdm8eRpBK2TFHFO6xuNfT2KcB6yhBtsJg== X-Received: by 2002:adf:9387:: with SMTP id 7-v6mr17123195wrp.269.1542623695517; Mon, 19 Nov 2018 02:34:55 -0800 (PST) Received: from localhost.localdomain ([37.162.18.180]) by smtp.gmail.com with ESMTPSA id e9sm14973298wro.16.2018.11.19.02.34.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 02:34:55 -0800 (PST) From: Paolo Valente To: Jens Axboe , Greg Kroah-Hartman , Tejun Heo , Li Zefan , Angelo Ruocco , Dennis Zhou , Josef Bacik , Liu Bo , Bart Van Assche , Johannes Weiner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Paolo Valente Subject: [PATCH V2 07/10] block, bfq: use standard file names for the proportional-share policy Date: Mon, 19 Nov 2018 11:34:21 +0100 Message-Id: <20181119103424.3853-8-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181119103424.3853-1-paolo.valente@linaro.org> References: <20181119103424.3853-1-paolo.valente@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some of the files exposed in a cgroup by bfq, for the proportional share policy, have the same meaning as the files owned by cfq (before legacy blk was removed). The old implementation of the cgroup interface didn't allow different entities to create cgroup files with the same name (in the same subsystem). So, for bfq, we had to add the prefix "bfq" to the names of its cgroup files. This commit renames the cgroup files of the bfq scheduler as those exposed by cfq, and makes bfq willing to share these files with any other future policy. Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- block/bfq-cgroup.c | 94 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 25 deletions(-) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index 038e418fa64f..0643147b2cbc 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -1055,50 +1055,67 @@ struct blkcg_policy blkcg_policy_bfq = { struct cftype bfq_blkcg_legacy_files[] = { { - .name = "bfq.weight", - .flags = CFTYPE_NOT_ON_ROOT, + .name = "weight", + .owner_name = "bfq", + .flags = CFTYPE_NOT_ON_ROOT | CFTYPE_SHARES_FILE, .seq_show = bfq_io_show_weight, .write_u64 = bfq_io_set_weight_legacy, }, /* statistics, covers only the tasks in the bfqg */ { - .name = "bfq.io_service_bytes", + .name = "io_service_bytes", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = (unsigned long)&blkcg_policy_bfq, .seq_show_cft = blkg_print_stat_bytes, }, { - .name = "bfq.io_serviced", + .name = "io_serviced", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = (unsigned long)&blkcg_policy_bfq, .seq_show_cft = blkg_print_stat_ios, }, #ifdef CONFIG_DEBUG_BLK_CGROUP { - .name = "bfq.time", + .name = "time", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.time), .seq_show_cft = bfqg_print_stat, }, { - .name = "bfq.sectors", + .name = "sectors", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .seq_show = bfqg_print_stat_sectors, }, { - .name = "bfq.io_service_time", + .name = "io_service_time", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.service_time), .seq_show_cft = bfqg_print_rwstat, }, { - .name = "bfq.io_wait_time", + .name = "io_wait_time", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.wait_time), .seq_show_cft = bfqg_print_rwstat, }, { - .name = "bfq.io_merged", + .name = "io_merged", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.merged), .seq_show_cft = bfqg_print_rwstat, }, { - .name = "bfq.io_queued", + .name = "io_queued", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.queued), .seq_show_cft = bfqg_print_rwstat, }, @@ -1106,66 +1123,92 @@ struct cftype bfq_blkcg_legacy_files[] = { /* the same statictics which cover the bfqg and its descendants */ { - .name = "bfq.io_service_bytes_recursive", + .name = "io_service_bytes_recursive", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = (unsigned long)&blkcg_policy_bfq, .seq_show_cft = blkg_print_stat_bytes_recursive, }, { - .name = "bfq.io_serviced_recursive", + .name = "io_serviced_recursive", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = (unsigned long)&blkcg_policy_bfq, .seq_show_cft = blkg_print_stat_ios_recursive, }, #ifdef CONFIG_DEBUG_BLK_CGROUP { - .name = "bfq.time_recursive", + .name = "time_recursive", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.time), .seq_show_cft = bfqg_print_stat_recursive, }, { - .name = "bfq.sectors_recursive", + .name = "sectors_recursive", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .seq_show = bfqg_print_stat_sectors_recursive, }, { - .name = "bfq.io_service_time_recursive", + .name = "io_service_time_recursive", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.service_time), .seq_show_cft = bfqg_print_rwstat_recursive, }, { - .name = "bfq.io_wait_time_recursive", + .name = "io_wait_time_recursive", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.wait_time), .seq_show_cft = bfqg_print_rwstat_recursive, }, { - .name = "bfq.io_merged_recursive", + .name = "io_merged_recursive", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.merged), .seq_show_cft = bfqg_print_rwstat_recursive, }, { - .name = "bfq.io_queued_recursive", + .name = "io_queued_recursive", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.queued), .seq_show_cft = bfqg_print_rwstat_recursive, }, { - .name = "bfq.avg_queue_size", + .name = "avg_queue_size", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .seq_show = bfqg_print_avg_queue_size, }, { - .name = "bfq.group_wait_time", + .name = "group_wait_time", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.group_wait_time), .seq_show_cft = bfqg_print_stat, }, { - .name = "bfq.idle_time", + .name = "idle_time", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.idle_time), .seq_show_cft = bfqg_print_stat, }, { - .name = "bfq.empty_time", + .name = "empty_time", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.empty_time), .seq_show_cft = bfqg_print_stat, }, { - .name = "bfq.dequeue", + .name = "dequeue", + .owner_name = "bfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct bfq_group, stats.dequeue), .seq_show_cft = bfqg_print_stat, }, @@ -1175,8 +1218,9 @@ struct cftype bfq_blkcg_legacy_files[] = { struct cftype bfq_blkg_files[] = { { - .name = "bfq.weight", - .flags = CFTYPE_NOT_ON_ROOT, + .name = "weight", + .owner_name = "bfq", + .flags = CFTYPE_NOT_ON_ROOT | CFTYPE_SHARES_FILE, .seq_show = bfq_io_show_weight, .write = bfq_io_set_weight, }, From patchwork Mon Nov 19 10:34:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10688461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9380914BD for ; Mon, 19 Nov 2018 10:35:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 816DE292B7 for ; Mon, 19 Nov 2018 10:35:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75143294C4; Mon, 19 Nov 2018 10:35:25 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F47E2972B for ; Mon, 19 Nov 2018 10:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728395AbeKSU6N (ORCPT ); Mon, 19 Nov 2018 15:58:13 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38912 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727833AbeKSU6M (ORCPT ); Mon, 19 Nov 2018 15:58:12 -0500 Received: by mail-wr1-f66.google.com with SMTP id b13so31409103wrx.6 for ; Mon, 19 Nov 2018 02:34:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oBc3JwPq73FtDGvqk3t8T7Oot3rzsOXj87W1YQabmq0=; b=U+uluio6KwtbMMoH3Jp0DEoAQtuhcEmvMYrNiM5KHAwwCapWC33wQhLaMnZr9S/I/0 Z6sK2Z1/uUcwEavzu8hwJhNC29Gt2B+bLxPWg0ogiXB9yWoJOlUzzK8ssUxgRpXHV3EU XnLEDqKsSc9kSrVv/zIWFoLbWLaZfx4laO4js= 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=oBc3JwPq73FtDGvqk3t8T7Oot3rzsOXj87W1YQabmq0=; b=UiSDbp3DagvaYi3JyOm2EGWPF93tDJpwHgsZE/Yax2uhvf0USYyS8eZBTzoW8HNubx obHBZIbjXpBDIPhMWyqhdWY0UKctwgfUkYtq9j4Wst6TWDG1VjZlfQowagYlbcvm39K8 sQykyqy3J90eUGSF+koeUS8V19hwxMMRSH32GFPzjOcSo99TDgBNiYLc7FDzxxN/Aea5 5CTCiFNvZ2hk6EJvtcQOjKiMpw5FDSHdKBks51TSnJ5nXglSo6YmgAgsUe1ELy7eSis2 GLCcIqS53OsBgJTLha62hgMqlCRdsnBvzfAijY7m/Sn1YpJyvGjKKfjN5g1l1r15eKyg pnyQ== X-Gm-Message-State: AGRZ1gIkRfz0uxplbYpg0IVe83YSA69y74ZyAabDhz/Om8OnCmdVTMwi mFO2oef/qWLsBTDeuSgLWc/ITg== X-Google-Smtp-Source: AJdET5etp8BezkBcu9ThAO0d/Z0yFM4/7bg5m+zKB/fG+37fSeJxpTsIAFoYhNzjTlWgIzYfHEJTRQ== X-Received: by 2002:a5d:4708:: with SMTP id y8-v6mr17551672wrq.16.1542623698837; Mon, 19 Nov 2018 02:34:58 -0800 (PST) Received: from localhost.localdomain ([37.162.18.180]) by smtp.gmail.com with ESMTPSA id e9sm14973298wro.16.2018.11.19.02.34.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 02:34:58 -0800 (PST) From: Paolo Valente To: Jens Axboe , Greg Kroah-Hartman , Tejun Heo , Li Zefan , Angelo Ruocco , Dennis Zhou , Josef Bacik , Liu Bo , Bart Van Assche , Johannes Weiner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Paolo Valente Subject: [PATCH V2 08/10] block, throttle: allow sharing cgroup statistic files Date: Mon, 19 Nov 2018 11:34:22 +0100 Message-Id: <20181119103424.3853-9-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181119103424.3853-1-paolo.valente@linaro.org> References: <20181119103424.3853-1-paolo.valente@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Angelo Ruocco Some of the cgroup files defined in the throttle policy have the same meaning as those defined in the proportional share policy. This commit uses the new file sharing interface in cgroup to share these files. Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- block/blk-throttle.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 6bfdaac53b6f..95825448c031 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1491,22 +1491,30 @@ static struct cftype throtl_legacy_files[] = { .write = tg_set_conf_uint, }, { - .name = "throttle.io_service_bytes", + .name = "io_service_bytes", + .owner_name = "throttle", + .flags = CFTYPE_SHARES_FILE, .private = (unsigned long)&blkcg_policy_throtl, .seq_show_cft = blkg_print_stat_bytes, }, { - .name = "throttle.io_service_bytes_recursive", + .name = "io_service_bytes_recursive", + .owner_name = "throttle", + .flags = CFTYPE_SHARES_FILE, .private = (unsigned long)&blkcg_policy_throtl, .seq_show_cft = blkg_print_stat_bytes_recursive, }, { - .name = "throttle.io_serviced", + .name = "io_serviced", + .owner_name = "throttle", + .flags = CFTYPE_SHARES_FILE, .private = (unsigned long)&blkcg_policy_throtl, .seq_show_cft = blkg_print_stat_ios, }, { - .name = "throttle.io_serviced_recursive", + .name = "io_serviced_recursive", + .owner_name = "throttle", + .flags = CFTYPE_SHARES_FILE, .private = (unsigned long)&blkcg_policy_throtl, .seq_show_cft = blkg_print_stat_ios_recursive, }, From patchwork Mon Nov 19 10:34:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10688459 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C72E13B5 for ; Mon, 19 Nov 2018 10:35:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C7B0287F8 for ; Mon, 19 Nov 2018 10:35:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 204DF292B7; Mon, 19 Nov 2018 10:35:24 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DDBE29708 for ; Mon, 19 Nov 2018 10:35:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728383AbeKSU6Q (ORCPT ); Mon, 19 Nov 2018 15:58:16 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35380 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727841AbeKSU6Q (ORCPT ); Mon, 19 Nov 2018 15:58:16 -0500 Received: by mail-wr1-f66.google.com with SMTP id 96so14543336wrb.2 for ; Mon, 19 Nov 2018 02:35:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=95cHSgXhObq6AUCu/Rr/+wEQTPHLVt9I8/orFJ2tnV8=; b=N8iZHEZvKWz0J/nual7jk0fkuGeRXXZ7k/3ibe4bHVxzhla7D7v8KTcgOO8yVpWvFT B3vEIw+EBmC/yavIAvjOIiUz2wiAPEAIzT1RHvDAgZUu4MTPxiKzIwxtEJH+JHWk3fW/ YZJUNoJLJnP75HF8BVdkglOlyHl+oOYs6W9pY= 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=95cHSgXhObq6AUCu/Rr/+wEQTPHLVt9I8/orFJ2tnV8=; b=VMIuJYk16+RD0s48IWkArhxq4CfFfat6wM2Sg90cc+9Q0LcazBl7BBfZ8sSkXEV6AD VODnoKXQlY4b6KAubUk/GHoVVUt8ClyVF+ubZkpLlj7VB7LfnPAqLqr+R8F78Ut0mDrQ dSQ1qH2F9M/NLs1qVHnnnS0FE6dH851iRxFMwKi7Xv71pYPCPGwTtszfLAvdbL1Vyyz1 oQAoPum14oVuNAbf8QtiikFRNft2kn1H6jaBVZnaYq5pqubkisel0MSpEqi/52EHK8Yt j+hcSCRNlebgHwin8BiM2gB54hnX6fd8uke6TUEbo0IC6dnFe03sEXR4NP1lM6kydNo1 dygA== X-Gm-Message-State: AGRZ1gLS2VMd6m1gRyk4HbvJ8ncbgSD1hGm0/G6YoioDSFcywIfa20Xy h4lDUiCrBBuH4PpTQ1O+fgArQQ== X-Google-Smtp-Source: AJdET5dv/kwKsiWQBLYn+3+c+70Y68/WWV68w94tCu7QaX1LfXLzsVsfON/+RAR1/k+eJjYW/4XsJg== X-Received: by 2002:adf:e247:: with SMTP id n7mr16869741wri.205.1542623702316; Mon, 19 Nov 2018 02:35:02 -0800 (PST) Received: from localhost.localdomain ([37.162.18.180]) by smtp.gmail.com with ESMTPSA id e9sm14973298wro.16.2018.11.19.02.34.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 02:35:01 -0800 (PST) From: Paolo Valente To: Jens Axboe , Greg Kroah-Hartman , Tejun Heo , Li Zefan , Angelo Ruocco , Dennis Zhou , Josef Bacik , Liu Bo , Bart Van Assche , Johannes Weiner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Paolo Valente Subject: [PATCH V2 09/10] doc, bfq-iosched: fix a few clerical errors Date: Mon, 19 Nov 2018 11:34:23 +0100 Message-Id: <20181119103424.3853-10-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181119103424.3853-1-paolo.valente@linaro.org> References: <20181119103424.3853-1-paolo.valente@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit fixes a few clerical errors in Documentation/block/bfq-iosched.txt. Signed-off-by: Paolo Valente --- Documentation/block/bfq-iosched.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/block/bfq-iosched.txt b/Documentation/block/bfq-iosched.txt index 8d8d8f06cab2..6d7dd5ab8554 100644 --- a/Documentation/block/bfq-iosched.txt +++ b/Documentation/block/bfq-iosched.txt @@ -42,7 +42,7 @@ sustainable throughputs, on the same systems as above: BFQ works for multi-queue devices too. -The table of contents follow. Impatients can just jump to Section 3. +The table of contents follows. Impatients can just jump to Section 3. CONTENTS @@ -51,7 +51,7 @@ CONTENTS 1-2 Server systems 2. How does BFQ work? 3. What are BFQ's tunables and how to properly configure BFQ? -4. BFQ group scheduling +4. Group scheduling with BFQ 4-1 Service guarantees provided 4-2 Interface @@ -294,7 +294,7 @@ too. per-process ioprio and weight ----------------------------- -Unless the cgroups interface is used (see "4. BFQ group scheduling"), +Unless the cgroups interface is used (see "4. Group scheduling with BFQ"), weights can be assigned to processes only indirectly, through I/O priorities, and according to the relation: weight = (IOPRIO_BE_NR - ioprio) * 10. From patchwork Mon Nov 19 10:34:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10688457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB5691923 for ; Mon, 19 Nov 2018 10:35:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C05E287F8 for ; Mon, 19 Nov 2018 10:35:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F5DB294C4; Mon, 19 Nov 2018 10:35:23 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0941F287F8 for ; Mon, 19 Nov 2018 10:35:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728431AbeKSU6U (ORCPT ); Mon, 19 Nov 2018 15:58:20 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:53363 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728426AbeKSU6T (ORCPT ); Mon, 19 Nov 2018 15:58:19 -0500 Received: by mail-wm1-f65.google.com with SMTP id g131so4347008wmg.3 for ; Mon, 19 Nov 2018 02:35:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2PZH8WwXkvnGeOOTNTp/CB09k6USJvSSB6C0CaaMGjI=; b=hcuU6/VqTQwptGHjtIMvqO0p51x14o0CH8VynZz+6pAYFV8wdEQyx+ljlgfV6rV2w7 ITCCyWJsgcX5EmmWYweoyDAMoKM4kZS/0KIuLLINuDr3CFzBBAYSz+58G1YiRCRMTQrt ivc6Bbj1bt5nmThOu57faArw/3BCDnwjUELl8= 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=2PZH8WwXkvnGeOOTNTp/CB09k6USJvSSB6C0CaaMGjI=; b=tKWGN2H2EQXK5UX2xb+/ac9ThMLbrJaBnfTf8AF406rL4H6yjmd1KdyBFLSC6XTRhC 7f/1nfs7WNDxXq+naPX+JBG9Q3KvHBXfS0s4mpIyj+lCyOkb2QKFJ9XFwkbRgb1f+OKT /Lf4I1LRh8MKHGJRswfxBUY8+9UXwQX4YN12o+GwMmhU3IBuagpFGEeXV98grJDwfn+d xeAran4E7kZ5c3Qac0ErYQVTJs4d2zUYqCuMOskvJXaJgxpHNWvmDzy4cI1MDTeXpLbw A5sHuu0valS0++tDstmh6UpjFFLShUJysGT/EDoYcZJgj74PmIysUdIET/MxdqUFy2fk k/ZA== X-Gm-Message-State: AGRZ1gJClcXd31Y4C6/BPfBEIc4BpRl2rrOzhraIDvSQbnjGVd74Lyce vsBpDuhzT7EKLBfAtfuEQirIOw== X-Google-Smtp-Source: AFSGD/V/PzPvdMmgio2MMuksaWEdLCDo8SfjRuu380b7ZwE1q0ngjmXv93lavCq2gXUdRW2aWbo06w== X-Received: by 2002:a1c:ddc3:: with SMTP id u186mr6436592wmg.110.1542623705169; Mon, 19 Nov 2018 02:35:05 -0800 (PST) Received: from localhost.localdomain ([37.162.18.180]) by smtp.gmail.com with ESMTPSA id e9sm14973298wro.16.2018.11.19.02.35.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 02:35:04 -0800 (PST) From: Paolo Valente To: Jens Axboe , Greg Kroah-Hartman , Tejun Heo , Li Zefan , Angelo Ruocco , Dennis Zhou , Josef Bacik , Liu Bo , Bart Van Assche , Johannes Weiner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Paolo Valente Subject: [PATCH V2 10/10] doc, bfq-iosched: make it consistent with the new cgroup interface Date: Mon, 19 Nov 2018 11:34:24 +0100 Message-Id: <20181119103424.3853-11-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181119103424.3853-1-paolo.valente@linaro.org> References: <20181119103424.3853-1-paolo.valente@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP BFQ now shares interface files with CFQ, for the proportional-share policy. Make documentation consistent with that. Signed-off-by: Paolo Valente --- Documentation/block/bfq-iosched.txt | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Documentation/block/bfq-iosched.txt b/Documentation/block/bfq-iosched.txt index 6d7dd5ab8554..3d7ef138ce6a 100644 --- a/Documentation/block/bfq-iosched.txt +++ b/Documentation/block/bfq-iosched.txt @@ -508,12 +508,14 @@ process. To get proportional sharing of bandwidth with BFQ for a given device, BFQ must of course be the active scheduler for that device. -Within each group directory, the names of the files associated with -BFQ-specific cgroup parameters and stats begin with the "bfq." -prefix. So, with cgroups-v1 or cgroups-v2, the full prefix for -BFQ-specific files is "blkio.bfq." or "io.bfq." For example, the group -parameter to set the weight of a group with BFQ is blkio.bfq.weight -or io.bfq.weight. +BFQ uses the standard interface files of the proportional-share +policy, previously used by CFQ. If one such file is read/written, then +the operation associated with the file is performed by BFQ for each +device where BFQ is the active scheduler. In addition, BFQ is +configured so as to share interface files with other entities (if some +of these files does happen to be shared, then its associated operation +is performed also by any of the other entities that is using the +file). As for cgroups-v1 (blkio controller), the exact set of stat files created, and kept up-to-date by bfq, depends on whether @@ -521,13 +523,13 @@ CONFIG_DEBUG_BLK_CGROUP is set. If it is set, then bfq creates all the stat files documented in Documentation/cgroup-v1/blkio-controller.txt. If, instead, CONFIG_DEBUG_BLK_CGROUP is not set, then bfq creates only the files -blkio.bfq.io_service_bytes -blkio.bfq.io_service_bytes_recursive -blkio.bfq.io_serviced -blkio.bfq.io_serviced_recursive +blkio.io_service_bytes +blkio.io_service_bytes_recursive +blkio.io_serviced +blkio.io_serviced_recursive The value of CONFIG_DEBUG_BLK_CGROUP greatly influences the maximum -throughput sustainable with bfq, because updating the blkio.bfq.* +throughput sustainable with BFQ, because updating the blkio.* stats is rather costly, especially for some of the stats enabled by CONFIG_DEBUG_BLK_CGROUP. @@ -536,8 +538,8 @@ Parameters to set For each group, there is only the following parameter to set. -weight (namely blkio.bfq.weight or io.bfq-weight): the weight of the -group inside its parent. Available values: 1..10000 (default 100). The +weight (namely blkio.weight or io.weight): the weight of the group +inside its parent. Available values: 1..10000 (default 100). The linear mapping between ioprio and weights, described at the beginning of the tunable section, is still valid, but all weights higher than IOPRIO_BE_NR*10 are mapped to ioprio 0.