From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Huacai Chen <chenhuacai@kernel.org>
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 13:05:37 +0800 [thread overview]
Message-ID: <0dcead8f-7178-5ab9-7367-898c63a30910@loongson.cn> (raw)
In-Reply-To: <9fe9a1f4-bdd0-d6b4-6b76-269e4ffdbc7e@loongson.cn>
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@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?
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
next prev parent reply other threads:[~2026-06-04 5:05 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 [this message]
2026-06-04 6:26 ` Huacai Chen
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=0dcead8f-7178-5ab9-7367-898c63a30910@loongson.cn \
--to=yangtiezhu@loongson.cn \
--cc=bpf@vger.kernel.org \
--cc=chenhuacai@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
/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).