Received: by 2002:ab2:1c04:0:b0:1f7:53ba:1ebe with SMTP id f4csp139424lqg; Fri, 26 Apr 2024 10:53:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBQZJYNDNNtZ+4gx9kXhx1vgwzCeekwnMxhDM7uc4nN09WdoMN9RPidLZ04uZ6ZhSde2FZf730amrw0ZC3qDOeZyIR96Pz+ZzKqLcuCA== X-Google-Smtp-Source: AGHT+IE2YDPZFrlnDwvReUpJOen0odHHFmR30YFL75hqKph+3V4PQWRNo4hxYdNwA4zzGget2ntW X-Received: by 2002:a17:902:d508:b0:1eb:1473:c878 with SMTP id b8-20020a170902d50800b001eb1473c878mr2629108plg.36.1714153982732; Fri, 26 Apr 2024 10:53:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714153982; cv=pass; d=google.com; s=arc-20160816; b=WIS0NpLZA4lzb/yJcEUblRU5DlwudqLgrj+KnpA33BcAvUMiFHkHoNmf9keaskafsp Pc2yokVCqgrr12MrAzeuKD5+Z3RFjEbk4+/ExunmfmxlB+ICYDPNIHN2LviuX4vbwAJL O7xnf3qksQs0h0AGJnuapaeN631amdnAtjoPv8c9fCFvnFvSpUuOPpd/19+4fOoALT8t Qx9EBAb5OTY2FL61/a8O6A57EI2mwmxUySvzakcfRBSjYNjrgrOUErUSZDNNdqD6XZjp BSE7U1eriIULB6Ch4BtCstGfVELHcEXtp0IClITh+wfPguSOn2jk+qKN1sFypVEFbTJs DPAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5+JV8nGNDt7Yb0J1C93bew3ffEU+OKReUrVUHx6lRBY=; fh=IrSv/yFgNtmfHmtr+oxKd0kCl/jxVW2Vds2PEcUXfsc=; b=dYwWTp4fgqXXzs8KX3dqsC/l8yyE3SfQ+f78sb1f9TT3+2C18Xq+LRy58TNJrGrcIR 2sENquG4G3KVLnNpqG1VXWgtuKwQK8wh1M8c3FMV1qhfCUcMOvoCTopVeLr3LHeWVw4r mfOnQHiuD/ocUjaP0P3HYeeL70C3JPV0tVTC5UYKTUiBwnQ+BbP9tUq5T9rpcm0JjIyR MDgBaJbzTNCuxpia/Hrdmhd1YEGdiGgTIEUU42wP/J4IICsyNxhQTsOJpvJrvisb8s7v 6cbLUNZD9HdR99GQ2edXr3dpg9eDO2RffeJH9h7eVL0UjYkb6RaQCKscbf26SKx1pEEq tjHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=jE+HT8fE; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-160287-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160287-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u16-20020a1709026e1000b001e8f5f468a4si12687733plk.416.2024.04.26.10.53.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 10:53:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160287-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=jE+HT8fE; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-160287-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160287-linux.lists.archive=gmail.com@vger.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id AD2BF2848D4 for ; Fri, 26 Apr 2024 15:29:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BCE7D14900B; Fri, 26 Apr 2024 15:28:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="jE+HT8fE" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 6E197148FF0 for ; Fri, 26 Apr 2024 15:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714145331; cv=none; b=RYZl1MFOdnftLy+DTE4yiWdppnIfK2yQ/1O9QNyuEgbKZHBR+qSXVTopaxHh9lU6ImyzyLLxTQGO/OBaXESGBhGgMkWvJMAUzoXotvKyKeDnvvr6Y5oFiD+BJA+JkFg8uGNx07TKDwv7gujOiA3lODHDBXENAvh4Q6vexSVu4Jw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714145331; c=relaxed/simple; bh=B9S+VgIc4hHSvEtMfMzv55OnFnUMC5C0EuUCYvhoK+c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EeSMMH+h7SYfj/9F1Br4RLNzd4cR57aMyU50HNYlH/wi0rMXDmy9vM8UHU0ISDyTixQC1eR2Wp7s5Dl87nxKp8A5dN/bIczGFcYxLqzV6sAd8mU/N8yAg0WLOClcqT6JErDxd/Xm54sA2sY14J2s5EkIO6ACDNbVi/D6iEStJYc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=jE+HT8fE; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=5+JV8nGNDt7Yb0J1C93bew3ffEU+OKReUrVUHx6lRBY=; b=jE+HT8fEk5nk3WgGMTjsyJxmHt RFv/JBKSxfDB7yTJ27NOxG5to192JMyfyKkkZ0bQI/YN4HPRsvQge5CaLYs9sG3IVDRabru6mRDLT ZEwUAzogWDtfsjWnWU2iMlLb217tXbci8JwOA684kwuKr6KCdyyZgPL7Uy8K6YuCcGH9YXz0KYRBJ u93vvpac5T2s4ZJoMXqr7rDlibkgYS8ZZgXjJcPgWmlhEAebwkRbm9ati6SWpQjAxggHEg8hl+TrR 5lvTrm+kvXpWlgZewTlHbOaUX+6X6jzS0BTKMt06NzcB3mwvJXzVBE1tsaKjMJftBXXsZqFKA0t7g EmcymXpA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0NVG-00000005U9x-0lSp; Fri, 26 Apr 2024 15:28:46 +0000 Date: Fri, 26 Apr 2024 16:28:46 +0100 From: Matthew Wilcox To: Suren Baghdasaryan Cc: Peter Xu , "Liam R. Howlett" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Lokesh Gidra , Alistair Popple Subject: Re: [PATCH] mm: Always sanity check anon_vma first for per-vma locks Message-ID: References: <20240410170621.2011171-1-peterx@redhat.com> <20240411171319.almhz23xulg4f7op@revolver> 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 Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Apr 26, 2024 at 08:07:45AM -0700, Suren Baghdasaryan wrote: > On Fri, Apr 26, 2024 at 7:00 AM Matthew Wilcox wrote: > > Intel's 0day got back to me with data and it's ridiculously good. > > Headline figure: over 3x throughput improvement with vm-scalability > > https://lore.kernel.org/all/202404261055.c5e24608-oliver.sang@intel.com/ > > > > I can't see why it's that good. It shouldn't be that good. I'm > > seeing big numbers here: > > > > 4366 ą 2% +565.6% 29061 perf-stat.overall.cycles-between-cache-misses > > > > and the code being deleted is only checking vma->vm_ops and > > vma->anon_vma. Surely that cache line is referenced so frequently > > during pagefault that deleting a reference here will make no difference > > at all? > > That indeed looks overly good. Sorry, I didn't have a chance to run > the benchmarks on my side yet because of the ongoing Android bootcamp > this week. No problem. Darn work getting in the way of having fun ;-) > > I still don't understand why we have to take the mmap_sem less often. > > Is there perhaps a VMA for which we have a NULL vm_ops, but don't set > > an anon_vma on a page fault? > > I think the only path in either do_anonymous_page() or > do_huge_pmd_anonymous_page() that skips calling anon_vma_prepare() is > the "Use the zero-page for reads" here: > https://elixir.bootlin.com/linux/latest/source/mm/memory.c#L4265. I > didn't look into this particular benchmark yet but will try it out > once I have some time to benchmark your change. Yes, Liam and I had just brainstormed that as being a plausible explanation too. I don't know how frequent it is to use anon memory read-only. Presumably it must happen often enough that we've bothered to implement the zero-page optimisation. But probably not nearly as often as this benchmark makes it happen ;-)