Re: [RFC PATCH 1/3] LoongArch: Implement CONFIG_THREAD_INFO_IN_TASK
From: Tiezhu Yang
Date: Wed Jun 03 2026 - 22:29:26 EST
On 2026/6/3 下午10:24, Huacai Chen wrote:
On Wed, Jun 3, 2026 at 10:30 AM Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> wrote:
...
For static structures like init_task, any uninitialized fields areI know it is the same for compilers, I mean the current way gives more
automatically zeroed out by the compiler according to the C standard.
Stripping away dozens of lines of ".field = 0" complies with modern
Linux kernel code-cleaning standards. It makes the macro much shorter
and highlights the only field that actually requires a special
runtime value (the kernel stack top in .reg03).
information for humans.
In addition, without reg02, this piece completely has no relationship
with CONFIG_THREAD_INFO_IN_TASK, so please drop it.
Do you mean keep the original INIT_THREAD as is? No any changes for it?
".reg03 = (unsigned long)&init_stack + sizeof(init_stack)," is not
necessary?
That is to say, do not modify arch/loongarch/include/asm/processor.h?
For reference, please see how INIT_THREAD is defined in other major
architectures, where they only initialize what is strictly necessary:
...
None of these commits remove current_pt_regs. Some of them has no
current_pt_regs before THREAD_INFO_IN_TASK, and ARM32 still has its
own implementations in arch/arm/include/asm/ptrace.h now which is
nearly the same as LoongArch.
If you think it should keep current_pt_regs() as is, I am OK, will do
it in the next version.
That is to say, do not modify arch/loongarch/include/asm/ptrace.h?
/* Helpers for working with the user stack pointer */
...
set_current() is a very good friend of get_current(). Though "$tp" is
enough for get_current(), from the x86 implementation we know that it
can also get from the per-cpu array (but suboptimal).
Move set_current() to current.h also don't need to include
<linux/percpu.h> and <linux/sched.h>, it only need to forwarding
declare "task_struct" and include <asm/percpu.h>, which is exactly
done in the x86 implementation.
And you needn't worry about the compiling, I have tested before I comment.
If you think this is proper, I am OK.
Replace __entry_task with current_task (x86) or cpu_tasks (uml)?
Replace entry_task_switch() with set_current()? or something else?
It seems a little strange for the following code in smp.c:
diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c
index 4b74409a98a3..3afdeca7bc2a 100644
--- a/arch/loongarch/kernel/smp.c
+++ b/arch/loongarch/kernel/smp.c
@@ -665,7 +665,7 @@ asmlinkage void start_secondary(void)
set_my_cpu_offset(per_cpu_offset(cpu));
cpu_probe();
- entry_task_switch(current);
+ set_current(current);
constant_clockevent_init();
loongson_init_secondary();
Thanks,
Tiezhu