Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp735776rdb; Fri, 2 Feb 2024 02:21:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMwpKJMxKPOu/rdkAQAX7e2oXR2pUUn5aNfW1MTn1vIBasP0wdObVL7moq/HJ/Ri1uR6a7 X-Received: by 2002:ac8:7d07:0:b0:42a:b387:a3e with SMTP id g7-20020ac87d07000000b0042ab3870a3emr1637847qtb.54.1706869288790; Fri, 02 Feb 2024 02:21:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706869288; cv=pass; d=google.com; s=arc-20160816; b=Ghqj+3MYYXSHiYBRvc0i62H2l5VkuGC/FgtWX8ceqE35E4yzQH8h01x7p6Bt6nJ8X3 7qFJUcArutp/veeIxgV8EEh1ZhF71003KNeHRT4LTJQAZJcAk0dly/MR7TFEDrYxh4iW o+9WGK9ecEFnEDJR2frNDHMcU4kBmPghwkN3+uRYWcsy15IAYxqfJEZImdkVt4RZ48J8 U73oeLCKaIQnE+0xyfxlWw82VNj/u1VS74YbZQDRzKI7hBH7uL0jqooITDColLvAgrdy ZrT5KXqK1VBuvzdoq2KbsR0lC1w2lC5jckL213Uo3CDDKKRKmjkemTs3pWwRuS3P3OAl cEWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=rHUubjG2+ljwApBZ6hDABkV98m7Hw2FnF726tLOciYE=; fh=0LvdioxDQ7O1bbwVVGrQOG4VcI4AnoM/16XTG1Tme3c=; b=MLiae/Ub8qhAn13MNd3Hmag6SGQy87YtqmuJSCU7aPvMszacSEqG5zE12DWuxaFqm0 ZYemIUFUYc/XPbwNeH6SeDuZzqIwtsUuOYZMuxiyj/B46qLXzGXhCNTFo5aecha2Hvby nUWMCGUnA60nGEFJKVbGXSt3wM0aNpfqxkV70vpY13XUQgdCy8mG74keoZrZs7FMK6ii XrQHntLIsXq9tsxL0WVLmdmH24ruGfyhFq0miWQa3of01cDsONU9Kw+H58M+X+YVZW8w 4uhCw+GkYT9S0k4rd6Chm+FBy6nV0SceFnBLGl5R7XW7w6FfB4udtAzR70WvclKp+erJ h5fA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eXpydKss; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49666-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49666-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXjYkiMC3q6YzFLXzlwX1nTcdSqxRgJO1G0oZzZfQ7iX+oIcNADXtC+ZuRHem/Aol31dRsdTzKDsPuUBpq/VNFSJ2OIrVucJGmCWUde8Q== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n17-20020a05622a041100b0042aaa53f36dsi1662662qtx.573.2024.02.02.02.21.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 02:21:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49666-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eXpydKss; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49666-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49666-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 417E01C23AEF for ; Fri, 2 Feb 2024 10:20:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C87517E580; Fri, 2 Feb 2024 10:18:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eXpydKss" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B62B97E566; Fri, 2 Feb 2024 10:18:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706869127; cv=none; b=kAqNBCf/YXawmCc3TW6sjM5POOnSST9FqssY1l5DQ9US6EIJ42wNNPUiBI0JQbz3m/wPizyhfzIizIFnL2L+ztcIjjUfj5WXDncE4vWtubWnkg/Y9ykznHQpyaDVE5T/j05O7FfxAVI0jfxafL01rAl70Ew1Sk4AL7nCpIm8RD0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706869127; c=relaxed/simple; bh=Yd0a+ZftwyTSvlXWR+7CaTgcZSKrnc27VqQo89TiJJM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fXc6kNq+EMn9MNhkolgabk6SbWpUa5yV5/azfJBbhpOwU1Szj2eBHvtTVjVyKpWS99ATkmkVGfNRZSwPCMkVMhtYf4QgmyPVZ5nBDd4rdJg3dQVE5dbHAVO1fqf7a6XSmFd9Pozfn5ASWQ2opfRye+waPH27OthGcwK2Qlin128= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eXpydKss; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9D0EC433C7; Fri, 2 Feb 2024 10:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706869127; bh=Yd0a+ZftwyTSvlXWR+7CaTgcZSKrnc27VqQo89TiJJM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eXpydKss+cXyo54ANmjEsyHUZese9myseD6Et1zIfD/9lfc5ho81DAwNz4ALSUmlC IzgvysWWg7TfYlTq0s2jTmoPsyzrsaUkkADtmThC7O4cxUx69jWiltz8Zm9xMNE1AO xF9mSKZ+X+WCsC61LRWDW7dZirMb+PFfYYU5Gu7OZ1UsnH2pw2p2wHf/4A3hAucLN7 QI4FdBirlBBQbASj9aePqMVq6vossStgbx9+8B5KKi/bMAKNsFW7ZEwxemdy69apvB jf/vmQ6K/HJex3AJKYuWku4kClGVYCiTl6PNCd5OpCx/1nOBA+T8c90n+halAry8Rk b/6HuiMy9ilnQ== Date: Fri, 2 Feb 2024 11:18:41 +0100 From: Christian Brauner To: Matthew Wilcox Cc: viro@zeniv.linux.org.uk, jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, CobeChen@zhaoxin.com, LouisQi@zhaoxin.com, JonasZhou@zhaoxin.com, JonasZhou-oc Subject: Re: [PATCH] fs/address_space: move i_mmap_rwsem to mitigate a false sharing with i_mmap. Message-ID: <20240202-erdacht-bereuen-825309cf8c78@brauner> References: <20240202093407.12536-1-JonasZhou-oc@zhaoxin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240202093407.12536-1-JonasZhou-oc@zhaoxin.com> [That needs a review from Willy.] On Fri, Feb 02, 2024 at 05:34:07PM +0800, JonasZhou-oc wrote: > In the struct address_space, there is a 32-byte gap between i_mmap > and i_mmap_rwsem. Due to the alignment of struct address_space > variables to 8 bytes, in certain situations, i_mmap and > i_mmap_rwsem may end up in the same CACHE line. > > While running Unixbench/execl, we observe high false sharing issues > when accessing i_mmap against i_mmap_rwsem. We move i_mmap_rwsem > after i_private_list, ensuring a 64-byte gap between i_mmap and > i_mmap_rwsem. > > For Intel Silver machines (2 sockets) using kernel v6.8 rc-2, the > score of Unixbench/execl improves by ~3.94%, and the score of > Unixbench/shell improves by ~3.26%. > > Baseline: > ------------------------------------------------------------- > 162 546 748 11374 21 0xffff92e266af90c0 > ------------------------------------------------------------- > 46.89% 44.65% 0.00% 0.00% 0x0 1 1 0xffffffff86d5fb96 460 258 271 1069 32 [k] __handle_mm_fault [kernel.vmlinux] memory.c:2940 0 1 > 4.21% 4.41% 0.00% 0.00% 0x4 1 1 0xffffffff86d0ed54 473 311 288 95 28 [k] filemap_read [kernel.vmlinux] atomic.h:23 0 1 > 0.00% 0.00% 0.04% 4.76% 0x8 1 1 0xffffffff86d4bcf1 0 0 0 5 4 [k] vma_interval_tree_remove [kernel.vmlinux] rbtree_augmented.h:204 0 1 > 6.41% 6.02% 0.00% 0.00% 0x8 1 1 0xffffffff86d4ba85 411 271 339 210 32 [k] vma_interval_tree_insert [kernel.vmlinux] interval_tree.c:23 0 1 > 0.00% 0.00% 0.47% 95.24% 0x10 1 1 0xffffffff86d4bd34 0 0 0 74 32 [k] vma_interval_tree_remove [kernel.vmlinux] rbtree_augmented.h:339 0 1 > 0.37% 0.13% 0.00% 0.00% 0x10 1 1 0xffffffff86d4bb4f 328 212 380 7 5 [k] vma_interval_tree_remove [kernel.vmlinux] rbtree_augmented.h:338 0 1 > 5.13% 5.08% 0.00% 0.00% 0x10 1 1 0xffffffff86d4bb4b 416 255 357 197 32 [k] vma_interval_tree_remove [kernel.vmlinux] rbtree_augmented.h:338 0 1 > 1.10% 0.53% 0.00% 0.00% 0x28 1 1 0xffffffff86e06eb8 395 228 351 24 14 [k] do_dentry_open [kernel.vmlinux] open.c:966 0 1 > 1.10% 2.14% 57.07% 0.00% 0x38 1 1 0xffffffff878c9225 1364 792 462 7003 32 [k] down_write [kernel.vmlinux] atomic64_64.h:109 0 1 > 0.00% 0.00% 0.01% 0.00% 0x38 1 1 0xffffffff878c8e75 0 0 252 3 2 [k] rwsem_down_write_slowpath [kernel.vmlinux] atomic64_64.h:109 0 1 > 0.00% 0.13% 0.00% 0.00% 0x38 1 1 0xffffffff878c8e23 0 596 63 2 2 [k] rwsem_down_write_slowpath [kernel.vmlinux] atomic64_64.h:15 0 1 > 2.38% 2.94% 6.53% 0.00% 0x38 1 1 0xffffffff878c8ccb 1150 818 570 1197 32 [k] rwsem_down_write_slowpath [kernel.vmlinux] atomic64_64.h:109 0 1 > 30.59% 32.22% 0.00% 0.00% 0x38 1 1 0xffffffff878c8cb4 423 251 380 648 32 [k] rwsem_down_write_slowpath [kernel.vmlinux] atomic64_64.h:15 0 1 > 1.83% 1.74% 35.88% 0.00% 0x38 1 1 0xffffffff86b4f833 1217 1112 565 4586 32 [k] up_write [kernel.vmlinux] atomic64_64.h:91 0 1 > > with this change: > ------------------------------------------------------------- > 360 12 300 57 35 0xffff982cdae76400 > ------------------------------------------------------------- > 50.00% 59.67% 0.00% 0.00% 0x0 1 1 0xffffffff8215fb86 352 200 191 558 32 [k] __handle_mm_fault [kernel.vmlinux] memory.c:2940 0 1 > 8.33% 5.00% 0.00% 0.00% 0x4 1 1 0xffffffff8210ed44 370 284 263 42 24 [k] filemap_read [kernel.vmlinux] atomic.h:23 0 1 > 0.00% 0.00% 5.26% 2.86% 0x8 1 1 0xffffffff8214bce1 0 0 0 4 4 [k] vma_interval_tree_remove [kernel.vmlinux] rbtree_augmented.h:204 0 1 > 33.33% 14.33% 0.00% 0.00% 0x8 1 1 0xffffffff8214ba75 344 186 219 140 32 [k] vma_interval_tree_insert [kernel.vmlinux] interval_tree.c:23 0 1 > 0.00% 0.00% 94.74% 97.14% 0x10 1 1 0xffffffff8214bd24 0 0 0 88 29 [k] vma_interval_tree_remove [kernel.vmlinux] rbtree_augmented.h:339 0 1 > 8.33% 20.00% 0.00% 0.00% 0x10 1 1 0xffffffff8214bb3b 296 209 226 167 31 [k] vma_interval_tree_remove [kernel.vmlinux] rbtree_augmented.h:338 0 1 > 0.00% 0.67% 0.00% 0.00% 0x28 1 1 0xffffffff82206f45 0 140 334 4 3 [k] do_dentry_open [kernel.vmlinux] open.c:966 0 1 > 0.00% 0.33% 0.00% 0.00% 0x38 1 1 0xffffffff8250a6c4 0 286 126 5 5 [k] errseq_sample [kernel.vmlinux] errseq.c:125 0 > > Signed-off-by: JonasZhou-oc > --- > 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 ed5966a70495..2d6ccde5d1be 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -482,10 +482,10 @@ struct address_space { > pgoff_t writeback_index; > const struct address_space_operations *a_ops; > unsigned long flags; > - struct rw_semaphore i_mmap_rwsem; > errseq_t wb_err; > spinlock_t i_private_lock; > struct list_head i_private_list; > + struct rw_semaphore i_mmap_rwsem; > void * i_private_data; > } __attribute__((aligned(sizeof(long)))) __randomize_layout; > /* > -- > 2.25.1 >