Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp3029078rdb; Fri, 22 Sep 2023 16:10:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEF5UzCxOKbSywOat/gEC9PtQ0174kK9pvnxuX7I25iEmQqmf1fA+slUX9T/tlMKLuQrLBt X-Received: by 2002:a05:6358:7e95:b0:143:9235:9f1f with SMTP id o21-20020a0563587e9500b0014392359f1fmr820901rwn.12.1695424251420; Fri, 22 Sep 2023 16:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695424251; cv=none; d=google.com; s=arc-20160816; b=ex7qc238JOLYI2yrHh1k6M7FLdn1ie1iv0oNZQXPaHoJaAAKwWA4afY7Zk86vEWswx Okov06Oyql3TWUOvUunRSv84ATr8L2fueYttBXuDIJfetgDKt7IHdw9C2YhJLd/vwWlK rDBV9gBolYxWp9U1PMH3KGsTMy3hm6ymKw2JmSRtBpTa4zCsBB4zMoatdNRZfK94tcqL XqRg5ZkwjXtJW8JqPJUW+VDgOqvgO77ho6pHMt3Wpq3sM+pOZgQI2pyH90gdpvdE2Q/a CkypznHX2S9vfTX+r839QyiQTDUSCYukOVSeB6/nYV5ZyJd675wce58d2zwxdeGOClo0 F7aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:mime-version :dkim-signature; bh=33plBw2S6RxLVTFtd8vbQkwkLM7hKUemGtBycCXA6jA=; fh=k88/jsi9NoGSTnxjnBZPrvQrNZ6qpoPwEZ6Nygp8cZ4=; b=B3KvDN5WBLBv9W7NHWV6xNgfcUYShkawTQzm93Cl47He3ATwelsrQ3iHHyiHOIJSp0 UwW0y/1Tl96R+W+crkvzbhEtNhB2qNYnycKV/vhwNQtkTL/veL14lfN5fX4OlAbJx1OR LnHO8hiI5DyHRyyaaTgXNMyHjb+pgq0pDmdx7PGF9c+HIZDO8jKld9/u13mf32uQwgmA zPGdLi1GK4xvzIJhoBRTUySsDKlLyZlng41IwRGYCQpYfY5UhvHatkD2b1eErMJ8lGjr t4KDUeraUkoD1QGvY2PhLJmaS9zQMUdPbqfF4yiLYnJ3jwsXYs9Z3SRnfUV1IPyZeGxZ eG2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DKJEpv40; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id o15-20020a656a4f000000b005774aba519dsi5429223pgu.298.2023.09.22.16.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 16:10:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DKJEpv40; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 2690B82D28DE; Fri, 22 Sep 2023 14:19:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbjIVVTa (ORCPT + 99 others); Fri, 22 Sep 2023 17:19:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229746AbjIVVT2 (ORCPT ); Fri, 22 Sep 2023 17:19:28 -0400 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FD72C1; Fri, 22 Sep 2023 14:19:23 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-3add83c9043so1580036b6e.2; Fri, 22 Sep 2023 14:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695417562; x=1696022362; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=33plBw2S6RxLVTFtd8vbQkwkLM7hKUemGtBycCXA6jA=; b=DKJEpv40AlsLxKXnWmRq1YWHL3gZqrPlE3qPHg5SVijtsQFgfKiK/KyjL4Kp+Vwep+ Bxkc1bTKAum7eyqoUXinVRp66EmgXbcCM2J3J4Etx80ym3jVMOi9XZYSU/Z4Wl5byXJ3 IGHCT+/7uTyPmJQb7Sj6spwfm+TU2EtRgerXh45iBryWge/7gxDYEIU06RfHXodUK3Se e45ebQY6TTjNzCKkSiYYI5E9oZJDsp5g+SgIpsg/XaweW+QhOEh9rReFSvYlIkq1sRX+ q4sWXhQZROQqVlsJZvaCMHFR2GrardBZmrmcuFtiI9ow7Z5fsXjcraoXroYx7oEy6JyS 84yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695417562; x=1696022362; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=33plBw2S6RxLVTFtd8vbQkwkLM7hKUemGtBycCXA6jA=; b=cMyvW4zt3y2F3qJR/CObFHCQirIlmoignV7iZ625SiI+iHU5lbY5s8bIK34mXKLcHt TNtX5UvGKOichHLr3GQTlJeZN/Jh9q6RyXflFcal1J/obr1sWuaTs1LfXBdOj/z4xYkU +Po4FDulQQqNSO0dCbi7eAFPjqXCh/alpQFFY1VFlpEsiBozvYSQz28ouaHgzC7t0LOK 3xBvxyUbqxS2sJYoo20Uvr+DMU5e03W8QX7zs8VLMa+MkUdlEYddRb1izIHISz3FXLqk CJ4pswntQaNhB78G5FeINzaXxi4QtKzZMx/ZrT9Fqss5nYdtF0Gn6ZVmbhQMB9EUruQC R62A== X-Gm-Message-State: AOJu0YyRmq8RRK5UGpKkdQU1uho+JqOQbaoSp+uYUNQETLXiP7voSaz8 GA5TYr8UswFVlQsIbxh3mxBxzAJKqldO5w9ub2RjfbC9 X-Received: by 2002:aca:2101:0:b0:3a7:4802:c3f with SMTP id 1-20020aca2101000000b003a748020c3fmr821282oiz.52.1695417562384; Fri, 22 Sep 2023 14:19:22 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:5dc9:0:b0:4f0:1250:dd51 with HTTP; Fri, 22 Sep 2023 14:19:21 -0700 (PDT) From: Mateusz Guzik Date: Fri, 22 Sep 2023 23:19:21 +0200 Message-ID: Subject: use per-cpu refcounts for apparmor labels? To: John Johansen Cc: apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Fri, 22 Sep 2023 14:19:29 -0700 (PDT) X-Spam-Level: ** 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? Thanks, -- Mateusz Guzik