Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1713630rdh; Tue, 26 Sep 2023 00:49:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZ0rFWwiJXObxMIrKzxwIMk6MRus/Nv/DG5n80bo+ATBFVw7kLGBO4d6u5fLo9sBdStuar X-Received: by 2002:a05:6808:1486:b0:3a7:73e0:d18f with SMTP id e6-20020a056808148600b003a773e0d18fmr12937029oiw.14.1695714574183; Tue, 26 Sep 2023 00:49:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695714574; cv=none; d=google.com; s=arc-20160816; b=d87HLFkIYl+EylL5K7Cee20B6MivgamN452H0m4C1X4UOsj6RdgL2FkKOgHB6Dfor2 n9GTNlj8VRdy+27K358pdznMeBvmtqIynWqSxePgmLI2sPL1vpvsPMYKwUGv5EgYgvrN +BLeL4MlbrvTfGlbGglfaNSnz4lMnuJdSsJ4gMEmV5fzjEx+yc7j7a0qvUR0TYd4pj7T NhgaGqLZBxBcGQHPXVa0jiOVpzXFVxeB05bDFep2zMFYj9l6BnPTY3TFtsKs5MDHWY+Z LRUC90AzpdubEwzhcmzm0anBRyocYIK+a5dRjQ6Ib3sbS+D48bvMaaRr62jcEmRkuR3Q A6HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=DGnBgwgmtbfK719f9UNMasB/4ulOSh0gVlRWhxC3N+U=; fh=eAs4Kb13WfWNtlPzQy3TXejRNevhTBl/uXMCwsbvDKA=; b=AcVmtqkhrynMwKP7Rgyj8O8Qths8zD8MtNSSOwLq+HQUwMkb5G+uJE40pYQx2wMmi9 ACMAAtfljinFUEcw/K9GIVcoWOGhUo4m06011LWuSI99BvtCGaOMW7LbyJh7Ofn5f4bJ AyOlMUzUzc1T2Z0Yv5zZqO0KjULyLSdKgKMXhxjRgzyK7wS+cM4Ap64hgCHMMmYsptXi wXzKkop2Uid7fANTYsPTbckZXdimbTJ0mY4oa0wZ1plHVQ+bRPz8ryJYssq8VcAqAghl OkQvb2gFSTBt/he8u/Y0HktJJhIRsBS/qeB3iRe/G+gVObORR5MTlECYLdF3pwpjKj6D mxvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=UOZYKzkL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id w67-20020a636246000000b00565f7784bc9si9086197pgb.186.2023.09.26.00.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 00:49:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=UOZYKzkL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CE492813CD94; Mon, 25 Sep 2023 23:21:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233751AbjIZGVo (ORCPT + 99 others); Tue, 26 Sep 2023 02:21:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231994AbjIZGVm (ORCPT ); Tue, 26 Sep 2023 02:21:42 -0400 Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC740E9; Mon, 25 Sep 2023 23:21:35 -0700 (PDT) Received: from [192.168.192.83] (unknown [50.39.103.33]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id C50B53F6B0; Tue, 26 Sep 2023 06:21:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1695709291; bh=DGnBgwgmtbfK719f9UNMasB/4ulOSh0gVlRWhxC3N+U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UOZYKzkLLB1YrUHxaSUbRx1kMOD2kbWp5I40oHG6yvyQpeSKY5DiW76MK+JY1nBDg U5EiDgGmTNl9kLhc9dF4yGpzEJJ7j/mpv9pBgrElDxmZp/UxVfMT+A5Ezg6YmYhM9S +xq/Zisi0QOtvTiu2IROEN6PrKAVHvYtcu/sCGgsvp4C1eb/H+HUMNjWx821Xp1DT0 J5qWRNgYCpr5acKizGN60k0zh+hJNbdpw+ppNImNGEcRmkhMg9tU2aeBViJWOot31b DGseTYMy/+KDaZ7YR94qcIuuIkMGbxyTkls+/w8Rsf+cV5lAjA0TK4BkkWHU8su39h tMv6Ob5/USdzQ== Message-ID: Date: Mon, 25 Sep 2023 23:21:26 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [apparmor] use per-cpu refcounts for apparmor labels? Content-Language: en-US To: Vinicius Costa Gomes , Mateusz Guzik Cc: linux-security-module@vger.kernel.org, apparmor@lists.ubuntu.com, linux-kernel@vger.kernel.org References: <87a5t9bypm.fsf@intel.com> From: John Johansen Organization: Canonical In-Reply-To: <87a5t9bypm.fsf@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 25 Sep 2023 23:21:53 -0700 (PDT) On 9/25/23 16:49, Vinicius Costa Gomes wrote: > Hi Mateusz, > > Mateusz Guzik writes: > >> I'm sanity-checking perf in various microbenchmarks and I found >> apparmor to be the main bottleneck in some of them. >> >> For example: will-it-scale open1_processes -t 16, top of the profile: >> 20.17% [kernel] [k] apparmor_file_alloc_security >> 20.08% [kernel] [k] apparmor_file_open >> 20.05% [kernel] [k] apparmor_file_free_security >> 18.39% [kernel] [k] apparmor_current_getsecid_subj >> [snip] >> >> This serializes on refing/unrefing apparmor objs, sounds like a great >> candidate for per-cpu refcounting instead (I'm assuming they are >> expected to be long-lived). >> >> I would hack it up myself, but I failed to find a clear spot to switch >> back from per-cpu to centalized operation and don't want to put >> serious effort into it. >> >> Can you sort this out? > I will add looking into it on the todo list. Its going to have to come after some other major cleanups land, and I am not sure we can make the semantic work well for some of these. For other we might get away with switching to a critical section like Vinicius's patch has done for apparmor_current_getsecid_subj. > I was looking at this same workload, and proposed a patch[1] some time > ago, see if it helps: > > https://lists.ubuntu.com/archives/apparmor/2023-August/012914.html > > But my idea was different, in many cases, we are looking at the label > associated with the current task, and there's no need to take the > refcount. > yes, and thanks for that. >> >> Thanks, >> -- >> Mateusz Guzik >> > > Cheers,