Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arm64: entry: Centralize preemption decision

For historical reasons, the decision of whether or not to preempt is
spread across arm64_preempt_schedule_irq() and __el1_irq(), and it would
be clearer if this were all in one place.

Also, arm64_preempt_schedule_irq() calls lockdep_assert_irqs_disabled(),
but this is redundant, as we have a subsequent identical assertion in
__exit_to_kernel_mode(), and preempt_schedule_irq() will
BUG_ON(!irqs_disabled()) anyway.

This patch removes the redundant assertion and centralizes the
preemption decision making within arm64_preempt_schedule_irq().

Other than the slight change to assertion behaviour, there should be no
functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20220214165216.2231574-7-mark.rutland@arm.com

authored by

Mark Rutland and committed by
Peter Zijlstra
8e12ab7c 99cf983c

+11 -9
+11 -9
arch/arm64/kernel/entry-common.c
··· 222 222 223 223 static void __sched arm64_preempt_schedule_irq(void) 224 224 { 225 - lockdep_assert_irqs_disabled(); 225 + if (!IS_ENABLED(CONFIG_PREEMPTION)) 226 + return; 227 + 228 + /* 229 + * Note: thread_info::preempt_count includes both thread_info::count 230 + * and thread_info::need_resched, and is not equivalent to 231 + * preempt_count(). 232 + */ 233 + if (READ_ONCE(current_thread_info()->preempt_count) != 0) 234 + return; 226 235 227 236 /* 228 237 * DAIF.DA are cleared at the start of IRQ/FIQ handling, and when GIC ··· 447 438 do_interrupt_handler(regs, handler); 448 439 irq_exit_rcu(); 449 440 450 - /* 451 - * Note: thread_info::preempt_count includes both thread_info::count 452 - * and thread_info::need_resched, and is not equivalent to 453 - * preempt_count(). 454 - */ 455 - if (IS_ENABLED(CONFIG_PREEMPTION) && 456 - READ_ONCE(current_thread_info()->preempt_count) == 0) 457 - arm64_preempt_schedule_irq(); 441 + arm64_preempt_schedule_irq(); 458 442 459 443 exit_to_kernel_mode(regs); 460 444 }