mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/kernel/cpu/resctrl: replace 'of->kn->priv' with of_rft()
@ 2021-01-04 11:08 zhouchuangao
  2021-01-07 22:29 ` Reinette Chatre
  0 siblings, 1 reply; 2+ messages in thread
From: zhouchuangao @ 2021-01-04 11:08 UTC (permalink / raw)
  To: fenghua.yu, reinette.chatre, tglx, mingo, bp, x86
  Cc: hpa, linux-kernel, zhouchuangao

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@xiaomi.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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/kernel/cpu/resctrl: replace 'of->kn->priv' with of_rft()
  2021-01-04 11:08 [PATCH] x86/kernel/cpu/resctrl: replace 'of->kn->priv' with of_rft() zhouchuangao
@ 2021-01-07 22:29 ` Reinette Chatre
  0 siblings, 0 replies; 2+ messages in thread
From: Reinette Chatre @ 2021-01-07 22:29 UTC (permalink / raw)
  To: zhouchuangao, fenghua.yu, tglx, mingo, bp, x86
  Cc: hpa, linux-kernel, zhouchuangao

Hi,

On 1/4/2021 3:08 AM, zhouchuangao wrote:
> 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.

Readability can be subjective. The current assignment appears succinct 
and in my opinion the additional layer of indirection does not improve 
the readability.

Reinette


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-07 22:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-04 11:08 [PATCH] x86/kernel/cpu/resctrl: replace 'of->kn->priv' with of_rft() zhouchuangao
2021-01-07 22:29 ` Reinette Chatre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®