* [PATCH v2 1/2] sched.h: always_inline alloc_tag_{save|restore} to fix modpost warnings
@ 2024-07-04 13:25 Suren Baghdasaryan
2024-07-04 13:25 ` [PATCH v2 2/2] arch/xtensa: always_inline get_current() and current_thread_info() Suren Baghdasaryan
0 siblings, 1 reply; 2+ messages in thread
From: Suren Baghdasaryan @ 2024-07-04 13:25 UTC (permalink / raw)
To: akpm
Cc: mingo, peterz, juri.lelli, vincent.guittot, chris, jcmvbkbc,
kent.overstreet, linux-kernel, lkp, surenb, stable
Mark alloc_tag_{save|restore} as always_inline to fix the following
modpost warnings:
WARNING: modpost: vmlinux: section mismatch in reference: alloc_tag_save+0x1c (section: .text.unlikely) -> initcall_level_names (section: .init.data)
WARNING: modpost: vmlinux: section mismatch in reference: alloc_tag_restore+0x3c (section: .text.unlikely) -> initcall_level_names (section: .init.data)
The warnings happen when these functions are called from an __init
function and they don't get inlined (remain in the .text section) while
the value returned by get_current() points into .init.data section.
Assuming get_current() always returns a valid address, this situation can
happen only during init stage and accessing .init.data from .text section
during that stage should pose no issues.
Fixes: 22d407b164ff ("lib: add allocation tagging support for memory allocation profiling")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202407032306.gi9nZsBi-lkp@intel.com/
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: <stable@vger.kernel.org>
---
Changes since v1 [1]:
- Added the second patch to resolve follow-up warnings
- Expanded changelog description, per Andrew Morton
- CC'ed stable, per Andrew Morton
- Added Fixes tag, per Andrew Morton
[1] https://lore.kernel.org/all/20240703221520.4108464-1-surenb@google.com/
include/linux/sched.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 61591ac6eab6..a5f4b48fca18 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2192,13 +2192,13 @@ static inline int sched_core_idle_cpu(int cpu) { return idle_cpu(cpu); }
extern void sched_set_stop_task(int cpu, struct task_struct *stop);
#ifdef CONFIG_MEM_ALLOC_PROFILING
-static inline struct alloc_tag *alloc_tag_save(struct alloc_tag *tag)
+static __always_inline struct alloc_tag *alloc_tag_save(struct alloc_tag *tag)
{
swap(current->alloc_tag, tag);
return tag;
}
-static inline void alloc_tag_restore(struct alloc_tag *tag, struct alloc_tag *old)
+static __always_inline void alloc_tag_restore(struct alloc_tag *tag, struct alloc_tag *old)
{
#ifdef CONFIG_MEM_ALLOC_PROFILING_DEBUG
WARN(current->alloc_tag != tag, "current->alloc_tag was changed:\n");
base-commit: 795c58e4c7fc6163d8fb9f2baa86cfe898fa4b19
--
2.45.2.803.g4e1b14247a-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v2 2/2] arch/xtensa: always_inline get_current() and current_thread_info()
2024-07-04 13:25 [PATCH v2 1/2] sched.h: always_inline alloc_tag_{save|restore} to fix modpost warnings Suren Baghdasaryan
@ 2024-07-04 13:25 ` Suren Baghdasaryan
0 siblings, 0 replies; 2+ messages in thread
From: Suren Baghdasaryan @ 2024-07-04 13:25 UTC (permalink / raw)
To: akpm
Cc: mingo, peterz, juri.lelli, vincent.guittot, chris, jcmvbkbc,
kent.overstreet, linux-kernel, lkp, surenb, stable
Mark get_current() and current_thread_info() functions as always_inline
to fix the following modpost warning:
WARNING: modpost: vmlinux: section mismatch in reference: get_current+0xc (section: .text.unlikely) -> initcall_level_names (section: .init.data)
The warning happens when these functions are called from an __init
function and they don't get inlined (remain in the .text section) while
the value they return points into .init.data section. Assuming
get_current() always returns a valid address, this situation can happen
only during init stage and accessing .init.data from .text section during
that stage should pose no issues.
Fixes: 22d407b164ff ("lib: add allocation tagging support for memory allocation profiling")
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: <stable@vger.kernel.org>
---
arch/xtensa/include/asm/current.h | 2 +-
arch/xtensa/include/asm/thread_info.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/xtensa/include/asm/current.h b/arch/xtensa/include/asm/current.h
index 08010dbf5e09..df275d554788 100644
--- a/arch/xtensa/include/asm/current.h
+++ b/arch/xtensa/include/asm/current.h
@@ -19,7 +19,7 @@
struct task_struct;
-static inline struct task_struct *get_current(void)
+static __always_inline struct task_struct *get_current(void)
{
return current_thread_info()->task;
}
diff --git a/arch/xtensa/include/asm/thread_info.h b/arch/xtensa/include/asm/thread_info.h
index 326db1c1d5d8..e0dffcc43b9e 100644
--- a/arch/xtensa/include/asm/thread_info.h
+++ b/arch/xtensa/include/asm/thread_info.h
@@ -91,7 +91,7 @@ struct thread_info {
}
/* how to get the thread information struct from C */
-static inline struct thread_info *current_thread_info(void)
+static __always_inline struct thread_info *current_thread_info(void)
{
struct thread_info *ti;
__asm__("extui %0, a1, 0, "__stringify(CURRENT_SHIFT)"\n\t"
--
2.45.2.803.g4e1b14247a-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-04 13:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-04 13:25 [PATCH v2 1/2] sched.h: always_inline alloc_tag_{save|restore} to fix modpost warnings Suren Baghdasaryan
2024-07-04 13:25 ` [PATCH v2 2/2] arch/xtensa: always_inline get_current() and current_thread_info() Suren Baghdasaryan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox