All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] Constify struct mtrr_ops for v2.6.33-rc6
       [not found] <4B65D712.3080804@gmail.com>
@ 2010-02-01 19:08 ` H. Peter Anvin
  2010-02-01 19:54 ` [tip:x86/mtrr] x86, mtrr: Constify struct mtrr_ops tip-bot for Emese Revfy
  1 sibling, 0 replies; 2+ messages in thread
From: H. Peter Anvin @ 2010-02-01 19:08 UTC (permalink / raw)
  To: Emese Revfy; +Cc: mingo, tglx, torvalds, linux-kernel

On 01/31/2010 11:16 AM, Emese Revfy wrote:
> From: Emese Revfy <re.emese@gmail.com>
> 
> Constify struct mtrr_ops.
> 
> This is part of the ops structure constification
> effort started by Arjan van de Ven et al.
> 
> Benefits of this constification:
> 
>  * prevents modification of data that is shared
>    (referenced) by many other structure instances
>    at runtime
> 
>  * detects/prevents accidental (but not intentional)
>    modification attempts on archs that enforce
>    read-only kernel data at runtime
> 
>  * potentially better optimized code as the compiler
>    can assume that the const data cannot be changed
> 
>  * the compiler/linker move const data into .rodata
>    and therefore exclude them from false sharing
> 
> Signed-off-by: Emese Revfy <re.emese@gmail.com>
> Acked-by: H. Peter Anvin <hpa@zytor.com>

Yes, but this doesn't exactly seem like 2.6.33 matter.  I will put it in
-tip for 2.6.34.

	-hpa

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

* [tip:x86/mtrr] x86, mtrr: Constify struct mtrr_ops
       [not found] <4B65D712.3080804@gmail.com>
  2010-02-01 19:08 ` [PATCH] Constify struct mtrr_ops for v2.6.33-rc6 H. Peter Anvin
@ 2010-02-01 19:54 ` tip-bot for Emese Revfy
  1 sibling, 0 replies; 2+ messages in thread
From: tip-bot for Emese Revfy @ 2010-02-01 19:54 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, re.emese, hpa, mingo, tglx

Commit-ID:  3b9cfc0a99f88c0db7c72363620584a9b40b4543
Gitweb:     http://git.kernel.org/tip/3b9cfc0a99f88c0db7c72363620584a9b40b4543
Author:     Emese Revfy <re.emese@gmail.com>
AuthorDate: Sun, 31 Jan 2010 20:16:34 +0100
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Mon, 1 Feb 2010 11:20:43 -0800

x86, mtrr: Constify struct mtrr_ops

This is part of the ops structure constification
effort started by Arjan van de Ven et al.

Benefits of this constification:

 * prevents modification of data that is shared
   (referenced) by many other structure instances
   at runtime

 * detects/prevents accidental (but not intentional)
   modification attempts on archs that enforce
   read-only kernel data at runtime

 * potentially better optimized code as the compiler
   can assume that the const data cannot be changed

 * the compiler/linker move const data into .rodata
   and therefore exclude them from false sharing

Signed-off-by: Emese Revfy <re.emese@gmail.com>
LKML-Reference: <4B65D712.3080804@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
 arch/x86/kernel/cpu/mtrr/amd.c     |    2 +-
 arch/x86/kernel/cpu/mtrr/centaur.c |    2 +-
 arch/x86/kernel/cpu/mtrr/cyrix.c   |    2 +-
 arch/x86/kernel/cpu/mtrr/generic.c |    2 +-
 arch/x86/kernel/cpu/mtrr/main.c    |    6 +++---
 arch/x86/kernel/cpu/mtrr/mtrr.h    |    6 +++---
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/amd.c b/arch/x86/kernel/cpu/mtrr/amd.c
index 33af141..92ba9cd 100644
--- a/arch/x86/kernel/cpu/mtrr/amd.c
+++ b/arch/x86/kernel/cpu/mtrr/amd.c
@@ -108,7 +108,7 @@ amd_validate_add_page(unsigned long base, unsigned long size, unsigned int type)
 	return 0;
 }
 
-static struct mtrr_ops amd_mtrr_ops = {
+static const struct mtrr_ops amd_mtrr_ops = {
 	.vendor            = X86_VENDOR_AMD,
 	.set               = amd_set_mtrr,
 	.get               = amd_get_mtrr,
diff --git a/arch/x86/kernel/cpu/mtrr/centaur.c b/arch/x86/kernel/cpu/mtrr/centaur.c
index de89f14..316fe3e 100644
--- a/arch/x86/kernel/cpu/mtrr/centaur.c
+++ b/arch/x86/kernel/cpu/mtrr/centaur.c
@@ -110,7 +110,7 @@ centaur_validate_add_page(unsigned long base, unsigned long size, unsigned int t
 	return 0;
 }
 
-static struct mtrr_ops centaur_mtrr_ops = {
+static const struct mtrr_ops centaur_mtrr_ops = {
 	.vendor            = X86_VENDOR_CENTAUR,
 	.set               = centaur_set_mcr,
 	.get               = centaur_get_mcr,
diff --git a/arch/x86/kernel/cpu/mtrr/cyrix.c b/arch/x86/kernel/cpu/mtrr/cyrix.c
index 228d982..68a3343 100644
--- a/arch/x86/kernel/cpu/mtrr/cyrix.c
+++ b/arch/x86/kernel/cpu/mtrr/cyrix.c
@@ -265,7 +265,7 @@ static void cyrix_set_all(void)
 	post_set();
 }
 
-static struct mtrr_ops cyrix_mtrr_ops = {
+static const struct mtrr_ops cyrix_mtrr_ops = {
 	.vendor            = X86_VENDOR_CYRIX,
 	.set_all	   = cyrix_set_all,
 	.set               = cyrix_set_arr,
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c
index 55da0c5..4d75584 100644
--- a/arch/x86/kernel/cpu/mtrr/generic.c
+++ b/arch/x86/kernel/cpu/mtrr/generic.c
@@ -752,7 +752,7 @@ int positive_have_wrcomb(void)
 /*
  * Generic structure...
  */
-struct mtrr_ops generic_mtrr_ops = {
+const struct mtrr_ops generic_mtrr_ops = {
 	.use_intel_if		= 1,
 	.set_all		= generic_set_all,
 	.get			= generic_get_mtrr,
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index 84e83de..fe4622e 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -60,14 +60,14 @@ static DEFINE_MUTEX(mtrr_mutex);
 u64 size_or_mask, size_and_mask;
 static bool mtrr_aps_delayed_init;
 
-static struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
+static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
 
-struct mtrr_ops *mtrr_if;
+const struct mtrr_ops *mtrr_if;
 
 static void set_mtrr(unsigned int reg, unsigned long base,
 		     unsigned long size, mtrr_type type);
 
-void set_mtrr_ops(struct mtrr_ops *ops)
+void set_mtrr_ops(const struct mtrr_ops *ops)
 {
 	if (ops->vendor && ops->vendor < X86_VENDOR_NUM)
 		mtrr_ops[ops->vendor] = ops;
diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
index a501dee..df5e41f 100644
--- a/arch/x86/kernel/cpu/mtrr/mtrr.h
+++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
@@ -32,7 +32,7 @@ extern int generic_get_free_region(unsigned long base, unsigned long size,
 extern int generic_validate_add_page(unsigned long base, unsigned long size,
 				     unsigned int type);
 
-extern struct mtrr_ops generic_mtrr_ops;
+extern const struct mtrr_ops generic_mtrr_ops;
 
 extern int positive_have_wrcomb(void);
 
@@ -53,10 +53,10 @@ void fill_mtrr_var_range(unsigned int index,
 		u32 base_lo, u32 base_hi, u32 mask_lo, u32 mask_hi);
 void get_mtrr_state(void);
 
-extern void set_mtrr_ops(struct mtrr_ops *ops);
+extern void set_mtrr_ops(const struct mtrr_ops *ops);
 
 extern u64 size_or_mask, size_and_mask;
-extern struct mtrr_ops *mtrr_if;
+extern const struct mtrr_ops *mtrr_if;
 
 #define is_cpu(vnd)	(mtrr_if && mtrr_if->vendor == X86_VENDOR_##vnd)
 #define use_intel()	(mtrr_if && mtrr_if->use_intel_if == 1)

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

end of thread, other threads:[~2010-02-01 19:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4B65D712.3080804@gmail.com>
2010-02-01 19:08 ` [PATCH] Constify struct mtrr_ops for v2.6.33-rc6 H. Peter Anvin
2010-02-01 19:54 ` [tip:x86/mtrr] x86, mtrr: Constify struct mtrr_ops tip-bot for Emese Revfy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.