From patchwork Thu Jan 25 14:59:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13531074 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6C4A3C48286 for ; Thu, 25 Jan 2024 15:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=IdR+8wqZwP9hJkD1ffOlQ7bP5MSzY1OSHbIeCTozUGQ=; b=LspPwlfEExyxTy F43H8pR8v/MiZmGoLgwy0Py5U+1/7VwUnwxKWxvjLlfsXAxdAR/62FWi1QXpRei47AobwQg3EVqxE IHOI+BeOG8ZS/sUcMKCeLLfS299IblHHSUxujJQqTdnTbTlW7Wem4w8zk5n3oizyGAL7H0bl9RbxU gn09jgPrhue1XeST7bXL0EnupIbHlsSa4oqrPo2FXEuO9pvqTSNZV4NexXJ+Oapa3GtVDAdDcrKCu vJWPaWykdENP6UiXsMd3Qkw/GXqQB5NDo1LPUi/Wj/9ZgNSmGotIVkVlEik/Jcdj1N2WUU3CkIYTR q+RLa3aX27gcITzvGK2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT1Od-00000000YfC-37AI; Thu, 25 Jan 2024 15:12:03 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT1OZ-00000000YcP-1w2I for linux-riscv@lists.infradead.org; Thu, 25 Jan 2024 15:12:01 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 95DB1CE33BD; Thu, 25 Jan 2024 15:11:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4302C433B1; Thu, 25 Jan 2024 15:11:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706195516; bh=qqT5s5v8kHRYnSn/7vdNCIRU1OWwV2sCCtz6w1JM1Uc=; h=From:To:Cc:Subject:Date:From; b=Tue9wRNhjMqZFzK9146TlHqSh0uS3ptUAk+FbgZLPMoo5orbTE+F/5izGNNkfxOnL cSpfL9FJ7/q3eNwQhDZTh4C7UzTy5Rz2tGw84k3NlUHq0VtjAYRNS9NwXMWGgy6cBA 8Mv4z7gyOxW46+SAVZYb41ehlqkVFEqWK0AFEJLuq2QgX4+kDMfe45s5i9yfEa4dIF 6asoOd75OLoQXMMJQOhKt0DuCwVCycuNQgR2CaArJsLts1byjJ9bfGhbD+XTnLs5Ui zUJ8G/U2/VczZsQR+2qtSouhJn5K68Wty5B84vIVtkJbwdGsPq2SSkHIZvCWZgWfax PMXyVsmyAsroA== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/2] riscv: enable lockless lockref implementation Date: Thu, 25 Jan 2024 22:59:05 +0800 Message-ID: <20240125145908.968-1-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240125_071159_730438_0B3CDBE9 X-CRM114-Status: UNSURE ( 7.40 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This series selects ARCH_USE_CMPXCHG_LOCKREF to enable the cmpxchg-based lockless lockref implementation for riscv. Then, implement arch_cmpxchg64_{relaxed|acquire|release}. After patch1: Using Linus' test case[1] on TH1520 platform, I see a 11.2% improvement. On JH7110 platform, I see 12.0% improvement. After patch2: on both TH1520 and JH7110 platforms, I didn't see obvious performance improvement with Linus' test case [1]. IMHO, this may be related with the fence and lr.d/sc.d hw implementations. In theory, lr/sc without fence could give performance improvement over lr/sc plus fence, so add the code here to leave performance improvement room on newer HW platforms. Link: http://marc.info/?l=linux-fsdevel&m=137782380714721&w=4 [1] Since v2: - rebase on v6.8-rc1 - collect Reviewed-by tag Since v1: - only select ARCH_USE_CMPXCHG_LOCKREF if 64BIT Jisheng Zhang (2): riscv: select ARCH_USE_CMPXCHG_LOCKREF riscv: cmpxchg: implement arch_cmpxchg64_{relaxed|acquire|release} arch/riscv/Kconfig | 1 + arch/riscv/include/asm/cmpxchg.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+)