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 9428DC02183 for ; Wed, 15 Jan 2025 10:51:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 102036B0083; Wed, 15 Jan 2025 05:51:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B2D16B0085; Wed, 15 Jan 2025 05:51:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBBEC6B0088; Wed, 15 Jan 2025 05:51:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CD14D6B0083 for ; Wed, 15 Jan 2025 05:51:09 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6B2C91411C6 for ; Wed, 15 Jan 2025 10:51:09 +0000 (UTC) X-FDA: 83009369058.03.985F13B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id 4ABF9100010 for ; Wed, 15 Jan 2025 10:51:07 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Fcw2s2mZ; spf=none (imf05.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736938267; 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=5KoBooUs/bnKv8OEOq3cKmUwKnCPueVx0k9hiDQNgNY=; b=mM6Dr9h7ToM3jftgpV7e6elOiQJX0DvITLY5NJ02f+6xtkayEZx1qCE7erkVBnD3fhQp7x 2NQ1uzgHS1F1nMAqtp89FS01eDgXSmxS3FT39D/HyGhQQzoZY/a/AUOwGXny5JP7y+IPFJ WHCybmDl9lgZO4CFlkxUXbnXvd9xpYs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736938267; a=rsa-sha256; cv=none; b=f+lHKRkRUp0JHxJshenIVTEmsi49PGIE1msAy0gTN5kwcP6s+mIEkx/zi5gZ4FY23a/c9F D55U4Fh10R74uZxj3bfWTCV9QeEVKvxfW3c/c7Pxbhuql2fnIWJMNu5ipwC1u3TnFWg2Ps PrEVGG3qkqUPbEwGCl0VYOGkHeHbomM= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Fcw2s2mZ; spf=none (imf05.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=5KoBooUs/bnKv8OEOq3cKmUwKnCPueVx0k9hiDQNgNY=; b=Fcw2s2mZ4a9bMb7rLM//a7aA+F IjThgjew7xPKKJ20p+xtLTk0ls+PK3BsmGTVxKYumpXM3tV4SebZMwKwBG3sz3yU9a1G+mEbBHiM7 FSDC55UTeHHFMngjx3Oky4aQI8zu7R1kjAvTc8CV3LDFDaQ2V1sZjahhVGmY3xH5BT3RBpQQs/XyK SVEqNcWEPWf+U/wsALFhHL9nVAmjgWGDv6iOoiQA/xNF1aJGOUkhzfpsSL8KuhYGDbpihUNAJqUNV Y/7iqX0YvPdmSYZ+2fMc04ezOp/iqaV3Os6lefy8IAgqLEkSrO2PgaWN7Hi7vdKHYPEfp79Rs4Hd7 uFRRP7Tg==; Received: from 77-249-17-89.cable.dynamic.v4.ziggo.nl ([77.249.17.89] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tY0zB-0000000C0hn-29i8; Wed, 15 Jan 2025 10:50:57 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 8E64D300346; Wed, 15 Jan 2025 11:50:56 +0100 (CET) Date: Wed, 15 Jan 2025 11:50:56 +0100 From: Peter Zijlstra To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, willy@infradead.org, liam.howlett@oracle.com, lorenzo.stoakes@oracle.com, david.laight.linux@gmail.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 v9 12/17] mm: move lesser used vma_area_struct members into the last cacheline Message-ID: <20250115105056.GY5388@noisy.programming.kicks-ass.net> References: <20250111042604.3230628-1-surenb@google.com> <20250111042604.3230628-13-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250111042604.3230628-13-surenb@google.com> X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 4ABF9100010 X-Stat-Signature: jrfyw4kf7inw5wu3h9npwxhifpofo7ou X-Rspam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GkBpyOedacOybP3rjxRgsOw+B31yEsqKYScKy5nG2MNTkQrkKXx7eMbS4eZQosyB3SPXNrB3BA7nQXcUt1iQ3TMOjTTfFv0qkcxMK64Q3Qv4BlmBMyHUyk30w8/Bky9HIaq5yjiPDxlyXxiq+NwcMUrWeryXm+YkC9bZ+h9WEWL9D2rsT1RCWAwrwX+DTrgN/dcw++3c5otqDU4uHn1es2z8QzYL2EjwimFzHWWQ2dsRcm7/u0KSQ== 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 08:25:59PM -0800, Suren Baghdasaryan wrote: > Move several vma_area_struct members which are rarely or never used > during page fault handling into the last cacheline to better pack > vm_area_struct. As a result vm_area_struct will fit into 3 as opposed > to 4 cachelines. New typical vm_area_struct layout: > > struct vm_area_struct { > union { > struct { > long unsigned int vm_start; /* 0 8 */ > long unsigned int vm_end; /* 8 8 */ > }; /* 0 16 */ > freeptr_t vm_freeptr; /* 0 8 */ > }; /* 0 16 */ > struct mm_struct * vm_mm; /* 16 8 */ > pgprot_t vm_page_prot; /* 24 8 */ > union { > const vm_flags_t vm_flags; /* 32 8 */ > vm_flags_t __vm_flags; /* 32 8 */ > }; /* 32 8 */ > unsigned int vm_lock_seq; /* 40 4 */ Does it not make sense to move this seq field near the refcnt? > /* XXX 4 bytes hole, try to pack */ > > struct list_head anon_vma_chain; /* 48 16 */ > /* --- cacheline 1 boundary (64 bytes) --- */ > struct anon_vma * anon_vma; /* 64 8 */ > const struct vm_operations_struct * vm_ops; /* 72 8 */ > long unsigned int vm_pgoff; /* 80 8 */ > struct file * vm_file; /* 88 8 */ > void * vm_private_data; /* 96 8 */ > atomic_long_t swap_readahead_info; /* 104 8 */ > struct mempolicy * vm_policy; /* 112 8 */ > struct vma_numab_state * numab_state; /* 120 8 */ > /* --- cacheline 2 boundary (128 bytes) --- */ > refcount_t vm_refcnt (__aligned__(64)); /* 128 4 */ > > /* XXX 4 bytes hole, try to pack */ > > struct { > struct rb_node rb (__aligned__(8)); /* 136 24 */ > long unsigned int rb_subtree_last; /* 160 8 */ > } __attribute__((__aligned__(8))) shared; /* 136 32 */ > struct anon_vma_name * anon_name; /* 168 8 */ > struct vm_userfaultfd_ctx vm_userfaultfd_ctx; /* 176 8 */ > > /* size: 192, cachelines: 3, members: 18 */ > /* sum members: 176, holes: 2, sum holes: 8 */ > /* padding: 8 */ > /* forced alignments: 2, forced holes: 1, sum forced holes: 4 */ > } __attribute__((__aligned__(64)));