From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60CE6C02180 for ; Wed, 15 Jan 2025 09:00:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C68036B007B; Wed, 15 Jan 2025 04:00:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BF0BA6B0082; Wed, 15 Jan 2025 04:00:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A927B6B0083; Wed, 15 Jan 2025 04:00:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8AA5F6B007B for ; Wed, 15 Jan 2025 04:00:18 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 42A2016107C for ; Wed, 15 Jan 2025 09:00:18 +0000 (UTC) X-FDA: 83009089716.06.D301C0C Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf02.hostedemail.com (Postfix) with ESMTP id BD55F80010 for ; Wed, 15 Jan 2025 09:00:15 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=LBTs8JtH; dmarc=none; spf=none (imf02.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736931616; a=rsa-sha256; cv=none; b=hxPtEQSSt6d734D2X2qW8EjTehmdOqr6SfefUZIai2rDB+Wh44shUAe79Vb292eNF/PDG8 E8Yp0zhtuDWCLvLFvVTVvPybKwchgBqZjEMlMM5uCzupEHjCVpFGAUxVq5oKs8uDAyW9UJ 1v1NXnSZwD25JuUS/j4XFzffbpPJH2E= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=LBTs8JtH; dmarc=none; spf=none (imf02.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736931616; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HCntI1LpVo3d0PAMWrnntnFDf2TjYHRAU9JAViMf0mc=; b=raKGvIFvyKZqZe/cLGCjXLo293OSdI+zVbpDtzKQdLnfSsClTBN8v3YQ3Ez6pITXrvHneS 507yNwAuJ0hVPAEzQcwnQQNyc2C/weDFzs9Oqo7aF5T78ooD9F3K+3jU4rxWtsKS5LngO5 BsKdZpttx1Uh0cBWrW4MHTS6CpD1bNk= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=HCntI1LpVo3d0PAMWrnntnFDf2TjYHRAU9JAViMf0mc=; b=LBTs8JtH3MvG6YdiKaGDOoo9tr 1juXtE7YqMfVrvonfL6Y31qVEs95gq8J0RJpNG+oGyRFZZpl+3ruLIMjiuyaywrpGmm3sz3oVRDVr Bj9DK2AFitLI6kjWQsqi7haeRgba7UU8TLhsgk3tZgOppLLsz+ztpyzq/p7YhM+AR/RXg6uOSsvtq hcaK0SSGe5Md+EHyUAvV74865AQpyKfm6U2UxaDIO2PmiCC/cvRmv8otTBvv7JP0Jolaa49aRsd2+ 3p2f3SasKhh087FyADAaDqt/KxZWSsDs/Y8wzgjtAwznEJf3ByK7qL69XTdyl7DOKdQAqjlqcmlk3 lZWz9Ylw==; Received: from 77-249-17-89.cable.dynamic.v4.ziggo.nl ([77.249.17.89] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tXzFo-0000000Ap3p-1FbV; Wed, 15 Jan 2025 09:00:00 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id AF1EF300346; Wed, 15 Jan 2025 09:59:59 +0100 (CET) Date: Wed, 15 Jan 2025 09:59:59 +0100 From: Peter Zijlstra To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, willy@infradead.org, liam.howlett@oracle.com, lorenzo.stoakes@oracle.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mjguzik@gmail.com, oliver.sang@intel.com, mgorman@techsingularity.net, david@redhat.com, peterx@redhat.com, oleg@redhat.com, dave@stgolabs.net, paulmck@kernel.org, brauner@kernel.org, dhowells@redhat.com, hdanton@sina.com, hughd@google.com, lokeshgidra@google.com, minchan@google.com, jannh@google.com, shakeel.butt@linux.dev, souravpanda@google.com, pasha.tatashin@soleen.com, klarasmodin@gmail.com, richard.weiyang@gmail.com, corbet@lwn.net, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v8 00/16] move per-vma lock into vm_area_struct Message-ID: <20250115085959.GD8385@noisy.programming.kicks-ass.net> References: <20250109023025.2242447-1-surenb@google.com> <20250109115142.GC2981@noisy.programming.kicks-ass.net> <20250110170105.GE4213@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20250110170105.GE4213@noisy.programming.kicks-ass.net> X-Stat-Signature: j8tt137i5m6b1biakty6p15cey7fa87j X-Rspam-User: X-Rspamd-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8NP0HXkT7hQDqx/ZYM9nMEwaCLNa46vl7W/65BnUoZbFkn612ljZnfNmGWe6D8ohRl3l1evG+oJh+blfufMrc9ZTVOB3bhTPzhCV+ozlQ6bnVtYObE1hqHJB9BzhvEb9p0utZ519AOnPmpCnNxuMFbZeRuZ+2jd1AwfLWruPUmUURgXuAzRO0PmhHcuwDMhZC9zaBxTAQ2PV/EFabYmrdiGoUxh6jWgxxod5j1ZVdxCHJWxmhVMmZzLMJownfmAAiW3WlD1ROM5c6xXnAge7fcjQONuIF59bEgRfMp7kB4uz/lgxOKkFMSx0tPyjHnN8AgrgvxoTUOjlGEUNxbKrTXKhFjb2VpsId+3y/F9tbACUCULeQAW6GTzSUr8ABxi1Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Jan 10, 2025 at 06:01:05PM +0100, Peter Zijlstra wrote: > On Thu, Jan 09, 2025 at 07:48:32AM -0800, Suren Baghdasaryan wrote: > > On Thu, Jan 9, 2025 at 3:51 AM Peter Zijlstra wrote: > > > > > > On Wed, Jan 08, 2025 at 06:30:09PM -0800, Suren Baghdasaryan wrote: > > > > Back when per-vma locks were introduces, vm_lock was moved out of > > > > vm_area_struct in [1] because of the performance regression caused by > > > > false cacheline sharing. Recent investigation [2] revealed that the > > > > regressions is limited to a rather old Broadwell microarchitecture and > > > > even there it can be mitigated by disabling adjacent cacheline > > > > prefetching, see [3]. > > > > Splitting single logical structure into multiple ones leads to more > > > > complicated management, extra pointer dereferences and overall less > > > > maintainable code. When that split-away part is a lock, it complicates > > > > things even further. With no performance benefits, there are no reasons > > > > for this split. Merging the vm_lock back into vm_area_struct also allows > > > > vm_area_struct to use SLAB_TYPESAFE_BY_RCU later in this patchset. > > > > This patchset: > > > > 1. moves vm_lock back into vm_area_struct, aligning it at the cacheline > > > > boundary and changing the cache to be cacheline-aligned to minimize > > > > cacheline sharing; > > > > 2. changes vm_area_struct initialization to mark new vma as detached until > > > > it is inserted into vma tree; > > > > 3. replaces vm_lock and vma->detached flag with a reference counter; > > > > 4. changes vm_area_struct cache to SLAB_TYPESAFE_BY_RCU to allow for their > > > > reuse and to minimize call_rcu() calls. > > > > > > Does not clean up that reattach nonsense :-( > > > > Oh, no. I think it does. That's why in [1] I introduce > > vma_iter_store_attached() to be used on already attached vmas and to > > avoid marking them attached again. Also I added assertions in > > vma_mark_attached()/vma_mark_detached() to avoid re-attaching or > > re-detaching. Unless I misunderstood your comment? > > Hmm, I'll go read the thing again, maybe I missed it. You're right. I was looking for the approach that changed the need to reattach, by moving the point of no return. This should do for now. Let me see if I can find time today to finally do a proper reading. Thanks!