Skip to content
  • Peter Zijlstra's avatar
    fcntl: add F_[SG]ETOWN_EX · ba0a6c9f
    Peter Zijlstra authored
    
    
    In order to direct the SIGIO signal to a particular thread of a
    multi-threaded application we cannot, like suggested by the manpage, put a
    TID into the regular fcntl(F_SETOWN) call.  It will still be send to the
    whole process of which that thread is part.
    
    Since people do want to properly direct SIGIO we introduce F_SETOWN_EX.
    
    The need to direct SIGIO comes from self-monitoring profiling such as with
    perf-counters.  Perf-counters uses SIGIO to notify that new sample data is
    available.  If the signal is delivered to the same task that generated the
    new sample it can augment that data by inspecting the task's user-space
    state right after it returns from the kernel.  This is esp.  convenient
    for interpreted or virtual machine driven environments.
    
    Both F_SETOWN_EX and F_GETOWN_EX take a pointer to a struct f_owner_ex
    as argument:
    
    struct f_owner_ex {
    	int   type;
    	pid_t pid;
    };
    
    Where type is one of F_OWNER_TID, F_OWNER_PID or F_OWNER_GID.
    
    Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
    Reviewed-by: default avatarOleg Nesterov <oleg@redhat.com>
    Tested-by: default avatarstephane eranian <eranian@googlemail.com>
    Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
    Cc: Roland McGrath <roland@redhat.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Christoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    ba0a6c9f