From patchwork Mon Jul 24 14:43:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13324883 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42D88C04A6A for ; Mon, 24 Jul 2023 14:44:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7C3E8E0005; Mon, 24 Jul 2023 10:44:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B2DE78E0001; Mon, 24 Jul 2023 10:44:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CD3A8E0005; Mon, 24 Jul 2023 10:44:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8F0AD8E0001 for ; Mon, 24 Jul 2023 10:44:02 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3758340B17 for ; Mon, 24 Jul 2023 14:44:02 +0000 (UTC) X-FDA: 81046775124.22.24BDC59 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 835A84001F for ; Mon, 24 Jul 2023 14:44:00 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QNJOk2CO; spf=pass (imf17.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690209840; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=nIKtzBmWRGT844idwPhXtk04JKqkdrudRCCJWt8f5Xc=; b=FmtaT5dl8sUjyPgUwZWZ2Rwqun7yLJLuhL299njwWpr7LDK/fbqb2q0Tsa9nf/0ahAeN+i DAQvwfTuwWTGZYB7h3QCawNmqUJeUb3JvH+IsIuou/KzdzVqcG5Zb3L5d/nY9t/D7Ace5D 9s7N/q5Ki4zq9yFhYrX/73ynnRv7CCw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690209840; a=rsa-sha256; cv=none; b=hXyGth0cQwrkUDm85OC3BOMabg3Z53S3fSZ+aAZP20C6uczGsHsOuBao2g9p0xfAvXU5hE VY8Y+UW4a2PlIn8VzPgJdnUuhnKs8Hrz5IoW7Y9MML3+Vn0psaEi+h7TX5vDyaN3+d8Krk QP6nyKz5P95VTx2pstoD67QVXEVCDfs= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QNJOk2CO; spf=pass (imf17.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 377F6611AC; Mon, 24 Jul 2023 14:43:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E8DCC433C7; Mon, 24 Jul 2023 14:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690209838; bh=V80fCBO6tgYnB7Y4diByKwMKMbOCb33FIejFATg08B8=; h=Subject:From:To:Cc:Date:From; b=QNJOk2COoCIQPzMYykF9XgsX08VRDrdH8EU44jFw20RzAArf8azQe8/8g+HZLq3VN 4IE+0rn/UW4CpdISFbcgE0U2cD4FPwCnZ1DlcsPa7llYhCtWxFghm2b2+WSbG2QbI9 0wCrXpeb1afMfCL7iMUsJbDqwRIZIqqxRSTNwB/ukQFcynI7rqTgumTvXgJvHwkRfc r7ToSVzOD6IJNW/nY+LZv0j2vKLpRa7SNXVb5v+YcGSHN8S5QXv+69HRjNDExiTvjX 2ldM5tgzdtI5mZTBUeOXIVMgxdLl/J4o20NVP8kE6ye/zc9xBkdio7MUT7tYCFzc/2 UMy2onSWLgFLA== Subject: [PATCH] libfs: Add a lock class for the offset map's xa_lock From: Chuck Lever To: brauner@kernel.org Cc: Chuck Lever , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Date: Mon, 24 Jul 2023 10:43:57 -0400 Message-ID: <169020933088.160441.9405180953116076087.stgit@manet.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Stat-Signature: 8wkt1ywn97546ukn4ypjbruosdmnkej9 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 835A84001F X-Rspam-User: X-HE-Tag: 1690209840-548209 X-HE-Meta: U2FsdGVkX18Ofpy8f4cAHHRdAbYrU3FQe6DOv4D8MTxIOI5giX3zIwcGBe9dp6zQowXUEfgz/m4ezcb3Lhc9lLhhtoBZeWa5URjrJ9xi/+L60/is64SuqzhuYemjLnYge737WqfXT7p2RCBSwpj2rpnWN2EMKWkaQJFHMd1Hk5gB0labn9b/u1aK6905Z5tYHajYUEaXmF2hCPIqyTIxCW0GTKsCpugZeAqHtp7V0ZEJ1R66aViJjxMZPIWYokUDCcrf+XNLTFx3k4TprQ+GmznDLtDrpIeHLwGjV6gMLuC1pLjfVVKHdtDNDqPkPb9oeUQjyA8wxG2WoTZ5H5Kc1U5pB33tTX6yFEzaGNpeEP/QXL99B/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-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Chuck Lever Tie the dynamically-allocated xarray locks into a single class so contention on the directory offset xarrays can be observed. Signed-off-by: Chuck Lever --- fs/libfs.c | 3 +++ 1 file changed, 3 insertions(+) I've been looking into the recent kernel bot reports of performance regressions on the will-it-scale benchmark. https://lore.kernel.org/linux-mm/202307171640.e299f8d5-oliver.sang@intel.com/ I haven't been able to run the reproducer yet, but I have created a small change to demonstrate that it is unlikely that it is the xa_lock itself that is the issue. All tests I've run here show "0.0" in the lock_stat contention metrics for the simple_offset_xa_lock class. It seems reasonable to include this small change in the patches already applied to your tree. diff --git a/fs/libfs.c b/fs/libfs.c index 68b0000dc518..fcc0f1f3c2dc 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -249,6 +249,8 @@ static unsigned long dentry2offset(struct dentry *dentry) return (unsigned long)dentry->d_fsdata; } +static struct lock_class_key simple_offset_xa_lock; + /** * simple_offset_init - initialize an offset_ctx * @octx: directory offset map to be initialized @@ -257,6 +259,7 @@ static unsigned long dentry2offset(struct dentry *dentry) void simple_offset_init(struct offset_ctx *octx) { xa_init_flags(&octx->xa, XA_FLAGS_ALLOC1); + lockdep_set_class(&octx->xa.xa_lock, &simple_offset_xa_lock); /* 0 is '.', 1 is '..', so always start with offset 2 */ octx->next_offset = 2;