Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp514837lqb; Wed, 29 May 2024 02:39:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVq7yvvffku7xMTBUONPJt8cbH+muXOeMPmearzRk2TodMIMTWKyePWLQV63uJ3amwczj/2mPf5ZKyckN5sSmTkwy2aLXb/dF+4lZ2BnA== X-Google-Smtp-Source: AGHT+IF5emM+KeISe8CAIi9gW2gARq0essnTPSiDU6QtzE1wQdK/lx5lEZVamkAsF6wh0a3/Dnra X-Received: by 2002:a50:d4d7:0:b0:579:d673:4e67 with SMTP id 4fb4d7f45d1cf-579d6734f4bmr6057139a12.26.1716975556160; Wed, 29 May 2024 02:39:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716975556; cv=pass; d=google.com; s=arc-20160816; b=QyKOTd31iwA/AnbXHEkaNnI4FTJHdJ+0cpThW4UzL86bSd+xta8WYfQA+QlOWeByoP DLKxeMRDNoUUQq3JvlxKSKnRogjueTWYigyn2lS57u+w5RO+2DUOcNTe/NvFmp+AGJh/ 5LOjhC1kCvtFtutTwHfTYLoHuq03rD+Ra5wNMtRf+7r0unchhTzRjfCPuTk/dEteinbx S1BynVlhL+Hv73UqM9RpMlc46oYt8mKQ8FExJ83Q2mBE1fA5cxSqn2yCeORU6hwC5KXt 1VChfYKllC8Wc4TTeM8s06ftmD4pJn07FD7v69PDyV1IwRmcCdCT0q67JhD1zQs4ug2l HcUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=nRx92IjGm86HR4V8oZzkRs0aIanlP+XxMvyW7SOoQPE=; fh=9P88KB4VldN1iwJUSitXPiTEUSvp89+YSkzIBfGtRt4=; b=cJ3ogr7nIpyj98wf3DWzxFGuMbSBVc0omMVwp+EMQU+NPG5tkbDAF/zOwVyOdOpkNW i/eqLTwfiuSKHih57KZR9Bp3DO9zKVwiYzxb55aze+qewtBAqaLdjSSeKzyINXkRvIz1 0pXMCYInMQ+IAkwABaCYQwO0DaVB6rtQrC1M68ZcosMcWswo479lgKP6XXdZShejYkzk DX+LPCngMl2UlarxSwEq2LLiQRZFHEFkXfTmllTC6T4djAGqjdfZrkY51P0oDjFDyJ3u 2MSmS4nDlc3ypCZ68Fn15eqxeIBfvk19d8vI8LPFW8BWy7RHXIjosNeMCEZI63m79lAs wx9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YR56hVG+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-193854-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193854-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-578524b4900si5915345a12.543.2024.05.29.02.39.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 02:39:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193854-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YR56hVG+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-193854-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193854-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D95541F264FA for ; Wed, 29 May 2024 09:38:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 437AB33CFC; Wed, 29 May 2024 09:38:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YR56hVG+" Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDBF516A381; Wed, 29 May 2024 09:38:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716975500; cv=none; b=Ou1i3bWq6G6+arSHYuVebTB4tlRPxmuj6RKgvWHmEEHKysHFwwyjPUZMyf3DFhTB3iLo3pc+YRv2SfwS4v3hKPMzwQuvwkYP5gv2nbqNWIqnxM+wEPNlClkpyy27NSTnSaqhcdjDve4n0GV4t995mVDiDpoQNuzt/hlhPgow/94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716975500; c=relaxed/simple; bh=nRx92IjGm86HR4V8oZzkRs0aIanlP+XxMvyW7SOoQPE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Ctky4x/bZQD0GtdVXkDs410Jiccc7OtcIaKp+2rDszebLjQjtqAzNJMt2L6ZRPgxAUDCwHfVc5sEjI4GXVfzhhFKgmkSAizzMx+UjbJ7zpqygJB9soFt7PLi9qAUcGIvefWfSaDoKPblbegH2XNBsrpLYufGhaetwAEcS5TYn5E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YR56hVG+; arc=none smtp.client-ip=209.85.208.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2e6f51f9de4so25522911fa.3; Wed, 29 May 2024 02:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716975497; x=1717580297; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nRx92IjGm86HR4V8oZzkRs0aIanlP+XxMvyW7SOoQPE=; b=YR56hVG+45U8zxvkuLUwK+wkrRHivvK1jlcj0kZfzXP2DqzPpRhPgPVTI9x9q9hjRA bTrocIfEzO6ZA191VcWAU4KJXZQroSqAuOqj39TIveN0CYrwhiml/1twtnJ9MSXVt8W2 uWjE/ppy1nJ0/XIS6L4KMnMAp2aBRi1MjKVyW8kgESOhuuY0Ca7c+lt9R0ww0zb2YgIo FVmINdYwiqQ2kE2+6Xejey+2r9rUbZY9bASlB+/wcgoSi+j1sKR2RSp4hoiGWbe+u127 Gv7OmU8OCNU384w/cTm6+r4PLlYr8VI62j713Vkf8X8qGSdWRIVZrLKENXLf335z7EzX aSKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716975497; x=1717580297; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nRx92IjGm86HR4V8oZzkRs0aIanlP+XxMvyW7SOoQPE=; b=fEnxUtRs5MBMFz35UVNi4dMh7ASKhFQuPpqvQu4rXabgZJxvXWLlcBNUNWqyGWN2UI 0xVYv2OkQOC88A5JndyG7nqdmlsSdGTVKs5zUVc8UOVtvdwwwZzw4TheFpaTpBCPV0wX 2oqarbm3OBGBS1gLFiluXgCuyAQIKLQD4Yhs5TBKEL40rFN7nhVi41T5E22GGdh7BTqk Ua2/Z7Zj25Odgz6C9CtRie7z4+q0elTwtitpkXAMsqKBJAJwS5So8T7HRGAsetDoIhNV GIEdQ8YsTqXf/B6JPEciTYRac65+Xdz7QDkxQrU5LJZ/eCvW6W5eK2WO29AYEMbsptJq NsYA== X-Forwarded-Encrypted: i=1; AJvYcCVZXmBpLSsLKWbSfIwqhJrneoS8uL+1FmPdG6oNisbQl1tli96Jo+UPCDIB9sq2w+jq1h1G9+l6+6CWIRAeP/Wp6p8QEQGGyW3NrihQve1fTSKxmSKUtDWZr+KW8Hs9rQgB/4U/qO1JVeQqLbk7ayzqD/CP X-Gm-Message-State: AOJu0YxftKEe4ULDTFO1ncV2amwVuOGoXJO/G1+akGnM65Hy5wCrgxL7 Vh96At4+rRE66kS6KzSFyvAl0RiH9WzTxoISpjrDtQ1xtNDcaNTOAy7562aqB9C7GsTtR7q2+cf z01sO4+BrvJUz2kbF5ERJIMHOLXc= X-Received: by 2002:a05:6512:3e19:b0:529:b718:8d00 with SMTP id 2adb3069b0e04-529b7188dc4mr5909595e87.8.1716975496547; Wed, 29 May 2024 02:38:16 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <096178c9-91de-4752-bdc4-6a31bcdcbaf8@amd.com> <4871a305-5d45-47d2-85f2-d718c423db80@canonical.com> <3b880c7c-0d19-4bb6-9f0f-fb69047f41cd@canonical.com> <5c94947b-1f1f-44a7-8b9c-b701c78350b4@canonical.com> <78cfe966-33ec-4858-b114-57697e478109@canonical.com> In-Reply-To: <78cfe966-33ec-4858-b114-57697e478109@canonical.com> From: Mateusz Guzik Date: Wed, 29 May 2024 11:38:04 +0200 Message-ID: Subject: Re: [RFC 0/9] Nginx refcount scalability issue with Apparmor enabled and potential solutions To: John Johansen Cc: Neeraj Upadhyay , paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, "Gautham R. Shenoy" , "Shukla, Santosh" , "Narayan, Ananth" , raghavendra.kodsarathimmappa@amd.com, koverstreet@google.com, paulmck@kernel.org, boqun.feng@gmail.com, vinicius.gomes@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 29, 2024 at 2:37=E2=80=AFAM John Johansen wrote: > I don't have objections to moving towards percpu refcounts, but the overh= ead > of a percpu stuct per label is a problem when we have thousands of labels > on the system. That is to say, this would have to be a config option. We > moved buffers from kmalloc to percpu to reduce memory overhead to reduce > contention. The to percpu, to a global pool because the percpu overhead w= as > too high for some machines, and then from a global pool to a hybrid schem= e > because of global lock contention. I don't see a way of doing that with t= he > label, which means a config would be the next best thing. > There was a patchset somewhere which adds counters starting as atomic and automagically converting themselves per-cpu if there as enough load applied to them. General point being it is plausible this may autotune itself. Another option would be a boot-time tunable. > Not part of your patch but something to be considered is that the label t= ree > needs a rework, its locking needs to move to read side a read side lock l= ess > scheme, and the plan was to make it also use a linked list such that new > labels are always queued at the end, allowing dynamically created labels = to > be lazily added to the tree. > It's not *my* patchset. ;) > I see the use of the kworker as problematic as well, especially if we are > talking using kconfig to switch reference counting modes. I am futzing wi= th > some ideas, on how to deal with this. > Thanks for the update. Hopefully this is going to get sorted out in the foreseeable future. --=20 Mateusz Guzik