Re: [patch] Real-Time Preemption, -RT-2.6.12-rc6-V0.7.47-20

From: Michal Schmidt
Date: Tue Jun 07 2005 - 14:03:31 EST


Ingo Molnar wrote:
- performance feature: i've implemented a new scheduler feature called 'delayed preemption', [...]

So far it's only for i386. On x84_64 the kernel doesn't compile.
Attached is my attempt to make it work on x86_64.
The diff is against RT-V0.7.47-26.

Warning: I don't know what I'm doing! But at least it compiles and boots for me.

Michich diff -Nurp -X linux-RT.mich/Documentation/dontdiff linux-RT/arch/x86_64/kernel/entry.S linux-RT.mich/arch/x86_64/kernel/entry.S
--- linux-RT/arch/x86_64/kernel/entry.S 2005-06-07 19:07:30.000000000 +0200
+++ linux-RT.mich/arch/x86_64/kernel/entry.S 2005-06-07 20:48:26.000000000 +0200
@@ -211,8 +211,8 @@ sysret_check:
/* Handle reschedules */
/* edx: work, edi: workmask */
sysret_careful:
- bt $TIF_NEED_RESCHED,%edx
- jnc sysret_signal
+ testl $(_TIF_NEED_RESCHED|_TIF_NEED_RESCHED_DELAYED),%edx
+ jz sysret_signal
sti
pushq %rdi
call schedule
@@ -231,7 +231,7 @@ sysret_signal:
leaq -ARGOFFSET(%rsp),%rdi # &pt_regs -> arg1
xorl %esi,%esi # oldset -> arg2
call ptregscall_common
-1: movl $_TIF_NEED_RESCHED,%edi
+1: movl $(_TIF_NEED_RESCHED|_TIF_NEED_RESCHED_DELAYED),%edi
jmp sysret_check

/* Do syscall tracing */
@@ -280,8 +280,8 @@ int_with_check:
/* First do a reschedule test. */
/* edx: work, edi: workmask */
int_careful:
- bt $TIF_NEED_RESCHED,%edx
- jnc int_very_careful
+ testl $(_TIF_NEED_RESCHED|_TIF_NEED_RESCHED_DELAYED),%edx
+ jz int_very_careful
sti
pushq %rdi
call schedule
@@ -310,7 +310,7 @@ int_signal:
movq %rsp,%rdi # &ptregs -> arg1
xorl %esi,%esi # oldset -> arg2
call do_notify_resume
-1: movl $_TIF_NEED_RESCHED,%edi
+1: movl $(_TIF_NEED_RESCHED|_TIF_NEED_RESCHED_DELAYED),%edi
int_restore_rest:
RESTORE_REST
cli
@@ -478,8 +478,8 @@ bad_iret:

/* edi: workmask, edx: work */
retint_careful:
- bt $TIF_NEED_RESCHED,%edx
- jnc retint_signal
+ testl $(_TIF_NEED_RESCHED|_TIF_NEED_RESCHED_DELAYED),%edx
+ jz retint_signal
sti
pushq %rdi
call schedule
@@ -499,7 +499,7 @@ retint_signal:
call do_notify_resume
RESTORE_REST
cli
- movl $_TIF_NEED_RESCHED,%edi
+ movl $(_TIF_NEED_RESCHED|_TIF_NEED_RESCHED_DELAYED),%edi
GET_THREAD_INFO(%rcx)
jmp retint_check

diff -Nurp -X linux-RT.mich/Documentation/dontdiff linux-RT/include/asm-x86_64/thread_info.h linux-RT.mich/include/asm-x86_64/thread_info.h
--- linux-RT/include/asm-x86_64/thread_info.h 2005-06-07 14:05:32.000000000 +0200
+++ linux-RT.mich/include/asm-x86_64/thread_info.h 2005-06-07 19:12:01.000000000 +0200
@@ -103,6 +103,7 @@ static inline struct thread_info *stack_
#define TIF_IRET 5 /* force IRET */
#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
#define TIF_SECCOMP 8 /* secure computing */
+#define TIF_NEED_RESCHED_DELAYED 9 /* rescheduling necessary upon return to userspace */
#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
#define TIF_IA32 17 /* 32bit process */
#define TIF_FORK 18 /* ret_from_fork */
@@ -117,6 +118,7 @@ static inline struct thread_info *stack_
#define _TIF_IRET (1<<TIF_IRET)
#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
#define _TIF_SECCOMP (1<<TIF_SECCOMP)
+#define _TIF_NEED_RESCHED_DELAYED (1<<TIF_NEED_RESCHED_DELAYED)
#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
#define _TIF_IA32 (1<<TIF_IA32)
#define _TIF_FORK (1<<TIF_FORK)