Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3459831pxa; Wed, 26 Aug 2020 00:25:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6DAt/hG3uPF7bRbvkf4O1FVIhUONBPkn86uscaTzw5eXh39+h/YhpNXEKr0sFQE2jjp1u X-Received: by 2002:a17:906:29cc:: with SMTP id y12mr14336048eje.212.1598426754827; Wed, 26 Aug 2020 00:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598426754; cv=none; d=google.com; s=arc-20160816; b=ff6KA56A9vjvLrtz2TJEIXvrxuZGf4oDtTjswLeV5tz5PXFxiD+y8d7mQxLP6at9nu 3199tMR0xuBWcbC1DeFs8mbHV9BlGqzBuobl4m1M/MkL9V+Te/tgpPpfsJAyL1n6MYvn 5EBF8xnV8XJeck+J8q6rw7D4Cy380sk1xfCGgSCHJC/G+iVVETPphiybmLcXsKZg5+jk znxzy+a79ugaPSxgmCa8d5es3dTVjEdcZLTUCxZM//7CG7FTWFeOjfJQ0EHhRjXFu14h fVrH6OwyVeYInF6edHCBaIfyrz70356Pn9BfHB1xpTeMyxEvv+CX2yz0fgFXc+6Znxaw TvoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=LB6spfrF4go3IY7iCSUb3LhlXy4I2BW6wXyiGZ0v4EY=; b=b7GMKtaYIlgLHoe67qSPTIrbz6uywwtpZNcA+aV6GDdWgVJ7JQAIQv/V/PcidhDUTl b7bn2Bzvgy//qGyAqyDJ9LZNlEdGlv6NLGrwAOELJhyPdAeQKYkh/GKRtyxMy54UVVwE clcT1i03adBj8djqOIsPmRNDYtxB+Tg6FS3Qlj0D+SPPTUYhO/ozZuNFjU6t749GGZMS wixrxDBhbp5YB85inE0YO2QNWjfGbwqZJ2l5/Gh9ffNZPAAqd7LarxT4ZZ/tC19IyHez A57TaSLyjUjmatqu1VQh2WZgT6yPlX/cq7qy01hiyMzOghAV/xOdeBdV0NpnIXsIZgwJ e7NQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g19si895986edp.601.2020.08.26.00.25.31; Wed, 26 Aug 2020 00:25:54 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726718AbgHZHYz (ORCPT + 99 others); Wed, 26 Aug 2020 03:24:55 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:54362 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726233AbgHZHYz (ORCPT ); Wed, 26 Aug 2020 03:24:55 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 02F4CECA6B47EDD70B14; Wed, 26 Aug 2020 15:24:50 +0800 (CST) Received: from [127.0.0.1] (10.67.76.251) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Wed, 26 Aug 2020 15:24:43 +0800 Subject: Re: [PATCH RESEND] fs: Move @f_count to different cacheline with @f_mode To: Will Deacon CC: , , "Mark Rutland" , Peter Zijlstra , Alexander Viro , Boqun Feng , Yuqi Jin References: <1592987548-8653-1-git-send-email-zhangshaokun@hisilicon.com> <20200821160252.GC21517@willie-the-truck> From: Shaokun Zhang Message-ID: Date: Wed, 26 Aug 2020 15:24:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <20200821160252.GC21517@willie-the-truck> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.76.251] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Will?? ?? 2020/8/22 0:02, Will Deacon ะด??: > 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: Thanks, > > - What impact does it actually have for real workloads? It is exposed by we do the unixbench test. About the real workloads, if it has many threads and open the same file, it shall be useful like unixbench. If not the scenes, it should not be regression with the patch because we only change the poistion of @f_count with @f_mode. > - How do we avoid regressing performance by innocently changing the struct > again later on? It shall be commented this change on the @f_count, I'm not sure it is enough. > - This thing is tagged with __randomize_layout, so it doesn't help anybody > using that crazy plugin This patch isolated the @f_count with @f_mode absolutely and we don't care the base address of the structure, or I may miss something what you said. > - What about all the other atomics and locks that share cachelines? An interesting question, to be honest, about this issue, we did performance profile using unixbench and found it, then we want to relax the conflicts. For other scenes, this method may be useful if it is debugged by the same conflicts, but it can't be detected automatically. Thanks, Shaokun > > Will > > . >