Skip to contentSkip to conversation

i386: use thread_info flags for debug regs and IO bitmaps

PATCH New Chuck Ebbert 1 participant 1 message Jul 10, 2006 ptrace support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i386: use thread_info flags for debug regs and IO bitmaps

From: Stephane Eranian <[email protected]>

Use thread info flags to track use of debug registers and IO bitmaps.

- add TIF_DEBUG to track when debug registers are active
- add TIF_IO_BITMAP to track when I/O bitmap is used
- modify __switch_to() to use the new TIF flags

Performance tested on Pentium II, ten runs of LMbench context switch benchmark (smaller is better:)

before after
avg 3.65 3.39
min 3.55 3.33

---

 arch/i386/kernel/ioport.c      |    1 
 arch/i386/kernel/process.c     |   50 +++++++++++++++++++++++------------------
 arch/i386/kernel/ptrace.c      |    5 +++-
 include/asm-i386/thread_info.h |    7 +++++
 4 files changed, 41 insertions(+), 22 deletions(-)
arch/i386/kernel/ioport.c +1 -0
@@ -79,6 +79,7 @@ asmlinkage long sys_ioperm(unsigned long
 
 		memset(bitmap, 0xff, IO_BITMAP_BYTES);
 		t->io_bitmap_ptr = bitmap;
+		set_thread_flag(TIF_IO_BITMAP);
 	}
 
 	/*
arch/i386/kernel/process.c +29 -21

100 lines not on this page · raw message

arch/i386/kernel/ptrace.c +4 -1
@@ -468,8 +468,11 @@ long arch_ptrace(struct task_struct *chi
 				  for(i=0; i<4; i++)
 					  if ((0x5f54 >> ((data >> (16 + 4*i)) & 0xf)) & 1)
 						  goto out_tsk;
+				  if (data)
+					  set_tsk_thread_flag(child, TIF_DEBUG);
+				  else
+					  clear_tsk_thread_flag(child, TIF_DEBUG);
 			  }
-
 			  addr -= (long) &dummy->u_debugreg;
 			  addr = addr >> 2;
 			  child->thread.debugreg[addr] = data;
include/asm-i386/thread_info.h +7 -0
@@ -140,6 +140,8 @@ static inline struct thread_info *curren
 #define TIF_SECCOMP		8	/* secure computing */
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_MEMDIE		16
+#define TIF_DEBUG		17	/* uses debug registers */
+#define TIF_IO_BITMAP		18	/* uses I/O bitmap */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
@@ -151,6 +153,8 @@ static inline struct thread_info *curren
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_DEBUG		(1<<TIF_DEBUG)
+#define _TIF_IO_BITMAP		(1<<TIF_IO_BITMAP)
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK \
@@ -159,6 +163,9 @@ static inline struct thread_info *curren
 /* work to do on any return to u-space */
 #define _TIF_ALLWORK_MASK	(0x0000FFFF & ~_TIF_SECCOMP)
 
+/* flags to check in __switch_to() */
+#define _TIF_WORK_CTXSW (_TIF_DEBUG|_TIF_IO_BITMAP)
+
 /*
  * Thread-synchronous status.
  *
Signature · 2 lines
Chuck
 "You can't read a newspaper if you can't read."  --George W. Bush