multithreaded coredumps for elf exeecutables for O(1) scheduler
Subsystems (4)
PATCH 1/1 multithreaded coredumps for elf exeecutables for O(1) scheduler
Attached is my current patch for creating multithreaded core dump files, that works with the O(1) scheduler.
This is a continuation of the work posted by Vamsi Krishna back on 3/21/02. I'm sorry for the delay. The problem of suspending the other thread processes for the duration of the core dump was a challenging problem with the O(1) scheduler.
Most of the patch is the same as that posted on 3/21/02 with some minor fixes and the rebasing to the 2.5.14 kernel. The interesting bits are in the additions to sched.c to pause and resume the thread processes under the O(1) scheduler.
Here I'm leveraging the work of Eric Foct for the process migration, to temporarily migrate the thread processes I need suspended to a "phantom runqueue". This is just an additional run queue that has no cpu. When I'm finish with the core dump I migrate them off the phantom run queue and continue processing whatever exit processing they do.
I tried a number of approaches to process pausing that didn't quite work before I settled on the attached implementation.
This work has been unit test on a 2 way and 4 way SMP systems with no lockups so far. YMMV.
Note: GDB 5.x will work with the core files created with this patch, provided the libpthread that gets loaded at gdb debug time is stripped of symbols.
Run strip on your libpthread so files and things should work fine for you.
--mgross
(W) 503-712-8218
MS: JF1-05
2111 N.E. 25th Ave.
Hillsboro, OR 97124
arch/i386/kernel/i387.c +33 -0
@@ -528,3 +528,36 @@return fpvalid; } + +int dump_task_fpu (struct task_struct *tsk,struct user_i387_struct *fpu ) +{ +int fpvalid; + + fpvalid = tsk->used_math; +if ( fpvalid ) { +if (tsk == current)unlazy_fpu ( tsk ); +if ( cpu_has_fxsr ) { +copy_fpu_fxsave ( tsk, fpu ); + }else { +copy_fpu_fsave ( tsk, fpu ); + } + } + +return fpvalid; +} + +int dump_task_extended_fpu (struct task_struct *tsk,struct user_fxsr_struct *fpu ) +{ +int fpvalid; + + fpvalid = tsk->used_math && cpu_has_fxsr; +if ( fpvalid ) { +if (tsk == current)unlazy_fpu ( tsk ); +memcpy ( fpu, &tsk->thread.i387.fxsave, +sizeof (struct user_fxsr_struct ) ); + } + +return fpvalid; +} + +
arch/i386/kernel/process.c +12 -0
@@ -610,6 +610,18 @@ dump->u_fpvalid =dump_fpu (regs, &dump->i387); } +/* +* Capture the user space registers if the task is not running (in user space) +*/ +int dump_task_regs (struct task_struct *tsk,struct pt_regs *regs) +{ + *regs = *(struct pt_regs *)((unsigned long )tsk->thread_info +THREAD_SIZE -sizeof (struct pt_regs )); + regs->xcs &=0xffff ; + regs->xds &=0xffff ; + regs->xes &=0xffff ; + regs->xss &=0xffff ; +return 1 ; +}/* * This special macro can be used to load a debugging register
Binary files linux-2.5.14.vannilla/core and linux2.5.14.tcore/core differ
fs/binfmt_elf.c +253 -89
427 lines not on this page · raw message
include/asm-i386/elf.h +10 -0
@@ -99,6 +99,16 @@#ifdef __KERNEL__#define SET_PERSONALITY (ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) + + +extern int dump_task_regs (struct task_struct *,struct pt_regs *); +extern int dump_task_fpu (struct task_struct *,struct user_i387_struct *); +extern int dump_task_extended_fpu (struct task_struct *,struct user_fxsr_struct *); + +#define ELF_CORE_COPY_TASK_REGS (tsk, pt_regs) dump_task_regs(tsk, pt_regs) +#define ELF_CORE_COPY_FPREGS (tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) +#define ELF_CORE_COPY_XFPREGS (tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs) +#endif #endif
include/linux/elf.h +3 -0
@@ -576,6 +576,9 @@#define NT_PRPSINFO 3#define NT_TASKSTRUCT 4#define NT_PRFPXREG 20 +#define NT_PRXFPREG 0x46e62b7f/* note name must be "LINUX" as per GDB */ +/* from gdb5.1/include/elf/common.h */ +/* Note header in a PT_NOTE section */ typedef struct elf32_note {
include/linux/elfcore.h +51 -0
55 lines not on this page · raw message
include/linux/sched.h +6 -0
@@ -130,6 +130,12 @@#include <linux/spinlock.h> + +/* functions for pausing and resumming functions common mm's without using signals */ +extern void suspend_threads (void ); +extern void resume_threads (void ); + +/* * This serializes "schedule()" and also protects * the run-queue from deletions/modifications (but
include/linux/sysctl.h +1 -0
@@ -87,6 +87,7 @@KERN_CAP_BSET =14 ,/* int: capability bounding set */ KERN_PANIC =15 ,/* int: panic timeout */ KERN_REALROOTDEV =16 ,/* real root device to mount after initrd */ +KERN_CORE_DUMPS_THREADS =17 ,/* int: include status of others threads in dump */ KERN_SPARC_REBOOT =21 ,/* reboot command on Sparc */ KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
kernel/sched.c +174 -9
239 lines not on this page · raw message
kernel/sysctl.c +5 -1
@@ -38,6 +38,8 @@#include <linux/nfs_fs.h> #endif +int core_dumps_threads =0 ; +#if defined(CONFIG_SYSCTL )/* External variables not in a header file. */
@@ -171,7 +173,9 @@ 0644, NULL, &proc_dointvec}, {KERN_TAINTED ,"tainted" , &tainted,sizeof (int ), 0644, NULL, &proc_dointvec}, - {KERN_CAP_BSET, "cap-bound", &cap_bset, sizeof(kernel_cap_t), + {KERN_CORE_DUMPS_THREADS, "core_dumps_threads", &core_dumps_threads, sizeof(int), + 0644, NULL, &proc_dointvec}, + {KERN_CAP_BSET, "cap-bound", &cap_bset, sizeof(kernel_cap_t), 0600, NULL, &proc_dointvec_bset}, #ifdef CONFIG_BLK_DEV_INITRD {KERN_REALROOTDEV, "real-root-dev", &real_root_dev, sizeof(int),
Quoted 14 lines · Mark Gross
Attached is my current patch for creating multithreaded core dump files, that works with the O(1) scheduler.
This is a continuation of the work posted by Vamsi Krishna back on 3/21/02. I'm sorry for the delay. The problem of suspending the other thread processes for the duration of the core dump was a challenging problem with the O(1) scheduler.
Most of the patch is the same as that posted on 3/21/02 with some minor fixes and the rebasing to the 2.5.14 kernel. The interesting bits are in the additions to
sched.cto pause and resume the thread processes under the O(1) scheduler.
Quoted 8 lines
Here I'm leveraging the work of Eric Foct for the process migration, to temporarily migrate the thread processes I need suspended to a "phantom runqueue". This is just an additional run queue that has no cpu. When I'm finish with the core dump I migrate them off the phantom run queue and continue processing whatever exit processing they do.
I tried a number of approaches to process pausing that didn't quite work before I settled on the attached implementation.
That's a very interesting approach... I like it.
Quoted 7 lines
This work has been unit test on a 2 way and 4 way SMP systems with no lockups so far. YMMV.
Note: GDB 5.x will work with the core files created with this patch, provided the libpthread that gets loaded at gdb debug time is stripped of symbols.
Run strip on your libpthread so files and things should work fine for you.
Or use GDB 5.2.
Signature · 2 lines
Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer