Commit 188c695b authored by Kalesh Singh's avatar Kalesh Singh Committed by wei li
Browse files

ANDROID: 16K: Allocate pad vma on the stack

Now that the padding VMA is only used in show_map_pad_vma(),
initialize the padding VMA struct on the stack.

This is a nice clean up and avoid having to deal with dynamic
allocation failure.

why need cp to android16-6.12-2025-06?
after we update GKI to android16-6.12-2025-06-r40, when we build userdebug version for sm8850 platform, we get below panic problem.

BUG: sleeping function called from invalid context at include/linux/sched/mm.h:321
in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 1884, name: dex2oat64
preempt_count: 0, expected: 0
RCU nest depth: 1, expected: 0
kernel BUG at ../soc-repo/kernel/sched/walt/walt_debug.c:16!
Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP

Call trace:
android_rvh_schedule_bug+0x0/0x8 [sched_walt_debug b3a737a331e2404089ee42239023f3eab3e6ddf5]
__might_resched+0x180/0x184
__might_sleep+0x38/0x84
__kmalloc_cache_noprof+0x74/0x568
show_map_pad_vma+0x54/0x188
show_map+0x4c/0x60
seq_read_iter+0x3f4/0x568
seq_read+0xf0/0x128
vfs_read+0x100/0x33c
ksys_read+0x78/0xe8
__arm64_sys_read+0x1c/0x2c
invoke_syscall+0x58/0x10c
el0_svc_common+0xa8/0xdc
do_el0_svc+0x1c/0x28
el0_svc+0x40/0xb8
el0t_64_sync_handler+0x70/0xbc
el0t_64_sync+0x1a8/0x1ac

after debug, we find the change in android16-6.12-2025-06_r38 introduce this.
https://android-review.googlesource.com/c/kernel/common/+/3796543



which changes /proc/pid/maps read will use rcu_read_lock, then kmalloc_cache_alloc which use GFP_KERNEL will cause __might_sleep, will trigger this check.

after research, this "ANDROID: 16K: Allocate pad vma on the stack" not use kmalloc_cache_alloc while hold rcu_read_lock can avoid this problem,

Bug: 440210631
Bug: 432564748
Bug: 456310587
Change-Id: I168cda6cdb98423a40bb691b687c0f99bd160db6
Signed-off-by: default avatarKalesh Singh <kaleshsingh@google.com>
(cherry picked from commit a45fb061)
parent a6dc9ebc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment