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 79E4FD75BCB for ; Thu, 21 Nov 2024 07:02:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D31C6B007B; Thu, 21 Nov 2024 02:02:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 75BA46B0082; Thu, 21 Nov 2024 02:02:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FB666B0083; Thu, 21 Nov 2024 02:02:10 -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 404836B007B for ; Thu, 21 Nov 2024 02:02:10 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id AFFF61612AF for ; Thu, 21 Nov 2024 07:02:09 +0000 (UTC) X-FDA: 82809205962.06.B212E05 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) by imf05.hostedemail.com (Postfix) with ESMTP id 19B4C100009 for ; Thu, 21 Nov 2024 07:00:26 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=lBZcsgJa; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf05.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.188 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732172342; a=rsa-sha256; cv=none; b=1U17yB14wAXys2ZQgHfxx7ccssNG5sFxhkcFwoZqobjMMQGgfDeus4BiFlYcUCJ73tv5GD a4ou35FLiqXkqLoZLSkJg+BRuhRgyckfZfX6mVm48D9wolk0R4rwQPaQCl4z0N2KzlRaBg AXvd0lBmxNjGyxe7TOtTnYg9qkYZQ7g= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=lBZcsgJa; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf05.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.188 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732172342; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Ap95Q1nsWIhzVEIGy3SKI0y8bEU8NHJzB+owS7s7oFk=; b=ITO7shb36Ix4yv6R1H7zFkkpT/s9aXb8KtGTWNdTdN0mzEIvXSOK8n6BtN61T8kGtEFdNs ePpV91RdY/QNVxzC+m5IlA5naSIzg5uuLDNC7j5TBAElmJ/ZYBFY6jm0SGQVFW9xcYGIf+ 4WqaGXM2EIaEMe0Hmtj3cevdqInfm6Y= Date: Wed, 20 Nov 2024 23:01:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1732172523; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ap95Q1nsWIhzVEIGy3SKI0y8bEU8NHJzB+owS7s7oFk=; b=lBZcsgJaHZ1iWQ8HkxNDrrNGu46xUgydVslYoZefgOefdLNNgQXSiMrR3U4kGlmy6XN5aC Qq76DHM997dZqvp4ODH3lmWODeOLVfPBVgKaot6jk1xdzcT3t/uVsvtI/V00eIvM82Zo3n Fe6dQhbXnC6OTbsfivkffvcSJA2Gp3c= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt 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, minchan@google.com, jannh@google.com, souravpanda@google.com, pasha.tatashin@soleen.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 v4 2/5] mm: move per-vma lock into vm_area_struct Message-ID: References: <20241120000826.335387-1-surenb@google.com> <20241120000826.335387-3-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Stat-Signature: m8qpp7t35cmjy8un8y9jecg4tw9j654t X-Rspamd-Queue-Id: 19B4C100009 X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1732172426-727692 X-HE-Meta: U2FsdGVkX1/iv8lMtFtUGv87khmKsLIFtx/iE+q1xxWzS13LAN+IUmhnfqGQHnoDYmqg/2DR9/2sg1EYpkdldcEp4aOUdPyNmzq9V0uovHYgf4hNhXQUYP3euJ5DUrAouM7p+Lll7Zo3m3rYlupMf1s46+aeKPiNjEHkuwhf2q+0TDgliBIxCFgkAgsqhrxJ5gVSr0hFpc9bf9ihCltRvaOvAw8ei7mxOmFuUBD+KT4qlrogoPnfpjE8CAioClMvy63EGYakY3znj/t5/ufxNF05+EDYm7gRzLxHkbCBQiHi8KJoq3J8Yyq9B1nJ4cjrPaZzTvHpCatSJDI8GvRehrgvZfdBY01fWf4lZ1I+HTMQ5Z9WBP8nM2lgFRog2H+Tu+wPsHQMtZw1z9PNC71OIqYAS5EFJ88I7TDUAU1pQerqgENRN94Hjbar1+XDmpUSSEHLOJuDFFBAJvkXWpcji7oUetsJfMLcGHii8P4GoNBjit84QC5xSMNZ3vwUpmkFz2+jF8F9Xtq1gzHNO9GdCjVHb2DYCkPrGjwFbRmj2ivQ+7HyPuh2Ww9ptMTOLZT5VGBiurzYfxVKcD6WoykVy/ZCMObh9xmn1AbehCNCmPr8JaE95nreMJtDQYPzwr709iIm0Xxpr/L3+UWuktlbyUg5B8GzxoIBdw9UwSet/3FsN44dYOA3NFBNB54rZru2IH/lvmUD3b4ydMOE0Uln1U6IzTDnRR14x6xCp/i5S44pQngUBhPZSyCjbEATUUSEVT7dvzwfpZ50cH6CHn2RCCZjWp4+vDSQ/sp1S0Esh6GVy8M02okB9eMO4ifrxH1Gr8TIuDgP/ebshloB/IOG5gFy1vNtNv1XFt5X/UbsR02hBAb+O1UV6Fhpfmldc1mDN9bEcJSWq0mRyxJlFLxA9WDH5GsKgRW8YP5jxuvnQ3RHeQfReKK/rZqbyYZVP0kvL6qBisos2es3k5qP0U8 kSZ/D7q+ BPTFcw6As2XJi9oRKjDTqOij4Yq8Uglkgl0pe7+Xw+gieP6apuxE4POF6HnMuPVJ5nr9aa6Y8uRCXY3Zx4Wy32B1cn9Dzks1nzJTmL3B+dHNwC1xlvKhyQXF5/6JjlQYjIKnPBru2WTzqw1iNUOgnPgwWhUio8kK3oks/FAdAefSek5ybqTU7pBfCKPWaLb2aeFW5 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 Wed, Nov 20, 2024 at 04:33:37PM -0800, Suren Baghdasaryan wrote: [...] > > > > > > > > Do we just want 'struct vm_area_struct' to be cacheline aligned or do we > > > > want 'struct vma_lock vm_lock' to be on a separate cacheline as well? > > > > > > We want both to minimize cacheline sharing. > > > > > > > For later, you will need to add a pad after vm_lock as well, so any > > future addition will not share the cacheline with vm_lock. I would do > > something like below. This is a nit and can be done later. > > > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > > index 7654c766cbe2..5cc4fff163a0 100644 > > --- a/include/linux/mm_types.h > > +++ b/include/linux/mm_types.h > > @@ -751,10 +751,12 @@ struct vm_area_struct { > > #endif > > struct vm_userfaultfd_ctx vm_userfaultfd_ctx; > > #ifdef CONFIG_PER_VMA_LOCK > > + CACHELINE_PADDING(__pad1__); > > /* Unstable RCU readers are allowed to read this. */ > > - struct vma_lock vm_lock ____cacheline_aligned_in_smp; > > + struct vma_lock vm_lock; > > + CACHELINE_PADDING(__pad2__); > > #endif > > -} __randomize_layout; > > +} __randomize_layout ____cacheline_aligned_in_smp; > > I thought SLAB_HWCACHE_ALIGN for vm_area_cachep added in this patch > would have the same result, no? > SLAB_HWCACHE_ALIGN is more about the slub allocator allocating cache aligned memory. It does not say anything about the internals of the struct for which the kmem_cache is being created. The ____cacheline_aligned_in_smp tag in your patch made sure that the field vm_lock will be put in a new cacheline and there can be a hole between vm_lock and the previous field if the previous field is not ending at the cacheline boundary. Please note that if you add a new field after vm_lock (without cacheline alignment tag), it will be on the same cacheline as vm_lock. So, your code is achieving the vm_lock on its own cacheline goal but vm_lock being the only field on that cacheline is not being achieved.