Received: by 10.213.65.68 with SMTP id h4csp1007213imn; Wed, 28 Mar 2018 18:05:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/bj/QhwswvsehpeCC6wRXGPAB7Cx6HQ3JC8FeCtsJ+uyHB77jrnrf1peioMzoFtmZd4L25 X-Received: by 10.99.102.132 with SMTP id a126mr3942297pgc.385.1522285556702; Wed, 28 Mar 2018 18:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522285556; cv=none; d=google.com; s=arc-20160816; b=TFEwlkv7Wb/mIU9HLs5uLyEHo+SalHkJAdd4Jl/lIUbu7UYe/dQH9KKKD2sCCUUs2x tUrVZXoiSTO1YvkOxJOP1z8M3G1BsuaAqZD/EjHdW4knIimGSeiMCXefb9RbywsR7b0p 7+xxrrcdUM3ZTzhe40gFrVQauIqki++nnC8weZDwhy09oMrIRJQjfmNz1yfn5/jFG2Ww xh4GajyZGk9nYFa/Cqu8zv9N4rTHOXknQYm2tWDzPGfglrU+9KGJZ1GreXfZN1/8gwbA XyVS5mhCLrGme7ETwjPppQgeeExrK+RFoxXhGUjY+9eUiEAv6KYBAc0qTTosaibKYbQs AqQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=fgJy7T8KHyKDBEZSW/PJzlHtzPiGsvbkXgscPwNbkNk=; b=oXIx/ROUKIliioMg+o2PTTggqImotjjWrfhPDmbfteE4U0JfP/6VczSglcHLdA7WXC YcTI4FzqERz2aJYpgvOzOzTHSTHILonWgmDljb/PIOzOsH9MBQehi9XmxDDHkQeqjxAz rcOVdMCbuAjxXsibIInod+Q7MXDHAJTErmIVDgJNiWkTIh/eqdTpuQTYdzgnJINquUH8 zt6SGSU9qstH8p2o9vTd7yaoNiJOUbfOMvDzzF/0B3vx/LChzdApz/Q4RtPgF0jOVW/i 05VJ5UnY7QOM4SEKUMaXfEPFxKsNB9ZOxe77ZGUL2iS+cL4wxQmYVrKDyH3TUqktm+mG VBFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67-v6si4871844pla.612.2018.03.28.18.05.41; Wed, 28 Mar 2018 18:05:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752021AbeC2BEe (ORCPT + 99 others); Wed, 28 Mar 2018 21:04:34 -0400 Received: from mx2.suse.de ([195.135.220.15]:42560 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751088AbeC2BEc (ORCPT ); Wed, 28 Mar 2018 21:04:32 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B29AAACCB; Thu, 29 Mar 2018 01:04:30 +0000 (UTC) Date: Wed, 28 Mar 2018 17:52:09 -0700 From: Davidlohr Bueso To: "Eric W. Biederman" Cc: Linux Containers , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, khlebnikov@yandex-team.ru, prakash.sangappa@oracle.com, luto@kernel.org, akpm@linux-foundation.org, oleg@redhat.com, serge.hallyn@ubuntu.com, esyr@redhat.com, jannh@google.com, linux-security-module@vger.kernel.org, Pavel Emelyanov , Nagarathnam Muthusamy Subject: Re: [REVIEW][PATCH 11/11] ipc/sem: Fix semctl(..., GETPID, ...) between pid namespaces Message-ID: <20180329005209.fnzr3hzvyr4oy3wi@linux-n805> References: <87vadmobdw.fsf_-_@xmission.com> <20180323191614.32489-11-ebiederm@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180323191614.32489-11-ebiederm@xmission.com> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 23 Mar 2018, Eric W. Biederman wrote: >Today the last process to update a semaphore is remembered and >reported in the pid namespace of that process. If there are processes >in any other pid namespace querying that process id with GETPID the >result will be unusable nonsense as it does not make any >sense in your own pid namespace. Yeah that sounds pretty wrong. > >Due to ipc_update_pid I don't think you will be able to get System V >ipc semaphores into a troublesome cache line ping-pong. Using struct >pids from separate process are not a problem because they do not share >a cache line. Using struct pid from different threads of the same >process are unlikely to be a problem as the reference count update >can be avoided. > >Further linux futexes are a much better tool for the job of mutual >exclusion between processes than System V semaphores. So I expect >programs that are performance limited by their interprocess mutual >exclusion primitive will be using futexes. You would be wrong. There are plenty of real workloads out there that do not use futexes and are care about performance; in the end futexes are only good for the uncontended cases, it can also destroy numa boxes if you consider the global hash table. Experience as shown me that sysvipc sems are quite still used. > >So while it is possible that enhancing the storage of the last >rocess of a System V semaphore from an integer to a struct pid >will cause a performance regression because of the effect >of frequently updating the pid reference count. I don't expect >that to happen in practice. How's that? Now thanks to ipc_update_pid() for each semop the user passes, perform_atomic_semop() will do two atomic updates for the cases where there are multiple processes updating the sem. This is not uncommon. Could you please provide some numbers. Thanks, Davidlohr