public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] module: constify within_module_*
@ 2013-01-09 23:09 Sasha Levin
  2013-01-09 23:09 ` [PATCH 2/5] jump label: constify lookup functions Sasha Levin
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Sasha Levin @ 2013-01-09 23:09 UTC (permalink / raw)
  To: tglx, mingo, hpa, rostedt, fweisbec, rusty, ananth,
	anil.s.keshavamurthy, masami.hiramatsu.pt, jbaron
  Cc: x86, linux-kernel, Sasha Levin

These helper functions just check a set intersection with a range, and
don't actually modify struct module.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 include/linux/module.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/module.h b/include/linux/module.h
index 7760c6d..2e5d49e 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -396,13 +396,13 @@ bool is_module_address(unsigned long addr);
 bool is_module_percpu_address(unsigned long addr);
 bool is_module_text_address(unsigned long addr);
 
-static inline int within_module_core(unsigned long addr, struct module *mod)
+static inline int within_module_core(unsigned long addr, const struct module *mod)
 {
 	return (unsigned long)mod->module_core <= addr &&
 	       addr < (unsigned long)mod->module_core + mod->core_size;
 }
 
-static inline int within_module_init(unsigned long addr, struct module *mod)
+static inline int within_module_init(unsigned long addr, const struct module *mod)
 {
 	return (unsigned long)mod->module_init <= addr &&
 	       addr < (unsigned long)mod->module_init + mod->init_size;
-- 
1.8.1


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

* [PATCH 2/5] jump label: constify lookup functions
  2013-01-09 23:09 [PATCH 1/5] module: constify within_module_* Sasha Levin
@ 2013-01-09 23:09 ` Sasha Levin
  2013-01-15 20:46   ` Sasha Levin
                     ` (2 more replies)
  2013-01-09 23:09 ` [PATCH 3/5] kprobes: constify check_kprobe_address_safe and friends Sasha Levin
                   ` (3 subsequent siblings)
  4 siblings, 3 replies; 18+ messages in thread
From: Sasha Levin @ 2013-01-09 23:09 UTC (permalink / raw)
  To: tglx, mingo, hpa, rostedt, fweisbec, rusty, ananth,
	anil.s.keshavamurthy, masami.hiramatsu.pt, jbaron
  Cc: x86, linux-kernel, Sasha Levin

Modify the parameters of all the lookup and the bookkeeping functions which
should be const to const.

For example, jump_label_text_reserved() doesn't modify the memory it works on,
it just checks whether there are any jump labels there.

Note I couldn't test the non-x86 architectures, but the changes are rather
trivial.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 arch/arm/include/asm/jump_label.h     |  2 +-
 arch/arm/kernel/jump_label.c          |  6 +++---
 arch/mips/include/asm/jump_label.h    |  2 +-
 arch/mips/kernel/jump_label.c         |  2 +-
 arch/powerpc/include/asm/jump_label.h |  2 +-
 arch/powerpc/kernel/jump_label.c      |  2 +-
 arch/s390/include/asm/jump_label.h    |  2 +-
 arch/s390/kernel/jump_label.c         |  8 ++++----
 arch/sparc/include/asm/jump_label.h   |  2 +-
 arch/sparc/kernel/jump_label.c        |  2 +-
 arch/x86/include/asm/jump_label.h     |  2 +-
 arch/x86/kernel/jump_label.c          |  6 +++---
 include/linux/jump_label.h            | 24 ++++++++++++------------
 kernel/jump_label.c                   | 27 +++++++++++++++------------
 14 files changed, 46 insertions(+), 43 deletions(-)

diff --git a/arch/arm/include/asm/jump_label.h b/arch/arm/include/asm/jump_label.h
index bfc198c..f4ee633 100644
--- a/arch/arm/include/asm/jump_label.h
+++ b/arch/arm/include/asm/jump_label.h
@@ -14,7 +14,7 @@
 #define JUMP_LABEL_NOP	"nop"
 #endif
 
-static __always_inline bool arch_static_branch(struct static_key *key)
+static __always_inline bool arch_static_branch(const struct static_key *key)
 {
 	asm goto("1:\n\t"
 		 JUMP_LABEL_NOP "\n\t"
diff --git a/arch/arm/kernel/jump_label.c b/arch/arm/kernel/jump_label.c
index 4ce4f78..9686fce 100644
--- a/arch/arm/kernel/jump_label.c
+++ b/arch/arm/kernel/jump_label.c
@@ -6,7 +6,7 @@
 
 #ifdef HAVE_JUMP_LABEL
 
-static void __arch_jump_label_transform(struct jump_entry *entry,
+static void __arch_jump_label_transform(const struct jump_entry *entry,
 					enum jump_label_type type,
 					bool is_static)
 {
@@ -24,13 +24,13 @@ static void __arch_jump_label_transform(struct jump_entry *entry,
 		patch_text(addr, insn);
 }
 
-void arch_jump_label_transform(struct jump_entry *entry,
+void arch_jump_label_transform(const struct jump_entry *entry,
 			       enum jump_label_type type)
 {
 	__arch_jump_label_transform(entry, type, false);
 }
 
-void arch_jump_label_transform_static(struct jump_entry *entry,
+void arch_jump_label_transform_static(const struct jump_entry *entry,
 				      enum jump_label_type type)
 {
 	__arch_jump_label_transform(entry, type, true);
diff --git a/arch/mips/include/asm/jump_label.h b/arch/mips/include/asm/jump_label.h
index 4d6d77e..a95ddf5 100644
--- a/arch/mips/include/asm/jump_label.h
+++ b/arch/mips/include/asm/jump_label.h
@@ -20,7 +20,7 @@
 #define WORD_INSN ".word"
 #endif
 
-static __always_inline bool arch_static_branch(struct static_key *key)
+static __always_inline bool arch_static_branch(const struct static_key *key)
 {
 	asm goto("1:\tnop\n\t"
 		"nop\n\t"
diff --git a/arch/mips/kernel/jump_label.c b/arch/mips/kernel/jump_label.c
index 6001610..bfba488 100644
--- a/arch/mips/kernel/jump_label.c
+++ b/arch/mips/kernel/jump_label.c
@@ -20,7 +20,7 @@
 
 #define J_RANGE_MASK ((1ul << 28) - 1)
 
-void arch_jump_label_transform(struct jump_entry *e,
+void arch_jump_label_transform(const struct jump_entry *e,
 			       enum jump_label_type type)
 {
 	union mips_instruction insn;
diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h
index ae098c4..c00b303 100644
--- a/arch/powerpc/include/asm/jump_label.h
+++ b/arch/powerpc/include/asm/jump_label.h
@@ -17,7 +17,7 @@
 #define JUMP_ENTRY_TYPE		stringify_in_c(FTR_ENTRY_LONG)
 #define JUMP_LABEL_NOP_SIZE	4
 
-static __always_inline bool arch_static_branch(struct static_key *key)
+static __always_inline bool arch_static_branch(const struct static_key *key)
 {
 	asm goto("1:\n\t"
 		 "nop\n\t"
diff --git a/arch/powerpc/kernel/jump_label.c b/arch/powerpc/kernel/jump_label.c
index a1ed8a8..f9626ec 100644
--- a/arch/powerpc/kernel/jump_label.c
+++ b/arch/powerpc/kernel/jump_label.c
@@ -12,7 +12,7 @@
 #include <asm/code-patching.h>
 
 #ifdef HAVE_JUMP_LABEL
-void arch_jump_label_transform(struct jump_entry *entry,
+void arch_jump_label_transform(const struct jump_entry *entry,
 			       enum jump_label_type type)
 {
 	u32 *addr = (u32 *)(unsigned long)entry->code;
diff --git a/arch/s390/include/asm/jump_label.h b/arch/s390/include/asm/jump_label.h
index 6c32190..96adb78 100644
--- a/arch/s390/include/asm/jump_label.h
+++ b/arch/s390/include/asm/jump_label.h
@@ -13,7 +13,7 @@
 #define ASM_ALIGN ".balign 4"
 #endif
 
-static __always_inline bool arch_static_branch(struct static_key *key)
+static __always_inline bool arch_static_branch(const struct static_key *key)
 {
 	asm goto("0:	brcl 0,0\n"
 		".pushsection __jump_table, \"aw\"\n"
diff --git a/arch/s390/kernel/jump_label.c b/arch/s390/kernel/jump_label.c
index b987ab2..85fa643 100644
--- a/arch/s390/kernel/jump_label.c
+++ b/arch/s390/kernel/jump_label.c
@@ -22,7 +22,7 @@ struct insn_args {
 	enum jump_label_type type;
 };
 
-static void __jump_label_transform(struct jump_entry *entry,
+static void __jump_label_transform(const struct jump_entry *entry,
 				   enum jump_label_type type)
 {
 	struct insn insn;
@@ -44,13 +44,13 @@ static void __jump_label_transform(struct jump_entry *entry,
 
 static int __sm_arch_jump_label_transform(void *data)
 {
-	struct insn_args *args = data;
+	const struct insn_args *args = data;
 
 	__jump_label_transform(args->entry, args->type);
 	return 0;
 }
 
-void arch_jump_label_transform(struct jump_entry *entry,
+void arch_jump_label_transform(const struct jump_entry *entry,
 			       enum jump_label_type type)
 {
 	struct insn_args args;
@@ -61,7 +61,7 @@ void arch_jump_label_transform(struct jump_entry *entry,
 	stop_machine(__sm_arch_jump_label_transform, &args, NULL);
 }
 
-void arch_jump_label_transform_static(struct jump_entry *entry,
+void arch_jump_label_transform_static(const struct jump_entry *entry,
 				      enum jump_label_type type)
 {
 	__jump_label_transform(entry, type);
diff --git a/arch/sparc/include/asm/jump_label.h b/arch/sparc/include/asm/jump_label.h
index 5080d16..44cb914 100644
--- a/arch/sparc/include/asm/jump_label.h
+++ b/arch/sparc/include/asm/jump_label.h
@@ -7,7 +7,7 @@
 
 #define JUMP_LABEL_NOP_SIZE 4
 
-static __always_inline bool arch_static_branch(struct static_key *key)
+static __always_inline bool arch_static_branch(const struct static_key *key)
 {
 		asm goto("1:\n\t"
 			 "nop\n\t"
diff --git a/arch/sparc/kernel/jump_label.c b/arch/sparc/kernel/jump_label.c
index 48565c1..231c10e 100644
--- a/arch/sparc/kernel/jump_label.c
+++ b/arch/sparc/kernel/jump_label.c
@@ -10,7 +10,7 @@
 
 #ifdef HAVE_JUMP_LABEL
 
-void arch_jump_label_transform(struct jump_entry *entry,
+void arch_jump_label_transform(const struct jump_entry *entry,
 			       enum jump_label_type type)
 {
 	u32 val;
diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h
index 3a16c14..6b6e976 100644
--- a/arch/x86/include/asm/jump_label.h
+++ b/arch/x86/include/asm/jump_label.h
@@ -11,7 +11,7 @@
 
 #define STATIC_KEY_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t"
 
-static __always_inline bool arch_static_branch(struct static_key *key)
+static __always_inline bool arch_static_branch(const struct static_key *key)
 {
 	asm goto("1:"
 		STATIC_KEY_INITIAL_NOP
diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
index 2889b3d..a7d2c5a 100644
--- a/arch/x86/kernel/jump_label.c
+++ b/arch/x86/kernel/jump_label.c
@@ -24,7 +24,7 @@ union jump_code_union {
 	} __attribute__((packed));
 };
 
-static void __jump_label_transform(struct jump_entry *entry,
+static void __jump_label_transform(const struct jump_entry *entry,
 				   enum jump_label_type type,
 				   void *(*poker)(void *, const void *, size_t))
 {
@@ -40,7 +40,7 @@ static void __jump_label_transform(struct jump_entry *entry,
 	(*poker)((void *)entry->code, &code, JUMP_LABEL_NOP_SIZE);
 }
 
-void arch_jump_label_transform(struct jump_entry *entry,
+void arch_jump_label_transform(const struct jump_entry *entry,
 			       enum jump_label_type type)
 {
 	get_online_cpus();
@@ -50,7 +50,7 @@ void arch_jump_label_transform(struct jump_entry *entry,
 	put_online_cpus();
 }
 
-__init_or_module void arch_jump_label_transform_static(struct jump_entry *entry,
+__init_or_module void arch_jump_label_transform_static(const struct jump_entry *entry,
 				      enum jump_label_type type)
 {
 	__jump_label_transform(entry, type, text_poke_early);
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 0976fc4..7c33d29 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -89,19 +89,19 @@ inline struct jump_entry *jump_label_get_entries(struct static_key *key)
 						& ~JUMP_LABEL_TRUE_BRANCH);
 }
 
-static inline bool jump_label_get_branch_default(struct static_key *key)
+static inline bool jump_label_get_branch_default(const struct static_key *key)
 {
 	if ((unsigned long)key->entries & JUMP_LABEL_TRUE_BRANCH)
 		return true;
 	return false;
 }
 
-static __always_inline bool static_key_false(struct static_key *key)
+static __always_inline bool static_key_false(const struct static_key *key)
 {
 	return arch_static_branch(key);
 }
 
-static __always_inline bool static_key_true(struct static_key *key)
+static __always_inline bool static_key_true(const struct static_key *key)
 {
 	return !static_key_false(key);
 }
@@ -112,15 +112,15 @@ extern struct jump_entry __stop___jump_table[];
 extern void jump_label_init(void);
 extern void jump_label_lock(void);
 extern void jump_label_unlock(void);
-extern void arch_jump_label_transform(struct jump_entry *entry,
+extern void arch_jump_label_transform(const struct jump_entry *entry,
 				      enum jump_label_type type);
-extern void arch_jump_label_transform_static(struct jump_entry *entry,
+extern void arch_jump_label_transform_static(const struct jump_entry *entry,
 					     enum jump_label_type type);
-extern int jump_label_text_reserved(void *start, void *end);
+extern int jump_label_text_reserved(const void *start, const void *end);
 extern void static_key_slow_inc(struct static_key *key);
 extern void static_key_slow_dec(struct static_key *key);
 extern void static_key_slow_dec_deferred(struct static_key_deferred *key);
-extern void jump_label_apply_nops(struct module *mod);
+extern void jump_label_apply_nops(const struct module *mod);
 extern void
 jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);
 
@@ -145,14 +145,14 @@ struct static_key_deferred {
 	struct static_key  key;
 };
 
-static __always_inline bool static_key_false(struct static_key *key)
+static __always_inline bool static_key_false(const struct static_key *key)
 {
 	if (unlikely(atomic_read(&key->enabled)) > 0)
 		return true;
 	return false;
 }
 
-static __always_inline bool static_key_true(struct static_key *key)
+static __always_inline bool static_key_true(const struct static_key *key)
 {
 	if (likely(atomic_read(&key->enabled)) > 0)
 		return true;
@@ -174,7 +174,7 @@ static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
 	static_key_slow_dec(&key->key);
 }
 
-static inline int jump_label_text_reserved(void *start, void *end)
+static inline int jump_label_text_reserved(const void *start, const void *end)
 {
 	return 0;
 }
@@ -182,7 +182,7 @@ static inline int jump_label_text_reserved(void *start, void *end)
 static inline void jump_label_lock(void) {}
 static inline void jump_label_unlock(void) {}
 
-static inline int jump_label_apply_nops(struct module *mod)
+static inline int jump_label_apply_nops(const struct module *mod)
 {
 	return 0;
 }
@@ -203,7 +203,7 @@ jump_label_rate_limit(struct static_key_deferred *key,
 #define STATIC_KEY_INIT STATIC_KEY_INIT_FALSE
 #define jump_label_enabled static_key_enabled
 
-static inline bool static_key_enabled(struct static_key *key)
+static inline bool static_key_enabled(const struct static_key *key)
 {
 	return (atomic_read(&key->enabled) > 0);
 }
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 60f48fa..ba2fa54 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -120,7 +120,8 @@ void jump_label_rate_limit(struct static_key_deferred *key,
 }
 EXPORT_SYMBOL_GPL(jump_label_rate_limit);
 
-static int addr_conflict(struct jump_entry *entry, void *start, void *end)
+static int addr_conflict(const struct jump_entry *entry,
+			const void *start, const void *end)
 {
 	if (entry->code <= (unsigned long)end &&
 		entry->code + JUMP_LABEL_NOP_SIZE > (unsigned long)start)
@@ -130,7 +131,8 @@ static int addr_conflict(struct jump_entry *entry, void *start, void *end)
 }
 
 static int __jump_label_text_reserved(struct jump_entry *iter_start,
-		struct jump_entry *iter_stop, void *start, void *end)
+		struct jump_entry *iter_stop,
+		const void *start, const void *end)
 {
 	struct jump_entry *iter;
 
@@ -150,7 +152,7 @@ static int __jump_label_text_reserved(struct jump_entry *iter_start,
  * running code can override this to make the non-live update case
  * cheaper.
  */
-void __weak __init_or_module arch_jump_label_transform_static(struct jump_entry *entry,
+void __weak __init_or_module arch_jump_label_transform_static(const struct jump_entry *entry,
 					    enum jump_label_type type)
 {
 	arch_jump_label_transform(entry, type);	
@@ -173,7 +175,7 @@ static void __jump_label_update(struct static_key *key,
 	}
 }
 
-static enum jump_label_type jump_label_type(struct static_key *key)
+static enum jump_label_type jump_label_type(const struct static_key *key)
 {
 	bool true_branch = jump_label_get_branch_default(key);
 	bool state = static_key_enabled(key);
@@ -219,10 +221,11 @@ void __init jump_label_init(void)
 struct static_key_mod {
 	struct static_key_mod *next;
 	struct jump_entry *entries;
-	struct module *mod;
+	const struct module *mod;
 };
 
-static int __jump_label_mod_text_reserved(void *start, void *end)
+static int __jump_label_mod_text_reserved(const void *start,
+						const void *end)
 {
 	struct module *mod;
 
@@ -242,7 +245,7 @@ static void __jump_label_mod_update(struct static_key *key, int enable)
 	struct static_key_mod *mod = key->next;
 
 	while (mod) {
-		struct module *m = mod->mod;
+		const struct module *m = mod->mod;
 
 		__jump_label_update(key, mod->entries,
 				    m->jump_entries + m->num_jump_entries,
@@ -259,7 +262,7 @@ static void __jump_label_mod_update(struct static_key *key, int enable)
  * loads patch these with arch_get_jump_label_nop(), which is specified by
  * the arch specific jump label code.
  */
-void jump_label_apply_nops(struct module *mod)
+void jump_label_apply_nops(const struct module *mod)
 {
 	struct jump_entry *iter_start = mod->jump_entries;
 	struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
@@ -274,7 +277,7 @@ void jump_label_apply_nops(struct module *mod)
 	}
 }
 
-static int jump_label_add_module(struct module *mod)
+static int jump_label_add_module(const struct module *mod)
 {
 	struct jump_entry *iter_start = mod->jump_entries;
 	struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
@@ -319,7 +322,7 @@ static int jump_label_add_module(struct module *mod)
 	return 0;
 }
 
-static void jump_label_del_module(struct module *mod)
+static void jump_label_del_module(const struct module *mod)
 {
 	struct jump_entry *iter_start = mod->jump_entries;
 	struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
@@ -351,7 +354,7 @@ static void jump_label_del_module(struct module *mod)
 	}
 }
 
-static void jump_label_invalidate_module_init(struct module *mod)
+static void jump_label_invalidate_module_init(const struct module *mod)
 {
 	struct jump_entry *iter_start = mod->jump_entries;
 	struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
@@ -419,7 +422,7 @@ early_initcall(jump_label_init_module);
  *
  * returns 1 if there is an overlap, 0 otherwise
  */
-int jump_label_text_reserved(void *start, void *end)
+int jump_label_text_reserved(const void *start, const void *end)
 {
 	int ret = __jump_label_text_reserved(__start___jump_table,
 			__stop___jump_table, start, end);
-- 
1.8.1


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

* [PATCH 3/5] kprobes: constify check_kprobe_address_safe and friends
  2013-01-09 23:09 [PATCH 1/5] module: constify within_module_* Sasha Levin
  2013-01-09 23:09 ` [PATCH 2/5] jump label: constify lookup functions Sasha Levin
@ 2013-01-09 23:09 ` Sasha Levin
  2013-01-21 11:49   ` Masami Hiramatsu
  2013-01-09 23:09 ` [PATCH 4/5] alternatives: constify alternatives_text_reserved Sasha Levin
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Sasha Levin @ 2013-01-09 23:09 UTC (permalink / raw)
  To: tglx, mingo, hpa, rostedt, fweisbec, rusty, ananth,
	anil.s.keshavamurthy, masami.hiramatsu.pt, jbaron
  Cc: x86, linux-kernel, Sasha Levin

Constify the parameters of lookup functions.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 arch/x86/kernel/kprobes-opt.c | 8 ++++----
 kernel/kprobes.c              | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
index c5e410e..5876966 100644
--- a/arch/x86/kernel/kprobes-opt.c
+++ b/arch/x86/kernel/kprobes-opt.c
@@ -192,7 +192,7 @@ static int __kprobes copy_optimized_instructions(u8 *dest, u8 *src)
 }
 
 /* Check whether insn is indirect jump */
-static int __kprobes insn_is_indirect_jump(struct insn *insn)
+static int __kprobes insn_is_indirect_jump(const struct insn *insn)
 {
 	return ((insn->opcode.bytes[0] == 0xff &&
 		(X86_MODRM_REG(insn->modrm.value) & 6) == 4) || /* Jump */
@@ -200,7 +200,7 @@ static int __kprobes insn_is_indirect_jump(struct insn *insn)
 }
 
 /* Check whether insn jumps into specified address range */
-static int insn_jump_into_range(struct insn *insn, unsigned long start, int len)
+static int insn_jump_into_range(const struct insn *insn, unsigned long start, int len)
 {
 	unsigned long target = 0;
 
@@ -278,7 +278,7 @@ static int __kprobes can_optimize(unsigned long paddr)
 }
 
 /* Check optimized_kprobe can actually be optimized. */
-int __kprobes arch_check_optimized_kprobe(struct optimized_kprobe *op)
+int __kprobes arch_check_optimized_kprobe(const struct optimized_kprobe *op)
 {
 	int i;
 	struct kprobe *p;
@@ -294,7 +294,7 @@ int __kprobes arch_check_optimized_kprobe(struct optimized_kprobe *op)
 
 /* Check the addr is within the optimized instructions. */
 int __kprobes
-arch_within_optimized_kprobe(struct optimized_kprobe *op, unsigned long addr)
+arch_within_optimized_kprobe(const struct optimized_kprobe *op, unsigned long addr)
 {
 	return ((unsigned long)op->kp.addr <= addr &&
 		(unsigned long)op->kp.addr + op->optinsn.size > addr);
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 098f396..7daddb0 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1402,7 +1402,7 @@ static inline int check_kprobe_rereg(struct kprobe *p)
 	return ret;
 }
 
-static __kprobes int check_kprobe_address_safe(struct kprobe *p,
+static __kprobes int check_kprobe_address_safe(const struct kprobe *p,
 					       struct module **probed_mod)
 {
 	int ret = 0;
-- 
1.8.1


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

* [PATCH 4/5] alternatives: constify alternatives_text_reserved
  2013-01-09 23:09 [PATCH 1/5] module: constify within_module_* Sasha Levin
  2013-01-09 23:09 ` [PATCH 2/5] jump label: constify lookup functions Sasha Levin
  2013-01-09 23:09 ` [PATCH 3/5] kprobes: constify check_kprobe_address_safe and friends Sasha Levin
@ 2013-01-09 23:09 ` Sasha Levin
  2013-01-21 11:38   ` Masami Hiramatsu
  2013-01-09 23:09 ` [PATCH 5/5] ftrace: constify ftrace_text_reserved Sasha Levin
  2013-01-10  9:02 ` [PATCH 1/5] module: constify within_module_* Rusty Russell
  4 siblings, 1 reply; 18+ messages in thread
From: Sasha Levin @ 2013-01-09 23:09 UTC (permalink / raw)
  To: tglx, mingo, hpa, rostedt, fweisbec, rusty, ananth,
	anil.s.keshavamurthy, masami.hiramatsu.pt, jbaron
  Cc: x86, linux-kernel, Sasha Levin

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 arch/x86/include/asm/alternative.h | 4 ++--
 arch/x86/kernel/alternative.c      | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
index 58ed6d9..4d0d2fb 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -61,7 +61,7 @@ extern void alternatives_smp_module_add(struct module *mod, char *name,
 					void *text, void *text_end);
 extern void alternatives_smp_module_del(struct module *mod);
 extern void alternatives_enable_smp(void);
-extern int alternatives_text_reserved(void *start, void *end);
+extern int alternatives_text_reserved(const void *start, const void *end);
 extern bool skip_smp_alternatives;
 #else
 static inline void alternatives_smp_module_add(struct module *mod, char *name,
@@ -69,7 +69,7 @@ static inline void alternatives_smp_module_add(struct module *mod, char *name,
 					       void *text, void *text_end) {}
 static inline void alternatives_smp_module_del(struct module *mod) {}
 static inline void alternatives_enable_smp(void) {}
-static inline int alternatives_text_reserved(void *start, void *end)
+static inline int alternatives_text_reserved(const void *start, const void *end)
 {
 	return 0;
 }
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index ef5ccca..0994e41 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -431,12 +431,12 @@ void alternatives_enable_smp(void)
 }
 
 /* Return 1 if the address range is reserved for smp-alternatives */
-int alternatives_text_reserved(void *start, void *end)
+int alternatives_text_reserved(const void *start, const void *end)
 {
 	struct smp_alt_module *mod;
 	const s32 *poff;
-	u8 *text_start = start;
-	u8 *text_end = end;
+	const u8 *text_start = start;
+	const u8 *text_end = end;
 
 	list_for_each_entry(mod, &smp_alt_modules, next) {
 		if (mod->text > text_end || mod->text_end < text_start)
-- 
1.8.1


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

* [PATCH 5/5] ftrace: constify ftrace_text_reserved
  2013-01-09 23:09 [PATCH 1/5] module: constify within_module_* Sasha Levin
                   ` (2 preceding siblings ...)
  2013-01-09 23:09 ` [PATCH 4/5] alternatives: constify alternatives_text_reserved Sasha Levin
@ 2013-01-09 23:09 ` Sasha Levin
  2013-01-10  9:02 ` [PATCH 1/5] module: constify within_module_* Rusty Russell
  4 siblings, 0 replies; 18+ messages in thread
From: Sasha Levin @ 2013-01-09 23:09 UTC (permalink / raw)
  To: tglx, mingo, hpa, rostedt, fweisbec, rusty, ananth,
	anil.s.keshavamurthy, masami.hiramatsu.pt, jbaron
  Cc: x86, linux-kernel, Sasha Levin

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 include/linux/ftrace.h | 4 ++--
 kernel/trace/ftrace.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 92691d8..cbd927f 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -277,7 +277,7 @@ extern void
 unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops);
 extern void unregister_ftrace_function_probe_all(char *glob);
 
-extern int ftrace_text_reserved(void *start, void *end);
+extern int ftrace_text_reserved(const void *start, const void *end);
 
 extern int ftrace_nr_registered_ops(void);
 
@@ -534,7 +534,7 @@ static inline int unregister_ftrace_command(char *cmd_name)
 {
 	return -EINVAL;
 }
-static inline int ftrace_text_reserved(void *start, void *end)
+static inline int ftrace_text_reserved(const void *start, const void *end)
 {
 	return 0;
 }
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 3ffe4c5..4ecdcf8 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1469,7 +1469,7 @@ unsigned long ftrace_location(unsigned long ip)
  * the function tracer. It checks the ftrace internal tables to
  * determine if the address belongs or not.
  */
-int ftrace_text_reserved(void *start, void *end)
+int ftrace_text_reserved(const void *start, const void *end)
 {
 	unsigned long ret;
 
-- 
1.8.1


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

* Re: [PATCH 1/5] module: constify within_module_*
  2013-01-09 23:09 [PATCH 1/5] module: constify within_module_* Sasha Levin
                   ` (3 preceding siblings ...)
  2013-01-09 23:09 ` [PATCH 5/5] ftrace: constify ftrace_text_reserved Sasha Levin
@ 2013-01-10  9:02 ` Rusty Russell
  4 siblings, 0 replies; 18+ messages in thread
From: Rusty Russell @ 2013-01-10  9:02 UTC (permalink / raw)
  To: Sasha Levin, tglx, mingo, hpa, rostedt, fweisbec, ananth,
	anil.s.keshavamurthy, masami.hiramatsu.pt, jbaron
  Cc: x86, linux-kernel, Sasha Levin

Sasha Levin <sasha.levin@oracle.com> writes:

> These helper functions just check a set intersection with a range, and
> don't actually modify struct module.
>
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>

Thanks, applied.

Cheers,
Rusty.

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

* Re: [PATCH 2/5] jump label: constify lookup functions
  2013-01-09 23:09 ` [PATCH 2/5] jump label: constify lookup functions Sasha Levin
@ 2013-01-15 20:46   ` Sasha Levin
  2013-01-15 23:19     ` Steven Rostedt
  2013-01-18 21:25   ` Steven Rostedt
  2013-01-18 21:25   ` Steven Rostedt
  2 siblings, 1 reply; 18+ messages in thread
From: Sasha Levin @ 2013-01-15 20:46 UTC (permalink / raw)
  To: Sasha Levin
  Cc: tglx, mingo, hpa, rostedt, fweisbec, rusty, ananth,
	anil.s.keshavamurthy, masami.hiramatsu.pt, jbaron, x86,
	linux-kernel

ping?

On Wed, Jan 9, 2013 at 6:09 PM, Sasha Levin <sasha.levin@oracle.com> wrote:
> Modify the parameters of all the lookup and the bookkeeping functions which
> should be const to const.
>
> For example, jump_label_text_reserved() doesn't modify the memory it works on,
> it just checks whether there are any jump labels there.
>
> Note I couldn't test the non-x86 architectures, but the changes are rather
> trivial.
>
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
>  arch/arm/include/asm/jump_label.h     |  2 +-
>  arch/arm/kernel/jump_label.c          |  6 +++---
>  arch/mips/include/asm/jump_label.h    |  2 +-
>  arch/mips/kernel/jump_label.c         |  2 +-
>  arch/powerpc/include/asm/jump_label.h |  2 +-
>  arch/powerpc/kernel/jump_label.c      |  2 +-
>  arch/s390/include/asm/jump_label.h    |  2 +-
>  arch/s390/kernel/jump_label.c         |  8 ++++----
>  arch/sparc/include/asm/jump_label.h   |  2 +-
>  arch/sparc/kernel/jump_label.c        |  2 +-
>  arch/x86/include/asm/jump_label.h     |  2 +-
>  arch/x86/kernel/jump_label.c          |  6 +++---
>  include/linux/jump_label.h            | 24 ++++++++++++------------
>  kernel/jump_label.c                   | 27 +++++++++++++++------------
>  14 files changed, 46 insertions(+), 43 deletions(-)
>
> diff --git a/arch/arm/include/asm/jump_label.h b/arch/arm/include/asm/jump_label.h
> index bfc198c..f4ee633 100644
> --- a/arch/arm/include/asm/jump_label.h
> +++ b/arch/arm/include/asm/jump_label.h
> @@ -14,7 +14,7 @@
>  #define JUMP_LABEL_NOP "nop"
>  #endif
>
> -static __always_inline bool arch_static_branch(struct static_key *key)
> +static __always_inline bool arch_static_branch(const struct static_key *key)
>  {
>         asm goto("1:\n\t"
>                  JUMP_LABEL_NOP "\n\t"
> diff --git a/arch/arm/kernel/jump_label.c b/arch/arm/kernel/jump_label.c
> index 4ce4f78..9686fce 100644
> --- a/arch/arm/kernel/jump_label.c
> +++ b/arch/arm/kernel/jump_label.c
> @@ -6,7 +6,7 @@
>
>  #ifdef HAVE_JUMP_LABEL
>
> -static void __arch_jump_label_transform(struct jump_entry *entry,
> +static void __arch_jump_label_transform(const struct jump_entry *entry,
>                                         enum jump_label_type type,
>                                         bool is_static)
>  {
> @@ -24,13 +24,13 @@ static void __arch_jump_label_transform(struct jump_entry *entry,
>                 patch_text(addr, insn);
>  }
>
> -void arch_jump_label_transform(struct jump_entry *entry,
> +void arch_jump_label_transform(const struct jump_entry *entry,
>                                enum jump_label_type type)
>  {
>         __arch_jump_label_transform(entry, type, false);
>  }
>
> -void arch_jump_label_transform_static(struct jump_entry *entry,
> +void arch_jump_label_transform_static(const struct jump_entry *entry,
>                                       enum jump_label_type type)
>  {
>         __arch_jump_label_transform(entry, type, true);
> diff --git a/arch/mips/include/asm/jump_label.h b/arch/mips/include/asm/jump_label.h
> index 4d6d77e..a95ddf5 100644
> --- a/arch/mips/include/asm/jump_label.h
> +++ b/arch/mips/include/asm/jump_label.h
> @@ -20,7 +20,7 @@
>  #define WORD_INSN ".word"
>  #endif
>
> -static __always_inline bool arch_static_branch(struct static_key *key)
> +static __always_inline bool arch_static_branch(const struct static_key *key)
>  {
>         asm goto("1:\tnop\n\t"
>                 "nop\n\t"
> diff --git a/arch/mips/kernel/jump_label.c b/arch/mips/kernel/jump_label.c
> index 6001610..bfba488 100644
> --- a/arch/mips/kernel/jump_label.c
> +++ b/arch/mips/kernel/jump_label.c
> @@ -20,7 +20,7 @@
>
>  #define J_RANGE_MASK ((1ul << 28) - 1)
>
> -void arch_jump_label_transform(struct jump_entry *e,
> +void arch_jump_label_transform(const struct jump_entry *e,
>                                enum jump_label_type type)
>  {
>         union mips_instruction insn;
> diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h
> index ae098c4..c00b303 100644
> --- a/arch/powerpc/include/asm/jump_label.h
> +++ b/arch/powerpc/include/asm/jump_label.h
> @@ -17,7 +17,7 @@
>  #define JUMP_ENTRY_TYPE                stringify_in_c(FTR_ENTRY_LONG)
>  #define JUMP_LABEL_NOP_SIZE    4
>
> -static __always_inline bool arch_static_branch(struct static_key *key)
> +static __always_inline bool arch_static_branch(const struct static_key *key)
>  {
>         asm goto("1:\n\t"
>                  "nop\n\t"
> diff --git a/arch/powerpc/kernel/jump_label.c b/arch/powerpc/kernel/jump_label.c
> index a1ed8a8..f9626ec 100644
> --- a/arch/powerpc/kernel/jump_label.c
> +++ b/arch/powerpc/kernel/jump_label.c
> @@ -12,7 +12,7 @@
>  #include <asm/code-patching.h>
>
>  #ifdef HAVE_JUMP_LABEL
> -void arch_jump_label_transform(struct jump_entry *entry,
> +void arch_jump_label_transform(const struct jump_entry *entry,
>                                enum jump_label_type type)
>  {
>         u32 *addr = (u32 *)(unsigned long)entry->code;
> diff --git a/arch/s390/include/asm/jump_label.h b/arch/s390/include/asm/jump_label.h
> index 6c32190..96adb78 100644
> --- a/arch/s390/include/asm/jump_label.h
> +++ b/arch/s390/include/asm/jump_label.h
> @@ -13,7 +13,7 @@
>  #define ASM_ALIGN ".balign 4"
>  #endif
>
> -static __always_inline bool arch_static_branch(struct static_key *key)
> +static __always_inline bool arch_static_branch(const struct static_key *key)
>  {
>         asm goto("0:    brcl 0,0\n"
>                 ".pushsection __jump_table, \"aw\"\n"
> diff --git a/arch/s390/kernel/jump_label.c b/arch/s390/kernel/jump_label.c
> index b987ab2..85fa643 100644
> --- a/arch/s390/kernel/jump_label.c
> +++ b/arch/s390/kernel/jump_label.c
> @@ -22,7 +22,7 @@ struct insn_args {
>         enum jump_label_type type;
>  };
>
> -static void __jump_label_transform(struct jump_entry *entry,
> +static void __jump_label_transform(const struct jump_entry *entry,
>                                    enum jump_label_type type)
>  {
>         struct insn insn;
> @@ -44,13 +44,13 @@ static void __jump_label_transform(struct jump_entry *entry,
>
>  static int __sm_arch_jump_label_transform(void *data)
>  {
> -       struct insn_args *args = data;
> +       const struct insn_args *args = data;
>
>         __jump_label_transform(args->entry, args->type);
>         return 0;
>  }
>
> -void arch_jump_label_transform(struct jump_entry *entry,
> +void arch_jump_label_transform(const struct jump_entry *entry,
>                                enum jump_label_type type)
>  {
>         struct insn_args args;
> @@ -61,7 +61,7 @@ void arch_jump_label_transform(struct jump_entry *entry,
>         stop_machine(__sm_arch_jump_label_transform, &args, NULL);
>  }
>
> -void arch_jump_label_transform_static(struct jump_entry *entry,
> +void arch_jump_label_transform_static(const struct jump_entry *entry,
>                                       enum jump_label_type type)
>  {
>         __jump_label_transform(entry, type);
> diff --git a/arch/sparc/include/asm/jump_label.h b/arch/sparc/include/asm/jump_label.h
> index 5080d16..44cb914 100644
> --- a/arch/sparc/include/asm/jump_label.h
> +++ b/arch/sparc/include/asm/jump_label.h
> @@ -7,7 +7,7 @@
>
>  #define JUMP_LABEL_NOP_SIZE 4
>
> -static __always_inline bool arch_static_branch(struct static_key *key)
> +static __always_inline bool arch_static_branch(const struct static_key *key)
>  {
>                 asm goto("1:\n\t"
>                          "nop\n\t"
> diff --git a/arch/sparc/kernel/jump_label.c b/arch/sparc/kernel/jump_label.c
> index 48565c1..231c10e 100644
> --- a/arch/sparc/kernel/jump_label.c
> +++ b/arch/sparc/kernel/jump_label.c
> @@ -10,7 +10,7 @@
>
>  #ifdef HAVE_JUMP_LABEL
>
> -void arch_jump_label_transform(struct jump_entry *entry,
> +void arch_jump_label_transform(const struct jump_entry *entry,
>                                enum jump_label_type type)
>  {
>         u32 val;
> diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h
> index 3a16c14..6b6e976 100644
> --- a/arch/x86/include/asm/jump_label.h
> +++ b/arch/x86/include/asm/jump_label.h
> @@ -11,7 +11,7 @@
>
>  #define STATIC_KEY_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t"
>
> -static __always_inline bool arch_static_branch(struct static_key *key)
> +static __always_inline bool arch_static_branch(const struct static_key *key)
>  {
>         asm goto("1:"
>                 STATIC_KEY_INITIAL_NOP
> diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
> index 2889b3d..a7d2c5a 100644
> --- a/arch/x86/kernel/jump_label.c
> +++ b/arch/x86/kernel/jump_label.c
> @@ -24,7 +24,7 @@ union jump_code_union {
>         } __attribute__((packed));
>  };
>
> -static void __jump_label_transform(struct jump_entry *entry,
> +static void __jump_label_transform(const struct jump_entry *entry,
>                                    enum jump_label_type type,
>                                    void *(*poker)(void *, const void *, size_t))
>  {
> @@ -40,7 +40,7 @@ static void __jump_label_transform(struct jump_entry *entry,
>         (*poker)((void *)entry->code, &code, JUMP_LABEL_NOP_SIZE);
>  }
>
> -void arch_jump_label_transform(struct jump_entry *entry,
> +void arch_jump_label_transform(const struct jump_entry *entry,
>                                enum jump_label_type type)
>  {
>         get_online_cpus();
> @@ -50,7 +50,7 @@ void arch_jump_label_transform(struct jump_entry *entry,
>         put_online_cpus();
>  }
>
> -__init_or_module void arch_jump_label_transform_static(struct jump_entry *entry,
> +__init_or_module void arch_jump_label_transform_static(const struct jump_entry *entry,
>                                       enum jump_label_type type)
>  {
>         __jump_label_transform(entry, type, text_poke_early);
> diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
> index 0976fc4..7c33d29 100644
> --- a/include/linux/jump_label.h
> +++ b/include/linux/jump_label.h
> @@ -89,19 +89,19 @@ inline struct jump_entry *jump_label_get_entries(struct static_key *key)
>                                                 & ~JUMP_LABEL_TRUE_BRANCH);
>  }
>
> -static inline bool jump_label_get_branch_default(struct static_key *key)
> +static inline bool jump_label_get_branch_default(const struct static_key *key)
>  {
>         if ((unsigned long)key->entries & JUMP_LABEL_TRUE_BRANCH)
>                 return true;
>         return false;
>  }
>
> -static __always_inline bool static_key_false(struct static_key *key)
> +static __always_inline bool static_key_false(const struct static_key *key)
>  {
>         return arch_static_branch(key);
>  }
>
> -static __always_inline bool static_key_true(struct static_key *key)
> +static __always_inline bool static_key_true(const struct static_key *key)
>  {
>         return !static_key_false(key);
>  }
> @@ -112,15 +112,15 @@ extern struct jump_entry __stop___jump_table[];
>  extern void jump_label_init(void);
>  extern void jump_label_lock(void);
>  extern void jump_label_unlock(void);
> -extern void arch_jump_label_transform(struct jump_entry *entry,
> +extern void arch_jump_label_transform(const struct jump_entry *entry,
>                                       enum jump_label_type type);
> -extern void arch_jump_label_transform_static(struct jump_entry *entry,
> +extern void arch_jump_label_transform_static(const struct jump_entry *entry,
>                                              enum jump_label_type type);
> -extern int jump_label_text_reserved(void *start, void *end);
> +extern int jump_label_text_reserved(const void *start, const void *end);
>  extern void static_key_slow_inc(struct static_key *key);
>  extern void static_key_slow_dec(struct static_key *key);
>  extern void static_key_slow_dec_deferred(struct static_key_deferred *key);
> -extern void jump_label_apply_nops(struct module *mod);
> +extern void jump_label_apply_nops(const struct module *mod);
>  extern void
>  jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);
>
> @@ -145,14 +145,14 @@ struct static_key_deferred {
>         struct static_key  key;
>  };
>
> -static __always_inline bool static_key_false(struct static_key *key)
> +static __always_inline bool static_key_false(const struct static_key *key)
>  {
>         if (unlikely(atomic_read(&key->enabled)) > 0)
>                 return true;
>         return false;
>  }
>
> -static __always_inline bool static_key_true(struct static_key *key)
> +static __always_inline bool static_key_true(const struct static_key *key)
>  {
>         if (likely(atomic_read(&key->enabled)) > 0)
>                 return true;
> @@ -174,7 +174,7 @@ static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
>         static_key_slow_dec(&key->key);
>  }
>
> -static inline int jump_label_text_reserved(void *start, void *end)
> +static inline int jump_label_text_reserved(const void *start, const void *end)
>  {
>         return 0;
>  }
> @@ -182,7 +182,7 @@ static inline int jump_label_text_reserved(void *start, void *end)
>  static inline void jump_label_lock(void) {}
>  static inline void jump_label_unlock(void) {}
>
> -static inline int jump_label_apply_nops(struct module *mod)
> +static inline int jump_label_apply_nops(const struct module *mod)
>  {
>         return 0;
>  }
> @@ -203,7 +203,7 @@ jump_label_rate_limit(struct static_key_deferred *key,
>  #define STATIC_KEY_INIT STATIC_KEY_INIT_FALSE
>  #define jump_label_enabled static_key_enabled
>
> -static inline bool static_key_enabled(struct static_key *key)
> +static inline bool static_key_enabled(const struct static_key *key)
>  {
>         return (atomic_read(&key->enabled) > 0);
>  }
> diff --git a/kernel/jump_label.c b/kernel/jump_label.c
> index 60f48fa..ba2fa54 100644
> --- a/kernel/jump_label.c
> +++ b/kernel/jump_label.c
> @@ -120,7 +120,8 @@ void jump_label_rate_limit(struct static_key_deferred *key,
>  }
>  EXPORT_SYMBOL_GPL(jump_label_rate_limit);
>
> -static int addr_conflict(struct jump_entry *entry, void *start, void *end)
> +static int addr_conflict(const struct jump_entry *entry,
> +                       const void *start, const void *end)
>  {
>         if (entry->code <= (unsigned long)end &&
>                 entry->code + JUMP_LABEL_NOP_SIZE > (unsigned long)start)
> @@ -130,7 +131,8 @@ static int addr_conflict(struct jump_entry *entry, void *start, void *end)
>  }
>
>  static int __jump_label_text_reserved(struct jump_entry *iter_start,
> -               struct jump_entry *iter_stop, void *start, void *end)
> +               struct jump_entry *iter_stop,
> +               const void *start, const void *end)
>  {
>         struct jump_entry *iter;
>
> @@ -150,7 +152,7 @@ static int __jump_label_text_reserved(struct jump_entry *iter_start,
>   * running code can override this to make the non-live update case
>   * cheaper.
>   */
> -void __weak __init_or_module arch_jump_label_transform_static(struct jump_entry *entry,
> +void __weak __init_or_module arch_jump_label_transform_static(const struct jump_entry *entry,
>                                             enum jump_label_type type)
>  {
>         arch_jump_label_transform(entry, type);
> @@ -173,7 +175,7 @@ static void __jump_label_update(struct static_key *key,
>         }
>  }
>
> -static enum jump_label_type jump_label_type(struct static_key *key)
> +static enum jump_label_type jump_label_type(const struct static_key *key)
>  {
>         bool true_branch = jump_label_get_branch_default(key);
>         bool state = static_key_enabled(key);
> @@ -219,10 +221,11 @@ void __init jump_label_init(void)
>  struct static_key_mod {
>         struct static_key_mod *next;
>         struct jump_entry *entries;
> -       struct module *mod;
> +       const struct module *mod;
>  };
>
> -static int __jump_label_mod_text_reserved(void *start, void *end)
> +static int __jump_label_mod_text_reserved(const void *start,
> +                                               const void *end)
>  {
>         struct module *mod;
>
> @@ -242,7 +245,7 @@ static void __jump_label_mod_update(struct static_key *key, int enable)
>         struct static_key_mod *mod = key->next;
>
>         while (mod) {
> -               struct module *m = mod->mod;
> +               const struct module *m = mod->mod;
>
>                 __jump_label_update(key, mod->entries,
>                                     m->jump_entries + m->num_jump_entries,
> @@ -259,7 +262,7 @@ static void __jump_label_mod_update(struct static_key *key, int enable)
>   * loads patch these with arch_get_jump_label_nop(), which is specified by
>   * the arch specific jump label code.
>   */
> -void jump_label_apply_nops(struct module *mod)
> +void jump_label_apply_nops(const struct module *mod)
>  {
>         struct jump_entry *iter_start = mod->jump_entries;
>         struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
> @@ -274,7 +277,7 @@ void jump_label_apply_nops(struct module *mod)
>         }
>  }
>
> -static int jump_label_add_module(struct module *mod)
> +static int jump_label_add_module(const struct module *mod)
>  {
>         struct jump_entry *iter_start = mod->jump_entries;
>         struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
> @@ -319,7 +322,7 @@ static int jump_label_add_module(struct module *mod)
>         return 0;
>  }
>
> -static void jump_label_del_module(struct module *mod)
> +static void jump_label_del_module(const struct module *mod)
>  {
>         struct jump_entry *iter_start = mod->jump_entries;
>         struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
> @@ -351,7 +354,7 @@ static void jump_label_del_module(struct module *mod)
>         }
>  }
>
> -static void jump_label_invalidate_module_init(struct module *mod)
> +static void jump_label_invalidate_module_init(const struct module *mod)
>  {
>         struct jump_entry *iter_start = mod->jump_entries;
>         struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
> @@ -419,7 +422,7 @@ early_initcall(jump_label_init_module);
>   *
>   * returns 1 if there is an overlap, 0 otherwise
>   */
> -int jump_label_text_reserved(void *start, void *end)
> +int jump_label_text_reserved(const void *start, const void *end)
>  {
>         int ret = __jump_label_text_reserved(__start___jump_table,
>                         __stop___jump_table, start, end);
> --
> 1.8.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 2/5] jump label: constify lookup functions
  2013-01-15 20:46   ` Sasha Levin
@ 2013-01-15 23:19     ` Steven Rostedt
  0 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2013-01-15 23:19 UTC (permalink / raw)
  To: Sasha Levin
  Cc: Sasha Levin, tglx, mingo, hpa, fweisbec, rusty, ananth,
	anil.s.keshavamurthy, masami.hiramatsu.pt, jbaron, x86,
	linux-kernel

On Tue, 2013-01-15 at 15:46 -0500, Sasha Levin wrote:
> ping?
> 

I'm still pretty busy. I'll try to take a look at it sometime this week.

-- Steve



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

* Re: [PATCH 2/5] jump label: constify lookup functions
  2013-01-09 23:09 ` [PATCH 2/5] jump label: constify lookup functions Sasha Levin
  2013-01-15 20:46   ` Sasha Levin
@ 2013-01-18 21:25   ` Steven Rostedt
  2013-01-21  6:51     ` Rusty Russell
  2013-01-25  4:15     ` Sasha Levin
  2013-01-18 21:25   ` Steven Rostedt
  2 siblings, 2 replies; 18+ messages in thread
From: Steven Rostedt @ 2013-01-18 21:25 UTC (permalink / raw)
  To: Sasha Levin
  Cc: tglx, mingo, hpa, fweisbec, rusty, ananth, anil.s.keshavamurthy,
	masami.hiramatsu.pt, jbaron, x86, linux-kernel, MartinSchwidefsky,
	Heiko Carstens, linux-s390

On Wed, 2013-01-09 at 18:09 -0500, Sasha Levin wrote:
> Modify the parameters of all the lookup and the bookkeeping functions which
> should be const to const.
> 
> For example, jump_label_text_reserved() doesn't modify the memory it works on,
> it just checks whether there are any jump labels there.

This is dependent on the module patch, which Rusty is taking. I need to
see that he has it before this can go in. At least see it in linux-next.

Also, you should have Cc'd the linux-arch mailing list. I'll send it
there.

> 
> Note I couldn't test the non-x86 architectures, but the changes are rather
> trivial.

I ran it on 25 archs, and s390 hit:

/work/autotest/nobackup/cross-linux.git/arch/s390/kernel/jump_label.c: In function 'arch_jump_label_transform':
/work/autotest/nobackup/cross-linux.git/arch/s390/kernel/jump_label.c:58:13: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]

-- Steve

Here's the patch:

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

diff --git a/arch/s390/kernel/jump_label.c
b/arch/s390/kernel/jump_label.c
index 85fa643..ef047ef 100644
--- a/arch/s390/kernel/jump_label.c
+++ b/arch/s390/kernel/jump_label.c
@@ -18,7 +18,7 @@ struct insn {
 } __packed;
 
 struct insn_args {
-	struct jump_entry *entry;
+	const struct jump_entry *entry;
 	enum jump_label_type type;
 };
 



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

* Re: [PATCH 2/5] jump label: constify lookup functions
  2013-01-09 23:09 ` [PATCH 2/5] jump label: constify lookup functions Sasha Levin
  2013-01-15 20:46   ` Sasha Levin
  2013-01-18 21:25   ` Steven Rostedt
@ 2013-01-18 21:25   ` Steven Rostedt
  2 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2013-01-18 21:25 UTC (permalink / raw)
  To: Sasha Levin, linux-arch
  Cc: tglx, mingo, hpa, fweisbec, rusty, ananth, anil.s.keshavamurthy,
	masami.hiramatsu.pt, jbaron, x86, linux-kernel

This should have been Cc'd to linux-arch.

-- Steve


On Wed, 2013-01-09 at 18:09 -0500, Sasha Levin wrote:
> Modify the parameters of all the lookup and the bookkeeping functions which
> should be const to const.
> 
> For example, jump_label_text_reserved() doesn't modify the memory it works on,
> it just checks whether there are any jump labels there.
> 
> Note I couldn't test the non-x86 architectures, but the changes are rather
> trivial.
> 
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
>  arch/arm/include/asm/jump_label.h     |  2 +-
>  arch/arm/kernel/jump_label.c          |  6 +++---
>  arch/mips/include/asm/jump_label.h    |  2 +-
>  arch/mips/kernel/jump_label.c         |  2 +-
>  arch/powerpc/include/asm/jump_label.h |  2 +-
>  arch/powerpc/kernel/jump_label.c      |  2 +-
>  arch/s390/include/asm/jump_label.h    |  2 +-
>  arch/s390/kernel/jump_label.c         |  8 ++++----
>  arch/sparc/include/asm/jump_label.h   |  2 +-
>  arch/sparc/kernel/jump_label.c        |  2 +-
>  arch/x86/include/asm/jump_label.h     |  2 +-
>  arch/x86/kernel/jump_label.c          |  6 +++---
>  include/linux/jump_label.h            | 24 ++++++++++++------------
>  kernel/jump_label.c                   | 27 +++++++++++++++------------
>  14 files changed, 46 insertions(+), 43 deletions(-)
> 
> diff --git a/arch/arm/include/asm/jump_label.h b/arch/arm/include/asm/jump_label.h
> index bfc198c..f4ee633 100644
> --- a/arch/arm/include/asm/jump_label.h
> +++ b/arch/arm/include/asm/jump_label.h
> @@ -14,7 +14,7 @@
>  #define JUMP_LABEL_NOP	"nop"
>  #endif
>  
> -static __always_inline bool arch_static_branch(struct static_key *key)
> +static __always_inline bool arch_static_branch(const struct static_key *key)
>  {
>  	asm goto("1:\n\t"
>  		 JUMP_LABEL_NOP "\n\t"
> diff --git a/arch/arm/kernel/jump_label.c b/arch/arm/kernel/jump_label.c
> index 4ce4f78..9686fce 100644
> --- a/arch/arm/kernel/jump_label.c
> +++ b/arch/arm/kernel/jump_label.c
> @@ -6,7 +6,7 @@
>  
>  #ifdef HAVE_JUMP_LABEL
>  
> -static void __arch_jump_label_transform(struct jump_entry *entry,
> +static void __arch_jump_label_transform(const struct jump_entry *entry,
>  					enum jump_label_type type,
>  					bool is_static)
>  {
> @@ -24,13 +24,13 @@ static void __arch_jump_label_transform(struct jump_entry *entry,
>  		patch_text(addr, insn);
>  }
>  
> -void arch_jump_label_transform(struct jump_entry *entry,
> +void arch_jump_label_transform(const struct jump_entry *entry,
>  			       enum jump_label_type type)
>  {
>  	__arch_jump_label_transform(entry, type, false);
>  }
>  
> -void arch_jump_label_transform_static(struct jump_entry *entry,
> +void arch_jump_label_transform_static(const struct jump_entry *entry,
>  				      enum jump_label_type type)
>  {
>  	__arch_jump_label_transform(entry, type, true);
> diff --git a/arch/mips/include/asm/jump_label.h b/arch/mips/include/asm/jump_label.h
> index 4d6d77e..a95ddf5 100644
> --- a/arch/mips/include/asm/jump_label.h
> +++ b/arch/mips/include/asm/jump_label.h
> @@ -20,7 +20,7 @@
>  #define WORD_INSN ".word"
>  #endif
>  
> -static __always_inline bool arch_static_branch(struct static_key *key)
> +static __always_inline bool arch_static_branch(const struct static_key *key)
>  {
>  	asm goto("1:\tnop\n\t"
>  		"nop\n\t"
> diff --git a/arch/mips/kernel/jump_label.c b/arch/mips/kernel/jump_label.c
> index 6001610..bfba488 100644
> --- a/arch/mips/kernel/jump_label.c
> +++ b/arch/mips/kernel/jump_label.c
> @@ -20,7 +20,7 @@
>  
>  #define J_RANGE_MASK ((1ul << 28) - 1)
>  
> -void arch_jump_label_transform(struct jump_entry *e,
> +void arch_jump_label_transform(const struct jump_entry *e,
>  			       enum jump_label_type type)
>  {
>  	union mips_instruction insn;
> diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h
> index ae098c4..c00b303 100644
> --- a/arch/powerpc/include/asm/jump_label.h
> +++ b/arch/powerpc/include/asm/jump_label.h
> @@ -17,7 +17,7 @@
>  #define JUMP_ENTRY_TYPE		stringify_in_c(FTR_ENTRY_LONG)
>  #define JUMP_LABEL_NOP_SIZE	4
>  
> -static __always_inline bool arch_static_branch(struct static_key *key)
> +static __always_inline bool arch_static_branch(const struct static_key *key)
>  {
>  	asm goto("1:\n\t"
>  		 "nop\n\t"
> diff --git a/arch/powerpc/kernel/jump_label.c b/arch/powerpc/kernel/jump_label.c
> index a1ed8a8..f9626ec 100644
> --- a/arch/powerpc/kernel/jump_label.c
> +++ b/arch/powerpc/kernel/jump_label.c
> @@ -12,7 +12,7 @@
>  #include <asm/code-patching.h>
>  
>  #ifdef HAVE_JUMP_LABEL
> -void arch_jump_label_transform(struct jump_entry *entry,
> +void arch_jump_label_transform(const struct jump_entry *entry,
>  			       enum jump_label_type type)
>  {
>  	u32 *addr = (u32 *)(unsigned long)entry->code;
> diff --git a/arch/s390/include/asm/jump_label.h b/arch/s390/include/asm/jump_label.h
> index 6c32190..96adb78 100644
> --- a/arch/s390/include/asm/jump_label.h
> +++ b/arch/s390/include/asm/jump_label.h
> @@ -13,7 +13,7 @@
>  #define ASM_ALIGN ".balign 4"
>  #endif
>  
> -static __always_inline bool arch_static_branch(struct static_key *key)
> +static __always_inline bool arch_static_branch(const struct static_key *key)
>  {
>  	asm goto("0:	brcl 0,0\n"
>  		".pushsection __jump_table, \"aw\"\n"
> diff --git a/arch/s390/kernel/jump_label.c b/arch/s390/kernel/jump_label.c
> index b987ab2..85fa643 100644
> --- a/arch/s390/kernel/jump_label.c
> +++ b/arch/s390/kernel/jump_label.c
> @@ -22,7 +22,7 @@ struct insn_args {
>  	enum jump_label_type type;
>  };
>  
> -static void __jump_label_transform(struct jump_entry *entry,
> +static void __jump_label_transform(const struct jump_entry *entry,
>  				   enum jump_label_type type)
>  {
>  	struct insn insn;
> @@ -44,13 +44,13 @@ static void __jump_label_transform(struct jump_entry *entry,
>  
>  static int __sm_arch_jump_label_transform(void *data)
>  {
> -	struct insn_args *args = data;
> +	const struct insn_args *args = data;
>  
>  	__jump_label_transform(args->entry, args->type);
>  	return 0;
>  }
>  
> -void arch_jump_label_transform(struct jump_entry *entry,
> +void arch_jump_label_transform(const struct jump_entry *entry,
>  			       enum jump_label_type type)
>  {
>  	struct insn_args args;
> @@ -61,7 +61,7 @@ void arch_jump_label_transform(struct jump_entry *entry,
>  	stop_machine(__sm_arch_jump_label_transform, &args, NULL);
>  }
>  
> -void arch_jump_label_transform_static(struct jump_entry *entry,
> +void arch_jump_label_transform_static(const struct jump_entry *entry,
>  				      enum jump_label_type type)
>  {
>  	__jump_label_transform(entry, type);
> diff --git a/arch/sparc/include/asm/jump_label.h b/arch/sparc/include/asm/jump_label.h
> index 5080d16..44cb914 100644
> --- a/arch/sparc/include/asm/jump_label.h
> +++ b/arch/sparc/include/asm/jump_label.h
> @@ -7,7 +7,7 @@
>  
>  #define JUMP_LABEL_NOP_SIZE 4
>  
> -static __always_inline bool arch_static_branch(struct static_key *key)
> +static __always_inline bool arch_static_branch(const struct static_key *key)
>  {
>  		asm goto("1:\n\t"
>  			 "nop\n\t"
> diff --git a/arch/sparc/kernel/jump_label.c b/arch/sparc/kernel/jump_label.c
> index 48565c1..231c10e 100644
> --- a/arch/sparc/kernel/jump_label.c
> +++ b/arch/sparc/kernel/jump_label.c
> @@ -10,7 +10,7 @@
>  
>  #ifdef HAVE_JUMP_LABEL
>  
> -void arch_jump_label_transform(struct jump_entry *entry,
> +void arch_jump_label_transform(const struct jump_entry *entry,
>  			       enum jump_label_type type)
>  {
>  	u32 val;
> diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h
> index 3a16c14..6b6e976 100644
> --- a/arch/x86/include/asm/jump_label.h
> +++ b/arch/x86/include/asm/jump_label.h
> @@ -11,7 +11,7 @@
>  
>  #define STATIC_KEY_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t"
>  
> -static __always_inline bool arch_static_branch(struct static_key *key)
> +static __always_inline bool arch_static_branch(const struct static_key *key)
>  {
>  	asm goto("1:"
>  		STATIC_KEY_INITIAL_NOP
> diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
> index 2889b3d..a7d2c5a 100644
> --- a/arch/x86/kernel/jump_label.c
> +++ b/arch/x86/kernel/jump_label.c
> @@ -24,7 +24,7 @@ union jump_code_union {
>  	} __attribute__((packed));
>  };
>  
> -static void __jump_label_transform(struct jump_entry *entry,
> +static void __jump_label_transform(const struct jump_entry *entry,
>  				   enum jump_label_type type,
>  				   void *(*poker)(void *, const void *, size_t))
>  {
> @@ -40,7 +40,7 @@ static void __jump_label_transform(struct jump_entry *entry,
>  	(*poker)((void *)entry->code, &code, JUMP_LABEL_NOP_SIZE);
>  }
>  
> -void arch_jump_label_transform(struct jump_entry *entry,
> +void arch_jump_label_transform(const struct jump_entry *entry,
>  			       enum jump_label_type type)
>  {
>  	get_online_cpus();
> @@ -50,7 +50,7 @@ void arch_jump_label_transform(struct jump_entry *entry,
>  	put_online_cpus();
>  }
>  
> -__init_or_module void arch_jump_label_transform_static(struct jump_entry *entry,
> +__init_or_module void arch_jump_label_transform_static(const struct jump_entry *entry,
>  				      enum jump_label_type type)
>  {
>  	__jump_label_transform(entry, type, text_poke_early);
> diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
> index 0976fc4..7c33d29 100644
> --- a/include/linux/jump_label.h
> +++ b/include/linux/jump_label.h
> @@ -89,19 +89,19 @@ inline struct jump_entry *jump_label_get_entries(struct static_key *key)
>  						& ~JUMP_LABEL_TRUE_BRANCH);
>  }
>  
> -static inline bool jump_label_get_branch_default(struct static_key *key)
> +static inline bool jump_label_get_branch_default(const struct static_key *key)
>  {
>  	if ((unsigned long)key->entries & JUMP_LABEL_TRUE_BRANCH)
>  		return true;
>  	return false;
>  }
>  
> -static __always_inline bool static_key_false(struct static_key *key)
> +static __always_inline bool static_key_false(const struct static_key *key)
>  {
>  	return arch_static_branch(key);
>  }
>  
> -static __always_inline bool static_key_true(struct static_key *key)
> +static __always_inline bool static_key_true(const struct static_key *key)
>  {
>  	return !static_key_false(key);
>  }
> @@ -112,15 +112,15 @@ extern struct jump_entry __stop___jump_table[];
>  extern void jump_label_init(void);
>  extern void jump_label_lock(void);
>  extern void jump_label_unlock(void);
> -extern void arch_jump_label_transform(struct jump_entry *entry,
> +extern void arch_jump_label_transform(const struct jump_entry *entry,
>  				      enum jump_label_type type);
> -extern void arch_jump_label_transform_static(struct jump_entry *entry,
> +extern void arch_jump_label_transform_static(const struct jump_entry *entry,
>  					     enum jump_label_type type);
> -extern int jump_label_text_reserved(void *start, void *end);
> +extern int jump_label_text_reserved(const void *start, const void *end);
>  extern void static_key_slow_inc(struct static_key *key);
>  extern void static_key_slow_dec(struct static_key *key);
>  extern void static_key_slow_dec_deferred(struct static_key_deferred *key);
> -extern void jump_label_apply_nops(struct module *mod);
> +extern void jump_label_apply_nops(const struct module *mod);
>  extern void
>  jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);
>  
> @@ -145,14 +145,14 @@ struct static_key_deferred {
>  	struct static_key  key;
>  };
>  
> -static __always_inline bool static_key_false(struct static_key *key)
> +static __always_inline bool static_key_false(const struct static_key *key)
>  {
>  	if (unlikely(atomic_read(&key->enabled)) > 0)
>  		return true;
>  	return false;
>  }
>  
> -static __always_inline bool static_key_true(struct static_key *key)
> +static __always_inline bool static_key_true(const struct static_key *key)
>  {
>  	if (likely(atomic_read(&key->enabled)) > 0)
>  		return true;
> @@ -174,7 +174,7 @@ static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
>  	static_key_slow_dec(&key->key);
>  }
>  
> -static inline int jump_label_text_reserved(void *start, void *end)
> +static inline int jump_label_text_reserved(const void *start, const void *end)
>  {
>  	return 0;
>  }
> @@ -182,7 +182,7 @@ static inline int jump_label_text_reserved(void *start, void *end)
>  static inline void jump_label_lock(void) {}
>  static inline void jump_label_unlock(void) {}
>  
> -static inline int jump_label_apply_nops(struct module *mod)
> +static inline int jump_label_apply_nops(const struct module *mod)
>  {
>  	return 0;
>  }
> @@ -203,7 +203,7 @@ jump_label_rate_limit(struct static_key_deferred *key,
>  #define STATIC_KEY_INIT STATIC_KEY_INIT_FALSE
>  #define jump_label_enabled static_key_enabled
>  
> -static inline bool static_key_enabled(struct static_key *key)
> +static inline bool static_key_enabled(const struct static_key *key)
>  {
>  	return (atomic_read(&key->enabled) > 0);
>  }
> diff --git a/kernel/jump_label.c b/kernel/jump_label.c
> index 60f48fa..ba2fa54 100644
> --- a/kernel/jump_label.c
> +++ b/kernel/jump_label.c
> @@ -120,7 +120,8 @@ void jump_label_rate_limit(struct static_key_deferred *key,
>  }
>  EXPORT_SYMBOL_GPL(jump_label_rate_limit);
>  
> -static int addr_conflict(struct jump_entry *entry, void *start, void *end)
> +static int addr_conflict(const struct jump_entry *entry,
> +			const void *start, const void *end)
>  {
>  	if (entry->code <= (unsigned long)end &&
>  		entry->code + JUMP_LABEL_NOP_SIZE > (unsigned long)start)
> @@ -130,7 +131,8 @@ static int addr_conflict(struct jump_entry *entry, void *start, void *end)
>  }
>  
>  static int __jump_label_text_reserved(struct jump_entry *iter_start,
> -		struct jump_entry *iter_stop, void *start, void *end)
> +		struct jump_entry *iter_stop,
> +		const void *start, const void *end)
>  {
>  	struct jump_entry *iter;
>  
> @@ -150,7 +152,7 @@ static int __jump_label_text_reserved(struct jump_entry *iter_start,
>   * running code can override this to make the non-live update case
>   * cheaper.
>   */
> -void __weak __init_or_module arch_jump_label_transform_static(struct jump_entry *entry,
> +void __weak __init_or_module arch_jump_label_transform_static(const struct jump_entry *entry,
>  					    enum jump_label_type type)
>  {
>  	arch_jump_label_transform(entry, type);	
> @@ -173,7 +175,7 @@ static void __jump_label_update(struct static_key *key,
>  	}
>  }
>  
> -static enum jump_label_type jump_label_type(struct static_key *key)
> +static enum jump_label_type jump_label_type(const struct static_key *key)
>  {
>  	bool true_branch = jump_label_get_branch_default(key);
>  	bool state = static_key_enabled(key);
> @@ -219,10 +221,11 @@ void __init jump_label_init(void)
>  struct static_key_mod {
>  	struct static_key_mod *next;
>  	struct jump_entry *entries;
> -	struct module *mod;
> +	const struct module *mod;
>  };
>  
> -static int __jump_label_mod_text_reserved(void *start, void *end)
> +static int __jump_label_mod_text_reserved(const void *start,
> +						const void *end)
>  {
>  	struct module *mod;
>  
> @@ -242,7 +245,7 @@ static void __jump_label_mod_update(struct static_key *key, int enable)
>  	struct static_key_mod *mod = key->next;
>  
>  	while (mod) {
> -		struct module *m = mod->mod;
> +		const struct module *m = mod->mod;
>  
>  		__jump_label_update(key, mod->entries,
>  				    m->jump_entries + m->num_jump_entries,
> @@ -259,7 +262,7 @@ static void __jump_label_mod_update(struct static_key *key, int enable)
>   * loads patch these with arch_get_jump_label_nop(), which is specified by
>   * the arch specific jump label code.
>   */
> -void jump_label_apply_nops(struct module *mod)
> +void jump_label_apply_nops(const struct module *mod)
>  {
>  	struct jump_entry *iter_start = mod->jump_entries;
>  	struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
> @@ -274,7 +277,7 @@ void jump_label_apply_nops(struct module *mod)
>  	}
>  }
>  
> -static int jump_label_add_module(struct module *mod)
> +static int jump_label_add_module(const struct module *mod)
>  {
>  	struct jump_entry *iter_start = mod->jump_entries;
>  	struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
> @@ -319,7 +322,7 @@ static int jump_label_add_module(struct module *mod)
>  	return 0;
>  }
>  
> -static void jump_label_del_module(struct module *mod)
> +static void jump_label_del_module(const struct module *mod)
>  {
>  	struct jump_entry *iter_start = mod->jump_entries;
>  	struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
> @@ -351,7 +354,7 @@ static void jump_label_del_module(struct module *mod)
>  	}
>  }
>  
> -static void jump_label_invalidate_module_init(struct module *mod)
> +static void jump_label_invalidate_module_init(const struct module *mod)
>  {
>  	struct jump_entry *iter_start = mod->jump_entries;
>  	struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
> @@ -419,7 +422,7 @@ early_initcall(jump_label_init_module);
>   *
>   * returns 1 if there is an overlap, 0 otherwise
>   */
> -int jump_label_text_reserved(void *start, void *end)
> +int jump_label_text_reserved(const void *start, const void *end)
>  {
>  	int ret = __jump_label_text_reserved(__start___jump_table,
>  			__stop___jump_table, start, end);



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

* Re: [PATCH 2/5] jump label: constify lookup functions
  2013-01-18 21:25   ` Steven Rostedt
@ 2013-01-21  6:51     ` Rusty Russell
  2013-01-25  4:15     ` Sasha Levin
  1 sibling, 0 replies; 18+ messages in thread
From: Rusty Russell @ 2013-01-21  6:51 UTC (permalink / raw)
  To: Steven Rostedt, Sasha Levin
  Cc: tglx, mingo, hpa, fweisbec, ananth, anil.s.keshavamurthy,
	masami.hiramatsu.pt, jbaron, x86, linux-kernel, MartinSchwidefsky,
	Heiko Carstens, linux-s390

Steven Rostedt <rostedt@goodmis.org> writes:
> On Wed, 2013-01-09 at 18:09 -0500, Sasha Levin wrote:
>> Modify the parameters of all the lookup and the bookkeeping functions which
>> should be const to const.
>> 
>> For example, jump_label_text_reserved() doesn't modify the memory it works on,
>> it just checks whether there are any jump labels there.
>
> This is dependent on the module patch, which Rusty is taking. I need to
> see that he has it before this can go in. At least see it in linux-next.
>
> Also, you should have Cc'd the linux-arch mailing list. I'll send it
> there.

I've put it in now.

Thanks,
Rusty.

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

* Re: [PATCH 4/5] alternatives: constify alternatives_text_reserved
  2013-01-09 23:09 ` [PATCH 4/5] alternatives: constify alternatives_text_reserved Sasha Levin
@ 2013-01-21 11:38   ` Masami Hiramatsu
  0 siblings, 0 replies; 18+ messages in thread
From: Masami Hiramatsu @ 2013-01-21 11:38 UTC (permalink / raw)
  To: Sasha Levin
  Cc: tglx, mingo, hpa, rostedt, fweisbec, rusty, ananth,
	anil.s.keshavamurthy, jbaron, x86, linux-kernel,
	yrl.pp-manager.tt@hitachi.com

(2013/01/10 8:09), Sasha Levin wrote:
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>

This looks good for me. And, please add a comment to explain
what this patch is for.

Thank you,

> ---
>  arch/x86/include/asm/alternative.h | 4 ++--
>  arch/x86/kernel/alternative.c      | 6 +++---
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
> index 58ed6d9..4d0d2fb 100644
> --- a/arch/x86/include/asm/alternative.h
> +++ b/arch/x86/include/asm/alternative.h
> @@ -61,7 +61,7 @@ extern void alternatives_smp_module_add(struct module *mod, char *name,
>  					void *text, void *text_end);
>  extern void alternatives_smp_module_del(struct module *mod);
>  extern void alternatives_enable_smp(void);
> -extern int alternatives_text_reserved(void *start, void *end);
> +extern int alternatives_text_reserved(const void *start, const void *end);
>  extern bool skip_smp_alternatives;
>  #else
>  static inline void alternatives_smp_module_add(struct module *mod, char *name,
> @@ -69,7 +69,7 @@ static inline void alternatives_smp_module_add(struct module *mod, char *name,
>  					       void *text, void *text_end) {}
>  static inline void alternatives_smp_module_del(struct module *mod) {}
>  static inline void alternatives_enable_smp(void) {}
> -static inline int alternatives_text_reserved(void *start, void *end)
> +static inline int alternatives_text_reserved(const void *start, const void *end)
>  {
>  	return 0;
>  }
> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> index ef5ccca..0994e41 100644
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -431,12 +431,12 @@ void alternatives_enable_smp(void)
>  }
>  
>  /* Return 1 if the address range is reserved for smp-alternatives */
> -int alternatives_text_reserved(void *start, void *end)
> +int alternatives_text_reserved(const void *start, const void *end)
>  {
>  	struct smp_alt_module *mod;
>  	const s32 *poff;
> -	u8 *text_start = start;
> -	u8 *text_end = end;
> +	const u8 *text_start = start;
> +	const u8 *text_end = end;
>  
>  	list_for_each_entry(mod, &smp_alt_modules, next) {
>  		if (mod->text > text_end || mod->text_end < text_start)
> 


-- 
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



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

* Re: [PATCH 3/5] kprobes: constify check_kprobe_address_safe and friends
  2013-01-09 23:09 ` [PATCH 3/5] kprobes: constify check_kprobe_address_safe and friends Sasha Levin
@ 2013-01-21 11:49   ` Masami Hiramatsu
  2013-01-25  4:09     ` Sasha Levin
  0 siblings, 1 reply; 18+ messages in thread
From: Masami Hiramatsu @ 2013-01-21 11:49 UTC (permalink / raw)
  To: Sasha Levin
  Cc: tglx, mingo, hpa, rostedt, fweisbec, rusty, ananth,
	anil.s.keshavamurthy, jbaron, x86, linux-kernel,
	yrl.pp-manager.tt@hitachi.com

(2013/01/10 8:09), Sasha Levin wrote:
> Constify the parameters of lookup functions.
> 
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
>  arch/x86/kernel/kprobes-opt.c | 8 ++++----
>  kernel/kprobes.c              | 2 +-
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
> index c5e410e..5876966 100644
> --- a/arch/x86/kernel/kprobes-opt.c
> +++ b/arch/x86/kernel/kprobes-opt.c
> @@ -192,7 +192,7 @@ static int __kprobes copy_optimized_instructions(u8 *dest, u8 *src)
>  }
>  
>  /* Check whether insn is indirect jump */
> -static int __kprobes insn_is_indirect_jump(struct insn *insn)
> +static int __kprobes insn_is_indirect_jump(const struct insn *insn)
>  {
>  	return ((insn->opcode.bytes[0] == 0xff &&
>  		(X86_MODRM_REG(insn->modrm.value) & 6) == 4) || /* Jump */
> @@ -200,7 +200,7 @@ static int __kprobes insn_is_indirect_jump(struct insn *insn)
>  }
>  
>  /* Check whether insn jumps into specified address range */
> -static int insn_jump_into_range(struct insn *insn, unsigned long start, int len)
> +static int insn_jump_into_range(const struct insn *insn, unsigned long start, int len)
>  {
>  	unsigned long target = 0;
>  

These are OK for me.

> @@ -278,7 +278,7 @@ static int __kprobes can_optimize(unsigned long paddr)
>  }
>  
>  /* Check optimized_kprobe can actually be optimized. */
> -int __kprobes arch_check_optimized_kprobe(struct optimized_kprobe *op)
> +int __kprobes arch_check_optimized_kprobe(const struct optimized_kprobe *op)
>  {
>  	int i;
>  	struct kprobe *p;

This can be change optimized_kprobe inside, e.g. change flags.
IMHO, I don't like to change this interface.

> @@ -294,7 +294,7 @@ int __kprobes arch_check_optimized_kprobe(struct optimized_kprobe *op)
>  
>  /* Check the addr is within the optimized instructions. */
>  int __kprobes
> -arch_within_optimized_kprobe(struct optimized_kprobe *op, unsigned long addr)
> +arch_within_optimized_kprobe(const struct optimized_kprobe *op, unsigned long addr)
>  {
>  	return ((unsigned long)op->kp.addr <= addr &&
>  		(unsigned long)op->kp.addr + op->optinsn.size > addr);

This is OK for me. But you need to update the prototype in
include/linux/kprobes.h too.

> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 098f396..7daddb0 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1402,7 +1402,7 @@ static inline int check_kprobe_rereg(struct kprobe *p)
>  	return ret;
>  }
>  
> -static __kprobes int check_kprobe_address_safe(struct kprobe *p,
> +static __kprobes int check_kprobe_address_safe(const struct kprobe *p,
>  					       struct module **probed_mod)
>  {
>  	int ret = 0;
> 

No, p is NOT constant in this function. This changes p->flags.

---
#ifdef KPROBES_CAN_USE_FTRACE
                /* Given address is not on the instruction boundary */
                if ((unsigned long)p->addr != ftrace_addr)
                        return -EILSEQ;
                p->flags |= KPROBE_FLAG_FTRACE;
#else   /* !KPROBES_CAN_USE_FTRACE */
---

Thank you,

-- 
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



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

* Re: [PATCH 3/5] kprobes: constify check_kprobe_address_safe and friends
  2013-01-21 11:49   ` Masami Hiramatsu
@ 2013-01-25  4:09     ` Sasha Levin
  2013-01-29 11:45       ` Masami Hiramatsu
  0 siblings, 1 reply; 18+ messages in thread
From: Sasha Levin @ 2013-01-25  4:09 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: tglx, mingo, hpa, rostedt, fweisbec, rusty, ananth,
	anil.s.keshavamurthy, jbaron, x86, linux-kernel,
	yrl.pp-manager.tt@hitachi.com

Hello Masami,

Thank you for your review!

My comments are below.

On 01/21/2013 06:49 AM, Masami Hiramatsu wrote:
> (2013/01/10 8:09), Sasha Levin wrote:
>> @@ -278,7 +278,7 @@ static int __kprobes can_optimize(unsigned long paddr)
>>  }
>>  
>>  /* Check optimized_kprobe can actually be optimized. */
>> -int __kprobes arch_check_optimized_kprobe(struct optimized_kprobe *op)
>> +int __kprobes arch_check_optimized_kprobe(const struct optimized_kprobe *op)
>>  {
>>  	int i;
>>  	struct kprobe *p;
> 
> This can be change optimized_kprobe inside, e.g. change flags.
> IMHO, I don't like to change this interface.

[snip]

>> -static __kprobes int check_kprobe_address_safe(struct kprobe *p,
>> +static __kprobes int check_kprobe_address_safe(const struct kprobe *p,
>>  					       struct module **probed_mod)
>>  {
>>  	int ret = 0;
>>
> 
> No, p is NOT constant in this function. This changes p->flags.
> 
> ---
> #ifdef KPROBES_CAN_USE_FTRACE
>                 /* Given address is not on the instruction boundary */
>                 if ((unsigned long)p->addr != ftrace_addr)
>                         return -EILSEQ;
>                 p->flags |= KPROBE_FLAG_FTRACE;
> #else   /* !KPROBES_CAN_USE_FTRACE */

As to arch_check_optimized_kprobe() and check_kprobe_address_safe(), this
is simply way too confusing. It doesn't make sense that a function named
check_[...]() would modify any of it's parameters.

For example, that entire block within KPROBES_CAN_USE_FTRACE should be split
out and go into update_kprobe_for_ftrace() or something similar.

If that makes sense, I can send a patch to split out all the parts that
modify anything in those two functions out of them.


Thanks,
Sasha

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

* Re: [PATCH 2/5] jump label: constify lookup functions
  2013-01-18 21:25   ` Steven Rostedt
  2013-01-21  6:51     ` Rusty Russell
@ 2013-01-25  4:15     ` Sasha Levin
  2013-01-25 10:16       ` Borislav Petkov
  1 sibling, 1 reply; 18+ messages in thread
From: Sasha Levin @ 2013-01-25  4:15 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: tglx, mingo, hpa, fweisbec, rusty, ananth, anil.s.keshavamurthy,
	masami.hiramatsu.pt, jbaron, x86, linux-kernel, MartinSchwidefsky,
	Heiko Carstens, linux-s390

On 01/18/2013 04:25 PM, Steven Rostedt wrote:
> On Wed, 2013-01-09 at 18:09 -0500, Sasha Levin wrote:
>> Modify the parameters of all the lookup and the bookkeeping functions which
>> should be const to const.
>>
>> For example, jump_label_text_reserved() doesn't modify the memory it works on,
>> it just checks whether there are any jump labels there.
> 
> This is dependent on the module patch, which Rusty is taking. I need to
> see that he has it before this can go in. At least see it in linux-next.
> 
> Also, you should have Cc'd the linux-arch mailing list. I'll send it
> there.
> 
>>
>> Note I couldn't test the non-x86 architectures, but the changes are rather
>> trivial.
> 
> I ran it on 25 archs, and s390 hit:
> 
> /work/autotest/nobackup/cross-linux.git/arch/s390/kernel/jump_label.c: In function 'arch_jump_label_transform':
> /work/autotest/nobackup/cross-linux.git/arch/s390/kernel/jump_label.c:58:13: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]
> 
> -- Steve
> 
> Here's the patch:
> 
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> 
> diff --git a/arch/s390/kernel/jump_label.c
> b/arch/s390/kernel/jump_label.c
> index 85fa643..ef047ef 100644
> --- a/arch/s390/kernel/jump_label.c
> +++ b/arch/s390/kernel/jump_label.c
> @@ -18,7 +18,7 @@ struct insn {
>  } __packed;
>  
>  struct insn_args {
> -	struct jump_entry *entry;
> +	const struct jump_entry *entry;
>  	enum jump_label_type type;
>  };
>  

Sorry about this. I didn't have the ability to build all arches over here :(

Would you like me to resend this patch with your fix?


Thanks,
Sasha


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

* Re: [PATCH 2/5] jump label: constify lookup functions
  2013-01-25  4:15     ` Sasha Levin
@ 2013-01-25 10:16       ` Borislav Petkov
  2013-01-25 13:03         ` Steven Rostedt
  0 siblings, 1 reply; 18+ messages in thread
From: Borislav Petkov @ 2013-01-25 10:16 UTC (permalink / raw)
  To: Sasha Levin
  Cc: Steven Rostedt, tglx, mingo, hpa, fweisbec, rusty, ananth,
	anil.s.keshavamurthy, masami.hiramatsu.pt, jbaron, x86,
	linux-kernel, MartinSchwidefsky, Heiko Carstens, linux-s390

On Thu, Jan 24, 2013 at 11:15:10PM -0500, Sasha Levin wrote:
> Sorry about this. I didn't have the ability to build all arches over here :(

Seen this already: https://www.kernel.org/pub/tools/crosstool/

?

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

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

* Re: [PATCH 2/5] jump label: constify lookup functions
  2013-01-25 10:16       ` Borislav Petkov
@ 2013-01-25 13:03         ` Steven Rostedt
  0 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2013-01-25 13:03 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Sasha Levin, tglx, mingo, hpa, fweisbec, rusty, ananth,
	anil.s.keshavamurthy, masami.hiramatsu.pt, jbaron, x86,
	linux-kernel, MartinSchwidefsky, Heiko Carstens, linux-s390

On Fri, 2013-01-25 at 11:16 +0100, Borislav Petkov wrote:
> On Thu, Jan 24, 2013 at 11:15:10PM -0500, Sasha Levin wrote:
> > Sorry about this. I didn't have the ability to build all arches over here :(
> 
> Seen this already: https://www.kernel.org/pub/tools/crosstool/

And look in the kernel tree:

  tools/testing/ktest/examples/crosstests.conf

-- Steve



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

* Re: [PATCH 3/5] kprobes: constify check_kprobe_address_safe and friends
  2013-01-25  4:09     ` Sasha Levin
@ 2013-01-29 11:45       ` Masami Hiramatsu
  0 siblings, 0 replies; 18+ messages in thread
From: Masami Hiramatsu @ 2013-01-29 11:45 UTC (permalink / raw)
  To: Sasha Levin
  Cc: tglx, mingo, hpa, rostedt, fweisbec, rusty, ananth,
	anil.s.keshavamurthy, jbaron, x86, linux-kernel,
	yrl.pp-manager.tt@hitachi.com

(2013/01/25 13:09), Sasha Levin wrote:
> As to arch_check_optimized_kprobe() and check_kprobe_address_safe(), this
> is simply way too confusing. It doesn't make sense that a function named
> check_[...]() would modify any of it's parameters.
> 
> For example, that entire block within KPROBES_CAN_USE_FTRACE should be split
> out and go into update_kprobe_for_ftrace() or something similar.
> 
> If that makes sense, I can send a patch to split out all the parts that
> modify anything in those two functions out of them.

I see, that makes sense :-)

Thank you,

-- 
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



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

end of thread, other threads:[~2013-01-29 11:45 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-09 23:09 [PATCH 1/5] module: constify within_module_* Sasha Levin
2013-01-09 23:09 ` [PATCH 2/5] jump label: constify lookup functions Sasha Levin
2013-01-15 20:46   ` Sasha Levin
2013-01-15 23:19     ` Steven Rostedt
2013-01-18 21:25   ` Steven Rostedt
2013-01-21  6:51     ` Rusty Russell
2013-01-25  4:15     ` Sasha Levin
2013-01-25 10:16       ` Borislav Petkov
2013-01-25 13:03         ` Steven Rostedt
2013-01-18 21:25   ` Steven Rostedt
2013-01-09 23:09 ` [PATCH 3/5] kprobes: constify check_kprobe_address_safe and friends Sasha Levin
2013-01-21 11:49   ` Masami Hiramatsu
2013-01-25  4:09     ` Sasha Levin
2013-01-29 11:45       ` Masami Hiramatsu
2013-01-09 23:09 ` [PATCH 4/5] alternatives: constify alternatives_text_reserved Sasha Levin
2013-01-21 11:38   ` Masami Hiramatsu
2013-01-09 23:09 ` [PATCH 5/5] ftrace: constify ftrace_text_reserved Sasha Levin
2013-01-10  9:02 ` [PATCH 1/5] module: constify within_module_* Rusty Russell

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