Skip to content
  • Eric W. Biederman's avatar
    ipc/shm: Fix shmctl(..., IPC_STAT, ...) between pid namespaces. · 98f929b1
    Eric W. Biederman authored
    Today shm_cpid and shm_lpid are remembered in the pid namespace of the
    creator and the processes that last touched a sysvipc shared memory
    segment.   If you have processes in multiple pid namespaces that
    is just wrong, and I don't know how this has been over-looked for
    so long.
    
    As only creation and shared memory attach and shared memory detach
    update the pids I do not expect there to be a repeat of the issues
    when struct pid was attached to each af_unix skb, which in some
    notable cases cut the performance in half.  The problem was threads of
    the same process updating same struct pid from different cpus causing
    the cache line to be highly contended and bounce between cpus.
    
    As creation, attach, and detach are expected to be rare operations for
    sysvipc shared memory segments I do not expect that kind of cache line
    ping pong to cause probems.  In addition because the pid is at a fixed
    location in the structure instead of being dynamic on a skb, the
    reference count of the pid does not need to be updated on each
    operation if the pid is the same.  This ability to simply skip the pid
    reference count changes if the pid is unchanging further reduces the
    likelihood of the a cache line holding a pid reference count
    ping-ponging between cpus.
    
    Fixes: b488893a
    
     ("pid namespaces: changes to show virtual ids to user")
    Reviewed-by: default avatarNagarathnam Muthusamy <nagarathnam.muthusamy@oracle.com>
    Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
    98f929b1