lkml.org 
[lkml]   [2000]   [Feb]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectCLONE_KILLVMCH flag proposal
    Hello

    I am trying to modify pthread library a way in which it would not
    need manager thread. It seems that it is pretty feasible with
    CLONE_PARENT but one thing is missing.

    If the main thread dies due to some fatal error other threads will live
    further. This problem is not easily solved without manager thread so
    kernel will have to help here.

    This is an proposal for CLONE_KILLVMCH. The process/thread that
    has this flag set will kill all its children that share the same VM
    (were created with CLONE_VM) when it dies.
    This way the main thread will clean threads when some fatal error
    or kill occurs that cannot be caught in user space.
    I think that this is the only obstacle to make pthread support without
    manager thread and thus solve performance problems with creating and
    managing threads.

    Any ideas are highly appreciated.

    Here goes the patch that implement CLONE_KILLVMCH. I think it is not
    perfect but consider something like this as addition to the kernel.

    best regards
    Pavel


    --- linux-2.3.45/include/linux/sched.h.bak Tue Feb 15 10:04:15 2000

    +++ linux-2.3.45/include/linux/sched.h Tue Feb 15 15:47:58 2000
    @@ -36,6 +36,7 @@
    #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing
    continue on the child too */
    #define CLONE_VFORK 0x00004000 /* set if the parent wants the
    child to wake it up on mm_release */
    #define CLONE_PARENT 0x00008000 /* set if we want to have the
    same parent as the cloner */
    +#define CLONE_KILLVMCH 0x00010000 /* set if all CLONE_VM children
    get kill when parent dies */

    /*
    * These are the constant used to fake the fixed-point load-average
    @@ -376,6 +377,7 @@

    #define PF_USEDFPU 0x00100000 /* task used FPU this quantum
    (SMP) */
    #define PF_DTRACE 0x00200000 /* delayed trace (used on m68k,
    i386) */
    +#define PF_KILLVMCH 0x00400000 /* kill CLONE_VM children */

    /*
    * Limit the stack by to some sane default: root can always
    --- linux-2.3.45/kernel/fork.c.bak Tue Feb 15 10:53:21 2000
    +++ linux-2.3.45/kernel/fork.c Tue Feb 15 10:53:22 2000
    @@ -647,6 +647,8 @@
    p->run_list.next = NULL;
    p->run_list.prev = NULL;

    + if (clone_flags & CLONE_KILLVMCH)
    + current->flags |= PF_KILLVMCH;
    if ((clone_flags & CLONE_VFORK) || !(clone_flags &
    CLONE_PARENT))
    p->p_pptr = p->p_opptr = current;
    p->p_cptr = NULL;
    --- linux-2.3.45/kernel/exit.c.bak Tue Feb 15 10:27:21 2000
    +++ linux-2.3.45/kernel/exit.c Tue Feb 15 16:31:59 2000
    @@ -287,6 +287,26 @@
    }

    /*
    + * kill children that were cloned with CLONE_VM
    + */
    +static void exit_kill_vmchild(void)
    +{
    + struct task_struct *p;
    + pid_t pid;
    +
    + read_lock_irq(&tasklist_lock);
    + for (p = current->p_cptr; p; p = p->p_osptr) {
    + if (current->mm == p->mm) {
    + pid = p->pid;
    + read_unlock_irq(&tasklist_lock);
    + kill_proc(pid, SIGKILL, 1);
    + read_lock_irq(&tasklist_lock);
    + }
    + }
    + read_unlock_irq(&tasklist_lock);
    +}
    +
    +/*
    * Send signals to all our closest relatives so that they know
    * to properly mourn us..
    */
    @@ -404,6 +424,8 @@
    #endif
    task_lock(tsk);
    sem_exit();
    + if (tsk->flags & PF_KILLVMCH)
    + exit_kill_vmchild();
    __exit_mm(tsk);
    __exit_files(tsk);
    __exit_fs(tsk);


    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:56    [W:0.026 / U:0.428 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site