Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp518248rwd; Wed, 31 May 2023 01:23:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LoUyquXEQIN6056OVF2s795DfD50Zoxq4mjC1Pmo/jCN8nYwvPeBjIxUnz3yO7LlLhT8R X-Received: by 2002:a05:6a20:4425:b0:101:1b94:31c1 with SMTP id ce37-20020a056a20442500b001011b9431c1mr6418643pzb.42.1685521380178; Wed, 31 May 2023 01:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685521380; cv=none; d=google.com; s=arc-20160816; b=wU+a9p476LWDhgl4yTWAu4jYy1I96xLVHDz7qDFTl440u1WpgvaBWqg3dBk3tec/Qj HSwcDi4+sBYuso+qWfoYoxB9e29yxsfePEq+9tSRsAoI8cJFEdmB9i77n/NU+hFXyTe2 MEiqFfr8Qghr2IfwJaRVJwWnK0XrYHdNGQDZt7+ZbRdy7qprYLy+TAzviLZo/2ma1SKa OCazFRyPuqzYMXL7z1ccUKcRoJEvzSfv4nq5YtspUEI9AVCqKCSutM1VW7wwlFxmmVGy gNZqol5h4SvkkkJqCYxDIZOrfOsU3DVt7XBrRCCk7HD4JWpNH0Sp9HB4mJaIZ4aFYVhi sVsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ArMOPQJTwIzM3jwJdOjOqqyCUO20DVW8WZXS/VJEvjE=; b=BHuZw/YOOjimrKH6YFf0ISbFkJ6uO3pYIOrOcFz60T+YWrclvhfLy74VXUK7Kgwq0b ecGtylMoliZs4137Mht51kO5m2glR2syI3N1GfKb8i0yYZSF7+OdUjVXMz2MH6E1L4X6 WxcCXzURIr4tnnl97BNqoWNS1LAjRupkqWJ7bGzf9mtu3wGXXTZPnub4kIQYjx0Hf0Fd kCs36kopPun/+kC3GtubQXGkh1mQIGmNTb1NjgvD1ywIy4nriJbSl4bdCD4N6nmVkVUw soYXST8J/jxz2wtwp5KLmCCHA7d1wYqnkGpIcdjkGkVSM/Puyt1eo3p59d47LfH3lF43 Waow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JMTHL3iG; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a22-20020a637f16000000b0050f6925a400si584355pgd.589.2023.05.31.01.22.47; Wed, 31 May 2023 01:23:00 -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=@kernel.org header.s=k20201202 header.b=JMTHL3iG; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234886AbjEaH4g (ORCPT + 99 others); Wed, 31 May 2023 03:56:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234817AbjEaH4T (ORCPT ); Wed, 31 May 2023 03:56:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6217013E; Wed, 31 May 2023 00:55:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D8D976358E; Wed, 31 May 2023 07:55:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD816C433D2; Wed, 31 May 2023 07:55:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685519702; bh=oQMKNQRLgA4ZCsezODjVAhD2XTTy3QKxeBK/2FUHClA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JMTHL3iGQTevlNsUjFG/8KGtglQhrdKh6TRlgrmvzMOHQPY9mKf0JOG/zVfvv7+9Q jVbAkp4UynX6IRnhAiDmkFsb1fuQGoBlE7jJyxPfK5PBXdUCnrL3i5uQy4tQ5fKXuu byQ8n/xuaf3R1YT0SdxbARajYAP0DCGDx5BvPuCB/e6ZeQuBnHVD+YChxLpDYyXB3D 2IMMOUSiVENkZLvH+88IqnkLH9/rneFOeIumHYMl8WQK6lGb0Ii2GF3hLmMWNhH2Da fyT1iRADU425l5/Je1TouTGgF74IWW1SVYLBkxWT/yRBNjbRCyzZp/BaIUeOtCXay9 GqpqUHz5UVXFw== Date: Wed, 31 May 2023 09:54:57 +0200 From: Christian Brauner To: Eric Biggers Cc: chenzhiyin , viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, nanhai.zou@intel.com Subject: Re: [PATCH] fs.h: Optimize file struct to prevent false sharing Message-ID: <20230531-wahlkabine-unantastbar-9f73a13262c0@brauner> References: <20230530020626.186192-1-zhiyin.chen@intel.com> <20230530-wortbruch-extra-88399a74392e@brauner> <20230531015549.GA1648@quark.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230531015549.GA1648@quark.localdomain> X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Tue, May 30, 2023 at 06:55:49PM -0700, Eric Biggers wrote: > On Tue, May 30, 2023 at 10:50:42AM +0200, Christian Brauner wrote: > > On Mon, May 29, 2023 at 10:06:26PM -0400, chenzhiyin wrote: > > > In the syscall test of UnixBench, performance regression occurred > > > due to false sharing. > > > > > > The lock and atomic members, including file::f_lock, file::f_count > > > and file::f_pos_lock are highly contended and frequently updated > > > in the high-concurrency test scenarios. perf c2c indentified one > > > affected read access, file::f_op. > > > To prevent false sharing, the layout of file struct is changed as > > > following > > > (A) f_lock, f_count and f_pos_lock are put together to share the > > > same cache line. > > > (B) The read mostly members, including f_path, f_inode, f_op are > > > put into a separate cache line. > > > (C) f_mode is put together with f_count, since they are used > > > frequently at the same time. > > > > > > The optimization has been validated in the syscall test of > > > UnixBench. performance gain is 30~50%, when the number of parallel > > > jobs is 16. > > > > > > Signed-off-by: chenzhiyin > > > --- > > > > Sounds interesting, but can we see the actual numbers, please? > > So struct file is marked with __randomize_layout which seems to make > > this whole reordering pointless or at least only useful if the > > structure randomization Kconfig is turned off. Is there any precedence > > to optimizing structures that are marked as randomizable? > > Most people don't use CONFIG_RANDSTRUCT. So it's still worth optimizing struct > layouts for everyone else. Ok, good to know. We should still see actual numbers and the commit message should mention that this interacts with __randomize_layout and why it's still useful.