diff options
| author | Gautam Menghani <gautam@linux.ibm.com> | 2026-10-12 13:59:17 +0530 |
|---|---|---|
| committer | Madhavan Srinivasan <maddy@linux.ibm.com> | 2026-11-10 16:56:15 +0530 |
| commit | d8c6ab0aeeca7cc2adfcf0ce1f796c6a86314ec0 (patch) | |
| tree | e1c725d8ef53d8e39d1ef1bc4e31dfa20dfab8f6 /tools/perf/scripts/python/bin/stackcollapse-report | |
| parent | 4e6e66ecf62185828f731914000a6b0baff355db (diff) | |
KVM: PPC: Book3S HV: Ensure that calls to idr_alloc are synchronized
Calls to idr_alloc() in __prealloc_nested() are not currently synchronized.
According to the documentation [1], the caller should provide their own
locking to prevent concurrent modifications to the idr to prevent bugs.
__prealloc_nested() calls idr_alloc() with GFP_KERNEL which can
sleep and mmu_lock is a spinlock. So idr_alloc() cannot be moved under
mmu_lock. In such cases the idr Documentation says:
If you need to take a lock while allocating a new ID from the IDR,
you may need to pass a restrictive set of GFP flags, which can lead
to the IDR being unable to allocate memory. To work around this,
you can call idr_preload() before taking the lock, and then
idr_preload_end() after the allocation.
Hence preload the idr memory with idr_preload() before taking mmu_lock,
which allows us to use idr_alloc(..., GFP_NOWAIT) under the spinlock.
This also allows to kill __prealloc_nested() and __add_nested(), as they
are not needed anymore with idr_preload().
[1]: lib/idr.c
Fixes: c0f00a18e2a8 ("KVM: PPC: Book3S HV Nested: Change nested guest lookup to use idr")
Cc: stable@vger.kernel.org # 5.19+
Co-developed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261012082922.218799-2-gautam@linux.ibm.com
Diffstat (limited to 'tools/perf/scripts/python/bin/stackcollapse-report')
0 files changed, 0 insertions, 0 deletions
