Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1352086ybz; Wed, 29 Apr 2020 20:31:01 -0700 (PDT) X-Google-Smtp-Source: APiQypLIXmIHI3K2bTxqXwUffz8bNEP6mSETU59YdxnjgjxBQN01rmBJxgWEeVU5hsiSTcMnMxDN X-Received: by 2002:a05:6402:22ed:: with SMTP id dn13mr884299edb.212.1588217461202; Wed, 29 Apr 2020 20:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588217461; cv=none; d=google.com; s=arc-20160816; b=i8sPwX6wD9Nsv5Orxuf1nz0BmthclF5dd46BD2oI7ZdKZej/h/uNesBKhZ+MtlQyol uBDsZgam0ge/iH4N6E65IfL3z2fokrXVXnlf1NRwdqawjEpMSuf+5im7BzmxflHDaTB3 cBaEd0kR63rVLlGUfTbtnG/e7esiBMmOw87rvH6we/yfrKTXDzYDDM/qX0b43/DZMsNa +zOGGeVZokSYQrJAHdJtPKI9rmvWVJo6JRs8etQ2MOeGD5RHm8a8yadXOSoTwWjDpglB chDXlTPrkwqIdvpeEopGATBf4HuL45WV5auxQ7eBcSg2FK9r+VLyd/0os4I12HaM+x70 TRzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=Sk7NRbW9qM3JTri2Qpy2bkfR5cNoFuA1iv6UuXtSAKQ=; b=up3xr/fm3SH6QhV64ZB9ToTtYPaVBOoI024pQsFH40pBIioKBBHnmtmZICAe8sc5iq S/AnM9TY1e/yJrZUkyh4MAUm30+flHjWV/ZY4t0d8+AxcKVgssnKxRoOXuNGUW8IpWn7 OxRsNl6NP0jnEeRjl04YzyiAbTaskGrauBz9Qz/ErWffQYx1aE5Olkx+fn1hPhySUIGt sWl5kId/4W2osdqPieLO4CE9FdBvtoIuL2632NGHMzDhuqyWrhrvDwO1slIS35X6pOM0 ibL+MKOVkCSmeSNCROBzGRTWJKn9KDUsEeCKImZ5XR1pShbvuMxuyFPnRLBS3jcwEcWG WCZQ== 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 q10si4563902edr.310.2020.04.29.20.30.36; Wed, 29 Apr 2020 20:31:01 -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 S1726577AbgD3D0p (ORCPT + 99 others); Wed, 29 Apr 2020 23:26:45 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:50886 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726309AbgD3D0o (ORCPT ); Wed, 29 Apr 2020 23:26:44 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id EDB4D33C49F59BC82B6E; Thu, 30 Apr 2020 11:26:41 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Thu, 30 Apr 2020 11:26:32 +0800 From: Shaokun Zhang To: , CC: Yuqi Jin , Alexander Viro , Shaokun Zhang Subject: [RFC PATCH] fs: Move @f_count to different cacheline with @f_mode Date: Thu, 30 Apr 2020 11:25:32 +0800 Message-ID: <1588217132-41242-1-git-send-email-zhangshaokun@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yuqi Jin __fget_files does check the @f_mode with mask variable and will do some atomic operations on @f_count while 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: Alexander Viro 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 4f6f59b4f22a..90e76283f0fd 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -953,7 +953,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; @@ -976,6 +975,7 @@ struct file { #endif /* #ifdef CONFIG_EPOLL */ struct address_space *f_mapping; errseq_t f_wb_err; + atomic_long_t f_count; } __randomize_layout __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */ -- 2.7.4