Re: [RFC PATCH 1/3] LoongArch: Implement CONFIG_THREAD_INFO_IN_TASK
From: Tiezhu Yang
Date: Thu Jun 04 2026 - 01:08:02 EST
On 2026/6/4 上午10:26, Tiezhu Yang wrote:
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?
I tested with stress-ng, it works well without modifying processor.h,
so I will keep the original INIT_THREAD in the upstream code.
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?
I tested with stress-ng, it works well without modifying ptrace.h,
so I will keep the original current_pt_regs in the upstream code
for now. We can delete it if there is obvious benefit in the future.
/* 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:
I will use current_task variable and set_current() in the next version
if no more comments.
Thanks,
Tiezhu