From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54EB9301472 for ; Fri, 27 Feb 2026 16:38:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772210288; cv=none; b=YUIlzBOmMuCIAFHd3lGDGAGQ33woFBPZ/OfmVwwTjwu8/Oz4Rpi83nxtgCSyDLuOzqRTDNYSKX3E0T2AjTx3Hd36415iX9ok/cS6ndBOlQZCDY4BPHpYiGg7LdF8vltZ2VT6Yb99lyRo0LV1Al+iC4HX6u3MuGAp/71iKB6d1l4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772210288; c=relaxed/simple; bh=lMXL/mlAqimXseoJgvNhre8MEuktOnws6M1xMb7iwqo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BL8lG3Zh0CYrojor8udzMC+xuro/vtFLxO8gq0S00dopgbFdvYieZl1sh1E8tZlbtkw42CttxI1BcPV14EuuqMy2sOeQa3E+nYFf9ksFYouYsbgzYXJsIn/8BFhPniJsHv1MwC1Zh3IfZO5zFjiuNtpUgb5V3+wjCMv+qGfjTYs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AK68/ilY; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AK68/ilY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772210286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cFN0VjvhWLaPYkQMfpAy7AmX3Ya0VP+SIdEjxLHDri0=; b=AK68/ilYPfoUhGnufcN+tylyHal2ItbHsr+VA0inYiLrKA9pUSsnHpiq/HSRtb/KbZeKb0 a2hxNxoB1PEcFaz0DvhXlT9QBRQmPsVcxdXjZr0QbEB1h7+Eq7fTQ1YcWqRXa5uNkEB8+O XPxpuUfYlLMt3hzlYebqA1ZJbhV+96g= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-173-w4kegXWqM1KLOSA01oC0zA-1; Fri, 27 Feb 2026 11:38:03 -0500 X-MC-Unique: w4kegXWqM1KLOSA01oC0zA-1 X-Mimecast-MFC-AGG-ID: w4kegXWqM1KLOSA01oC0zA_1772210282 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 85BD81956068; Fri, 27 Feb 2026 16:38:01 +0000 (UTC) Received: from madcap2.tricolour.ca (unknown [10.22.58.4]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 51C63180066F; Fri, 27 Feb 2026 16:37:56 +0000 (UTC) Date: Fri, 27 Feb 2026 11:37:52 -0500 From: Richard Guy Briggs To: Waiman Long Cc: Paul Moore , Eric Paris , Christian Brauner , Al Viro , linux-kernel@vger.kernel.org, audit@vger.kernel.org, Ricardo Robaina Subject: Re: [PATCH v3 2/2] audit: Use the new {get,put}_fs_pwd_pool() APIs to get/put pwd references Message-ID: References: <20260206201918.1988344-1-longman@redhat.com> <20260206201918.1988344-3-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260206201918.1988344-3-longman@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 On 2026-02-06 15:19, Waiman Long wrote: > When the audit subsystem is enabled, it can do a lot of get_fs_pwd() > calls to get references to fs->pwd and then releasing those references > back with path_put() later. That may cause a lot of spinlock contention > on a single pwd's dentry lock because of the constant changes to the > reference count when there are many processes on the same working > directory actively doing open/close system calls. This can cause > noticeable performance regresssion when compared with the case where > the audit subsystem is turned off especially on systems with a lot of > CPUs which is becoming more common these days. > > To avoid this kind of performance regression, use the new > get_fs_pwd_pool() and put_fs_pwd_pool() APIs to acquire and release a > fs->pwd reference. This should greatly reduce the number of path_get() > and path_put() calls that are needed. > > After installing a test kernel with auditing enabled and counters > added to track the get_fs_pwd_pool() and put_fs_pwd_pool() calls on > a 2-socket 96-core test system and running a parallel kernel build, > the counter values for this particular test run were shown below. > > fs_get_path=307,903 > fs_get_pool=56,583,192 > fs_put_path=6,209 > fs_put_pool=56,885,147 > > Of the about 57M calls to get_fs_pwd_pool() and put_fs_pwd_pool(), the > majority of them are just updating the pwd_refs counters. Only less than > 1% of those calls require an actual path_get() and path_put() calls. The > difference between fs_get_path and fs_put_path represents the extra pwd > references that were still stored in various active task->fs's when the > counter values were retrieved. > > It can be seen that the number of path_get() and path_put() calls are > reduced by quite a lot. > > Signed-off-by: Waiman Long Reviewed-by: Richard Guy Briggs > --- > kernel/auditsc.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c > index dd0563a8e0be..af22f8be4d70 100644 > --- a/kernel/auditsc.c > +++ b/kernel/auditsc.c > @@ -931,6 +931,9 @@ static inline void audit_free_names(struct audit_context *context) > { > struct audit_names *n, *next; > > + if (!context->name_count) > + return; /* audit_alloc_name() has not been called */ > + > list_for_each_entry_safe(n, next, &context->names_list, list) { > list_del(&n->list); > if (n->name) > @@ -939,7 +942,7 @@ static inline void audit_free_names(struct audit_context *context) > kfree(n); > } > context->name_count = 0; > - path_put(&context->pwd); > + put_fs_pwd_pool(current->fs, &context->pwd); > context->pwd.dentry = NULL; > context->pwd.mnt = NULL; > } > @@ -2165,7 +2168,7 @@ static struct audit_names *audit_alloc_name(struct audit_context *context, > > context->name_count++; > if (!context->pwd.dentry) > - get_fs_pwd(current->fs, &context->pwd); > + get_fs_pwd_pool(current->fs, &context->pwd); > return aname; > } > > -- > 2.52.0 > - RGB -- Richard Guy Briggs Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada Upstream IRC: SunRaycer Voice: +1.613.860 2354 SMS: +1.613.518.6570