Skip to content

Commit fd9e526

Browse files
roxellAleksey Makarov
authored andcommitted
arch/arm64: Add lazy preempt support
arm64 is missing support for PREEMPT_RT. The main feature which is lacking is support for lazy preemption. The arch-specific entry code, thread information structure definitions, and associated data tables have to be extended to provide this support. Then the Kconfig file has to be extended to indicate the support is available, and also to indicate that support for full RT preemption is now available. Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
1 parent 5515b8d commit fd9e526

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ config ARM64
6969
select HAVE_PERF_REGS
7070
select HAVE_PERF_USER_STACK_DUMP
7171
select HAVE_RCU_TABLE_FREE
72+
select HAVE_PREEMPT_LAZY
7273
select HAVE_SYSCALL_TRACEPOINTS
7374
select IRQ_DOMAIN
7475
select IRQ_FORCED_THREADING

arch/arm64/include/asm/thread_info.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct thread_info {
4747
mm_segment_t addr_limit; /* address limit */
4848
struct task_struct *task; /* main task structure */
4949
int preempt_count; /* 0 => preemptable, <0 => bug */
50+
int preempt_lazy_count; /* 0 => preemptable, <0 => bug */
5051
int cpu; /* cpu */
5152
};
5253

@@ -101,6 +102,7 @@ static inline struct thread_info *current_thread_info(void)
101102
#define TIF_NEED_RESCHED 1
102103
#define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
103104
#define TIF_FOREIGN_FPSTATE 3 /* CPU's FP state is not current's */
105+
#define TIF_NEED_RESCHED_LAZY 4
104106
#define TIF_NOHZ 7
105107
#define TIF_SYSCALL_TRACE 8
106108
#define TIF_SYSCALL_AUDIT 9
@@ -117,6 +119,7 @@ static inline struct thread_info *current_thread_info(void)
117119
#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
118120
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
119121
#define _TIF_FOREIGN_FPSTATE (1 << TIF_FOREIGN_FPSTATE)
122+
#define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY)
120123
#define _TIF_NOHZ (1 << TIF_NOHZ)
121124
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
122125
#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)

arch/arm64/kernel/asm-offsets.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ int main(void)
3535
BLANK();
3636
DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
3737
DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count));
38+
DEFINE(TI_PREEMPT_LAZY, offsetof(struct thread_info, preempt_lazy_count));
3839
DEFINE(TI_ADDR_LIMIT, offsetof(struct thread_info, addr_limit));
3940
DEFINE(TI_TASK, offsetof(struct thread_info, task));
4041
DEFINE(TI_CPU, offsetof(struct thread_info, cpu));

arch/arm64/kernel/entry.S

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,16 @@ el1_irq:
367367
#ifdef CONFIG_PREEMPT
368368
get_thread_info tsk
369369
ldr w24, [tsk, #TI_PREEMPT] // get preempt count
370-
cbnz w24, 1f // preempt count != 0
370+
cbnz w24, 2f // preempt count != 0
371371
ldr x0, [tsk, #TI_FLAGS] // get flags
372-
tbz x0, #TIF_NEED_RESCHED, 1f // needs rescheduling?
373-
bl el1_preempt
372+
tbnz x0, #TIF_NEED_RESCHED, 1f // needs rescheduling?
373+
374+
ldr w24, [tsk, #TI_PREEMPT_LAZY] // get preempt lazy count
375+
cbnz w24, 2f // preempt lazy count != 0
376+
tbz x0, #TIF_NEED_RESCHED_LAZY, 2f // needs rescheduling?
374377
1:
378+
bl el1_preempt
379+
2:
375380
#endif
376381
#ifdef CONFIG_TRACE_IRQFLAGS
377382
bl trace_hardirqs_on
@@ -385,6 +390,7 @@ el1_preempt:
385390
1: bl preempt_schedule_irq // irq en/disable is done inside
386391
ldr x0, [tsk, #TI_FLAGS] // get new tasks TI_FLAGS
387392
tbnz x0, #TIF_NEED_RESCHED, 1b // needs rescheduling?
393+
tbnz x0, #TIF_NEED_RESCHED_LAZY, 1b // needs rescheduling?
388394
ret x24
389395
#endif
390396

@@ -622,6 +628,7 @@ fast_work_pending:
622628
str x0, [sp, #S_X0] // returned x0
623629
work_pending:
624630
tbnz x1, #TIF_NEED_RESCHED, work_resched
631+
tbnz x1, #TIF_NEED_RESCHED_LAZY, work_resched
625632
/* TIF_SIGPENDING, TIF_NOTIFY_RESUME or TIF_FOREIGN_FPSTATE case */
626633
ldr x2, [sp, #S_PSTATE]
627634
mov x0, sp // 'regs'

0 commit comments

Comments
 (0)