Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp467731imm; Fri, 1 Jun 2018 04:19:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL/JGzn3xXHPBkWcmKMO4MzfiOfbgywItV1dQbOr3IaHFaXvfT/6X6K+a340TNvT5Dc1e11 X-Received: by 2002:a62:4a0c:: with SMTP id x12-v6mr10575845pfa.142.1527851951264; Fri, 01 Jun 2018 04:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527851951; cv=none; d=google.com; s=arc-20160816; b=u8suEEh8KsPZRC/xJXYvPc4o9KNDt7kBnnVgffUT6BaKqWImIX5X++3ssFr/N0Hqwa fj1lr+/ZYrTQpIqshJKFaSByBy/Vvs8/92bQ4L0aXdBkvigFeVMFlkG0iShOipkSK0EU A3zoSRH+1x29EraosAupj6NBwdFr5dv1RFU5kYbHku9kMDAxT/ZLdmi6TGJ4JCE43vAG epufdIgrKQP5nas7XxGJIZcjLuc5eHhuYTQiK7IIIL+fbQtCvk3dX6St2OgyponDLCQN qvQyM5/gflz52fds6TYJG68LQ6etYWURBPvZQ4bEn8rF0Ri0f3UlBL7V6Z+F+umzMaSs aP5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:arc-authentication-results; bh=LoqImo/BjxV1cG/v0vIncyYW8GtvT/CyjiOoJYgUrkQ=; b=zcm2BLLKX5aa4uJA+Psi5wVxRc/6nrBIWWCHFiHUh1ZjKslYOaW9NlUl4MFfKKc9d9 ZyWnnJbmfi4HR9PzxQEcmzlPaR48/wRkfQjxtgBwYpjwYZhKFP0+0q50cKo+YmiAnxQF KPuS4ygL03VmOuzAH7xtUQb03kN1UMnoNFKORZ3zPKJN5MniflnHfXFXtsj4H+81dx4V e0lzZDo71EGLdq6z5uHAU5TKQeQG4g7A8GKtu0Q34VkGdFfSmgdQNyxae220V/RvbAVA dE5yynx+c/AdoBzVxnWH85q/HGTQDtkOOFsqstgk33V945ehFsinhV0cmU1Dn7opmfTa ZQ3g== 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 h89-v6si19703817pld.378.2018.06.01.04.18.56; Fri, 01 Jun 2018 04:19: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 S1751699AbeFALSW convert rfc822-to-8bit (ORCPT + 99 others); Fri, 1 Jun 2018 07:18:22 -0400 Received: from seldsegrel01.sonyericsson.com ([37.139.156.29]:2390 "EHLO SELDSEGREL01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751301AbeFALSV (ORCPT ); Fri, 1 Jun 2018 07:18:21 -0400 Subject: Re: [PATCH V3 0/5] selinux:Significant reduce of preempt_disable holds To: Stephen Smalley , Paul Moore , Eric Paris , James Morris , Daniel Jurgens , Doug Ledford , , , , "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> From: peter enderborg Message-ID: <4838bb4f-34bc-407e-343b-113d6bef4be0@sony.com> Date: Fri, 1 Jun 2018 13:18:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <9332801c-6102-2486-ab60-b48bb38ae207@tycho.nsa.gov> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8BIT Content-Language: en-GB Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. It maybe not needed atomic at the time. But the duplication holds a rcu_read_lock so it need to be atomic now. > > 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. > > >