Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp359648pxa; Fri, 21 Aug 2020 09:04:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFKtGJ+61rUBlmG5BHgRpDr0P11NYtbSqC1t0WNsEKQt6NHmI09xXh9DL3+1t2OwG1Iyd1 X-Received: by 2002:a17:906:403:: with SMTP id d3mr3517707eja.522.1598025876595; Fri, 21 Aug 2020 09:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598025876; cv=none; d=google.com; s=arc-20160816; b=RG5TR3WU1wFBip+9863SGTVv9ceAM5EMW/2oUG313W1bhOyDi2saKLjrfkglKrff8M uQ+LQDwm1zpU95vPdvz1bHYfjOkw4QeEkWpcxiNgkbP0DrEMVsxn9q9aMPfUBAaQ08fU DBFDpzvDO8RFfR639krPqhRjaMh9R15Y9fSC3hj0jSUVrG80MHXGKKka0hwWQsas1dFM aSrwqkk0wHzPmhuF+6QiAZHUm8FrigfSJu9rT3DYyrxkuhICqyWfvAIugyiXaabWnQzM NqFhai/1fyjvYxOhneIk2++lmVEv48HnIZX6HXsDyTsIybZfsevqfLw7Rj98SrjtN6po qM2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vjhGKiWEeqBNtRqVwdb8FwLYszPdziZP7n9ch0hxii8=; b=aipIqqFKAUUAZ8Mb+F5n5LF90HVbDkKHAnu8IoQUaplGjqArxPg8rvIrqlKOj9xSIH 7eFzzeUMD+WGck96oM1AHPltnvnGIW37xFPZ/OoRcYDASPQdrGithTMy91rwiV3UmxkS qhX1d1YdS7NqB55Tf5L3U0B0pidQYd+AS6eTWRP3TIQx1tpFSJ7VIHl0niYzlFpjNAu/ uavxH8LrVpI+t9In4CBOZNhWnHYtidrIKvRXGpebUi8dHACevuhmIWHXwnshXuHlAjdh U+tRnGRn2LXlga6orFPvX85qG29CrnkvdMrS90HoiHuH2jHLWeG5yOP4mkWnbh7ggZEs gd2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ImovsCZr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si1438567edb.556.2020.08.21.09.04.12; Fri, 21 Aug 2020 09:04:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ImovsCZr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726820AbgHUQDH (ORCPT + 99 others); Fri, 21 Aug 2020 12:03:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:35600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbgHUQC6 (ORCPT ); Fri, 21 Aug 2020 12:02:58 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 363A7207BB; Fri, 21 Aug 2020 16:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598025777; bh=EV/GR+9VB23wO4HYAr+8yBHz5vSm7Ev/KRXR37JYI2g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ImovsCZrJ/tdgS2ncCQiTS/L8yCwYE9ohFeJBAvirJKdRqeaxw8/m9aRr5h2sGaHC XgEWMfxB3M1PQKRQRdjLE03otqTFiLJPx5bVVQi35AAXT1D6p1YlIv8iZWEuFzqiAP FPJxlahOObcq2GKrNbYshgjpdDJ/xEuoFZEgWaJk= Date: Fri, 21 Aug 2020 17:02:53 +0100 From: Will Deacon To: Shaokun Zhang Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Rutland , Peter Zijlstra , Alexander Viro , Boqun Feng , Yuqi Jin Subject: Re: [PATCH RESEND] fs: Move @f_count to different cacheline with @f_mode Message-ID: <20200821160252.GC21517@willie-the-truck> References: <1592987548-8653-1-git-send-email-zhangshaokun@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1592987548-8653-1-git-send-email-zhangshaokun@hisilicon.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 24, 2020 at 04:32:28PM +0800, Shaokun Zhang wrote: > get_file_rcu_many, which is called by __fget_files, has used > atomic_try_cmpxchg now and it can reduce the access number of the global > variable to improve the performance of atomic instruction compared with > atomic_cmpxchg. > > __fget_files does check the @f_mode with mask variable and will do some > atomic operations on @f_count, but both are on the same cacheline. > Many CPU cores do file access and it will cause much conflicts on @f_count. > If we could make the two members into different cachelines, it shall relax > the siutations. > > We have tested this on ARM64 and X86, the result is as follows: > Syscall of unixbench has been run on Huawei Kunpeng920 with this patch: > 24 x System Call Overhead 1 > > System Call Overhead 3160841.4 lps (10.0 s, 1 samples) > > System Benchmarks Partial Index BASELINE RESULT INDEX > System Call Overhead 15000.0 3160841.4 2107.2 > ======== > System Benchmarks Index Score (Partial Only) 2107.2 > > Without this patch: > 24 x System Call Overhead 1 > > System Call Overhead 2222456.0 lps (10.0 s, 1 samples) > > System Benchmarks Partial Index BASELINE RESULT INDEX > System Call Overhead 15000.0 2222456.0 1481.6 > ======== > System Benchmarks Index Score (Partial Only) 1481.6 > > And on Intel 6248 platform with this patch: > 40 CPUs in system; running 24 parallel copies of tests > > System Call Overhead 4288509.1 lps (10.0 s, 1 samples) > > System Benchmarks Partial Index BASELINE RESULT INDEX > System Call Overhead 15000.0 4288509.1 2859.0 > ======== > System Benchmarks Index Score (Partial Only) 2859.0 > > Without this patch: > 40 CPUs in system; running 24 parallel copies of tests > > System Call Overhead 3666313.0 lps (10.0 s, 1 samples) > > System Benchmarks Partial Index BASELINE RESULT INDEX > System Call Overhead 15000.0 3666313.0 2444.2 > ======== > System Benchmarks Index Score (Partial Only) 2444.2 > > Cc: Will Deacon > Cc: Mark Rutland > Cc: Peter Zijlstra > Cc: Alexander Viro > Cc: Boqun Feng > Signed-off-by: Yuqi Jin > Signed-off-by: Shaokun Zhang > --- > include/linux/fs.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 3f881a892ea7..0faeab5622fb 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -955,7 +955,6 @@ struct file { > */ > spinlock_t f_lock; > enum rw_hint f_write_hint; > - atomic_long_t f_count; > unsigned int f_flags; > fmode_t f_mode; > struct mutex f_pos_lock; > @@ -979,6 +978,7 @@ struct file { > struct address_space *f_mapping; > errseq_t f_wb_err; > errseq_t f_sb_err; /* for syncfs */ > + atomic_long_t f_count; > } __randomize_layout > __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */ Hmm. So the microbenchmark numbers look lovely, but: - What impact does it actually have for real workloads? - How do we avoid regressing performance by innocently changing the struct again later on? - This thing is tagged with __randomize_layout, so it doesn't help anybody using that crazy plugin - What about all the other atomics and locks that share cachelines? Will