linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/resctrl: Constify kernfs_ops
@ 2020-11-10 23:02 Rikard Falkeborn
  2020-11-18 23:35 ` Reinette Chatre
  2020-11-19 17:40 ` [tip: x86/cache] " tip-bot2 for Rikard Falkeborn
  0 siblings, 2 replies; 3+ messages in thread
From: Rikard Falkeborn @ 2020-11-10 23:02 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov
  Cc: Fenghua Yu, Reinette Chatre, H. Peter Anvin, x86, linux-kernel,
	Rikard Falkeborn

The only usage of the kf_ops field in the rftype struct is to pass it as
argument to __kernfs_create_file(), which accepts a pointer to const.
Make it a pointer to const. This makes it possible to make
rdtgroup_kf_single_ops and kf_mondata_ops const, which allows the
compiler to put them in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 arch/x86/kernel/cpu/resctrl/internal.h | 2 +-
 arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 6cb068fcf501..5540b025880c 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -264,7 +264,7 @@ void __exit rdtgroup_exit(void);
 struct rftype {
 	char			*name;
 	umode_t			mode;
-	struct kernfs_ops	*kf_ops;
+	const struct kernfs_ops	*kf_ops;
 	unsigned long		flags;
 	unsigned long		fflags;
 
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index af323e2e3100..78dcbb8e0172 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -240,13 +240,13 @@ static ssize_t rdtgroup_file_write(struct kernfs_open_file *of, char *buf,
 	return -EINVAL;
 }
 
-static struct kernfs_ops rdtgroup_kf_single_ops = {
+static const struct kernfs_ops rdtgroup_kf_single_ops = {
 	.atomic_write_len	= PAGE_SIZE,
 	.write			= rdtgroup_file_write,
 	.seq_show		= rdtgroup_seqfile_show,
 };
 
-static struct kernfs_ops kf_mondata_ops = {
+static const struct kernfs_ops kf_mondata_ops = {
 	.atomic_write_len	= PAGE_SIZE,
 	.seq_show		= rdtgroup_mondata_show,
 };
-- 
2.29.2


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

* Re: [PATCH] x86/resctrl: Constify kernfs_ops
  2020-11-10 23:02 [PATCH] x86/resctrl: Constify kernfs_ops Rikard Falkeborn
@ 2020-11-18 23:35 ` Reinette Chatre
  2020-11-19 17:40 ` [tip: x86/cache] " tip-bot2 for Rikard Falkeborn
  1 sibling, 0 replies; 3+ messages in thread
From: Reinette Chatre @ 2020-11-18 23:35 UTC (permalink / raw)
  To: Rikard Falkeborn, Thomas Gleixner, Ingo Molnar, Borislav Petkov
  Cc: Fenghua Yu, H. Peter Anvin, x86, linux-kernel

On 11/10/2020 3:02 PM, Rikard Falkeborn wrote:
> The only usage of the kf_ops field in the rftype struct is to pass it as
> argument to __kernfs_create_file(), which accepts a pointer to const.
> Make it a pointer to const. This makes it possible to make
> rdtgroup_kf_single_ops and kf_mondata_ops const, which allows the
> compiler to put them in read-only memory.
> 
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>

Thank you very much Rikard.

Acked-by: Reinette Chatre <reinette.chatre@intel.com>

Reinette

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

* [tip: x86/cache] x86/resctrl: Constify kernfs_ops
  2020-11-10 23:02 [PATCH] x86/resctrl: Constify kernfs_ops Rikard Falkeborn
  2020-11-18 23:35 ` Reinette Chatre
@ 2020-11-19 17:40 ` tip-bot2 for Rikard Falkeborn
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Rikard Falkeborn @ 2020-11-19 17:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Rikard Falkeborn, Borislav Petkov, Reinette Chatre, x86, linux-kernel

The following commit has been merged into the x86/cache branch of tip:

Commit-ID:     2002d2951398317d0f46e64ae6d8dd58ed541c6d
Gitweb:        https://git.kernel.org/tip/2002d2951398317d0f46e64ae6d8dd58ed541c6d
Author:        Rikard Falkeborn <rikard.falkeborn@gmail.com>
AuthorDate:    Wed, 11 Nov 2020 00:02:28 +01:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Thu, 19 Nov 2020 18:23:45 +01:00

x86/resctrl: Constify kernfs_ops

The only usage of the kf_ops field in the rftype struct is to pass
it as argument to __kernfs_create_file(), which accepts a pointer to
const. Make it a pointer to const. This makes it possible to make
rdtgroup_kf_single_ops and kf_mondata_ops const, which allows the
compiler to put them in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Reinette Chatre <reinette.chatre@intel.com>
Link: https://lkml.kernel.org/r/20201110230228.801785-1-rikard.falkeborn@gmail.com
---
 arch/x86/kernel/cpu/resctrl/internal.h | 2 +-
 arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 6cb068f..5540b02 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -264,7 +264,7 @@ void __exit rdtgroup_exit(void);
 struct rftype {
 	char			*name;
 	umode_t			mode;
-	struct kernfs_ops	*kf_ops;
+	const struct kernfs_ops	*kf_ops;
 	unsigned long		flags;
 	unsigned long		fflags;
 
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index af323e2..78dcbb8 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -240,13 +240,13 @@ static ssize_t rdtgroup_file_write(struct kernfs_open_file *of, char *buf,
 	return -EINVAL;
 }
 
-static struct kernfs_ops rdtgroup_kf_single_ops = {
+static const struct kernfs_ops rdtgroup_kf_single_ops = {
 	.atomic_write_len	= PAGE_SIZE,
 	.write			= rdtgroup_file_write,
 	.seq_show		= rdtgroup_seqfile_show,
 };
 
-static struct kernfs_ops kf_mondata_ops = {
+static const struct kernfs_ops kf_mondata_ops = {
 	.atomic_write_len	= PAGE_SIZE,
 	.seq_show		= rdtgroup_mondata_show,
 };

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

end of thread, other threads:[~2020-11-19 17:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10 23:02 [PATCH] x86/resctrl: Constify kernfs_ops Rikard Falkeborn
2020-11-18 23:35 ` Reinette Chatre
2020-11-19 17:40 ` [tip: x86/cache] " tip-bot2 for Rikard Falkeborn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).