Commit e85affb0 authored by Yang Yang's avatar Yang Yang Committed by Will Deacon
Browse files

ANDROID: Fixed the KMI corruption issue caused by the patch of 72d04bdc.



Due to 72d04bdc ("sbitmap: fix io hung due to race on sbitmap_word
::cleared") directly adding spinlock_t swap_1ock to struct sbitmap_word
in sbitmap.h, KMI was damaged. In order to achieve functionality without
damaging KMI, we can only apply for a block of memory with a size of
map_nr * (sizeof (* sb ->map)+sizeof(spinlock_t)) to ensure that each
struct sbitmap-word receives protection from spinlock.
The actual memory distribution used is as follows:
----------------------
struct sbitmap_word[0]
......................
struct sbitmap_word[n]
-----------------------
spinlock_t swap_lock[0]
.......................
spinlock_t swap_lock[n]
----------------------
sbitmap_word[0] corresponds to swap_lock[0], and sbitmap_word[n]
corresponds to swap_lock[n], and so on.

Fixes: ea86ea2c ("sbitmap: ammortize cost of clearing bits")
Signed-off-by: default avatarYang Yang <yang.yang@vivo.com>
Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>

Bug: 382398521
Link: https://lore.kernel.org/r/20240716082644.659566-1-yang.yang@vivo.com


Change-Id: Idcab0dd5fd7c3147efd05dd6cc51757c2b0464f6
Signed-off-by: default avatarliuyu <liuyu@allwinnertech.com>
Bug: 401681610
parent 89371240
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment