diff options
author | Yury Norov <yury.norov@gmail.com> | 2023-12-11 18:27:48 -0800 |
---|---|---|
committer | Yury Norov <yury.norov@gmail.com> | 2023-12-16 08:43:00 -0800 |
commit | 18eda5a178066852986b0380f201295cefa582e7 (patch) | |
tree | 6edacca2555e3ec9be1f6eedf7f7899fc7a4c485 | |
parent | 4d56bf2e0c2321894cdb654b96944710fbd62314 (diff) | |
download | linux-18eda5a178066852986b0380f201295cefa582e7.tar.gz linux-18eda5a178066852986b0380f201295cefa582e7.tar.xz |
microblaze: optimize get_mmu_context()
Simplify get_mmu_context() by using find_and_set_bit_wrap().
Signed-off-by: Yury Norov <yury.norov@gmail.com>
-rw-r--r-- | arch/microblaze/include/asm/mmu_context_mm.h | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/arch/microblaze/include/asm/mmu_context_mm.h b/arch/microblaze/include/asm/mmu_context_mm.h index c2c77f708455..209c3a62353a 100644 --- a/arch/microblaze/include/asm/mmu_context_mm.h +++ b/arch/microblaze/include/asm/mmu_context_mm.h @@ -82,12 +82,11 @@ static inline void get_mmu_context(struct mm_struct *mm) return; while (atomic_dec_if_positive(&nr_free_contexts) < 0) steal_context(); - ctx = next_mmu_context; - while (test_and_set_bit(ctx, context_map)) { - ctx = find_next_zero_bit(context_map, LAST_CONTEXT+1, ctx); - if (ctx > LAST_CONTEXT) - ctx = 0; - } + + do { + ctx = find_and_set_bit_wrap(context_map, LAST_CONTEXT + 1, next_mmu_context); + } while (ctx > LAST_CONTEXT); + next_mmu_context = (ctx + 1) & LAST_CONTEXT; mm->context = ctx; context_mm[ctx] = mm; |