Skip to contentSkip to conversation

arm64: Disable branch profiling for all arm64 code

PATCH Applied Breno Leitao 4 participants 10 messages Jan 6 – Jan 8

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 arm64: Disable branch profiling for all arm64 code

The arm64 kernel doesn't boot with annotated branches (PROFILE_ANNOTATED_BRANCHES) enabled and CONFIG_DEBUG_VIRTUAL together.

Bisecting it, I found that disabling branch profiling in arch/arm64/mm solved the problem. Narrowing down a bit further, I found that physaddr.c is the file that needs to have branch profiling disabled to get the machine to boot.

I suspect that it might invoke some ftrace helper very early in the boot process and ftrace is still not enabled(!?).

Rather than playing whack-a-mole with individual files, disable branch profiling for the entire arch/arm64 tree, similar to what x86 already does in arch/x86/Kbuild.

Fixes ec6d06efb0bac ("arm64: Add support for CONFIG_DEBUG_VIRTUAL")

---
Changes in v2:
- Expand the scope to arch/arm64 instead of just physaddr.c
- Link to v1: https://lore.kernel.org/all/[email protected]/

---
 arch/arm64/Kbuild | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/Kbuild +4 -0
index 5bfbf7d79c99..d876bc0e5421 100644
@@ -1,4 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0-only
+
+# Branch profiling isn't noinstr-safe
+subdir-ccflags-$(CONFIG_TRACE_BRANCH_PROFILING) += -DDISABLE_BRANCH_PROFILING
+
 obj-y			+= kernel/ mm/ net/
 obj-$(CONFIG_KVM)	+= kvm/
 obj-$(CONFIG_XEN)	+= xen/

---
base-commit: c8ebd433459bcbf068682b09544e830acd7ed222
change-id: 20251231-annotated-75de3f33cd7b

Best regards,

Signature · 1 line
Breno Leitao <[email protected]>
reviewer Acked-by on v2 1/1
#1 lore raw
Quoted 11 lines · Breno Leitao

The arm64 kernel doesn't boot with annotated branches (PROFILE_ANNOTATED_BRANCHES) enabled and CONFIG_DEBUG_VIRTUAL together.

Bisecting it, I found that disabling branch profiling in arch/arm64/mm solved the problem. Narrowing down a bit further, I found that physaddr.c is the file that needs to have branch profiling disabled to get the machine to boot.

I suspect that it might invoke some ftrace helper very early in the boot process and ftrace is still not enabled(!?).

Quoted 7 lines

Rather than playing whack-a-mole with individual files, disable branch profiling for the entire arch/arm64 tree, similar to what x86 already does in arch/x86/Kbuild.

Fixes ec6d06efb0bac ("arm64: Add support for CONFIG_DEBUG_VIRTUAL")

I don't think ec6d06efb0bac is to blame here, and CONFIG_DEBUG_VIRTUAL is unsound in a number of places, so I'd prefer to remove that Fixes tag and backport this for all stable trees.

Regardless, I'm in favour of disabling CONFIG_DEBUG_VIRTUAL widely, so:

Mark.

Quoted 30 lines

---
Changes in v2:
- Expand the scope to arch/arm64 instead of just physaddr.c
- Link to v1: https://lore.kernel.org/all/[email protected]/

---
 arch/arm64/Kbuild | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/Kbuild +4 -1
index 5bfbf7d79c99..d876bc0e5421 100644
@@ -1,4 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0-only
+
+# Branch profiling isn't noinstr-safe
+subdir-ccflags-$(CONFIG_TRACE_BRANCH_PROFILING) += -DDISABLE_BRANCH_PROFILING
+
 obj-y			+= kernel/ mm/ net/
 obj-$(CONFIG_KVM)	+= kvm/
 obj-$(CONFIG_XEN)	+= xen/
 
---

base-commit: c8ebd433459bcbf068682b09544e830acd7ed222
change-id: 20251231-annotated-75de3f33cd7b

Best regards,

Signature · 1 line
Breno Leitao <[email protected]>
reviewer
#2 lore raw
Quoted 20 lines · Mark Rutland
Quoted 11 lines · Breno Leitao

The arm64 kernel doesn't boot with annotated branches (PROFILE_ANNOTATED_BRANCHES) enabled and CONFIG_DEBUG_VIRTUAL together.

Bisecting it, I found that disabling branch profiling in arch/arm64/mm solved the problem. Narrowing down a bit further, I found that physaddr.c is the file that needs to have branch profiling disabled to get the machine to boot.

I suspect that it might invoke some ftrace helper very early in the boot process and ftrace is still not enabled(!?).

Quoted 7 lines

Rather than playing whack-a-mole with individual files, disable branch profiling for the entire arch/arm64 tree, similar to what x86 already does in arch/x86/Kbuild.

Fixes ec6d06efb0bac ("arm64: Add support for CONFIG_DEBUG_VIRTUAL")
Quoted 7 lines

I don't think ec6d06efb0bac is to blame here, and CONFIG_DEBUG_VIRTUAL is unsound in a number of places, so I'd prefer to remove that Fixes tag and backport this for all stable trees.

Regardless, I'm in favour of disabling CONFIG_DEBUG_VIRTUAL widely, so:

Whoops; s/CONFIG_DEBUG_VIRTUAL/PROFILE_ANNOTATED_BRANCHES/ in both places in my reply.

Mark.

#6 lore raw
In reply to Mark Rutland
Quoted 16 lines · Mark Rutland
Quoted 15 lines · Breno Leitao

The arm64 kernel doesn't boot with annotated branches (PROFILE_ANNOTATED_BRANCHES) enabled and CONFIG_DEBUG_VIRTUAL together.

Bisecting it, I found that disabling branch profiling in arch/arm64/mm solved the problem. Narrowing down a bit further, I found that physaddr.c is the file that needs to have branch profiling disabled to get the machine to boot.

I suspect that it might invoke some ftrace helper very early in the boot process and ftrace is still not enabled(!?).

Rather than playing whack-a-mole with individual files, disable branch profiling for the entire arch/arm64 tree, similar to what x86 already does in arch/x86/Kbuild.

Quoted 7 lines
Quoted 3 lines
Fixes ec6d06efb0bac ("arm64: Add support for CONFIG_DEBUG_VIRTUAL")

I don't think ec6d06efb0bac is to blame here, and CONFIG_DEBUG_VIRTUAL is unsound in a number of places, so I'd prefer to remove that Fixes tag and backport this for all stable trees.

That is fair, thanks for the review.

Should I submit a new version without the fixes tag, or, do you guys do it while merging the patch?

thanks
--breno

reviewer
#7 lore raw
Quoted 21 lines · Breno Leitao
Quoted 20 lines · Mark Rutland
Quoted 18 lines · Breno Leitao

The arm64 kernel doesn't boot with annotated branches (PROFILE_ANNOTATED_BRANCHES) enabled and CONFIG_DEBUG_VIRTUAL together.

Bisecting it, I found that disabling branch profiling in arch/arm64/mm solved the problem. Narrowing down a bit further, I found that physaddr.c is the file that needs to have branch profiling disabled to get the machine to boot.

I suspect that it might invoke some ftrace helper very early in the boot process and ftrace is still not enabled(!?).

Rather than playing whack-a-mole with individual files, disable branch profiling for the entire arch/arm64 tree, similar to what x86 already does in arch/x86/Kbuild.

Fixes ec6d06efb0bac ("arm64: Add support for CONFIG_DEBUG_VIRTUAL")
Quoted 8 lines
Quoted 3 lines

I don't think ec6d06efb0bac is to blame here, and CONFIG_DEBUG_VIRTUAL is unsound in a number of places, so I'd prefer to remove that Fixes tag and backport this for all stable trees.

That is fair, thanks for the review.

Should I submit a new version without the fixes tag, or, do you guys do it while merging the patch?

I assume that Catalin or Will can handle that when applying (if they agree with me); no need to respin.

Mark.

#8 lore raw
Quoted 26 lines · Mark Rutland
Quoted 25 lines · Breno Leitao
Quoted 23 lines · Mark Rutland
Quoted 11 lines · Breno Leitao

The arm64 kernel doesn't boot with annotated branches (PROFILE_ANNOTATED_BRANCHES) enabled and CONFIG_DEBUG_VIRTUAL together.

Bisecting it, I found that disabling branch profiling in arch/arm64/mm solved the problem. Narrowing down a bit further, I found that physaddr.c is the file that needs to have branch profiling disabled to get the machine to boot.

I suspect that it might invoke some ftrace helper very early in the boot process and ftrace is still not enabled(!?).

Quoted 7 lines

Rather than playing whack-a-mole with individual files, disable branch profiling for the entire arch/arm64 tree, similar to what x86 already does in arch/x86/Kbuild.

Fixes ec6d06efb0bac ("arm64: Add support for CONFIG_DEBUG_VIRTUAL")

I don't think ec6d06efb0bac is to blame here, and CONFIG_DEBUG_VIRTUAL is unsound in a number of places, so I'd prefer to remove that Fixes tag and backport this for all stable trees.

Quoted 7 lines
Quoted 4 lines

That is fair, thanks for the review.

Should I submit a new version without the fixes tag, or, do you guys do it while merging the patch?

I assume that Catalin or Will can handle that when applying (if they agree with me); no need to respin.

Thanks Mark.

maintainer
#3 lore raw
In reply to Mark Rutland
Quoted 2 lines · On Tue, 6 Jan 2026 12:24:09 +0000 Mark Rutland <[email protected]> wrote:

Whoops; s/CONFIG_DEBUG_VIRTUAL/PROFILE_ANNOTATED_BRANCHES/ in both places in my reply.

Note, it could still be useful ;-)

I've been running my yearly branch profiling build on both my main workstation and my server. I post the results from my server publicly (this is updated every night):

https://rostedt.org/branches/current

If you check out the branch_annotated file, you can see there's still quite a bit that gets it wrong. Some of these is because of bad assumptions by the developer, others is because the code moved around causing new branches to make later annotated branches go the opposite way.

Note, its still slow to download, not only because my internet is 20mbs up, but also because that web server is running on a machine with this profiling still enabled. I'll rebuild the kernel and disable it this weekend.

-- Steve

#4 lore raw

Hello Steven,

Quoted 13 lines · Steven Rostedt
Quoted 2 lines · On Tue, 6 Jan 2026 12:24:09 +0000 Mark Rutland <[email protected]> wrote:

Whoops; s/CONFIG_DEBUG_VIRTUAL/PROFILE_ANNOTATED_BRANCHES/ in both places in my reply.

Note, it could still be useful ;-)

I've been running my yearly branch profiling build on both my main workstation and my server. I post the results from my server publicly (this is updated every night):

Quoted 6 lines

https://rostedt.org/branches/current

If you check out the branch_annotated file, you can see there's still quite a bit that gets it wrong. Some of these is because of bad assumptions by the developer, others is because the code moved around causing new branches to make later annotated branches go the opposite way.

I am starting to look and remove some of these likely/unlikely hint that are 100% wrong on some very sane configuration (arm64 baremetal hosts running a webserver).

So far, these are the fixes I have in flight now.

* https://lore.kernel.org/all/[email protected]/
* https://lore.kernel.org/all/[email protected]/
* https://lore.kernel.org/all/[email protected]/

maintainer
#5 lore raw
Quoted 9 lines · On Wed, 7 Jan 2026 01:37:36 -0800 Breno Leitao <[email protected]> wrote:

I am starting to look and remove some of these likely/unlikely hint that are 100% wrong on some very sane configuration (arm64 baremetal hosts running a webserver).

So far, these are the fixes I have in flight now.

* https://lore.kernel.org/all/[email protected]/
* https://lore.kernel.org/all/[email protected]/
* https://lore.kernel.org/all/[email protected]/

Nice. Thanks for letting me know. I'm happy to see that someone besides me is using the annotated branch profiler to fix real issues in the kernel.

I would love it if more people did the same. Anyway, please advertise this as much as possible. If it shows that it is helping to fix real bugs, maybe it would attract the interest of more developers, and more importantly, it keeps the tooling in place. I'm constantly fighting to keep it from being removed from the kernel :-p

-- Steve

maintainer Applied
#9 lore raw
In reply to Breno Leitao
Quoted 9 lines · Breno Leitao

The arm64 kernel doesn't boot with annotated branches (PROFILE_ANNOTATED_BRANCHES) enabled and CONFIG_DEBUG_VIRTUAL together.

Bisecting it, I found that disabling branch profiling in arch/arm64/mm solved the problem. Narrowing down a bit further, I found that physaddr.c is the file that needs to have branch profiling disabled to get the machine to boot.

[...]

Applied to arm64 (for-next/misc), thanks!

[1/1] arm64: Disable branch profiling for all arm64 code

      https://git.kernel.org/arm64/c/f22c81bebf8b

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev