Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp805808imm; Thu, 31 May 2018 09:41:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKMiSRTyLfq3RlvR11hSGOuNOxZ08d8g1ragetQVPgijn+jyUrmSM/8z3D1YhI+Ngqs+CBl X-Received: by 2002:a17:902:8f93:: with SMTP id z19-v6mr7598265plo.166.1527784871641; Thu, 31 May 2018 09:41:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527784871; cv=none; d=google.com; s=arc-20160816; b=L4xlPXvoyzhozBIQatF+lBgYQYUkOdAto/NOxeiYyW5SHzUIYGy4b/cyUnNg6w+jqd KV+T5ZTP7lyzjVOZKqD+buWMwkdp5PHy9IenmJe+JjzgA+mdG0pRWAQsB2ayO1f3SNks bmdK7/h8xOAzbbXkS9lpriBIcyrQQzkW+YqfPOLf55O7s7z53k9RrVj+/JM85wzw8JGU h6fVjwu4UevAQ7T9PBelVxMxLjGzkU5gKt6xSofbiWrBodyB00J8Z7L/r67R9BPCZGt7 AqUGq16oZAp6yCid4eu1qVqPSDrHRPVXmwSxy1uw1k8AzKb1styklSG8R0SUbNPus7E8 /AZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:to:from:subject:ironport-phdr :arc-authentication-results; bh=JAB5PfWKKVtKYa2vfJRv+zK5M35JyRvDlWzqeHxEb0I=; b=PlO4w1IEVzWr25BlvgO9zx9LC6y+9Ix8Id+pmY8hWyG8+HlyF0Nx4KM1mf7Z5NsRDq 4OcAPs3HvttmenQTsSvY9d3mmyv49IgUCCPGFy5ozmgSpR1W4zjQpxTOtgMYhGCX9IWg kHbpxMAaOMGiW2fB3Z0BhclZo31+dgctwlUTpQgUBNcEki+5YGJ26gBasCg6FhsBiLT6 wcorBmsABdeZhcb3v9lWfUBNT9obbs5YhKBpxvcxT+rFH0rddtpTDTDZ6tbJRUrgxiXf acIgiHZ+BRL5WCukK8EVa52r/Qspp74xpBjUqUFT9YTeOc7ebfZ4eQua4mzVIJLZ7Xu2 9bYg== 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 r3-v6si39421669pli.324.2018.05.31.09.40.57; Thu, 31 May 2018 09:41:11 -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 S1755758AbeEaQjP (ORCPT + 99 others); Thu, 31 May 2018 12:39:15 -0400 Received: from ucol19pa12.eemsg.mail.mil ([214.24.24.85]:56534 "EHLO ucol19pa12.eemsg.mail.mil" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755618AbeEaQjN (ORCPT ); Thu, 31 May 2018 12:39:13 -0400 X-IronPort-AV: E=Sophos;i="5.49,463,1520899200"; d="scan'208";a="571966306" Received: from emsm-gh1-uea10.ncsc.mil ([214.29.60.2]) by ucol19pa12.eemsg.mail.mil with ESMTP/TLS/AES256-SHA; 31 May 2018 16:39:09 +0000 X-IronPort-AV: E=Sophos;i="5.49,463,1520899200"; d="scan'208";a="12351470" IronPort-PHdr: =?us-ascii?q?9a23=3AZZ+MMBfI4ztkqZ2G0ympQDa8lGMj4u6mDksu8p?= =?us-ascii?q?Mizoh2WeGdxc29ZRGN2/xhgRfzUJnB7Loc0qyK6/2mATRIyK3CmUhKSIZLWR?= =?us-ascii?q?4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBx?= =?us-ascii?q?rwKxd+KPjrFY7OlcS30P2594HObwlSizexfbN/IA+qoQnNq8IbnZZsJqEtxx?= =?us-ascii?q?XTv3BGYf5WxWRmJVKSmxbz+MK994N9/ipTpvws6ddOXb31cKokQ7NYCi8mM3?= =?us-ascii?q?0u683wqRbDVwqP6WACXWgQjxFFHhLK7BD+Xpf2ryv6qu9w0zSUMMHqUbw5Xy?= =?us-ascii?q?mp4rx1QxH0ligIKz858HnWisNuiqJbvAmhrAF7z4LNfY2ZKOZycqbbcNwUX2?= =?us-ascii?q?pBWttaWTJHDI2ycoADC/MNMfhEo4X4oVYFsBmwChS2BO731zFGhmH43aM53e?= =?us-ascii?q?ovHw7J0w4vEM4BvnnPsNX4N70fXfypwKTGzzjOae5d1zfn6IjPdxAsueyCXa?= =?us-ascii?q?5ufsrJyUkgCQXFhUiNp4zgJTyV0uANvHab7uF9Uu+vkHMoqxpqrzizxsYjlo?= =?us-ascii?q?nJhoUPxlDC7iV22pw5JdK/SE5leNOpFoZbuSKCN4ZuX88vTG5ltDw6x7Ebo5?= =?us-ascii?q?K3YicHxIo9yxLCbfGMbpKG7Qj5VOmLJDd1nHdleLWiiBms6UWg0ej8VtWs0F?= =?us-ascii?q?ZNsypFjsHAtnAT2BzX7ciKUud98V272TaOygDT8ftIIVw0lKXHK54hxaQ8lp?= =?us-ascii?q?wPvkTYAiD6gkD2jK6Sdkk8++io7froYqn+q5OBOIJ5hRvyP6QzlsClH+g1PR?= =?us-ascii?q?YCU3KG9eik0b3s50z5QLFEjv0slanZtYjXJd8Gqa6iGAJVzoYi5Aq/Dzehyt?= =?us-ascii?q?gYm2IHI0hfdBKIiIjpJUnCIOrkAvenn1SsjDBryujePrL/HpXCMGLDnK3/cr?= =?us-ascii?q?Z79kFT1hAzwstY55JOBbEMO+nzWkj3tN3YFBM2Lwu0w+P/AtVnyoweQX6PAr?= =?us-asc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yDOsUIxUYb?= =?us-ascii?q?dofJ0jD26rLszxwc9x0dqld3de9VOnT3EbwsCkfwHaO1D02wxd0UY/pHGjnS?= =?us-ascii?q?K+yCwymDYs+O7X8CvTzKzGeRYJPXRHDD1uiVrgL4+ug/gAUUSoZhRvnxygsw?= =?us-ascii?q?Ky3KVfpaJiP0HPUExIeG7wNGgkXayu8vKGYshS+NYzvC5KSuWgcBWfTbLgpx?= =?us-ascii?q?YyzSzuBS1dySo9ejXsvY/221R+iWSAPDNwoWDfdMVY2xjS/prfSORX0z5AQz?= =?us-ascii?q?N3zXGdPVWmMNTh0J3S37fKtuSvUSjpAoZeaybm5YOJsC+q4ythBhjp27j5ot?= =?us-ascii?q?T6FUAXmWmz8tJJWCPOoQe2Kt3z3rm+NOlkVk1pAkLsrdR8F504k4E1wpoX3C?= =?us-ascii?q?5JqI+S+C88jWrrMdhdkZn7ZX4JSC9Dl8XZ+yD5yUZjKTSP3Iu/WXKDlJgyL+?= =?us-ascii?q?Kma38bj3pup/tBD72Zufkdx3N4?= X-IPAS-Result: =?us-ascii?q?A2ALAwCLJBBb/wHyM5BcGgEBAQEBAgEBAQEIAQEBAYMZK?= =?us-ascii?q?2J/hB+UaEYBAQEBAQZ/KYEPk1CBZDYBhEACggQhOBQBAgEBAQEBAQIBayiCN?= =?us-ascii?q?SQBgk8BBSMPAVYLGAICJgICVwYBDAgBAYJeQAKBcg2neoIcg3gBAYRIgWiBC?= =?us-ascii?q?oc3gQyBB4EPJIJphDeDPIJUAphpCY5bBoE8hliEfyuHLosUIYFSKwgCGAghD?= =?us-ascii?q?4J/gh8XjWEBUSOBKgEBjB4qgh0BAQ?= Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by EMSM-GH1-UEA10.NCSC.MIL with ESMTP; 31 May 2018 16:39:08 +0000 Received: from moss-pluto.infosec.tycho.ncsc.mil (moss-pluto.infosec.tycho.ncsc.mil [192.168.25.131]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id w4VGd3gv012862; Thu, 31 May 2018 12:39:05 -0400 Subject: Re: [PATCH V3 0/5] selinux:Significant reduce of preempt_disable holds From: Stephen Smalley To: peter enderborg , Paul Moore , Eric Paris , James Morris , Daniel Jurgens , Doug Ledford , selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, "Serge E . Hallyn" , "Paul E . McKenney" References: <20180530141104.28569-1-peter.enderborg@sony.com> <8bbb095e-31c3-0062-d17c-662e4832cc17@tycho.nsa.gov> <1cf240b9-57ee-eee3-228f-5ad4a3a39e57@sony.com> <9332801c-6102-2486-ab60-b48bb38ae207@tycho.nsa.gov> <71925d61-743e-76a1-b0dd-1948468e2773@sony.com> Message-ID: Date: Thu, 31 May 2018 12:40:27 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/31/2018 10:21 AM, Stephen Smalley wrote: > On 05/31/2018 10:12 AM, peter enderborg wrote: >> On 05/31/2018 02:42 PM, Stephen Smalley wrote: >>> On 05/31/2018 05:04 AM, peter enderborg wrote: >>>> On 05/30/2018 10:34 PM, Stephen Smalley wrote: >>>>> On 05/30/2018 10:10 AM, Peter Enderborg wrote: >>>>>> The boolean change becomes a lot more heavy with this patch, >>>>>> but it is a very rare usage in compare with read only operations. >>>>>> The lock held during a policydb_copy is about 1ms on a XEON. >>>>> This has a very substantial performance impact on setsebool, e.g. time setsebool httpd_can_sendmail=1. >>>>> That's because you are doing a full vmalloc();policydb_write();policydb_read();vfree() sequence on it. >>>>> In comparison, KaiGai's old attempt to replace the policy rwlock with RCU only duplicated the conditional policydb state (via a cond_policydb_dup) that he introduced. Is there a reason you couldn't use that approach? >>>> That one did not make it, so I went for a other path. Make it simple, using the same serialisation that exist. That also make it easier to maintain. >>>> We do not  use the booleans in android since they are not allowed so im not aware of any use case where this administrative function are >>>> used in such frequent manner that it would have an impact. And it must be some other large overhead with interprocess communication and >>>> a multiple writes to sysfs during a boolean settings?  However my concern is/was memory pressure, setting booleans will generate pressure >>>> with lot of atomic allocation and large vmallocs. >>> Yes, that is also a concern. I would prefer to only duplicate the conditional policydb state as in KaiGai's patch. >>> Keeping temporary setting of booleans lightweight is desirable for other use cases than Android. >>> >>> I'm also concerned by the implications of switching all of the allocations to atomic. KaiGai's patch did not take that approach either, and it obviously could make policy reload more prone to transient failures. >> >> On the version 2 of the patchset you pointed out that I did a shallow copy, so I did a "deap" copy. As I see it the KaiGai cond_policydb_dup also do a shallow copy. > > In your earlier patch set, you just did a memcpy of the policydb and then proceeded to mutate parts of the conditional policydb state, which would have modified the original too. KaiGai was performing a deep copy of the conditional portions of the policydb I believe. > >> You dont happend to know exactly why KaiGai's patch never was accepted? > > As I recall, there wasn't anything wrong with the code itself; he just wasn't satisfied that it ended up being a worthwhile tradeoff based on his own performance testing. His use case however was different - he was concerned with networking performance, and the introduction of the netnode/netport caches largely eliminated the policy rwlock as a concern there. > >> >>> But my goal is the fast path for real time critical functions such as audio, and it will be a cost for >>>> administrative tasks. On the xeon it takes about ~98 ms to run the security_set_bools compared to about ~8 ms without the overhead >>>> of copying the policydb.  About ~6 ms is rcu sync and ~8 ms is the same as the original update of selinux statuses, and about ~25 ms >>>> is policydb_destroy() of the old copy. >>> >>> >>>