[PATCH v3 0/3] Move thread_info into task_struct for LoongArch

Tiezhu Yang posted 3 patches 5 days, 1 hour ago
.../core/thread-info-in-task/arch-support.txt |  2 +-
arch/loongarch/Kconfig                        |  1 +
arch/loongarch/include/asm/current.h          | 31 +++++++++++++++++++
arch/loongarch/include/asm/smp.h              |  3 +-
arch/loongarch/include/asm/stackframe.h       |  9 ++++--
arch/loongarch/include/asm/switch_to.h        |  6 ++--
arch/loongarch/include/asm/thread_info.h      | 10 ------
arch/loongarch/kernel/asm-offsets.c           |  6 ++--
arch/loongarch/kernel/entry.S                 |  7 +++--
arch/loongarch/kernel/head.S                  | 18 ++++++-----
arch/loongarch/kernel/process.c               |  2 ++
arch/loongarch/kernel/relocate.c              |  2 +-
arch/loongarch/kernel/setup.c                 |  1 +
arch/loongarch/kernel/smp.c                   |  6 ++--
arch/loongarch/kernel/switch.S                | 14 +++++----
arch/loongarch/kernel/traps.c                 |  8 +++++
arch/loongarch/net/bpf_jit.c                  | 26 ++++++++++++++++
17 files changed, 114 insertions(+), 38 deletions(-)
create mode 100644 arch/loongarch/include/asm/current.h
[PATCH v3 0/3] Move thread_info into task_struct for LoongArch
Posted by Tiezhu Yang 5 days, 1 hour ago
Based on 7.1-rc7, tested with stress-ng, successfully passed
the 10-hours stress testing suite, and UnixBench benchmarking
shows a steady performance lift across all core counts.

Thanks Huacai, Wang Rui, sashiko-bot and bot+bpf-ci for your
review comments and valuable suggestions.

Tiezhu Yang (3):
  LoongArch: Implement CONFIG_THREAD_INFO_IN_TASK
  LoongArch: BPF: Inline bpf_get_current_task{_btf}() helpers
  LoongArch: BPF: Inline bpf_get_smp_processor_id() helper

 .../core/thread-info-in-task/arch-support.txt |  2 +-
 arch/loongarch/Kconfig                        |  1 +
 arch/loongarch/include/asm/current.h          | 31 +++++++++++++++++++
 arch/loongarch/include/asm/smp.h              |  3 +-
 arch/loongarch/include/asm/stackframe.h       |  9 ++++--
 arch/loongarch/include/asm/switch_to.h        |  6 ++--
 arch/loongarch/include/asm/thread_info.h      | 10 ------
 arch/loongarch/kernel/asm-offsets.c           |  6 ++--
 arch/loongarch/kernel/entry.S                 |  7 +++--
 arch/loongarch/kernel/head.S                  | 18 ++++++-----
 arch/loongarch/kernel/process.c               |  2 ++
 arch/loongarch/kernel/relocate.c              |  2 +-
 arch/loongarch/kernel/setup.c                 |  1 +
 arch/loongarch/kernel/smp.c                   |  6 ++--
 arch/loongarch/kernel/switch.S                | 14 +++++----
 arch/loongarch/kernel/traps.c                 |  8 +++++
 arch/loongarch/net/bpf_jit.c                  | 26 ++++++++++++++++
 17 files changed, 114 insertions(+), 38 deletions(-)
 create mode 100644 arch/loongarch/include/asm/current.h

-- 
2.42.0
Re: [PATCH v3 0/3] Move thread_info into task_struct for LoongArch
Posted by Huacai Chen 3 days ago
Hi, Tiezhu,

I have queued this series for 7.2, does the below series depend on this one?

https://lore.kernel.org/loongarch/20260521125636.26744-1-yangtiezhu@loongson.cn/T/#t
https://lore.kernel.org/loongarch/20260428080051.20938-1-yangtiezhu@loongson.cn/T/#t

Huacai

On Fri, Jun 12, 2026 at 9:16 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> Based on 7.1-rc7, tested with stress-ng, successfully passed
> the 10-hours stress testing suite, and UnixBench benchmarking
> shows a steady performance lift across all core counts.
>
> Thanks Huacai, Wang Rui, sashiko-bot and bot+bpf-ci for your
> review comments and valuable suggestions.
>
> Tiezhu Yang (3):
>   LoongArch: Implement CONFIG_THREAD_INFO_IN_TASK
>   LoongArch: BPF: Inline bpf_get_current_task{_btf}() helpers
>   LoongArch: BPF: Inline bpf_get_smp_processor_id() helper
>
>  .../core/thread-info-in-task/arch-support.txt |  2 +-
>  arch/loongarch/Kconfig                        |  1 +
>  arch/loongarch/include/asm/current.h          | 31 +++++++++++++++++++
>  arch/loongarch/include/asm/smp.h              |  3 +-
>  arch/loongarch/include/asm/stackframe.h       |  9 ++++--
>  arch/loongarch/include/asm/switch_to.h        |  6 ++--
>  arch/loongarch/include/asm/thread_info.h      | 10 ------
>  arch/loongarch/kernel/asm-offsets.c           |  6 ++--
>  arch/loongarch/kernel/entry.S                 |  7 +++--
>  arch/loongarch/kernel/head.S                  | 18 ++++++-----
>  arch/loongarch/kernel/process.c               |  2 ++
>  arch/loongarch/kernel/relocate.c              |  2 +-
>  arch/loongarch/kernel/setup.c                 |  1 +
>  arch/loongarch/kernel/smp.c                   |  6 ++--
>  arch/loongarch/kernel/switch.S                | 14 +++++----
>  arch/loongarch/kernel/traps.c                 |  8 +++++
>  arch/loongarch/net/bpf_jit.c                  | 26 ++++++++++++++++
>  17 files changed, 114 insertions(+), 38 deletions(-)
>  create mode 100644 arch/loongarch/include/asm/current.h
>
> --
> 2.42.0
>
>
Re: [PATCH v3 0/3] Move thread_info into task_struct for LoongArch
Posted by Tiezhu Yang 2 days, 1 hour ago
On 2026/6/14 上午10:51, Huacai Chen wrote:
> Hi, Tiezhu,
> 
> I have queued this series for 7.2, does the below series depend on this one?
> 
> https://lore.kernel.org/loongarch/20260521125636.26744-1-yangtiezhu@loongson.cn/T/#t

This is independent on CONFIG_THREAD_INFO_IN_TASK.

> https://lore.kernel.org/loongarch/20260428080051.20938-1-yangtiezhu@loongson.cn/T/#t

This is dependent on CONFIG_THREAD_INFO_IN_TASK.

But anyway, I plan to send new version for the above two series of
selftests once this "Move thread_info into task_struct for LoongArch"
series is merged into the mainline, maybe after 7.2-rc1.

Because the code under selftests need to be updated, for example,
it can use bpf_get_current_task_btf()->thread_info.preempt_count
for get_preempt_count(), and it should use ld.wu rather than ld.w
for bpf_get_smp_processor_id().

Thanks,
Tiezhu

Re: [PATCH v3 0/3] Move thread_info into task_struct for LoongArch
Posted by Huacai Chen 2 days ago
On Mon, Jun 15, 2026 at 9:41 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> On 2026/6/14 上午10:51, Huacai Chen wrote:
> > Hi, Tiezhu,
> >
> > I have queued this series for 7.2, does the below series depend on this one?
> >
> > https://lore.kernel.org/loongarch/20260521125636.26744-1-yangtiezhu@loongson.cn/T/#t
>
> This is independent on CONFIG_THREAD_INFO_IN_TASK.
>
> > https://lore.kernel.org/loongarch/20260428080051.20938-1-yangtiezhu@loongson.cn/T/#t
>
> This is dependent on CONFIG_THREAD_INFO_IN_TASK.
>
> But anyway, I plan to send new version for the above two series of
> selftests once this "Move thread_info into task_struct for LoongArch"
> series is merged into the mainline, maybe after 7.2-rc1.
>
> Because the code under selftests need to be updated, for example,
> it can use bpf_get_current_task_btf()->thread_info.preempt_count
> for get_preempt_count(), and it should use ld.wu rather than ld.w
> for bpf_get_smp_processor_id().
You can update new versions now, then they can be merged together.

Huacai

>
> Thanks,
> Tiezhu
>
Re: [PATCH v3 0/3] Move thread_info into task_struct for LoongArch
Posted by Tiezhu Yang 1 day, 23 hours ago
On 2026/6/15 上午10:23, Huacai Chen wrote:
> On Mon, Jun 15, 2026 at 9:41 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>>
>> On 2026/6/14 上午10:51, Huacai Chen wrote:
>>> Hi, Tiezhu,
>>>
>>> I have queued this series for 7.2, does the below series depend on this one?
>>>
>>> https://lore.kernel.org/loongarch/20260521125636.26744-1-yangtiezhu@loongson.cn/T/#t
>>
>> This is independent on CONFIG_THREAD_INFO_IN_TASK.
>>
>>> https://lore.kernel.org/loongarch/20260428080051.20938-1-yangtiezhu@loongson.cn/T/#t
>>
>> This is dependent on CONFIG_THREAD_INFO_IN_TASK.
>>
>> But anyway, I plan to send new version for the above two series of
>> selftests once this "Move thread_info into task_struct for LoongArch"
>> series is merged into the mainline, maybe after 7.2-rc1.
>>
>> Because the code under selftests need to be updated, for example,
>> it can use bpf_get_current_task_btf()->thread_info.preempt_count
>> for get_preempt_count(), and it should use ld.wu rather than ld.w
>> for bpf_get_smp_processor_id().
> You can update new versions now, then they can be merged together.

Thanks for your suggestion.

However, considering that these selftest patches need to be
routed through the BPF tree (rather than the LoongArch tree),
updating them right now during the active merge window might
be inappropriate and risky.

Given that these selftests strictly depend on the "move
thread_info into task_struct" core changes, sending them to
the BPF list now could cause cross-tree dependency issues and
potential build breakages if the core series undergoes any late
adjustments before hitting mainline.

Moreover, because these are selftest adaptations rather than
urgent bug fixes, they aren't high-priority for this immediate
window. I will rebase and submit the new version to the BPF tree
right after 7.2-rc1, once the LoongArch base infrastructure is
securely merged into the mainline.

Thanks,
Tiezhu

Re: [PATCH v3 0/3] Move thread_info into task_struct for LoongArch
Posted by Huacai Chen 1 day, 23 hours ago
On Mon, Jun 15, 2026 at 11:16 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> On 2026/6/15 上午10:23, Huacai Chen wrote:
> > On Mon, Jun 15, 2026 at 9:41 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
> >>
> >> On 2026/6/14 上午10:51, Huacai Chen wrote:
> >>> Hi, Tiezhu,
> >>>
> >>> I have queued this series for 7.2, does the below series depend on this one?
> >>>
> >>> https://lore.kernel.org/loongarch/20260521125636.26744-1-yangtiezhu@loongson.cn/T/#t
> >>
> >> This is independent on CONFIG_THREAD_INFO_IN_TASK.
> >>
> >>> https://lore.kernel.org/loongarch/20260428080051.20938-1-yangtiezhu@loongson.cn/T/#t
> >>
> >> This is dependent on CONFIG_THREAD_INFO_IN_TASK.
> >>
> >> But anyway, I plan to send new version for the above two series of
> >> selftests once this "Move thread_info into task_struct for LoongArch"
> >> series is merged into the mainline, maybe after 7.2-rc1.
> >>
> >> Because the code under selftests need to be updated, for example,
> >> it can use bpf_get_current_task_btf()->thread_info.preempt_count
> >> for get_preempt_count(), and it should use ld.wu rather than ld.w
> >> for bpf_get_smp_processor_id().
> > You can update new versions now, then they can be merged together.
>
> Thanks for your suggestion.
>
> However, considering that these selftest patches need to be
> routed through the BPF tree (rather than the LoongArch tree),
> updating them right now during the active merge window might
> be inappropriate and risky.
>
> Given that these selftests strictly depend on the "move
> thread_info into task_struct" core changes, sending them to
> the BPF list now could cause cross-tree dependency issues and
> potential build breakages if the core series undergoes any late
> adjustments before hitting mainline.
>
> Moreover, because these are selftest adaptations rather than
> urgent bug fixes, they aren't high-priority for this immediate
> window. I will rebase and submit the new version to the BPF tree
> right after 7.2-rc1, once the LoongArch base infrastructure is
> securely merged into the mainline.
In history most arch-specific selftests are merged via arch trees,
including perf, bpf, ftrace, kvm and so on.

Huacai

>
> Thanks,
> Tiezhu
>
Re: [PATCH v3 0/3] Move thread_info into task_struct for LoongArch
Posted by Alexei Starovoitov 1 day, 23 hours ago
On Sun, Jun 14, 2026 at 8:31 PM Huacai Chen <chenhuacai@kernel.org> wrote:
>
> On Mon, Jun 15, 2026 at 11:16 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
> >
> > On 2026/6/15 上午10:23, Huacai Chen wrote:
> > > On Mon, Jun 15, 2026 at 9:41 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
> > >>
> > >> On 2026/6/14 上午10:51, Huacai Chen wrote:
> > >>> Hi, Tiezhu,
> > >>>
> > >>> I have queued this series for 7.2, does the below series depend on this one?
> > >>>
> > >>> https://lore.kernel.org/loongarch/20260521125636.26744-1-yangtiezhu@loongson.cn/T/#t
> > >>
> > >> This is independent on CONFIG_THREAD_INFO_IN_TASK.
> > >>
> > >>> https://lore.kernel.org/loongarch/20260428080051.20938-1-yangtiezhu@loongson.cn/T/#t
> > >>
> > >> This is dependent on CONFIG_THREAD_INFO_IN_TASK.
> > >>
> > >> But anyway, I plan to send new version for the above two series of
> > >> selftests once this "Move thread_info into task_struct for LoongArch"
> > >> series is merged into the mainline, maybe after 7.2-rc1.
> > >>
> > >> Because the code under selftests need to be updated, for example,
> > >> it can use bpf_get_current_task_btf()->thread_info.preempt_count
> > >> for get_preempt_count(), and it should use ld.wu rather than ld.w
> > >> for bpf_get_smp_processor_id().
> > > You can update new versions now, then they can be merged together.
> >
> > Thanks for your suggestion.
> >
> > However, considering that these selftest patches need to be
> > routed through the BPF tree (rather than the LoongArch tree),
> > updating them right now during the active merge window might
> > be inappropriate and risky.
> >
> > Given that these selftests strictly depend on the "move
> > thread_info into task_struct" core changes, sending them to
> > the BPF list now could cause cross-tree dependency issues and
> > potential build breakages if the core series undergoes any late
> > adjustments before hitting mainline.
> >
> > Moreover, because these are selftest adaptations rather than
> > urgent bug fixes, they aren't high-priority for this immediate
> > window. I will rebase and submit the new version to the BPF tree
> > right after 7.2-rc1, once the LoongArch base infrastructure is
> > securely merged into the mainline.
> In history most arch-specific selftests are merged via arch trees,
> including perf, bpf, ftrace, kvm and so on.

This is not true at all.
All bpf selftests are going through bpf-next tree.
For example, x86 and arm64 bpf JIT changes always go
through bpf-next.
loongarch is causing problems this way by taking bpf JIT changes
into the loongarch tree.
Re: [PATCH v3 0/3] Move thread_info into task_struct for LoongArch
Posted by Huacai Chen 1 day, 18 hours ago
Hi, Alexei,

On Mon, Jun 15, 2026 at 11:45 AM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Sun, Jun 14, 2026 at 8:31 PM Huacai Chen <chenhuacai@kernel.org> wrote:
> >
> > On Mon, Jun 15, 2026 at 11:16 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
> > >
> > > On 2026/6/15 上午10:23, Huacai Chen wrote:
> > > > On Mon, Jun 15, 2026 at 9:41 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
> > > >>
> > > >> On 2026/6/14 上午10:51, Huacai Chen wrote:
> > > >>> Hi, Tiezhu,
> > > >>>
> > > >>> I have queued this series for 7.2, does the below series depend on this one?
> > > >>>
> > > >>> https://lore.kernel.org/loongarch/20260521125636.26744-1-yangtiezhu@loongson.cn/T/#t
> > > >>
> > > >> This is independent on CONFIG_THREAD_INFO_IN_TASK.
> > > >>
> > > >>> https://lore.kernel.org/loongarch/20260428080051.20938-1-yangtiezhu@loongson.cn/T/#t
> > > >>
> > > >> This is dependent on CONFIG_THREAD_INFO_IN_TASK.
> > > >>
> > > >> But anyway, I plan to send new version for the above two series of
> > > >> selftests once this "Move thread_info into task_struct for LoongArch"
> > > >> series is merged into the mainline, maybe after 7.2-rc1.
> > > >>
> > > >> Because the code under selftests need to be updated, for example,
> > > >> it can use bpf_get_current_task_btf()->thread_info.preempt_count
> > > >> for get_preempt_count(), and it should use ld.wu rather than ld.w
> > > >> for bpf_get_smp_processor_id().
> > > > You can update new versions now, then they can be merged together.
> > >
> > > Thanks for your suggestion.
> > >
> > > However, considering that these selftest patches need to be
> > > routed through the BPF tree (rather than the LoongArch tree),
> > > updating them right now during the active merge window might
> > > be inappropriate and risky.
> > >
> > > Given that these selftests strictly depend on the "move
> > > thread_info into task_struct" core changes, sending them to
> > > the BPF list now could cause cross-tree dependency issues and
> > > potential build breakages if the core series undergoes any late
> > > adjustments before hitting mainline.
> > >
> > > Moreover, because these are selftest adaptations rather than
> > > urgent bug fixes, they aren't high-priority for this immediate
> > > window. I will rebase and submit the new version to the BPF tree
> > > right after 7.2-rc1, once the LoongArch base infrastructure is
> > > securely merged into the mainline.
> > In history most arch-specific selftests are merged via arch trees,
> > including perf, bpf, ftrace, kvm and so on.
>
> This is not true at all.
> All bpf selftests are going through bpf-next tree.
> For example, x86 and arm64 bpf JIT changes always go
> through bpf-next.
> loongarch is causing problems this way by taking bpf JIT changes
> into the loongarch tree.
I'm sorry for my mistake. Yes, you are right, most BPF changes go
through bpf-next, but LoongArch is not the first and not the only
exception. See commit 806381e1a24c6eec2b431cbba2ba1b81e518fea8 and
3203a08c1266689c204fb8f10d6bb5186921fce2.

Frankly, cross subsystem patches usually have some extra difficulty to
get merged because of dependencies & confliction, and my mentor gave
me a solution: Merge a single tag from another subsystem (e.g. from
the bpf tree) to create a clean base, and then apply arch patches on
top of that base.


Huacai
Re: [PATCH v3 0/3] Move thread_info into task_struct for LoongArch
Posted by Tiezhu Yang 1 day, 19 hours ago
On 2026/6/15 上午11:45, Alexei Starovoitov wrote:
> On Sun, Jun 14, 2026 at 8:31 PM Huacai Chen <chenhuacai@kernel.org> wrote:
>>
>> On Mon, Jun 15, 2026 at 11:16 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>>>
>>> On 2026/6/15 上午10:23, Huacai Chen wrote:
>>>> On Mon, Jun 15, 2026 at 9:41 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>>>>>
>>>>> On 2026/6/14 上午10:51, Huacai Chen wrote:
>>>>>> Hi, Tiezhu,
>>>>>>
>>>>>> I have queued this series for 7.2, does the below series depend on this one?
>>>>>>
>>>>>> https://lore.kernel.org/loongarch/20260521125636.26744-1-yangtiezhu@loongson.cn/T/#t
>>>>>
>>>>> This is independent on CONFIG_THREAD_INFO_IN_TASK.
>>>>>
>>>>>> https://lore.kernel.org/loongarch/20260428080051.20938-1-yangtiezhu@loongson.cn/T/#t
>>>>>
>>>>> This is dependent on CONFIG_THREAD_INFO_IN_TASK.
>>>>>
>>>>> But anyway, I plan to send new version for the above two series of
>>>>> selftests once this "Move thread_info into task_struct for LoongArch"
>>>>> series is merged into the mainline, maybe after 7.2-rc1.
>>>>>
>>>>> Because the code under selftests need to be updated, for example,
>>>>> it can use bpf_get_current_task_btf()->thread_info.preempt_count
>>>>> for get_preempt_count(), and it should use ld.wu rather than ld.w
>>>>> for bpf_get_smp_processor_id().
>>>> You can update new versions now, then they can be merged together.
>>>
>>> Thanks for your suggestion.
>>>
>>> However, considering that these selftest patches need to be
>>> routed through the BPF tree (rather than the LoongArch tree),
>>> updating them right now during the active merge window might
>>> be inappropriate and risky.
>>>
>>> Given that these selftests strictly depend on the "move
>>> thread_info into task_struct" core changes, sending them to
>>> the BPF list now could cause cross-tree dependency issues and
>>> potential build breakages if the core series undergoes any late
>>> adjustments before hitting mainline.
>>>
>>> Moreover, because these are selftest adaptations rather than
>>> urgent bug fixes, they aren't high-priority for this immediate
>>> window. I will rebase and submit the new version to the BPF tree
>>> right after 7.2-rc1, once the LoongArch base infrastructure is
>>> securely merged into the mainline.
>> In history most arch-specific selftests are merged via arch trees,
>> including perf, bpf, ftrace, kvm and so on.
> 
> This is not true at all.
> All bpf selftests are going through bpf-next tree.
> For example, x86 and arm64 bpf JIT changes always go
> through bpf-next.
> loongarch is causing problems this way by taking bpf JIT changes
> into the loongarch tree.

I will prepare and send the new version of bpf selftests patches
based on the bpf-next repo shortly. In the cover letter, I will
explicitly state the dependency on the "Move thread_info into
task_struct for LoongArch" series.

I will leave it to you and the LoongArch maintainer to decide on
the best way and timing for the actual merge.

Thanks,
Tiezhu