From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F205EEE020C for ; Tue, 26 Sep 2023 06:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233709AbjIZGVn (ORCPT ); Tue, 26 Sep 2023 02:21:43 -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 Precedence: bulk List-ID: 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,