Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp658055imm; Thu, 31 May 2018 07:14:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLXJ5KcCzpzCCGhK4TB3SfbPEQ/orotkrNICpBeU66kFZwxX+aUvTpPkQaqD12bxDXmhfUV X-Received: by 2002:a17:902:8a95:: with SMTP id p21-v6mr7267354plo.325.1527776068249; Thu, 31 May 2018 07:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527776068; cv=none; d=google.com; s=arc-20160816; b=abaQ7oc5kjEGaYYURU6GYBBldOEkpc3h+euAvroiGXf0gwVK92hXYvRCPTZ/usqRw1 wQ9TXntAt/pUj2H5Qk6/YjbbkrRio83Gi/lHr6YKQLPqDHSRQ3cz8/Vh3GTbAO86jpGS aueOxs13+2qgOC05NaCloiqTqTzDyvGa2GMgfjvjwxqiNBxnJ38xPfbKQgG2+TPe4Pbg 8OiVjpe4pM0vhedmOjFzOghhe2awaGUiq6wwxBFGvY8Gb6MvwYdSkCX1X7vFumWDP7PZ NGr0TCEGlZ0gGlM5tYPoacjE06wlKuXaRuX+FaHr7kTVBQFKbaseSbCYV7Z1F7fp4Rfu ia2Q== 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=TSFI2po7KU4XUSvcOabWUvTZr8y1lNjQf9skilBXdAc=; b=c49m6TiKKr/9xExJ8U79D4o8jEBHrNygARrRHA1yVGyf/QI+06sfT/i6M/7Sq6X7aq 78yS0Mh0BoH8KwpT8XcJmuaP0AVlyAmBNV9YtEHIqMkM/BgLXjafxSJaJU+M4Og7g0Cb enAxHrOQv8iwyR0wZC69dT5Ci1KtcCqlFKWpjuVQbnH30wAtd5r+FHejuhM5vSincdUg C4WEQqn20jveLZJeZZj2arGp7C+qHV5mJ2eBexzM5/44iPI4Cq1k1svL68I81kmwkIQt BHmV2MQ2i7BQUVKX68c2JB+bSTJW4/cGZrogwGsg3S1sT0cfBOmTQKVj4nQOOeTZYEY/ /a7Q== 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 r28-v6si10781944pfe.168.2018.05.31.07.14.14; Thu, 31 May 2018 07:14:28 -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 S1755378AbeEaOMS convert rfc822-to-8bit (ORCPT + 99 others); Thu, 31 May 2018 10:12:18 -0400 Received: from seldsegrel01.sonyericsson.com ([37.139.156.29]:5389 "EHLO SELDSEGREL01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755202AbeEaOMO (ORCPT ); Thu, 31 May 2018 10:12:14 -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: <71925d61-743e-76a1-b0dd-1948468e2773@sony.com> Date: Thu, 31 May 2018 16:12:11 +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. 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. You dont happend to know exactly why KaiGai's patch never was accepted? > 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. > > >