From patchwork Sat Aug 12 12:37:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Guzik X-Patchwork-Id: 134887 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1705708vqi; Sat, 12 Aug 2023 06:14:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjJffu1Urhe1+KIXQPdLKAPKEhIrdUbcAMslP/bd/Sp52WGMG8W5yTbDjnTLqIq+YSimj8 X-Received: by 2002:a17:906:7491:b0:992:c8d7:b66f with SMTP id e17-20020a170906749100b00992c8d7b66fmr3966921ejl.75.1691846050294; Sat, 12 Aug 2023 06:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691846050; cv=none; d=google.com; s=arc-20160816; b=fO+5QjGTACDIp1xQMaH2snXfl2fh1tE8OAjB3n+R5zGwsfmXW9DDCEmw6SB3Js5LTx wRoy6weir67sNW3Myn9fsXvxGNGnT6fqI3pHh/qCwLxKmh5wwJBghXUJlSjRv6xwqQZy L8SobkmrrXBOJYWas5JNeNk/bzz+dAhfqEuk9z6CObLs/9zp33dhW3UtmO4XfFM6hUO7 xHz9oSa1N2sjk7gJo1MnTYvoC9hFZqAmUo38U5GF7lVVwUb4UUYwqK7j6bF0o4yzXVw3 c1HUepF6gVXsNYGf+l4IUmyLnb3VhFTxreP4pm2SpSzgjO//rVMaMZO4sfJlVO0Oi4UA YSUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=UClbfeDcgLrN9gw9PYVkTWcXPt6ww2x5TRV68gA4hiI=; fh=cIBi9AaxwYvjwpM79gbFOvheXhB2lWjIUWOVRqAAQkc=; b=FBAh+AvVReazcOogjhINWr/V+pk21RLx/iAuNMfVN5GuUrwtw9TQqqSRoj6BUEcfps +DZ1tQebe1QCDBQ2B5stLOLOIiIvro8bey5ILDL21plp2zoZwL3q1cJ8JJjdlqECMCgG slgUeP15n1PgwWuj5z3xy9uCpx8scGmbPLUxmWARKb5OP++malMHISw7g6rSO1P0MKxJ 66sP0NHlS7D7P8UBHL2WGfyfCnr7TMrurSGgpWkbu1Itx188JHWOJsme9eeUf7NWTWgG oWiFjV8f5dxIABUwHaGsxlRq4gexGq/qWNWIKGKe4t2ZCBNefJCOLn1SggtK9qxJX8Wt wKRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mh6Y4ZEZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i17-20020a170906115100b0099cd8eab16csi5038683eja.559.2023.08.12.06.13.46; Sat, 12 Aug 2023 06:14:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mh6Y4ZEZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236795AbjHLMiC (ORCPT + 99 others); Sat, 12 Aug 2023 08:38:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbjHLMiA (ORCPT ); Sat, 12 Aug 2023 08:38:00 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD7A519A3; Sat, 12 Aug 2023 05:38:03 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-99cdb0fd093so396763266b.1; Sat, 12 Aug 2023 05:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691843882; x=1692448682; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UClbfeDcgLrN9gw9PYVkTWcXPt6ww2x5TRV68gA4hiI=; b=mh6Y4ZEZNsyNB3U7m5PslH3Ec3aMSRICP6qsSSA35bJik7XE1bXlzPV4G2IvonEBmL P1vgs5rslx+GlIWKkENxVFFheO/KpA5bNNek4UnkDK/HbpwTubAsf4uai1aH+zpKC/t+ qEvyiBZ/nGp/ZYxgQS5fTv8ZgmHEYOkxpwM/zLYbttCEwhrSg9VEteT1YT2hCm5+z+7K T5VMWnO5NSc9WRa9af7uhl5EVmCa3Pe44axlqza2W9q3iTu6/UOANb1rHMygQYZR/fRI uxT3ltNBVCbqXXiqBzK07TznU5CKKmCtQPYjh49anInv3w/Y+t0pe6MAkc+toCdURrB9 AD5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691843882; x=1692448682; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UClbfeDcgLrN9gw9PYVkTWcXPt6ww2x5TRV68gA4hiI=; b=hauhC2IHEYV6XgBhZZbFME/sUcDFJWOwDt1lREmgmqL4DMxhtgPSysXgzM5NqqGhJt oiwswV/7j+qNFH6xKDMWM+poW4DnM69FBCRhvrjdwQbu1MJmyvckRpo81s2hbvMQl1Wu DNsHWwa95SyMD5zmqNoLwxwsv867lSCqN1B5T8slJKkabLI0eSJTxK/3URY0sYfWHFtB L4zPALu858ZVd6zCGCd97Q7WXwgTeB4ThDUW+tLpqdjpuQeQ+sr7PuLAjNYbhD5IoNH+ OGFm1imsHYVAEllQ8jbh1AZiPVcNCusf/2q+GlHrw00f6D5dUKtBGywI0ATPB1L6TBSX twSg== X-Gm-Message-State: AOJu0YwioOOxDJpdUd5FufGKpBZXRHeZtCws9G7F9Z/Kb5uC2604meFU fu/n2HA6vdUxkTHut53QN2180ZSeEM8= X-Received: by 2002:a17:906:291:b0:99b:efd3:3dcc with SMTP id 17-20020a170906029100b0099befd33dccmr4173224ejf.62.1691843882069; Sat, 12 Aug 2023 05:38:02 -0700 (PDT) Received: from f.. (cst-prg-75-195.cust.vodafone.cz. [46.135.75.195]) by smtp.gmail.com with ESMTPSA id ov14-20020a170906fc0e00b0099290e2c163sm3402567ejb.204.2023.08.12.05.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Aug 2023 05:38:01 -0700 (PDT) From: Mateusz Guzik To: brauner@kernel.org Cc: viro@zeniv.linux.org.uk, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Mateusz Guzik Subject: [PATCH] vfs: remove spin_lock_prefetch(&sb->s_inode_list_lock) from new_inode Date: Sat, 12 Aug 2023 14:37:57 +0200 Message-Id: <20230812123757.1666664-1-mjguzik@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774029163513395963 X-GMAIL-MSGID: 1774029163513395963 It showed up in 2001, in the following commit in a historical repo [1]: commit c37fa164f793735b32aa3f53154ff1a7659e6442 Author: linus1 Date: Thu Aug 16 11:00:00 2001 -0800 v2.4.9.9 -> v2.4.9.10 with a changelog which does not mention it. Since then the line got only touched up to keep compiling. While it may have been of benefit back in the day, it is guaranteed to at best not get in the way in the multicore setting -- as the code performs *a lot* of work between the prefetch and actual lock acquire, any contention means the cacheline is already invalid by the time the routine calls spin_lock(). It adds spurious traffic, for short. On top of it prefetch is notoriously tricky to use for single-threaded purposes, making it questionable from the get go. As such, remove it. I concede upfront I did not see value in benchmarking this change, but I can do it if that is deemed appropriate. Also worth nothing is that this was the only remaining consumer. [1] https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/fs/inode.c?id=c37fa164f793735b32aa3f53154ff1a7659e6442 Signed-off-by: Mateusz Guzik --- fs/inode.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 8fefb69e1f84..67611a360031 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -16,7 +16,6 @@ #include #include #include -#include #include /* for inode_has_buffers */ #include #include @@ -1041,8 +1040,6 @@ struct inode *new_inode(struct super_block *sb) { struct inode *inode; - spin_lock_prefetch(&sb->s_inode_list_lock); - inode = new_inode_pseudo(sb); if (inode) inode_sb_list_add(inode);