lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1609758533-14337-1-git-send-email-zhouchuangao@xiaomi.com>
Date:   Mon,  4 Jan 2021 19:08:53 +0800
From:   zhouchuangao <chuangaozhou@...il.com>
To:     fenghua.yu@...el.com, reinette.chatre@...el.com,
        tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, x86@...nel.org
Cc:     hpa@...or.com, linux-kernel@...r.kernel.org,
        zhouchuangao <zhouchuangao@...omi.com>
Subject: [PATCH] x86/kernel/cpu/resctrl: replace 'of->kn->priv' with of_rft()

The use of 'of->kn->priv' to get rftype can be found in several
places in arch/x86/kernel/cpu/resctrl/rdtgroup.c, which may reduce
readability.

So replace the direct use 'of->kn->priv' with inline function
of_rft(), which is more readable.

Signed-off-by: zhouchuangao <zhouchuangao@...omi.com>
---
 arch/x86/kernel/cpu/resctrl/internal.h | 5 +++++
 arch/x86/kernel/cpu/resctrl/rdtgroup.c | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index ee71c47..f684b6d 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -409,6 +409,11 @@ struct rdt_membw {
 	u32				*mb_map;
 };
 
+static inline struct rftype *of_rft(struct kernfs_open_file *of)
+{
+	return of->kn->priv;
+}
+
 static inline bool is_llc_occupancy_enabled(void)
 {
 	return (rdt_mon_features & (1 << QOS_L3_OCCUP_EVENT_ID));
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 29ffb95..b0ea6fc 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -222,7 +222,7 @@ static int rdtgroup_add_file(struct kernfs_node *parent_kn, struct rftype *rft)
 static int rdtgroup_seqfile_show(struct seq_file *m, void *arg)
 {
 	struct kernfs_open_file *of = m->private;
-	struct rftype *rft = of->kn->priv;
+	struct rftype *rft = of_rft(of);
 
 	if (rft->seq_show)
 		return rft->seq_show(of, m, arg);
@@ -232,7 +232,7 @@ static int rdtgroup_seqfile_show(struct seq_file *m, void *arg)
 static ssize_t rdtgroup_file_write(struct kernfs_open_file *of, char *buf,
 				   size_t nbytes, loff_t off)
 {
-	struct rftype *rft = of->kn->priv;
+	struct rftype *rft = of_rft(of);
 
 	if (rft->write)
 		return rft->write(of, buf, nbytes, off);
@@ -253,7 +253,7 @@ static const struct kernfs_ops kf_mondata_ops = {
 
 static bool is_cpu_list(struct kernfs_open_file *of)
 {
-	struct rftype *rft = of->kn->priv;
+	struct rftype *rft = of_rft(of);
 
 	return rft->flags & RFTYPE_FLAGS_CPUS_LIST;
 }
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ