From patchwork Tue May 21 08:01:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10953115 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 4445313AD for ; Tue, 21 May 2019 08:02:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 369A828538 for ; Tue, 21 May 2019 08:02:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A994287D4; Tue, 21 May 2019 08:02:39 +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 AEE6728538 for ; Tue, 21 May 2019 08:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727132AbfEUICh (ORCPT ); Tue, 21 May 2019 04:02:37 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44318 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727122AbfEUICh (ORCPT ); Tue, 21 May 2019 04:02:37 -0400 Received: by mail-wr1-f67.google.com with SMTP id w13so6641974wru.11 for ; Tue, 21 May 2019 01:02:36 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=0Qyb2ZjHa3whLh+RqF+kWmGToKxa/X+H2gjIFhEE6sE=; b=m7bAU2KR9Hevmy1UDUpkxJIc6hl7VJkvHANJ8apIiHD0MPfPmeVhfmwmBiqv0xnW5U U7sBem1g0ZFi17AZiIyn5lr67YmFGZLtUGJT2Yi7AnOUTx06OheejUmpQDECITXRrOWA vF2TO5BlHjaWelNSh4tcisdtFMooSP8wv6xouAoYrmzEVqXWzH14BO0408AE/NX0qkyC bNSbwXYi/kHVOFV1S02n0+Q2fvHHqq/qTdIx2LBMlfXS2J50a2MXvHwJ8D9UtNg3wYaM 1ikr/rvUNlLo8YRBK3YoYJi0znS3KrI/WeIlqB+tN71t7f1OwE5jCANY38DY7RhUqVVm 9e9w== 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:mime-version:content-transfer-encoding; bh=0Qyb2ZjHa3whLh+RqF+kWmGToKxa/X+H2gjIFhEE6sE=; b=sO15r/KzSYMsSlmI0VNIVSDuD0XPyKls5/9G1KN1z8PHdPx2sVMFTConrNvDIML910 gC2LR8OJZZlD7p5InO80KRJH6AFfrr0+99AHVMTaByUsbiXlGuJ0bmxva8NNuNC7qtY5 WewsCt7+StzQWMb73dwYTGGsTpJ4crCtrQrgmGq5XfZ5hve68CQYgGRKaUgQ93UWKZ0L 1fLM1osgTSDKf/R/jqgv2uqYmCMeiyrNWubPZM1ypmhImro87CMotCnt9LbXF/uw3RLU 0HiNWS+qPxF0jWJ6OfKywzXDOuV/Oy+dD2zREdoTgQ0F5nXJrxYlJ2K9ZbhDIIaGeHOL Ixsg== X-Gm-Message-State: APjAAAWWPP2v3bnqqpJiFQV8B1MdrScZwZy8e3u67nKg8AildVb2FOKX KfztS6/sr3iLYxM/4fh68FAQHIOBMYI= X-Google-Smtp-Source: APXvYqxQvIFwezlmIsaefzH0JpE22nHQ3G2Kc1TFLSAI7PUr2y4W50DvNzt5ZshZd4aBp6JoZsV48w== X-Received: by 2002:a5d:4004:: with SMTP id n4mr15547070wrp.240.1558425755326; Tue, 21 May 2019 01:02:35 -0700 (PDT) Received: from localhost.localdomain ([88.147.35.136]) by smtp.gmail.com with ESMTPSA id p8sm11322301wro.0.2019.05.21.01.02.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 01:02:34 -0700 (PDT) From: Paolo Valente To: Jens Axboe 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, Angelo Ruocco , Paolo Valente Subject: [PATCH 1/2] cgroup: let a symlink too be created with a cftype file Date: Tue, 21 May 2019 10:01:54 +0200 Message-Id: <20190521080155.36178-2-paolo.valente@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190521080155.36178-1-paolo.valente@linaro.org> References: <20190521080155.36178-1-paolo.valente@linaro.org> MIME-Version: 1.0 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 This commit enables a cftype to have a symlink (of any name) that points to the file associated with the cftype. Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- include/linux/cgroup-defs.h | 3 +++ kernel/cgroup/cgroup.c | 33 +++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 77258d276f93..2ad9f53ecefe 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -101,6 +101,8 @@ enum { CFTYPE_WORLD_WRITABLE = (1 << 4), /* (DON'T USE FOR NEW FILES) S_IWUGO */ CFTYPE_DEBUG = (1 << 5), /* create when cgroup_debug */ + CFTYPE_SYMLINKED = (1 << 6), /* pointed to by symlink too */ + /* 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 */ @@ -538,6 +540,7 @@ struct cftype { * end of cftype array. */ char name[MAX_CFTYPE_NAME]; + char link_name[MAX_CFTYPE_NAME]; unsigned long private; /* diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 217cec4e22c6..f77dee5eb82a 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -1460,8 +1460,8 @@ struct cgroup *task_cgroup_from_root(struct task_struct *task, static struct kernfs_syscall_ops cgroup_kf_syscall_ops; -static char *cgroup_file_name(struct cgroup *cgrp, const struct cftype *cft, - char *buf) +static char *cgroup_fill_name(struct cgroup *cgrp, const struct cftype *cft, + char *buf, bool write_link_name) { struct cgroup_subsys *ss = cft->ss; @@ -1471,13 +1471,26 @@ static char *cgroup_file_name(struct cgroup *cgrp, const struct cftype *cft, snprintf(buf, CGROUP_FILE_NAME_MAX, "%s%s.%s", dbg, cgroup_on_dfl(cgrp) ? ss->name : ss->legacy_name, - cft->name); + write_link_name ? cft->link_name : cft->name); } else { - strscpy(buf, cft->name, CGROUP_FILE_NAME_MAX); + strscpy(buf, write_link_name ? cft->link_name : cft->name, + CGROUP_FILE_NAME_MAX); } return buf; } +static char *cgroup_file_name(struct cgroup *cgrp, const struct cftype *cft, + char *buf) +{ + return cgroup_fill_name(cgrp, cft, buf, false); +} + +static char *cgroup_link_name(struct cgroup *cgrp, const struct cftype *cft, + char *buf) +{ + return cgroup_fill_name(cgrp, cft, buf, true); +} + /** * cgroup_file_mode - deduce file mode of a control file * @cft: the control file in question @@ -1636,6 +1649,9 @@ static void cgroup_rm_file(struct cgroup *cgrp, const struct cftype *cft) } kernfs_remove_by_name(cgrp->kn, cgroup_file_name(cgrp, cft, name)); + if (cft->flags & CFTYPE_SYMLINKED) + kernfs_remove_by_name(cgrp->kn, + cgroup_link_name(cgrp, cft, name)); } /** @@ -3809,6 +3825,7 @@ static int cgroup_add_file(struct cgroup_subsys_state *css, struct cgroup *cgrp, { char name[CGROUP_FILE_NAME_MAX]; struct kernfs_node *kn; + struct kernfs_node *kn_link; struct lock_class_key *key = NULL; int ret; @@ -3839,6 +3856,14 @@ static int cgroup_add_file(struct cgroup_subsys_state *css, struct cgroup *cgrp, spin_unlock_irq(&cgroup_file_kn_lock); } + if (cft->flags & CFTYPE_SYMLINKED) { + kn_link = kernfs_create_link(cgrp->kn, + cgroup_link_name(cgrp, cft, name), + kn); + if (IS_ERR(kn_link)) + return PTR_ERR(kn_link); + } + return 0; } From patchwork Tue May 21 08:01:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10953117 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 A04571395 for ; Tue, 21 May 2019 08:02:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92DD3289A3 for ; Tue, 21 May 2019 08:02:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 805402899F; Tue, 21 May 2019 08:02:47 +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 229FE28988 for ; Tue, 21 May 2019 08:02:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727202AbfEUICm (ORCPT ); Tue, 21 May 2019 04:02:42 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:37757 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725790AbfEUICl (ORCPT ); Tue, 21 May 2019 04:02:41 -0400 Received: by mail-wm1-f68.google.com with SMTP id 7so1814644wmo.2 for ; Tue, 21 May 2019 01:02:40 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=DOhhDvGFx5TQBrV3vUuuJNqU81qFULp2qAUcY70tdpo=; b=U5lZgDhD03GpNQCNQxmESbv9lWfJZcDrizZYolBCQqWW/xEYt9UwLILokyg8eZw2fv OoHDixUXEs4MfaUj9VCaYKeLQ6CgxSEf+3dN3WetIPP+SUCRY7n1qJjhUO9i7So752mT eOVjY3sdJA+kTXkPvE52Mc0lf6Qz9kuRXbijZTvxFeFXk/rtACX7jccmZp1RgxGZpYNb R8icSFl8ioKe7x+3GqeaG1+kGo2RQ5tP0EH7tAtsrz9RlLQT0gbcEiXM0C89oq41RMxJ 131Ipwk/vsUv5tD+3ALHha2SVRHMkreikP5BaMJXOjM6YlJ28mWz/Gj0x3kuklYPyrNb hU3A== 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:mime-version:content-transfer-encoding; bh=DOhhDvGFx5TQBrV3vUuuJNqU81qFULp2qAUcY70tdpo=; b=S42pJUsomWjoyrb/lT99yelXxzToVMyCVp8ltymNV/xzNQ29g5uI413lWlvuOaXwOa f5/DdEJHBphncIyfS12fhN9ebYNdUPjL8dw6YSuZAa3t2O5OwdvB/0I2NyQit7m/H89S w61v95ocXsustgPQI/gc6OG62MnMlE75bYWvKVCLMGLR6edyGf7336aokAlr2JMSylB7 SB3lokYr+U4H2bzg1ThETco3O71kD+Xzq+oZznwS/EG2yPKmziikvKu+3pS45IFqqoHo GuTOlDBg8WQ+2YkmveIl4poEF7LTjKtklW9/Q9+qYjQz+6WzhZTlUr3kge2rMN4G3xTn Iimw== X-Gm-Message-State: APjAAAVjM1iisAR+36YdcPUzOOiuEfylCTAD6K39hcrKDf/XKjEmc9l3 qn6z4+7lZ3GV/RIPFcv8fyRHZw== X-Google-Smtp-Source: APXvYqyspoPg9SEqm8OAK4EKMduyZ0wkoaz46tnzvrFz0D5YKN4kzgcvCqAOYUkBdjzY7BugddgXkw== X-Received: by 2002:a1c:3287:: with SMTP id y129mr2330502wmy.153.1558425759355; Tue, 21 May 2019 01:02:39 -0700 (PDT) Received: from localhost.localdomain ([88.147.35.136]) by smtp.gmail.com with ESMTPSA id p8sm11322301wro.0.2019.05.21.01.02.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 01:02:38 -0700 (PDT) From: Paolo Valente To: Jens Axboe 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, Angelo Ruocco , Johannes Thumshirn , Paolo Valente Subject: [PATCH 2/2] block, bfq: add weight symlink to the bfq.weight cgroup parameter Date: Tue, 21 May 2019 10:01:55 +0200 Message-Id: <20190521080155.36178-3-paolo.valente@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190521080155.36178-1-paolo.valente@linaro.org> References: <20190521080155.36178-1-paolo.valente@linaro.org> MIME-Version: 1.0 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 Many userspace tools and services use the proportional-share policy of the blkio/io cgroups controller. The CFQ I/O scheduler implemented this policy for the legacy block layer. To modify the weight of a group in case CFQ was in charge, the 'weight' parameter of the group must be modified. On the other hand, the BFQ I/O scheduler implements the same policy in blk-mq, but, with BFQ, the parameter to modify has a different name: bfq.weight (forced choice until legacy block was present, because two different policies cannot share a common parameter in cgroups). Due to CFQ legacy, most if not all userspace configurations still use the parameter 'weight', and for the moment do not seem likely to be changed. But, when CFQ went away with legacy block, such a parameter ceased to exist. So, a simple workaround has been proposed [1] to make all configurations work: add a symlink, named weight, to bfq.weight. This commit adds such a symlink. [1] https://lkml.org/lkml/2019/4/8/555 Suggested-by: Johannes Thumshirn Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- block/bfq-cgroup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index b3796a40a61a..59f46904cb11 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -1046,7 +1046,8 @@ struct blkcg_policy blkcg_policy_bfq = { struct cftype bfq_blkcg_legacy_files[] = { { .name = "bfq.weight", - .flags = CFTYPE_NOT_ON_ROOT, + .link_name = "weight", + .flags = CFTYPE_NOT_ON_ROOT | CFTYPE_SYMLINKED, .seq_show = bfq_io_show_weight, .write_u64 = bfq_io_set_weight_legacy, }, @@ -1166,7 +1167,8 @@ struct cftype bfq_blkcg_legacy_files[] = { struct cftype bfq_blkg_files[] = { { .name = "bfq.weight", - .flags = CFTYPE_NOT_ON_ROOT, + .link_name = "weight", + .flags = CFTYPE_NOT_ON_ROOT | CFTYPE_SYMLINKED, .seq_show = bfq_io_show_weight, .write = bfq_io_set_weight, },