Skip to content

Commit 4fc9225

Browse files
jpbruckerwilldeacon
authored andcommitted
arm64: mm: Add asid_gen_match() helper
Add a macro to check if an ASID is from the current generation, since a subsequent patch will introduce a third user for this test. Signed-off-by: Jean-Philippe Brucker <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent bd4298c commit 4fc9225

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/arm64/mm/context.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ static void set_reserved_asid_bits(void)
9292
bitmap_clear(asid_map, 0, NUM_USER_ASIDS);
9393
}
9494

95+
#define asid_gen_match(asid) \
96+
(!(((asid) ^ atomic64_read(&asid_generation)) >> asid_bits))
97+
9598
static void flush_context(void)
9699
{
97100
int i;
@@ -220,16 +223,15 @@ void check_and_switch_context(struct mm_struct *mm, unsigned int cpu)
220223
* because atomic RmWs are totally ordered for a given location.
221224
*/
222225
old_active_asid = atomic64_read(&per_cpu(active_asids, cpu));
223-
if (old_active_asid &&
224-
!((asid ^ atomic64_read(&asid_generation)) >> asid_bits) &&
226+
if (old_active_asid && asid_gen_match(asid) &&
225227
atomic64_cmpxchg_relaxed(&per_cpu(active_asids, cpu),
226228
old_active_asid, asid))
227229
goto switch_mm_fastpath;
228230

229231
raw_spin_lock_irqsave(&cpu_asid_lock, flags);
230232
/* Check that our ASID belongs to the current generation. */
231233
asid = atomic64_read(&mm->context.id);
232-
if ((asid ^ atomic64_read(&asid_generation)) >> asid_bits) {
234+
if (!asid_gen_match(asid)) {
233235
asid = new_context(mm);
234236
atomic64_set(&mm->context.id, asid);
235237
}

0 commit comments

Comments
 (0)