From patchwork Mon Nov 12 09:56: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: 150800 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2947710ljp; Mon, 12 Nov 2018 01:57:10 -0800 (PST) X-Google-Smtp-Source: AJdET5dI+QBZTL3qpqr1Dj6kAocrUU2w2Qx9HguWTFvoa5wtMxvmbrBhP1/A3SSLrazHIN8iwV5I X-Received: by 2002:a17:902:ab81:: with SMTP id f1-v6mr282971plr.103.1542016630013; Mon, 12 Nov 2018 01:57:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542016630; cv=none; d=google.com; s=arc-20160816; b=bk7LHeaQdbkDjTpHWMsR7yaxfwikYNPLAfKrhySReNXj5un6bqNmptKqWtk4S1Ylx1 H+I7kKM92pJNe8eeaCEiId9jhTlBggofqkeanuw35inobPnjvo41YzGdkSukig9AoMPe 29ifUPeCW7PQf+ZqJt9wSTXuTJMWrvF/ROGKgZ/AxYbDj9LgRyZTSwVLCP8AoxM4A+HB q6Ktjnhc6YWCO5WOVYFPGgQqWDNs/RSiFxK0Xg33xnWL2TkJaWtht8J9+6gqnwZF1oZ4 xWiwQTG7HC8TbbrL38x10bIrgJAz27+5IqZHvqpx5GhhPh+QvmVfEEfoNIDOLbYBeBAa 9UBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=gEkvf3D0ybtQ1XCiNuNOR20e0/KEmaDMFTtp87FuqbE=; b=cSh/ajqZzKe9fp8zO38STfDNERqek832xtpbod3tEnL42x6OQs4vV411/46Ua/PtmC QRNigyyAZ6k48/opt6AIQcobcGSFD8KeRZWZV1b+t/8DC5Gyqglkto4NxNMsNRJO8EyX byxwEJJdbfMmWBH8SYIFN+nM/rOE6WXwxHoqICFq0aThU68Uvj/iwZ/vkrmW+bXgAECU 7s7J2tXCjkyKCiFX6ReOPYikqMdE5RLLQJP+UVz+js2/wcbs8CVgOVrDm0QA8vuivvbu bWT7j3KlZj6B69NrLgOyjxIOIBhpijz1e8CvgGpaFxeYqfl1aHm6+wZuB5XX4xwpbUZq 5KbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N8KkHvWq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h13-v6si16137413pgj.457.2018.11.12.01.57.09; Mon, 12 Nov 2018 01:57:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N8KkHvWq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728436AbeKLTtf (ORCPT + 32 others); Mon, 12 Nov 2018 14:49:35 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:53820 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728268AbeKLTte (ORCPT ); Mon, 12 Nov 2018 14:49:34 -0500 Received: by mail-wm1-f65.google.com with SMTP id f10-v6so7787163wme.3 for ; Mon, 12 Nov 2018 01:57: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=gEkvf3D0ybtQ1XCiNuNOR20e0/KEmaDMFTtp87FuqbE=; b=N8KkHvWqCG3FPBQKMMKSv7Pg/NLzZZA7xMvcJW6U01Wj0GNYTuJeCcya4ODW4IlfDY bjeINPfviBlUjWGw0A/F1Z2j5xFDixkEn+Wq8pjVDa2f0IyCUhwOwJnWnNFIaWBeVVTq d85CwbZ1TDnYV7195SRPVFTFCEtIMsDAzsBRA= 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=gEkvf3D0ybtQ1XCiNuNOR20e0/KEmaDMFTtp87FuqbE=; b=lD60VaFG6xAAtb1WpH992IKiEtaxXhB9pmOzX6udt4FEG1adb7mkbaugKMn7zcczpv 1oj1pB95sHzEP2/W1+xhAVRSORgZonttpFhYsYFsDL7ZS9RMVpLn9YWYIWxiOH/0uxiV DoN+JAeN69d9SKZf9X5KxOpuAMTXagl3tvTRPp/8Eqw2Qewfd6AHlk8idFCZ3MRrmhY+ x1QONpqO3vVM8K/Rx0yKIHXX9L004ffF/ghYVJHJcH9Tduq0xAWSB2GvzGkK5iMsdsMW 4XAMAfFxCX3W2pHwlVj9GWk3cUODet0rGQjbY1b5oX+mA82sFQaiShU6VhPc/8sCXu5L Thbw== X-Gm-Message-State: AGRZ1gIbvnyi+8EclyIZBR4wZEEGpJCVa0WVQxe5VtSqppbxJWuDznp6 jsM2Xffd/ZjWFbz6hheJNzES8w== X-Received: by 2002:a1c:3954:: with SMTP id g81-v6mr6728831wma.139.1542016624983; Mon, 12 Nov 2018 01:57:04 -0800 (PST) Received: from localhost.localdomain ([93.68.220.21]) by smtp.gmail.com with ESMTPSA id r14-v6sm21273089wro.8.2018.11.12.01.57.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 01:57: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 01/12] kernfs: add function to find kernfs_node without increasing ref counter Date: Mon, 12 Nov 2018 10:56:21 +0100 Message-Id: <20181112095632.69114-2-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181112095632.69114-1-paolo.valente@linaro.org> References: <20181112095632.69114-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Angelo Ruocco The kernfs pseudo file system doesn't export any function to only find a node by name, without also getting a reference on it. But in some cases it is useful to just locate a kernfs node, while using it or not depends on some other condition. This commit adds a function to just look for a node, without getting a reference on it. Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- fs/kernfs/dir.c | 13 +++++++++++++ include/linux/kernfs.h | 7 +++++++ 2 files changed, 20 insertions(+) -- 2.16.1 diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 4ca0b5c18192..0003c665869d 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -892,6 +892,19 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent, return parent; } +struct kernfs_node *kernfs_find(struct kernfs_node *parent, + const unsigned char *name) +{ + struct kernfs_node *kn; + + mutex_lock(&kernfs_mutex); + kn = kernfs_find_ns(parent, name, NULL); + mutex_unlock(&kernfs_mutex); + + return kn; +} +EXPORT_SYMBOL_GPL(kernfs_find); + /** * kernfs_find_and_get_ns - find and get kernfs_node with the given name * @parent: kernfs_node to search under diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h index 5b36b1287a5a..26e69d285964 100644 --- a/include/linux/kernfs.h +++ b/include/linux/kernfs.h @@ -309,6 +309,8 @@ void pr_cont_kernfs_path(struct kernfs_node *kn); struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn); struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name, const void *ns); +struct kernfs_node *kernfs_find(struct kernfs_node *parent, + const unsigned char *name); struct kernfs_node *kernfs_walk_and_get_ns(struct kernfs_node *parent, const char *path, const void *ns); void kernfs_get(struct kernfs_node *kn); @@ -391,6 +393,11 @@ static inline struct kernfs_node * kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name, const void *ns) { return NULL; } + +static inline struct kernfs_node * +kernfs_find(struct kernfs_node *parent, const char *name) +{ return NULL; } + static inline struct kernfs_node * kernfs_walk_and_get_ns(struct kernfs_node *parent, const char *path, const void *ns) From patchwork Mon Nov 12 09:56: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: 150801 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2947752ljp; Mon, 12 Nov 2018 01:57:12 -0800 (PST) X-Google-Smtp-Source: AJdET5ertwnxhLLQu6r2l5Z3PyziBk5mt2/lYxdSN6capcHgFXLCySz5LQpT5WNIm8oUGrZi1ONW X-Received: by 2002:a17:902:70cb:: with SMTP id l11-v6mr321059plt.30.1542016632612; Mon, 12 Nov 2018 01:57:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542016632; cv=none; d=google.com; s=arc-20160816; b=TdXftU8/DM54vcNdVgRmjlamaldNqnhFZvtzN34MtUR3qMvL9uvzT1or4vcwoJ+xzA c852B3vBZriHX/X/YeCIWYR/nQkFoEf6Z3cxCfdcCug6P42MpjGEkk6CiuclHWdKozLs qBR/b8DW5nhwrIEd+r1FGXkZEuvUMOz8ZsWEnK/quSbnovftgFGscMsRvvk8HKzGNkFf Or+QDkOU+BwEotwnJ6rUcbVd9Snn5fbor+G7qO0DQwxOED66KK+YSPzOBrzwJcQX4lqh YtpzZeOtqF9h2xTrg3M4RiuBteLLQbFCTsgapoKxUG4UVTlCtbpmv1CrHNIaeJOuVVM1 5YEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=rpZR9mJwWH7OFtYLISHMCJG8f05AVkaLjpshd/8XLBg=; b=lYC6D6KTM3zwYYP/LQilk0OYZCginNV/T/WVxuHR5Yw0w5FV/iy4hLnTjkDWtAMM8K hm8LlGOITcdUmFyOyuJpvCltj/Et49Lrk4RYEjjRWZLk/4NMaLYpHQ2VpyQMaeK6j3mr 7lCfC8C7JwaDebIrUlZwubdnISNazUuHyCph43z/OHLyqRvcBht1ELQ7Z0FWsc0CDzZ7 ygBuRYcnvVH0I9jIuEE+11iQSOP+hw98tYEK7UR3yhvPnDJmy12mDOX6YX7chSbIlOzO QeEZiG9OaJqMBQ9ZKpZiEG7uF4mwltjE5GO/RNghtpMoKoHrywtn2wtbjpoX0JlbALcn L3Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QDGg0Xfc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h13-v6si16137413pgj.457.2018.11.12.01.57.12; Mon, 12 Nov 2018 01:57:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QDGg0Xfc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728752AbeKLTti (ORCPT + 32 others); Mon, 12 Nov 2018 14:49:38 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:35802 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728518AbeKLTth (ORCPT ); Mon, 12 Nov 2018 14:49:37 -0500 Received: by mail-wm1-f67.google.com with SMTP id t15-v6so7516385wmt.0 for ; Mon, 12 Nov 2018 01:57:08 -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=rpZR9mJwWH7OFtYLISHMCJG8f05AVkaLjpshd/8XLBg=; b=QDGg0Xfc28PGvnVlOCCcIqTsT8u+2STJ/BRHsU4TWNb0Qf39eUTzZBIPZWewRac+F9 r48HnFML9ikjsTAzSxVkv0tFmaCQtYLBMHy0CbrhczPcXAlEm1vn9O3ROOQfl4KxKeZt qrhsIG/0OD+gZ8HfdS87YYirC8OfV4zYGI4ck= 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=rpZR9mJwWH7OFtYLISHMCJG8f05AVkaLjpshd/8XLBg=; b=FVOOjcmyClJSJtzv3ONmA4NRWaW5DDr9gNd2Tj89dbQXDL4wUS6qXUTIDMSBlBk2W2 rtvEOzMwwmO4yiNQa3UmzgsEN7er1PA+21PS2lBdSGypU3j4wmjGnhB0uMani69kLdo+ hq3UCum8bqipBlgnbX96oYDd+aKyRP3A+HlCv6fpcgMp0Qtd5jTEudpn49AXXSmCSZK5 2n+Zwo9Py/YFeCnoMRPGKNZVMlLjk/9muH3PuH9Rb5hgXLqlb9uv1br0B7/rflCQhKgh FxZ3WKTKJ8ksfJ1b+ROgz6quuKO7G8VaDyu8d/+Tx6q6uVUYCMxFgJjF/hBp1FuVd93A nc/A== X-Gm-Message-State: AGRZ1gJP6jLjB/GS/ikv5V+bOi8TxdYlkYdeAphz1IfK7Ve4sjjapIiF GvY7l/YtFkbn6sThjRikfaUO4A== X-Received: by 2002:a1c:2097:: with SMTP id g145-v6mr6949615wmg.57.1542016627706; Mon, 12 Nov 2018 01:57:07 -0800 (PST) Received: from localhost.localdomain ([93.68.220.21]) by smtp.gmail.com with ESMTPSA id r14-v6sm21273089wro.8.2018.11.12.01.57.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 01:57:07 -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 02/12] cgroup: add hook seq_show_cft with also the owning cftype as parameter Date: Mon, 12 Nov 2018 10:56:22 +0100 Message-Id: <20181112095632.69114-3-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181112095632.69114-1-paolo.valente@linaro.org> References: <20181112095632.69114-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.16.1 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 8b79318810ad..74012b61fe19 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -1448,7 +1448,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) { @@ -3549,17 +3550,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 12 09:56: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: 150802 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2947798ljp; Mon, 12 Nov 2018 01:57:17 -0800 (PST) X-Google-Smtp-Source: AJdET5cITgCbbUFn5p3y+D7QxJqnwwtw01Hw6VmlvYnauPY2kKU5scgmcxGL1QD14SbPYFedo5Ww X-Received: by 2002:a63:db02:: with SMTP id e2mr228189pgg.419.1542016636929; Mon, 12 Nov 2018 01:57:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542016636; cv=none; d=google.com; s=arc-20160816; b=BggnlzBZQZGBwfA+abERejujiCGNl686jMkcNI9ClAGxmHY1jklHNyXtKQsyHAPwMK B69qi8ACO3xWaIRSm2ZFQPAJ3ErDyQZh576r4mKUbcA3B8EtwD5xhP5nHyMb5yUKRLwM T3nWrTKmSmZfkYWYwWcRieVCnUzk4qPjYo35ouputlPmHYIoExmlin9G0f424z9D0MiQ eQnPJNHbybwGqU77fIg37N00T01VLkFjST2MkNsSfa2OTpCJRMlsjQPjnS5ERuHo9b2k 0YrJVVZ9kFhyAbG+m8DLfvV/PPxI+5wrM3lwRcjGEJZbFPGravLraPSDmhc2MLoDU9lY OSCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=8xbRyM6QwPa7TVZsyiZmOJOApeuwNEt2y2o/S0ePHa0=; b=WlDVmpP55ehZJMCFoO+R8vIm2SruWAQKY8xQs20xkJQHnm5t+S/D4Z69H4NWR2f8SI z65izdv1+U6ZuJYemqvBWN5os+sZvcYZv6iYCIPBxEgLozVqx3F9BSelvg98HAjeWlSG p0Q/xjpOpZHNE5X72HtQ4jrfB9Ak3iQbQCwU8TmPpUTLdAyp6fi4hMRRh5eXaZvCOtGR X9CWBUW92j0M6ik78qp66PTod4mr05nvFs/5icfBwsgCxmjruhoJPtFbdHR+ZlcCdwja +5xnIkCUbSHc+2ebeEeqb1/1hnyxzza3tZjwzIFGUZSLzrCd82r/qcHNW6FhJuCXzzSy dKPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EmNZZwfN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si14799113pgk.201.2018.11.12.01.57.16; Mon, 12 Nov 2018 01:57:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EmNZZwfN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729130AbeKLTtm (ORCPT + 32 others); Mon, 12 Nov 2018 14:49:42 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:52843 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728518AbeKLTtl (ORCPT ); Mon, 12 Nov 2018 14:49:41 -0500 Received: by mail-wm1-f68.google.com with SMTP id r11-v6so7787821wmb.2 for ; Mon, 12 Nov 2018 01:57:11 -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=8xbRyM6QwPa7TVZsyiZmOJOApeuwNEt2y2o/S0ePHa0=; b=EmNZZwfNxLXK+P6tQx6apBYGQYeD6C8RIa624keJp1BJlk5x/qN/qirqT4XkSmOAkq /+MRYyGr+IN8WALypACSG/I8SRvN90v3VTp3FyYlO2QfuIuX257rruignxy0lyfCdeZH T934WlYeKBKyynLJaUKmGv3j+IPC6QaR8kzFw= 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=8xbRyM6QwPa7TVZsyiZmOJOApeuwNEt2y2o/S0ePHa0=; b=b+AN5fsSMoEpnniWEzxFvGX3NZcEbY0yb5tOdyqX40kza+sVt5q5ssQRN4C2eSsUtk /3hzByiIblsrULQoWMPW956EWZDgZv1cRTHZ6DqNp7VFnjUXeAxLZcp06SnQoZx1NRnI SpE2SSS7FxoWkK6IvA0ddCs/n/unPfR36gnueJ4kVgIJWvQxa2VISlZOqhATXObk+zhy 9sIjgtcEz4u3aY+3oGxTDhMZZ6qY7+yVW/JvM1AF+dzPdPyYx3uaK98LsCXpRr2SL59m YRv3VX/JEawyV5qkzqUjFwcqL6fOd8+TMmZIH2ORDmnAz+Jj6KeOlmE8lgdiVYiPQcIN OtJQ== X-Gm-Message-State: AGRZ1gJOm+jO0bShAxOjfYZnFp2pdTk7by1CWWJze90kCByuw5LttGh6 0AI8Qu3cvqu1eqeVIJMV9w/87g== X-Received: by 2002:a1c:ae4a:: with SMTP id x71-v6mr6982936wme.125.1542016630787; Mon, 12 Nov 2018 01:57:10 -0800 (PST) Received: from localhost.localdomain ([93.68.220.21]) by smtp.gmail.com with ESMTPSA id r14-v6sm21273089wro.8.2018.11.12.01.57.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 01:57:09 -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 03/12] block, cgroup: pass cftype to functions that need to use it Date: Mon, 12 Nov 2018 10:56:23 +0100 Message-Id: <20181112095632.69114-4-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181112095632.69114-1-paolo.valente@linaro.org> References: <20181112095632.69114-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 +++---- block/cfq-iosched.c | 56 ++++++++++++++++++++++++---------------------- include/linux/blk-cgroup.h | 10 +++++---- 5 files changed, 81 insertions(+), 69 deletions(-) -- 2.16.1 diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index d9a7916ff0ab..50b2d7ba6b9d 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 992da5592c6e..f173e7437203 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -667,15 +667,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; } @@ -684,15 +685,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; } @@ -710,13 +712,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; } @@ -725,13 +729,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 4bda70e8db48..5c43821dc528 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/block/cfq-iosched.c b/block/cfq-iosched.c index 6a3d87dd3c1a..af0c59c2dcde 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -1884,17 +1884,17 @@ static int cfq_set_leaf_weight(struct cgroup_subsys_state *css, return __cfq_set_weight(css, val, false, false, true); } -static int cfqg_print_stat(struct seq_file *sf, void *v) +static int cfqg_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_cfq, seq_cft(sf)->private, false); + &blkcg_policy_cfq, cft->private, false); return 0; } -static int cfqg_print_rwstat(struct seq_file *sf, void *v) +static int cfqg_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_cfq, seq_cft(sf)->private, true); + &blkcg_policy_cfq, cft->private, true); return 0; } @@ -1914,19 +1914,21 @@ static u64 cfqg_prfill_rwstat_recursive(struct seq_file *sf, return __blkg_prfill_rwstat(sf, pd, &sum); } -static int cfqg_print_stat_recursive(struct seq_file *sf, void *v) +static int cfqg_print_stat_recursive(struct seq_file *sf, struct cftype *cft, + void *v) { blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), cfqg_prfill_stat_recursive, &blkcg_policy_cfq, - seq_cft(sf)->private, false); + cft->private, false); return 0; } -static int cfqg_print_rwstat_recursive(struct seq_file *sf, void *v) +static int cfqg_print_rwstat_recursive(struct seq_file *sf, struct cftype *cft, + void *v) { blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), cfqg_prfill_rwstat_recursive, &blkcg_policy_cfq, - seq_cft(sf)->private, true); + cft->private, true); return 0; } @@ -2034,7 +2036,7 @@ static struct cftype cfq_blkcg_legacy_files[] = { { .name = "time", .private = offsetof(struct cfq_group, stats.time), - .seq_show = cfqg_print_stat, + .seq_show_cft = cfqg_print_stat, }, { .name = "sectors", @@ -2043,39 +2045,39 @@ static struct cftype cfq_blkcg_legacy_files[] = { { .name = "io_service_bytes", .private = (unsigned long)&blkcg_policy_cfq, - .seq_show = blkg_print_stat_bytes, + .seq_show_cft = blkg_print_stat_bytes, }, { .name = "io_serviced", .private = (unsigned long)&blkcg_policy_cfq, - .seq_show = blkg_print_stat_ios, + .seq_show_cft = blkg_print_stat_ios, }, { .name = "io_service_time", .private = offsetof(struct cfq_group, stats.service_time), - .seq_show = cfqg_print_rwstat, + .seq_show_cft = cfqg_print_rwstat, }, { .name = "io_wait_time", .private = offsetof(struct cfq_group, stats.wait_time), - .seq_show = cfqg_print_rwstat, + .seq_show_cft = cfqg_print_rwstat, }, { .name = "io_merged", .private = offsetof(struct cfq_group, stats.merged), - .seq_show = cfqg_print_rwstat, + .seq_show_cft = cfqg_print_rwstat, }, { .name = "io_queued", .private = offsetof(struct cfq_group, stats.queued), - .seq_show = cfqg_print_rwstat, + .seq_show_cft = cfqg_print_rwstat, }, /* the same statictics which cover the cfqg and its descendants */ { .name = "time_recursive", .private = offsetof(struct cfq_group, stats.time), - .seq_show = cfqg_print_stat_recursive, + .seq_show_cft = cfqg_print_stat_recursive, }, { .name = "sectors_recursive", @@ -2084,32 +2086,32 @@ static struct cftype cfq_blkcg_legacy_files[] = { { .name = "io_service_bytes_recursive", .private = (unsigned long)&blkcg_policy_cfq, - .seq_show = blkg_print_stat_bytes_recursive, + .seq_show_cft = blkg_print_stat_bytes_recursive, }, { .name = "io_serviced_recursive", .private = (unsigned long)&blkcg_policy_cfq, - .seq_show = blkg_print_stat_ios_recursive, + .seq_show_cft = blkg_print_stat_ios_recursive, }, { .name = "io_service_time_recursive", .private = offsetof(struct cfq_group, stats.service_time), - .seq_show = cfqg_print_rwstat_recursive, + .seq_show_cft = cfqg_print_rwstat_recursive, }, { .name = "io_wait_time_recursive", .private = offsetof(struct cfq_group, stats.wait_time), - .seq_show = cfqg_print_rwstat_recursive, + .seq_show_cft = cfqg_print_rwstat_recursive, }, { .name = "io_merged_recursive", .private = offsetof(struct cfq_group, stats.merged), - .seq_show = cfqg_print_rwstat_recursive, + .seq_show_cft = cfqg_print_rwstat_recursive, }, { .name = "io_queued_recursive", .private = offsetof(struct cfq_group, stats.queued), - .seq_show = cfqg_print_rwstat_recursive, + .seq_show_cft = cfqg_print_rwstat_recursive, }, #ifdef CONFIG_DEBUG_BLK_CGROUP { @@ -2119,27 +2121,27 @@ static struct cftype cfq_blkcg_legacy_files[] = { { .name = "group_wait_time", .private = offsetof(struct cfq_group, stats.group_wait_time), - .seq_show = cfqg_print_stat, + .seq_show_cft = cfqg_print_stat, }, { .name = "idle_time", .private = offsetof(struct cfq_group, stats.idle_time), - .seq_show = cfqg_print_stat, + .seq_show_cft = cfqg_print_stat, }, { .name = "empty_time", .private = offsetof(struct cfq_group, stats.empty_time), - .seq_show = cfqg_print_stat, + .seq_show_cft = cfqg_print_stat, }, { .name = "dequeue", .private = offsetof(struct cfq_group, stats.dequeue), - .seq_show = cfqg_print_stat, + .seq_show_cft = cfqg_print_stat, }, { .name = "unaccounted_time", .private = offsetof(struct cfq_group, stats.unaccounted_time), - .seq_show = cfqg_print_stat, + .seq_show_cft = cfqg_print_stat, }, #endif /* CONFIG_DEBUG_BLK_CGROUP */ { } /* terminate */ diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index 1e76ceebeb5d..7e016338724e 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -212,10 +212,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 12 09:56: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: 150803 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2947844ljp; Mon, 12 Nov 2018 01:57:21 -0800 (PST) X-Google-Smtp-Source: AJdET5f3mf+B6QCcKKuuR0EFd6wzV59WdVwnMwYsELIw6cWbOhKfYgrBSH/Jem1bdNTkShcOGrEW X-Received: by 2002:a62:20c1:: with SMTP id m62-v6mr269061pfj.111.1542016641725; Mon, 12 Nov 2018 01:57:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542016641; cv=none; d=google.com; s=arc-20160816; b=sB7T26sTcYaguyL/nY0CpE5DikCkk77TXWONs2Y+O1o+FcyyHbfz3p8sYrGg599dfd RiXDY6F+2zJCLqR6dHdgdxTms1xO8u57l2SJRNQydPDuA7/CuCpwBSR/pjW10HcLUhmW nEtLtkSFtmPhZUkejeSkZyWELHUOaJM3yCN9LSDzYrqcMHXGHXlgDXtZDxoq30++r4Se 5OdOnju/Yn7JCEIy/IRjf9BLDNTmjuNk3TrCdBw9Vph2aJD0HTReUZd13mJ8j6akjMs0 1+FhOdSVNTkLtAhGb8PcJv8cuWREAXNoaz6pZCcDPMVFhqwIjGYuN4y9tyzsq2HvkK8b ew4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=symMBI0AEZzZj3jXIeKSzDkA196PYWRtmcxOC8y15f0=; b=CEd+1etEgUeFunXgGfKn5VoWFOcAw43b11gEpHr1UpvSG+sp9J4IMGfughntWVJvSf PEUk8Rjz2coQD7/CEC91Sk4HxGkyHEqToWHw6axtLMj58r+jHev5+HgHKjp6Q8Rhc5j8 foQ2ngal4oLoNSTzak413lwlHTHItBPYftZSAqQADoOj/TwhmijPM41rDAo9LnwBUbO5 /+PwcDT8AEToAGsFTOEOEKr6Rl3QcNTyGVEk0002wkFZtPPSQTenDQdliWT0wMXo7beD hAnpjzKqaJia+P1uGYWGsGUONO13jtGta9Sz+UdV2WQ0h6H3uxlS0AwsnMNc8pFsDlCU mHfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PLZQsYk8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o68-v6si11379750pfb.269.2018.11.12.01.57.21; Mon, 12 Nov 2018 01:57:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PLZQsYk8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729234AbeKLTtr (ORCPT + 32 others); Mon, 12 Nov 2018 14:49:47 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37080 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728810AbeKLTtn (ORCPT ); Mon, 12 Nov 2018 14:49:43 -0500 Received: by mail-wr1-f65.google.com with SMTP id o15-v6so8559267wrv.4 for ; Mon, 12 Nov 2018 01:57:14 -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=symMBI0AEZzZj3jXIeKSzDkA196PYWRtmcxOC8y15f0=; b=PLZQsYk8zx5Q6H+H+XLenq9zy5WTTXzbjsINOjU45dyhex93N5hCav2aGJsu5FmV2p TwXAeQNkschEKoKPJaFtk3IKly/y954thUgWArusiHRfCOorjEt67znBLPbkOXdFz+uH jkwbbS5vgHj6TxcDWHCYS9W4Y1QoGNib19Qyw= 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=symMBI0AEZzZj3jXIeKSzDkA196PYWRtmcxOC8y15f0=; b=LybT6D7ToVWOtAqSFMnXxBrajNgK2ldA/pev9b/rP8SB2ZPtNR9EnRQkskMIIWXoKt A5AGzVSlOjjhrcvK+CoayS0V6SAjSUdDHwkMVd0URuzpbvdWXo0kqZl19D1i7VrdEP2j jMAxu9deZ6yyeXkGHF/rfUXUKEtrkDrgNX3ugj5NioT4iZi8ybYsF6HrA5ZR7vqhDJzG Ghp2Qw+4bZXtwnM2r3keF2Mrh0d4nWU3OLvTKuG1H9WukAbdQ8wYnWscm8gxb2P5pAIw H3K71bLwETBj1yWL/MjBQ/jwK2+PCgpgMFlE/w9nkYj4epR5pDiM/4CVvZkNv1ThzTZB pBkw== X-Gm-Message-State: AGRZ1gJGEzp4JOfr3Dk2QMwzuR8c7nkhNYTirTH82iHJ1wFX4UMqqcwg XuHfV2h2HCbdc3xm603J88TUbQ== X-Received: by 2002:adf:f8d0:: with SMTP id f16-v6mr292162wrq.265.1542016633209; Mon, 12 Nov 2018 01:57:13 -0800 (PST) Received: from localhost.localdomain ([93.68.220.21]) by smtp.gmail.com with ESMTPSA id r14-v6sm21273089wro.8.2018.11.12.01.57.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 01:57:12 -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 04/12] cgroup: link cftypes of the same subsystem with the same name Date: Mon, 12 Nov 2018 10:56:24 +0100 Message-Id: <20181112095632.69114-5-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181112095632.69114-1-paolo.valente@linaro.org> References: <20181112095632.69114-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Angelo Ruocco When a cgroup policy is activated, it creates its files in its subsystem directory. Two policies are not able to create a file with the same name: if a policy tries to create a file that has the same name as a file created by another policy, the cgroup core stops it, warns the user about the error, and then proceeds to delete all the files created by the last policy. However, in some specific situations, it may be useful for two or more policies to use a common file, e.g., the I/O schedulers bfq and cfq have the same "weight" attribute, that changes the behavior of the two schedulers in a similar way. This commit prepares the interface that allows two policies of the same subsystem 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(-) -- 2.16.1 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 74012b61fe19..e3cc437669a8 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -1579,9 +1579,12 @@ 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(cgrp->kn, + cgroup_file_name(cgrp, cft, name)); + struct cftype *cfts = kn->priv; lockdep_assert_held(&cgroup_mutex); @@ -1596,7 +1599,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); + } } /** @@ -3467,6 +3482,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; @@ -3615,6 +3631,23 @@ 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 = kernfs_find(cgrp->kn, cgroup_file_name(cgrp, cft, name)); + if (kn) { + struct cftype *cfts = kn->priv; + + if (cfts->flags & CFTYPE_SHARES_FILE) { + /* + * kn->count keeps track of how many cftypes + * share kn + */ + kernfs_get(kn); + goto out_set_cfile; + } + } + } + kn = __kernfs_create_file(cgrp->kn, cgroup_file_name(cgrp, cft, name), cgroup_file_mode(cft), GLOBAL_ROOT_UID, GLOBAL_ROOT_GID, @@ -3629,6 +3662,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; @@ -3726,11 +3760,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; @@ -3760,6 +3829,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 12 09:56:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 150811 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2948387ljp; Mon, 12 Nov 2018 01:58:11 -0800 (PST) X-Google-Smtp-Source: AJdET5fOLS30G/QiA6F0L6jGzJ4o3E70dzSmih4R/kEV4P1BlPwxKtlVGcko3M2JBt8L4Ey6aC++ X-Received: by 2002:a17:902:9009:: with SMTP id a9-v6mr307810plp.134.1542016691532; Mon, 12 Nov 2018 01:58:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542016691; cv=none; d=google.com; s=arc-20160816; b=HTA28hER/1n1BsuoNc9dFU1lVXx96chhXfoeRun9aeYOJnAosKkocfEhBHohSqOqmq ZGquSJymjOjF9K4l48Uo/GuWTobWNnWe3RQN2S2IcaAsam2PTQZ2te3SvudXRZ+QQiES s8yuFiA9h/WM4BlOlMy9vis+vpqxjuDYetREtD3bOvuwowNDbakUbKhiqxCoOGGkUPQT Elau7WQGKWpzISjMZSDJtoBavOCfL7xlynaG/VEVAGQy6yjVQrcwzGX1u0AvzNsBMZYA IIFEong+EyGVNaoArQypQHsZqSaGJHc98gHLERSJd8rcWrh0Z7AiBDX0C5ijZrQyI7bQ 2kPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=P7bU520jYWPTb3cyPzcSyUy1YpHK+qexJMs0P6lqanE=; b=aIsjA2YPv8rfIMvwnGvtetRdXEuq7G12l5sU4hcqeemO2Ad9IOExJtvg2PE3YutSlp JHKVSn+5Kti+a49607j5KLDmel1NvrwtlaRzwpM7KNt63hUn3HlzLHbJdlWsguCo7wQq +EUbkjV0hdBcYXqxSCuh+54wmhXTyyKS7VnqRDzWsy/L5bXkQ6dTuMqnvBksZv/FiacG nharuwzgF/z9U/Mv4z3CdSGTk5W2WYpkwoH6wQwQ24fSy2SGoFtcP+G+uiJmGbe+zce8 qX7a5+7J+5yWLGxGWvuK8SsmwJIuLIsSXsLMCrn2DyfS6pwLuV2m3bYFWiwVN0VQF7Cw jZSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JtQQC93a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d18si16004323pgm.212.2018.11.12.01.58.11; Mon, 12 Nov 2018 01:58:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JtQQC93a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729199AbeKLTtq (ORCPT + 32 others); Mon, 12 Nov 2018 14:49:46 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:54599 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729138AbeKLTtp (ORCPT ); Mon, 12 Nov 2018 14:49:45 -0500 Received: by mail-wm1-f65.google.com with SMTP id r63-v6so7828627wma.4 for ; Mon, 12 Nov 2018 01:57:16 -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=P7bU520jYWPTb3cyPzcSyUy1YpHK+qexJMs0P6lqanE=; b=JtQQC93arLRCUkYIzxYNMaBRBMon6J3hW9n1Xxh71Mx0tPT2003ZczFsHzJ42mmoOX CFbUgZR3B0Jz5VRmHN1WePt8B0KRBQkeu6YZZjQxZMnpbSTRsYSnZaaMTfMQXbgZ9JGD le/9K33CGl4PFQx+RuuGtMEVzyJUE113m9ick= 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=P7bU520jYWPTb3cyPzcSyUy1YpHK+qexJMs0P6lqanE=; b=MGk8VnXDlZQZc/s3Dq2xSWhja9/Vtpjk+I9JlIb3wV2SR+1mYRrJ2LejGw1myul6Dp vI4W3dPhh/NEGy+np8GDtjCUCTg4O5CzhPNookNKKAcjj2Kmt/kQQu/NQJMXlVXnUFc5 SyygasGslkYIIn+rxSitk0jf33fhJ8GwmExQ/u5EcLPNzpH1AlE67J5EAmwDtVAquusl 2cpgB3My58ccNiIAs4mVzGKYqqdIi/uq5LYzjBrWvaWjM1gWA58cxCMsdeP6YTP6EQ0k DzMbXJ+MCkbD11+AgMB8C1U7q6PdCZfec20JNjIOokAkS6JNXOjcjPdC1GPFOA2eUTcL 3OeQ== X-Gm-Message-State: AGRZ1gL+VLD9MD4MFUeJeV98TlOinPJJfMeMQam3eaoWXj3XKhYyJLEP Q5G1wy9dXRziiy893478LZInxg== X-Received: by 2002:a1c:b5ce:: with SMTP id e197-v6mr6848082wmf.30.1542016635664; Mon, 12 Nov 2018 01:57:15 -0800 (PST) Received: from localhost.localdomain ([93.68.220.21]) by smtp.gmail.com with ESMTPSA id r14-v6sm21273089wro.8.2018.11.12.01.57.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 01:57:15 -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 05/12] cgroup: add owner name to cftypes Date: Mon, 12 Nov 2018 10:56:25 +0100 Message-Id: <20181112095632.69114-6-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181112095632.69114-1-paolo.valente@linaro.org> References: <20181112095632.69114-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) -- 2.16.1 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 9968332cceed..bf17a9843f45 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -293,6 +293,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 12 09:56:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 150804 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2947884ljp; Mon, 12 Nov 2018 01:57:24 -0800 (PST) X-Google-Smtp-Source: AJdET5c8r+xzl0HTrPV15pqIpe3GvRLxyNKSlhQmEPUZWuvqTBIozS5ZCkO6yp6bsuJFQc7rjdN1 X-Received: by 2002:a17:902:c03:: with SMTP id 3-v6mr272816pls.141.1542016644421; Mon, 12 Nov 2018 01:57:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542016644; cv=none; d=google.com; s=arc-20160816; b=W6RlbJ8aN99UqWk2My1zG35ruFZXj6PSXjQp5fyL6alaS8V7Lgr+KJMD+RCSz3Erb4 HFJ7TsWiS/sLqmkAJN8SlYICjd7GN+YESHe3xHEbbiTDL5hBk2VkShs4iXQiRQPXW5+x 3Y7NKWlIbHcMzZEVVrGdvv17QwBT0pBaASte3BKPgtRq36a+gRcNAptZy3qPjakrKCFV zcw5vRA1rgyqjgfbe8d/RG+hd3k5E1z4FgLa1vwEClU43Vmo/1unNgFYg10AjuM4Jctr m5XWEwxXg2YZ13EmHd/1jF4tRIlnpHOFz0mcm8XpL0+5jLAIzonlmcCe6jRA7vxv2kDm 4Zxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=P3gM8CEth45UYnNHSZF98Zi/zDAo21J+oNJpFvTMXDU=; b=PYdBLiEX6kJ44bRnrRdIQFjQddnj0NmTvLn6esKrppvrNhIRd3F5+dl7BTMuQCcbgX GPcbe52Z9cG7bdG/Kc5aRUjckXuGhW04xXl8ADM1K2ItDl9zabpwJ4xZRA2/wZnLx8Nm 8RJhCqmBdCr2xrrSG2fhH/v5vo4DKPFO73Ezhwy6mQCCgNYYLnMEUxoATs9DKT24qX+0 7lLNY4Z/JxN16F75NpLT+f6fJjpxrcqtmvuGRnEgKLk/rgbPqdc3yJf9q+tUM4odiiUD Rhw2Smct8h0+xeEYBx+322cjCpgSVfxeRrVKhSR8PfrtF4p8N6VsUB3EUJskNkLIu5cX lmOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F+07G256; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l137-v6si20976365pfd.260.2018.11.12.01.57.24; Mon, 12 Nov 2018 01:57:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F+07G256; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729276AbeKLTtt (ORCPT + 32 others); Mon, 12 Nov 2018 14:49:49 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33464 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729150AbeKLTtr (ORCPT ); Mon, 12 Nov 2018 14:49:47 -0500 Received: by mail-wr1-f68.google.com with SMTP id u9-v6so8589191wrr.0 for ; Mon, 12 Nov 2018 01:57:18 -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=P3gM8CEth45UYnNHSZF98Zi/zDAo21J+oNJpFvTMXDU=; b=F+07G256OoZzsTmnbt0RELuT0heBN/K8A2OrFVYc5axzgzepR5T2xKkZNXlibAtKAJ 809E2WdhkOSlr2VxSQawiDZ9b1WIzjE9faJ7tuvvOP/NGFenBt5I92R4MWTVciVtbKU9 TdhCVPR+K7VkxBtuZ276fOv470Q1nrjMDL6vk= 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=P3gM8CEth45UYnNHSZF98Zi/zDAo21J+oNJpFvTMXDU=; b=lOF6HF/ELV/urYo1qNSxPsL9UJLD9sbBLDO5hr4KYpczpnD9TO2PToL59tJfRWLd7r fMZ00e9eEDw9JIQqQ09WPju2XxFcGAjhfT0Dx77nmC9xHGX+JFZDKLY2g246D1fbo2Dg q5+b2aFh8Z9ecrH8dJhrZ4TLFYTFzcwl+/b5/N/mM4DQ6Ao8rj9Yar2R/MqQeIUTU9x3 GzpESeuw2MbmcoAJft8TqAwtQxvLK0T9pIgucwjoY0uphBNcuGbWR0jJzZhU1FM4Iotg gsobGZ7q7fdfTeMDH9fXVNx+fMeuRG/BDr+bnrIkERHBXks11IBPvebCs8xJu+4mHjnm /gDA== X-Gm-Message-State: AGRZ1gJ5WFC6mQFm58SDknrJoxDwZVVLeUqsSfAyq36fYInc1oogM3tz hzOv7yB57aTBAehfaWU+REwlrA== X-Received: by 2002:a5d:5544:: with SMTP id g4-v6mr311353wrw.222.1542016637942; Mon, 12 Nov 2018 01:57:17 -0800 (PST) Received: from localhost.localdomain ([93.68.220.21]) by smtp.gmail.com with ESMTPSA id r14-v6sm21273089wro.8.2018.11.12.01.57.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 01:57:17 -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 06/12] block, bfq: align min and default weights with cfq Date: Mon, 12 Nov 2018 10:56:26 +0100 Message-Id: <20181112095632.69114-7-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181112095632.69114-1-paolo.valente@linaro.org> References: <20181112095632.69114-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Angelo Ruocco The I/O schedulers bfq and cfq expose a cgroup attribute with the same meaning: weight. This commit changes bfq default and min weights to match the ones set by cfq. Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- block/bfq-iosched.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.16.1 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 12 09:56:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 150805 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2947918ljp; Mon, 12 Nov 2018 01:57:28 -0800 (PST) X-Google-Smtp-Source: AJdET5diE3rV/GJng390jPHznnLRQ0awYgF5Tnov4+WYadbcdqbdk+C8KjyYSwx80lR9JrH+ynNA X-Received: by 2002:a62:c42:: with SMTP id u63-v6mr267121pfi.43.1542016647912; Mon, 12 Nov 2018 01:57:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542016647; cv=none; d=google.com; s=arc-20160816; b=0dtzBXXP1OcMiV5cexZjn5RQ6+hASLoJwBSm0uvurhhpuFf7z830VXHmdX5Xzt8ekS jJawQlsZ1QWLCFNvU/AnTh9j1v3fQh+k55XC62nuJyY/LyhgssntJJHE0j/VtDQSY8BH yY78xnG9H8wMj5bxyEQr/9OC9O4KAl3NaNN8JEPGNIdjymdouX64KaESQWGcxX8oGeG3 qpC8yGcMICwiOgFCZJF6oFrravfhZOy0FLMVhrfDEfWEpfb3QOYwtPgj1Qghz7Gj07rK TpnRumqszLg8qbGQP/bvb6KR/E7dudIOutQ/wvl4szCxt0JuQvr/BItas28+/qjPjimk ZG+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=z1yDznB1zlUn9X3/WRtGxgozB4Whpg1+Jm0y+uUAhQs=; b=ANhuZDbzBakJbu+s6q93s6a4zgXGOYwoAVYblBVAI4330D9by921MOIHUDSgRrRTOe qwjMMUyWunLxchjdDM0+8QFgoSUfmQLMgaGY7gPGO4yWTRjk7tLJxE5Zi6AE5SbS1WXn oeQkDlWwjrN3i3BMox8oboyiIrZ0WlM4mqPhbrTNaf4MG1ZEzec4AjBLzdClzeg6k3qv oHYJ1PwMS4Yw6hfCXJ4zFh5V1Y/X/ohVmDmnpd5FI6pGVHyJ/1ouXuPXSyDxRkBm9mzx 27ub6npjyxxSOWShbhJZoXgkzAfjo9L+bwVt03BJOVmFvV9bg4YZbTqRlQA20aPnTSBd uJ2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PyZ8gOJo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3-v6si17588666plc.103.2018.11.12.01.57.27; Mon, 12 Nov 2018 01:57:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PyZ8gOJo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729308AbeKLTtw (ORCPT + 32 others); Mon, 12 Nov 2018 14:49:52 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:45380 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbeKLTtv (ORCPT ); Mon, 12 Nov 2018 14:49:51 -0500 Received: by mail-wr1-f66.google.com with SMTP id k15-v6so8540100wre.12 for ; Mon, 12 Nov 2018 01:57:21 -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=z1yDznB1zlUn9X3/WRtGxgozB4Whpg1+Jm0y+uUAhQs=; b=PyZ8gOJocogy3BEEQogAOEoynZMxE8x1fvBu0cP2+n30x2NDzxjSXsAPqPzS7QF2yn 559MfbGKyuGBpBtaanAwzOoQhFxdw4OpTCdGb2uaAZpuWQhrfq2eoWDkvEvCAEIUZ6/X Pmr2XAYw4kpma6U7p99Xbla+MYZenfrHl3AVM= 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=z1yDznB1zlUn9X3/WRtGxgozB4Whpg1+Jm0y+uUAhQs=; b=lJinqK8TvSrIEvKuukarOIWxXUrQVdExUaUEfCH2ixo8WED7rMPblGGt7lfa8leoch mOTaHPyP5McqlGy8YS1j5Xt0lbW+3BsLFGjBh0zs6mZGZioA4IoeylTxe7DvVrgqwOaJ dl9k5uvllBevfUGyyplU+Nj670WEOqnPtlRZA5jLkzpo3IsUWEmW0B7+9k+DzHJpurzO yV5VO4X0G4NfHX2sYJ8o0EtGu0GitGiD6ovxkE4bkw8EWV54L3KceWSNNt0rWpHC3sus /VsbY7lHwBEFmRmf4szwOn4JsxwtV3emErW1Fyd6KyonxvKy0QIwxGAD2pILx2x9rYby O+qw== X-Gm-Message-State: AGRZ1gKFL0nYTIjW5IX1sWgBekHRxZHSPAim1QrwkETJRkG6YrdtVXiB C4Xs7Q0fn7C7iiGGYqquWFPjng== X-Received: by 2002:a5d:4a11:: with SMTP id m17-v6mr273341wrq.259.1542016640333; Mon, 12 Nov 2018 01:57:20 -0800 (PST) Received: from localhost.localdomain ([93.68.220.21]) by smtp.gmail.com with ESMTPSA id r14-v6sm21273089wro.8.2018.11.12.01.57.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 01:57:19 -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 07/12] cgroup: make all functions of all cftypes be invoked Date: Mon, 12 Nov 2018 10:56:27 +0100 Message-Id: <20181112095632.69114-8-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181112095632.69114-1-paolo.valente@linaro.org> References: <20181112095632.69114-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Angelo Ruocco When two or more policies 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(-) -- 2.16.1 diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index e3cc437669a8..6d4cfd6395ec 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -3481,66 +3481,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; @@ -3562,22 +3603,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 12 09:56:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 150806 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2947929ljp; Mon, 12 Nov 2018 01:57:29 -0800 (PST) X-Google-Smtp-Source: AJdET5cFPAf2fxskvL/adk7VkztO0z9i4uaDzwnkI+34kUdQM/FPpAY1LwJfPuLYmliI+wX1k6uJ X-Received: by 2002:a63:b218:: with SMTP id x24mr229058pge.223.1542016649617; Mon, 12 Nov 2018 01:57:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542016649; cv=none; d=google.com; s=arc-20160816; b=hFlZ8Sv4QP+3+rZXdUYoMHaGeYGARPOfUNHEYfTzK6BiJoDvT3vovDz2RzCH2FuiYa /QUQX/8RSOCenKc8cJG7mh11a1nglojkkM5fAOxWuKULWDMIrb5GeEDu7EMtsL2y28AJ eNNcO3iwA4cWSJxo483NVcWU0FfANhI+bTFCymM0aZoZy6jQ4w0mcTLRO1Dhr6Io91sA iGvLJtKKlHxTvsOvz81uGoDZQ+S963A9Z1PfDGksLqc7XPaa7TpnoVTSM7RFaIa4u5xT VTIm+rJLgmhXWgPWTOturj/YCIfUh6VnckKR0m3WGwJOmt4fYDrELm3b+2PQj/lDWVy/ aiVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=BhhSrhl3GPkKSUoXIhn9nAMo7Bh19cGOMzxu3Gi9vPg=; b=lm9HMAxq4MlR/BhPy3BlJeZhLiDFiE8da1H2sJHne3bxpD0/XHfB5gq1r7CRwz8Pmx 4nKhFAl4to11RiT6T8xOXbBnA1R1t3YIICZMrtQ5sOguthyxuFWD0fXUL+T6JatiP+gy sxqoltBxyfjKlGf7hpWB/EuRebqfR7uYB8oppqYkpi9GjB9t3poFiKEKDZzAyyIQ9lLN WMWGwMnxFRSuYEMOsmJg7CMmqJNsAItFjmGVrVZRGhgqpUeT53iO6M5xnL8RigVKZXyI kpoVyFtUujFf2mG5V34hJ309qjT1uzLD6xfZ+MgNrI9WkGpCATK5DeZ6i0DW4FkdcfUe WZ4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QG+hymxr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d187-v6si18845537pfa.68.2018.11.12.01.57.29; Mon, 12 Nov 2018 01:57:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QG+hymxr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729338AbeKLTtx (ORCPT + 32 others); Mon, 12 Nov 2018 14:49:53 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53849 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729150AbeKLTtw (ORCPT ); Mon, 12 Nov 2018 14:49:52 -0500 Received: by mail-wm1-f66.google.com with SMTP id f10-v6so7788142wme.3 for ; Mon, 12 Nov 2018 01:57:23 -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=BhhSrhl3GPkKSUoXIhn9nAMo7Bh19cGOMzxu3Gi9vPg=; b=QG+hymxrp0k2JHc1mCXq7bGzmIVfKn8kyei84SG0+Y3J9yu8gRuP/KiUBxNO6H35Yw PAM/xy0h10htiE9hYdXK9BcdZPCqgmM0bjBMsEt8TvvDzFJTQMZNtCgl4n1iF4YqNIE/ nqEomghns5VaEzxAIC/4QDraAfkZx5bQG9Ixk= 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=BhhSrhl3GPkKSUoXIhn9nAMo7Bh19cGOMzxu3Gi9vPg=; b=K0Z4fNtPx29BcohML4GPZ9krN4/CG7etL/qaQozxfPm32yNl2tPrJfkcsdLczzobAV BAu6gRXfzDT2EG7aYs5JUU07cM+DCD7EnyH8BIj8e4wCvJHHxfy3BC6ZEHFhiCGfmcWM yFsDO6Eujdk8WdiD96t4AOHemK6fT+XDK7PEdw2SavIgzaoHUsOi4/m3svR+EAMZC+V/ YR7pRSi9i7Ah/1R65ApdvW+Y5aKNLuuv2jFsiDxjNDtC6GiUTboL53OB2vbApHy1uCFB HDdZH0X/FkIjZ+U+7x6u4B/nZjjC4AHCkH9mMvpZ+u3BRm6MD8EqDix3T9ZjeO7hrwiv jCAg== X-Gm-Message-State: AGRZ1gIbdbSv7gdxThrePXXfAxq9+cYwy7s9nlKb48zulmciRVgmncCJ cPXM93OTjWc04l5vMBG/5uYFcL7LtByutyVq X-Received: by 2002:a1c:3c83:: with SMTP id j125-v6mr6771922wma.65.1542016642661; Mon, 12 Nov 2018 01:57:22 -0800 (PST) Received: from localhost.localdomain ([93.68.220.21]) by smtp.gmail.com with ESMTPSA id r14-v6sm21273089wro.8.2018.11.12.01.57.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 01:57:22 -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 08/12] block, cfq: allow cgroup files to be shared Date: Mon, 12 Nov 2018 10:56:28 +0100 Message-Id: <20181112095632.69114-9-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181112095632.69114-1-paolo.valente@linaro.org> References: <20181112095632.69114-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Angelo Ruocco Some of the files exposed in a cgroup by cfq have the same meaning as the files exposed by bfq and throttle. This commit allows these files to be shared. Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- block/cfq-iosched.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) -- 2.16.1 diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index af0c59c2dcde..f046039bdfc6 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -2016,7 +2016,8 @@ static struct cftype cfq_blkcg_legacy_files[] = { }, { .name = "weight", - .flags = CFTYPE_NOT_ON_ROOT, + .owner_name = "cfq", + .flags = CFTYPE_NOT_ON_ROOT | CFTYPE_SHARES_FILE, .seq_show = cfq_print_weight, .write_u64 = cfq_set_weight, }, @@ -2035,40 +2036,56 @@ static struct cftype cfq_blkcg_legacy_files[] = { /* statistics, covers only the tasks in the cfqg */ { .name = "time", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.time), .seq_show_cft = cfqg_print_stat, }, { .name = "sectors", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .seq_show = cfqg_print_stat_sectors, }, { .name = "io_service_bytes", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = (unsigned long)&blkcg_policy_cfq, .seq_show_cft = blkg_print_stat_bytes, }, { .name = "io_serviced", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = (unsigned long)&blkcg_policy_cfq, .seq_show_cft = blkg_print_stat_ios, }, { .name = "io_service_time", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.service_time), .seq_show_cft = cfqg_print_rwstat, }, { .name = "io_wait_time", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.wait_time), .seq_show_cft = cfqg_print_rwstat, }, { .name = "io_merged", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.merged), .seq_show_cft = cfqg_print_rwstat, }, { .name = "io_queued", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.queued), .seq_show_cft = cfqg_print_rwstat, }, @@ -2076,70 +2093,97 @@ static struct cftype cfq_blkcg_legacy_files[] = { /* the same statictics which cover the cfqg and its descendants */ { .name = "time_recursive", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.time), .seq_show_cft = cfqg_print_stat_recursive, }, { .name = "sectors_recursive", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .seq_show = cfqg_print_stat_sectors_recursive, }, { .name = "io_service_bytes_recursive", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = (unsigned long)&blkcg_policy_cfq, .seq_show_cft = blkg_print_stat_bytes_recursive, }, { .name = "io_serviced_recursive", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = (unsigned long)&blkcg_policy_cfq, .seq_show_cft = blkg_print_stat_ios_recursive, }, { .name = "io_service_time_recursive", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.service_time), .seq_show_cft = cfqg_print_rwstat_recursive, }, { .name = "io_wait_time_recursive", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.wait_time), .seq_show_cft = cfqg_print_rwstat_recursive, }, { .name = "io_merged_recursive", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.merged), .seq_show_cft = cfqg_print_rwstat_recursive, }, { .name = "io_queued_recursive", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.queued), .seq_show_cft = cfqg_print_rwstat_recursive, }, #ifdef CONFIG_DEBUG_BLK_CGROUP { .name = "avg_queue_size", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .seq_show = cfqg_print_avg_queue_size, }, { .name = "group_wait_time", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.group_wait_time), .seq_show_cft = cfqg_print_stat, }, { .name = "idle_time", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.idle_time), .seq_show_cft = cfqg_print_stat, }, { .name = "empty_time", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.empty_time), .seq_show_cft = cfqg_print_stat, }, { .name = "dequeue", + .owner_name = "cfq", + .flags = CFTYPE_SHARES_FILE, .private = offsetof(struct cfq_group, stats.dequeue), .seq_show_cft = cfqg_print_stat, }, { .name = "unaccounted_time", + .owner_name = "cfq", .private = offsetof(struct cfq_group, stats.unaccounted_time), .seq_show_cft = cfqg_print_stat, }, @@ -2181,7 +2225,8 @@ static ssize_t cfq_set_weight_on_dfl(struct kernfs_open_file *of, static struct cftype cfq_blkcg_files[] = { { .name = "weight", - .flags = CFTYPE_NOT_ON_ROOT, + .owner_name = "cfq", + .flags = CFTYPE_NOT_ON_ROOT | CFTYPE_SHARES_FILE, .seq_show = cfq_print_weight_on_dfl, .write = cfq_set_weight_on_dfl, }, From patchwork Mon Nov 12 09:56:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 150807 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2947968ljp; Mon, 12 Nov 2018 01:57:32 -0800 (PST) X-Google-Smtp-Source: AJdET5d6WbjLkWiwukgsU1tjvzjLxvW477CjWSJ7rMHREDbdExMRtZAbOdOwmK8K+U+E8CuvMVlX X-Received: by 2002:a17:902:3143:: with SMTP id w61-v6mr310865plb.58.1542016652518; Mon, 12 Nov 2018 01:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542016652; cv=none; d=google.com; s=arc-20160816; b=xAbDnMNb3ofeeGXMsNVnUpG3nVVqg2ymcWfh9yRPTRwScIOY8x7pwwfSSZPu9jDaLk uFvHOaJFZptlZAMGSpR1SsVuuuHFCnPUye3mXiivWsXzZ+OppqeB3qIKX6mgeQpLSRzn PkHH9eJ7g5oTgP/A0wM4xxIjsDjj1pxLdfWWBgAsIkLoJkzo6AtAbn1U9Yc/yFOD9i25 twBpc8cC/bfYioiPJuzXGIfUoXNqMc09Nv+souw6ABg3sQSXZH8YhZ5xoeAxMKbnLK4s TDWrYJHT9jZQ+e24lIZA2SzpvxY3Dp9x/HnfrclMTg7yPpiBWvFs/s6OvmPzBkNXS1B+ i2kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=0oaKQg1Db4rRhO3WCbNaQdRbhtsjokz1BpBDDqQDnH0=; b=phLFIjG9EhruzJc5uMg0TsAFCgvh7AlnuQzntuDPOZAf9EpASW+GuatA07AOobqyuy zTohIZFJxTbfspZf204bG8BVVNTDNpNTAoD9HWwiT09VsrAg7MgHSBxRWRAe1bXU6qj9 if+0+Wh/lJbUe0gGwenRzeCts/O8+XO+tcsQ2U+d3a+oMI9+yZMO66l4UY9wSBIAHQIz lVEliL60P/R+VZZc1cgXKWdSJuCwNET/ZR6IZAd7gevQnHTufqfDtMGCmwqk2H+hXdl4 N0CP57kfuFosPh2dTckCLSS8frplRvp104IniVhlEXentVi5DpHg6/zK2LxQyO6DGzJB iiFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rg5OfuRn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w19-v6si16969969pgl.278.2018.11.12.01.57.32; Mon, 12 Nov 2018 01:57:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rg5OfuRn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729367AbeKLTt6 (ORCPT + 32 others); Mon, 12 Nov 2018 14:49:58 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:54615 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729341AbeKLTt4 (ORCPT ); Mon, 12 Nov 2018 14:49:56 -0500 Received: by mail-wm1-f68.google.com with SMTP id r63-v6so7829068wma.4 for ; Mon, 12 Nov 2018 01:57:26 -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=0oaKQg1Db4rRhO3WCbNaQdRbhtsjokz1BpBDDqQDnH0=; b=Rg5OfuRnIxfiEqH0WAirw+p5zFFM2A3eP+/qNVgYtz/p1XWMtJQwYM05UW/C4+j5gX IaZnE3XI6wvJCXcd4FQ1Hx5aghznqX87ea65MY8LBS1tfU6fXt06wlGlTPcLKrs9JP1t 5iM+S+o9ye6yz2LV6kWJfSIofPFST2APQ3GVM= 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=0oaKQg1Db4rRhO3WCbNaQdRbhtsjokz1BpBDDqQDnH0=; b=Ef8Qn95TBgcp+oSGdgXiM+cTs92DNDQV8iKC+1sOXqsMAIj4lbEQxI+ZZlT/F8csnN wJTsXyG125PPlU0YxGbjcC6v07Nb7aRZ5YCLBGgPa5SOPu3snmPKtySZAcp1LY0N4ZWI 2MeFsIg1bOPNnyKDpoTp9b/0AxIkM9mQunrbyzNzrMsR8n9AxcGUaSng5e9BQuHkHqi3 fJAE89ws9EQttOVcYZ+6GlVCvrS0qGTFKxDSBFwmWnthL8M/+M8r6O6udRgU7Gi2/Asf Wiq1tyQqRoOU25+GOhr+qTndVudzYyCFJX14KpUfhuuMhqkU3vt27PI3RYlnS9Be7WsG 9l5g== X-Gm-Message-State: AGRZ1gJd34JnkR7/aYXI528oYVpjJxnvr6W0vC0SZSPMTyeu2kNZb0oT A/EEkWyu8fFG2+MRzSx21y0LsA== X-Received: by 2002:a7b:c84f:: with SMTP id c15-v6mr6284511wml.79.1542016645423; Mon, 12 Nov 2018 01:57:25 -0800 (PST) Received: from localhost.localdomain ([93.68.220.21]) by smtp.gmail.com with ESMTPSA id r14-v6sm21273089wro.8.2018.11.12.01.57.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 01:57:24 -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 09/12] block, bfq: use standard file names for the proportional-share policy Date: Mon, 12 Nov 2018 10:56:29 +0100 Message-Id: <20181112095632.69114-10-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181112095632.69114-1-paolo.valente@linaro.org> References: <20181112095632.69114-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 share these files with any other policy. Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- block/bfq-cgroup.c | 94 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 25 deletions(-) -- 2.16.1 diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index 50b2d7ba6b9d..9148fc38c737 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 12 09:56:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 150808 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2947990ljp; Mon, 12 Nov 2018 01:57:34 -0800 (PST) X-Google-Smtp-Source: AJdET5dbubmYo9xtnWYBlNlZZoj+xX466redX0dt3BNnfEEmltZojwMbWR8hz/vWDpk9dgtqg/ej X-Received: by 2002:a63:5026:: with SMTP id e38mr241133pgb.123.1542016654307; Mon, 12 Nov 2018 01:57:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542016654; cv=none; d=google.com; s=arc-20160816; b=ht4uBYMV7CwJ4qfjkWZTJ0VAesMaNX6rfWB9Oj6zuCfvkZwIDSAlQr79KUJGmFFsER XaFbz3/Y/yNV+frUVH5F6wqu60BYboOOWIhNJTsSruDjE7Ujm95mDBuSefZ5CtyS919z CnumUJMsNl+7OgaYtr3MCU0bs0LpwmOMiJh8wQCKJivu9e9Mt/JKF91rVo41Jvq21RA2 w+/xZV2KqhV2eFS+SbBtYLDjgHgEAyE3aNfOS7P3d0QmpAJXbRg6jD4lqd0SkPNa9Uyp kJRAXXhmlfk7ao2irvkNp5aTnJkm8bHsFSszR4VYjz2N23ZCNw0WxEPMKdRBtRlO52eE 4rPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=tJzqIZ4whiBiBt1HUGz+jcfYWcwBBnR88Hf7l4Y3mww=; b=TYUM8/U5mKsYTvoxN4/32CaSKfBIrNzmBCm6A/dfoD1YMC/BMIUoc6JLsd5/aBQyGB +MBlo50H+6ImyGJuafnevyfoAw3NeVX0ivoWeS9GBtFsNh4uyOD2RcoBLt6gJ7nvSln7 y7ul2cUG0qQ15UjVGK3Kg5HcgVnd37YWuZUmiCJawN2hH81nj6cnLOXFlk7wGMArJeyL sVvZS1r7y65BBBoNMt3ZgX9EBFrkfOtGYn+Mk+uTN3YG3T3hQGs0z2oNn7xlXsLz0NRh iGVgjF4azOheqdBApOOcUpYQoOc53NbVJ03VvKYaa88ec4StfjEd7ZRPSVQMKGxS/HFW Z1Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FDIijxyz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d139-v6si17814084pfd.93.2018.11.12.01.57.33; Mon, 12 Nov 2018 01:57:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FDIijxyz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729387AbeKLTt6 (ORCPT + 32 others); Mon, 12 Nov 2018 14:49:58 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38612 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729343AbeKLTt5 (ORCPT ); Mon, 12 Nov 2018 14:49:57 -0500 Received: by mail-wm1-f65.google.com with SMTP id f2-v6so7461593wme.3 for ; Mon, 12 Nov 2018 01:57:28 -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=tJzqIZ4whiBiBt1HUGz+jcfYWcwBBnR88Hf7l4Y3mww=; b=FDIijxyzwzKUw8K/20a1vK7NhMkivhaxGdBShwBbInbBKMPrlnQRfW4Q14WNLJlAgk +5kolkin8wKT5bN1KavHsyCPbdwxMplfi0IRkntZ056n0gKQV+UuCM8samekxvyVvzGV rA+3TSy9ixB0Rhl9TjcTj+dGLIzKf73wxGTX4= 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=tJzqIZ4whiBiBt1HUGz+jcfYWcwBBnR88Hf7l4Y3mww=; b=Yn1ZcOZW1WLQPoupo7djaxDykIsDBTLQVRF7wfM7h/WPlrVPyViDmsp0p6sR5xLBE9 u2MGs8MCWVzc6D12lBK2aoxvgnLIfATvfZdqrzdcqnxEwvv66curDtTd2jn+Dh+u57sv tSW9lIZIiiFxnBuOzIZKVLWOGsg1leNjD+4q403Mh37+7610I9eot/7l+tpzX9m9T7R9 DuPOHMYLxzfPd/j94Qr4E8lQpif40ixPhhf7w1oNjE1o0N1z2uGUa7mJ0WJ/67ougUqY TEBhN7Tk6CzNxGiYk4L9HAH0fVf9ezGUHEw2oC2T6LyrxEed8cZVm/QdYNOrkNFzAr8f F/qA== X-Gm-Message-State: AGRZ1gJNQ0Gd+ipziPh/0pV4AoH0hoEFf4/cHd5avBAPpF8l5arjtsaz MRkbXpMVVR1uYA4d1ajG7ZgBeg== X-Received: by 2002:a1c:58c5:: with SMTP id m188-v6mr6705885wmb.85.1542016647902; Mon, 12 Nov 2018 01:57:27 -0800 (PST) Received: from localhost.localdomain ([93.68.220.21]) by smtp.gmail.com with ESMTPSA id r14-v6sm21273089wro.8.2018.11.12.01.57.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 01:57:27 -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 10/12] block, throttle: allow sharing cgroup statistic files Date: Mon, 12 Nov 2018 10:56:30 +0100 Message-Id: <20181112095632.69114-11-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181112095632.69114-1-paolo.valente@linaro.org> References: <20181112095632.69114-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.16.1 diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 5c43821dc528..239957c12d34 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 12 09:56:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 150809 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2947999ljp; Mon, 12 Nov 2018 01:57:34 -0800 (PST) X-Google-Smtp-Source: AJdET5edFpBjuxs3e5wG2c7xpI+Er885LHNXJ2DLIKCdeWAE4K9ZKXheyYK2F1YX8uJpeDgXKSD9 X-Received: by 2002:a63:4a4a:: with SMTP id j10-v6mr275521pgl.0.1542016654809; Mon, 12 Nov 2018 01:57:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542016654; cv=none; d=google.com; s=arc-20160816; b=TRbCxLPLHivXGZ6lPbY9aIAlXKhe9lawuNXNey2+lNkYrjmdC6aSPn0bPdOR6G5qQL cgZkndTt84N+VWUO5GfCDi9fN8xS8L6Pcw2CyyG2nRwv/TjUWi+7w+ODuGtUNzA3Xlfr 0LTvw/zs71X/TXW4vCiG0LUgofsU9SZMWKquuIvyEwpXmz4f6eOxBKo6eJdHFgFx54Ty H1bwUulBiIiVp4+/RwCTBB5G+GKT+nVkEvdenJ10MbDfmX4omi8q8sr3ttzKOtKEdqLC 6Nk0uFSPMTg2/9YU/eW/h0gik/sHRoa5CgduSh0ZwoP6oGULmmFokTMV0VfLjoTPnyAm r9mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=95cHSgXhObq6AUCu/Rr/+wEQTPHLVt9I8/orFJ2tnV8=; b=06Er+/xemVY0M/vSTDt/eHkEg4+Shja3MTSqxX/T1Qxl2wem4fdoXL6TH41/+o1QQ2 3cSQWYH3Lu1efEGWJwF5CQ4KDxclAwXKYjMT4KxiT8xtzetqx4MmdzJRr/3llfJk5E97 jI9HU9+Qed/qyH6THgXoYOIqR+8Qq0o83sIKN0O/eS9rFyIekHgEXTTfifcPTJijIg+z w2wdYHikQUQcPwAy9Sx6DwvPipCBZQ30rXqQJ14KzFWZSzjXgALKZvfMPGtD/7lZLOR1 f4SXv7cPVGZw6SMRh89PlecloZhW2gzZ+g6FmfCXWvn5vREDC/MGELovCY32SqF2NjdY qyFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZntydDL3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d139-v6si17814084pfd.93.2018.11.12.01.57.34; Mon, 12 Nov 2018 01:57:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZntydDL3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729418AbeKLTuA (ORCPT + 32 others); Mon, 12 Nov 2018 14:50:00 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36994 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729389AbeKLTt7 (ORCPT ); Mon, 12 Nov 2018 14:49:59 -0500 Received: by mail-wm1-f66.google.com with SMTP id p2-v6so7461989wmc.2 for ; Mon, 12 Nov 2018 01:57:31 -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=ZntydDL3A95QZ0Q9bqPS7efY9/AnOcRfFMoWhJjuF9Gk55eXToWWO0MFVufb41xZUb nHLiTbmFBZG9+1cdt8aSYqRhhgzNW6mvo/J47vdQ+DPObGyWLAiX1dVnw6VnyGsWrHIX 7rTjNGD9VyfMoQr33985it7yVDU+01tI7ZnNQ= 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=MZB64cJcPtmwcsGUQEThjLZ1KdvjATBNxreRdw1n6w1tV4flWc8xUCUqNYxtHWNdig zrU7ra3Biteu7gfB/Ag5Etn6uHsgKvM6VAgJwsxm/1xUPy3kUCFLvSYoKh/zgBtxnFeX kRSX4CEoUAYewYFmxIebMsO/vsm5hrGuoapICZZcZUeHH9FfHlLxXU3vwFTGUfMG3O3I VA/yqZhsgFmkgj75MC0i4e+nki6adEaW6wLw1zSfGNXFdj5B/YaH34L7jpLHySjxIiyt YEGGeFkVNK2uonB3WBIPL91DWLFvaaivuKvkhm65vZbx6vhPWx97ZOsDOq5aU66IqRHd IkdA== X-Gm-Message-State: AGRZ1gKIeGdjlwb7PWgj1WKx327Dk666oeBpXS5KJ5RgUlF11mQJzi98 iAJE8D99VBil+wDT6WqONPJpbw== X-Received: by 2002:a1c:3b06:: with SMTP id i6-v6mr6807918wma.18.1542016650265; Mon, 12 Nov 2018 01:57:30 -0800 (PST) Received: from localhost.localdomain ([93.68.220.21]) by smtp.gmail.com with ESMTPSA id r14-v6sm21273089wro.8.2018.11.12.01.57.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 01:57:29 -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 11/12] doc, bfq-iosched: fix a few clerical errors Date: Mon, 12 Nov 2018 10:56:31 +0100 Message-Id: <20181112095632.69114-12-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181112095632.69114-1-paolo.valente@linaro.org> References: <20181112095632.69114-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.16.1 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 12 09:56:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 150810 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2948034ljp; Mon, 12 Nov 2018 01:57:38 -0800 (PST) X-Google-Smtp-Source: AJdET5euEW0WF+1uDpzQ7HNqo8ekA08JcP3VFe6jVTbX6y0B5cS/J90vZJHLuciZC28kT4YfHjaf X-Received: by 2002:a17:902:6b46:: with SMTP id g6-v6mr283241plt.33.1542016658022; Mon, 12 Nov 2018 01:57:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542016658; cv=none; d=google.com; s=arc-20160816; b=qc/7BMRcBdyGuTXA/aTeulm3IXOIABgfKmh0olowUGeN838/BO4SBgqWLi8AfAZyor tVxxXhJnOSWLujH9UsJnaFCSkiHx3aBuOIqDFKGuiPyPH8UdW8di8xrzQfO+tKVf8pm6 wDp19/5LsRGtIRvax0YlATL632sXzZUdnAYWUef2Lx7/A7vT4r8vfxPL6zr2l0P1+Q7M p7vYNi6sP8i8mYUAOxfN6kZYbXpleW2I+NCkTEB8yYzgXsHs4/AMPmNs0wv+WWd7jmzT CIMBAN+OKMHJIIODKa5YFhzMN5pj96FF0pPBj7tWlnVAbpdD/Dl5sj1ehv91zDvr0BlU EbmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=MpOWBJhYX62m+dv0e4xXNBLs0Dhr3TZXbDUpfWqj7Ic=; b=As0u79vSxAhRbfF58ZdSjYwsJl4VrmhwPLVGdJ7Yn1FHeci8xZiORvb9kR/8O+2dGP AtkcwR6Fke2+NgiM6zBRNogh34dyyfbUHCdTzWa5W6A/Lt2Q41iYwMbXgLsfWuPUmbXP jeh6c5XpCHXNty5Q8/6LbHOK6aMsWx36ZDsiCmlBF7JwxYqXHctIW0Y3hv5iv1zpyQ6d A1N3uR23IYtYqu3ZK5bGVSIZOrU1v/0V2VJY7en6E8RB0F6N2paAcWvi+LIsrlZLxL6I pPPQxm1RdFBEr+TLLI1n7+JTLy18QGAjm7G2lLTq5NeNtSzais8RSNGrNBuRa4fPhwet mOLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VFGD5aON; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d139-v6si17814084pfd.93.2018.11.12.01.57.37; Mon, 12 Nov 2018 01:57:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VFGD5aON; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729449AbeKLTuD (ORCPT + 32 others); Mon, 12 Nov 2018 14:50:03 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35834 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729389AbeKLTuC (ORCPT ); Mon, 12 Nov 2018 14:50:02 -0500 Received: by mail-wm1-f66.google.com with SMTP id t15-v6so7517739wmt.0 for ; Mon, 12 Nov 2018 01:57:33 -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=MpOWBJhYX62m+dv0e4xXNBLs0Dhr3TZXbDUpfWqj7Ic=; b=VFGD5aONmJPgDKVWuSsADhnuupo20davPrcXxMNwaQMZewp7EC2pNfPmhVeF7QXgpS akGJu9VK0L9wXDLo3UCtHJXHfph1HyHmjiXaGZ/dtlh85gW/caRxP0MJp6ZsuOqy8afm oR3leMzaETYNT3djwxxEJi91rWG0izRRGxgJ0= 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=MpOWBJhYX62m+dv0e4xXNBLs0Dhr3TZXbDUpfWqj7Ic=; b=ZwsI1m/WQR1HXRkM6jKeK7WEV5DI2HJyoNt7hf/NUNyGRPWpYH+oE88T1vTrOZeB4l nbga3DcgDR1N7U3xfWtFihcmK0Ztt7Z8sEFUtqRUihbqs7XdraZcbiYidJXa8uHbH0r4 UwdqxTLjdhYEaKXPNllA299VsRaJmK1x7heBACAHoLBwKrYqcMKZcnZ8RExyUwNS2QD3 YxP6oMNaGolMH4Kd30s22X7ScIAvoc/Xk8SjLtGIcVeditU0v8WiEmvsf1u8fGr0u+GQ y78a1hC5e+3o0R4lJr2M68jZF6WNjh/FQk37w9ugrwcF85da8SXDFKB+mgGEMQnomklm NyAg== X-Gm-Message-State: AGRZ1gK9TuOqAoJs+tTLEwzY8g0F9XuoGiLEDu8DMxu3oaF9UG6AGuBr htdfeunR4m6RREyxz5maJeeaDw== X-Received: by 2002:a1c:111:: with SMTP id 17-v6mr1356272wmb.55.1542016652729; Mon, 12 Nov 2018 01:57:32 -0800 (PST) Received: from localhost.localdomain ([93.68.220.21]) by smtp.gmail.com with ESMTPSA id r14-v6sm21273089wro.8.2018.11.12.01.57.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 01:57:32 -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 12/12] doc, bfq-iosched: make it consistent with the new cgroup interface Date: Mon, 12 Nov 2018 10:56:32 +0100 Message-Id: <20181112095632.69114-13-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181112095632.69114-1-paolo.valente@linaro.org> References: <20181112095632.69114-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) -- 2.16.1 diff --git a/Documentation/block/bfq-iosched.txt b/Documentation/block/bfq-iosched.txt index 6d7dd5ab8554..b1faf091266e 100644 --- a/Documentation/block/bfq-iosched.txt +++ b/Documentation/block/bfq-iosched.txt @@ -508,12 +508,11 @@ 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 shares interface files with CFQ. So, if one reads/writes a file +provided by the proportional share policy for a group, then the +associated operation is performed by/on BFQ for each device where BFQ +is the active scheduler, and by/on CFQ for each device where CFQ is +the active scheduler. 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 +520,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 +535,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.