Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1712833rdh; Tue, 26 Sep 2023 00:47:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3jUhrQI3afA4WIH69g6K4ScvgGDDjwLG5YHWsGHNdblWQZh10Sw5q5Xh5S8cxp0afTJPp X-Received: by 2002:a05:6a21:99a6:b0:15d:9ee7:1816 with SMTP id ve38-20020a056a2199a600b0015d9ee71816mr11571228pzb.10.1695714439814; Tue, 26 Sep 2023 00:47:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695714439; cv=none; d=google.com; s=arc-20160816; b=EIEfCRHbcLe/Z5fwKnekHTJRuFtY5KPOsp9WiSGbC6Xg7tnuHe2+L1tLNETpj7SOtu YakI20/HqSe2tMIkqCcXl2dDwQyohIpmxTi+SPnhqLKPVcyRc7mjggBC+d2raaxShTsB hqOD5DT1AO/CwEE2IRlqFgEZ0Nl8IkrfAlHB+tMr9rjdFvWGDUIf4wcM8268TmMDWi6J FpIIpDehCbTKICKE2Lrb9eL11JByC+GV2FKHN015OOV0n031KcxJs5dt7lpRXndub4LN Y5mTiDQCXF/3MEZ3xyukoX/9+b2hgmBx0t8Vo4BBAoC5YN26lw3rKp1WmvCCe1Fr9daX 310Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=BTM5VmZcMw2pODPuaPEzQ6BlA0Fl+S6sRVBCSJSKw8I=; fh=QSB47mWNqNJ6HIS/tM5yVapTorEpBbKKFvbEYeNuqSc=; b=RoEIClDARP6gLnry5K0Yw26gnrnex0xtFhFRUYrxIPsJaL7NK+RGLRGH4Q6ompcCW8 rxdenG85lL2E0xgSeYSElrOey1RF+b1gPquOZcmxJuFsi/Po8tKCwk6PPU0L2D8QQZWc I372aq5dcKGKwJUIN/EID+OQTbeqHDHpaqEB/wBE5S3HcBEKANmrpvYSJrijd653MskV +3RxehZJ1FxbjO11tse2CFmlP/RxMqyxGG73XCrS7JKhDpqG+2av6UYkusSR3Qt+P0js fLAfWOiVKhbms097jczEFARsAfmOoXXuysn9FicPh3zD2uB5nCqPVlXOvQGwnHsfTV/B Bz5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nY7+VvuS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id t11-20020a170902d28b00b001c60502ccd4si6313017plc.642.2023.09.26.00.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 00:47:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nY7+VvuS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 62C618061381; Mon, 25 Sep 2023 16:49:31 -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 S230044AbjIYXte (ORCPT + 99 others); Mon, 25 Sep 2023 19:49:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbjIYXtd (ORCPT ); Mon, 25 Sep 2023 19:49:33 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F1F4FB; Mon, 25 Sep 2023 16:49:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695685767; x=1727221767; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=o4UGOstkYMKSTDEBD6eiJUra05gPDpzN03VLDsHK1nc=; b=nY7+VvuSlNZ0kFr1jP73gX6lmmsqdOloct2+Rdo7xbsVuePUNp2QHw3E PT79OfwORX3ana0IFMjIqEJKR2Z74ulB7q7GCZjnsmc3dwNHXaO/mV1R3 OsxlIRWnQVk7KELmFin4lG4DhistgeRVD2KQQrVva/DqNzHoDGFtZ2o/x qBND82iGhpt73wIcJQWNWg7SG+OYxUZtZBmCdbbeBUYPhRVwrG5Yruvoq iQRxgBl1GT325WsRQ/07scE8HUKwcAuFXl5rqcFEarwtFz8lRHJ+A7VPz V8KFsvd77aJAPpVxuqxGH+Hb88CpFXxOOO3khF+EkSXtcI8+kux4YnkdV A==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="360821167" X-IronPort-AV: E=Sophos;i="6.03,176,1694761200"; d="scan'208";a="360821167" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2023 16:49:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="922200708" X-IronPort-AV: E=Sophos;i="6.03,176,1694761200"; d="scan'208";a="922200708" Received: from jbuzinsk-mobl1.amr.corp.intel.com (HELO vcostago-mobl3) ([10.212.11.99]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2023 16:49:26 -0700 From: Vinicius Costa Gomes To: Mateusz Guzik , John Johansen Cc: linux-security-module@vger.kernel.org, apparmor@lists.ubuntu.com, linux-kernel@vger.kernel.org Subject: Re: [apparmor] use per-cpu refcounts for apparmor labels? In-Reply-To: References: Date: Mon, 25 Sep 2023 16:49:25 -0700 Message-ID: <87a5t9bypm.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 16:49:31 -0700 (PDT) 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 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. > > Thanks, > -- > Mateusz Guzik > Cheers, -- Vinicius