From: Huacai Chen <chenhuacai@kernel.org>
To: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: loongarch@lists.linux.dev, bpf@vger.kernel.org,
linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 1/3] LoongArch: Implement CONFIG_THREAD_INFO_IN_TASK
Date: Thu, 4 Jun 2026 14:26:40 +0800 [thread overview]
Message-ID: <CAAhV-H76bD-bsw_btJuxw7sciQn8o5AwXEuQ7+rT-jBX6dHZjA@mail.gmail.com> (raw)
In-Reply-To: <9fe9a1f4-bdd0-d6b4-6b76-269e4ffdbc7e@loongson.cn>
On Thu, Jun 4, 2026 at 10:26 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> On 2026/6/3 下午10:24, Huacai Chen wrote:
> > On Wed, Jun 3, 2026 at 10:30 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> ...
>
> >> For static structures like init_task, any uninitialized fields are
> >> 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).
> > I know it is the same for compilers, I mean the current way gives more
> > 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?
Yes.
>
> >> 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?
Yes.
>
> >>>> /* 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 you want to avoid "current", then please use "cpu_tasks"
rather than "current_task", but "set_current" is a friend of
"get_current", just use it.
Huacai
> 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
>
next prev parent reply other threads:[~2026-06-04 6:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 7:20 [RFC PATCH 0/3] Move thread_info into task_struct for LoongArch Tiezhu Yang
2026-04-28 7:20 ` [RFC PATCH 1/3] LoongArch: Implement CONFIG_THREAD_INFO_IN_TASK Tiezhu Yang
2026-06-01 13:46 ` Huacai Chen
2026-06-03 2:30 ` Tiezhu Yang
2026-06-03 14:24 ` Huacai Chen
2026-06-04 2:26 ` Tiezhu Yang
2026-06-04 5:05 ` Tiezhu Yang
2026-06-04 6:26 ` Huacai Chen [this message]
2026-04-28 7:20 ` [RFC PATCH 2/3] LoongArch: BPF: Inline bpf_get_current_task{_btf}() helpers Tiezhu Yang
2026-04-28 7:20 ` [RFC PATCH 3/3] LoongArch: BPF: Inline bpf_get_smp_processor_id() helper Tiezhu Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAhV-H76bD-bsw_btJuxw7sciQn8o5AwXEuQ7+rT-jBX6dHZjA@mail.gmail.com \
--to=chenhuacai@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=yangtiezhu@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).