Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp481869rwd; Thu, 1 Jun 2023 03:01:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Ony8gvuegfEY+wXbPSWor1VBzKW9D/pKicuyS7i6+XYqO0FlmQtwWEtpPxko1CrCdrj6R X-Received: by 2002:a17:903:643:b0:1ab:2034:26da with SMTP id kh3-20020a170903064300b001ab203426damr7096384plb.51.1685613661418; Thu, 01 Jun 2023 03:01:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685613661; cv=none; d=google.com; s=arc-20160816; b=z059nFreojBmaNG3r+vb4AEID25+54Ehx3TWmlnl/uu5XW/6T2gjBMMMG3Dgn000WW 4J0m5WVuFSKvaZ0UxR8YHJas3S0DVM2BCz/Fvk02BKg8dsSdLQ7v/ESDRp2/8lBYAqC+ npJbFe8LcPutWZggRk3KaRJsk4U6fwo/Nl0/pDZTtonJibjc+C7DY0TAw22W6fiqovMy FreS+rz6lvfPCXf6GoWIrnVjcN+AsNNXVgrsc2t4j3Nzs21SOZkPZ7SMgq1gnCPVb4o3 K7v5C1fuy3zowo0JW4lULEeZx3OnaiLZb+p8si6VLEDVQ2XIehn1sRTI+SSYOc2nRD3S UfoQ== 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=NOQzwbL33F5g9uq8mtfCJhkqhOeA6C9oVQgCEDSv2GY=; b=Oa1mxITU9tV1HjuUnCZ7rWUuEgjS8OU2Kc6l2fv9pXcyWQX9p1d2McaDrcY3FyqV0/ PjprwVGP0E/lg1HDOf3kNxis2ITPBd8D+49Dc7bWd8EEQmWNER6rjos/E8By89eLxEUb tYzmc2U5Tk8mOu1tRh+08H4dyIpLjmAdQN/wRkeIg7IwTjsBsMJTu5GKpZT4fBc1j0oS uOEHpt85qzIA0azDlhKpu+pEMvq+V60bTfizcZa6HZFz5au3A6/ONWFOt1X5UDpHkswg Jahklorb++CD4Q8Oc4Y2wh29/pER04T4410z37fYHv+Xej3BYBkak2DPp/TFTn0+Jw2a Fkyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Hw085gAQ; 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 e3-20020a170902b78300b001a97fd670d5si1363905pls.367.2023.06.01.03.00.38; Thu, 01 Jun 2023 03:01:01 -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=Hw085gAQ; 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 S231529AbjFAJuV (ORCPT + 99 others); Thu, 1 Jun 2023 05:50:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232339AbjFAJuL (ORCPT ); Thu, 1 Jun 2023 05:50:11 -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 4BD5A95; Thu, 1 Jun 2023 02:50:10 -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 D43756425C; Thu, 1 Jun 2023 09:50:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7162C433EF; Thu, 1 Jun 2023 09:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685613009; bh=fUFnP8JClGnkC9Vy2F7MOXl5BeYzlX+HFhd4pvaRKEY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Hw085gAQLoUmZavmnB+3G/SMg5IaFloQgLLlbOstLecC/Fu3S/lz7yXW31YFirolX S/1RtdLNWznxI8Fwb+T1hELUWKQciw6y7RnT+qNt7APCDD2YDzXlKS5NReVgI0GaqI 8kDRekd5510mPBJ6FzrhdxyuOhW3uChD8gX9B82v31SB50XVD2mhPdlVFwq9glSH6L S3q+TWbVA5o9L400RNtiznTZ5cBdHWjpq+J7dCD0wOcxIbSKw1DyWjgbO+2c0jeruV xHYuEvsnQGhD/5aMf5O4u9WRSadRMQx5Nf17fK2hF1AmcsFs3n+iiisksQESTiV+zt ax2QzrDwZIZ6g== Date: Thu, 1 Jun 2023 11:49:59 +0200 From: Christian Brauner To: chenzhiyin Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, nanhai.zou@intel.com, Dave Chinner Subject: Re: [PATCH] fs.h: Optimize file struct to prevent false sharing Message-ID: <20230601-pelle-gemustert-4ba4b700c3db@brauner> References: <20230531-wahlkabine-unantastbar-9f73a13262c0@brauner> <20230601092400.27162-1-zhiyin.chen@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230601092400.27162-1-zhiyin.chen@intel.com> 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 Thu, Jun 01, 2023 at 05:24:00AM -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. > Due to '__randomize_layout' attribute of file struct, the updated layout > only can be effective when CONFIG_RANDSTRUCT_NONE is 'y'. > > The optimization has been validated in the syscall test of UnixBench. > performance gain is 30~50%. Furthermore, to confirm the optimization > effectiveness on the other codes path, the results of fsdisk, fsbuffer > and fstime are also shown. > > Here are the detailed test results of unixbench. > > Command: numactl -C 3-18 ./Run -c 16 syscall fsbuffer fstime fsdisk > > Without Patch > ------------------------------------------------------------------------ > File Copy 1024 bufsize 2000 maxblocks 875052.1 KBps (30.0 s, 2 samples) > File Copy 256 bufsize 500 maxblocks 235484.0 KBps (30.0 s, 2 samples) > File Copy 4096 bufsize 8000 maxblocks 2815153.5 KBps (30.0 s, 2 samples) > System Call Overhead 5772268.3 lps (10.0 s, 7 samples) > > System Benchmarks Partial Index BASELINE RESULT INDEX > File Copy 1024 bufsize 2000 maxblocks 3960.0 875052.1 2209.7 > File Copy 256 bufsize 500 maxblocks 1655.0 235484.0 1422.9 > File Copy 4096 bufsize 8000 maxblocks 5800.0 2815153.5 4853.7 > System Call Overhead 15000.0 5772268.3 3848.2 > ======== > System Benchmarks Index Score (Partial Only) 2768.3 > > With Patch > ------------------------------------------------------------------------ > File Copy 1024 bufsize 2000 maxblocks 1009977.2 KBps (30.0 s, 2 samples) > File Copy 256 bufsize 500 maxblocks 264765.9 KBps (30.0 s, 2 samples) > File Copy 4096 bufsize 8000 maxblocks 3052236.0 KBps (30.0 s, 2 samples) > System Call Overhead 8237404.4 lps (10.0 s, 7 samples) > > System Benchmarks Partial Index BASELINE RESULT INDEX > File Copy 1024 bufsize 2000 maxblocks 3960.0 1009977.2 2550.4 > File Copy 256 bufsize 500 maxblocks 1655.0 264765.9 1599.8 > File Copy 4096 bufsize 8000 maxblocks 5800.0 3052236.0 5262.5 > System Call Overhead 15000.0 8237404.4 5491.6 > ======== > System Benchmarks Index Score (Partial Only) 3295.3 > > Signed-off-by: chenzhiyin > --- Dave had some more concerns and perf analysis requests for this. So this will be put on hold until these are addressed.