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 880BAC46467 for ; Wed, 11 Jan 2023 16:29:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD95D900002; Wed, 11 Jan 2023 11:29:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D61698E0001; Wed, 11 Jan 2023 11:29:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDBAA900002; Wed, 11 Jan 2023 11:29:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A86388E0001 for ; Wed, 11 Jan 2023 11:29:04 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 82709120827 for ; Wed, 11 Jan 2023 16:29:04 +0000 (UTC) X-FDA: 80343052608.21.13754CE Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by imf05.hostedemail.com (Postfix) with ESMTP id BA27410000E for ; Wed, 11 Jan 2023 16:29:01 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Yzh3gZKn; spf=pass (imf05.hostedemail.com: domain of surenb@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673454541; a=rsa-sha256; cv=none; b=oKPCNvRxk6kLVJvX8fJ6PSXGwm6wEfY/NWCGFE2sKm1/EeHqAYmNbndZta7vWZiGuEadDC mFPhz1dQ6l0R18MyTIfUnPqtUgv1GchMzl6ZyGbHHW/v94f5wYD1FhAxjQc5MkL38/Atjn Z3Vi0QzF1yLyLu6SjU2QywyAVRjlYeM= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Yzh3gZKn; spf=pass (imf05.hostedemail.com: domain of surenb@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673454541; 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=4Lr8tSm6MqUPgF/LWfHDA9iNzXlwa0xD0GVdK5cZd9g=; b=Ax3ED4YUKdnew+3028J0sFc1LvrPYuQTc2H9X/x32o7vVTN36tOyiz3pSZILn+ydggWpS9 DoEAYMERZUU4GWSpmoa26aLaOG3d+cUEvECakBM13Oo4ep1awMDkRnnN/t93wMz3qsk+i7 ZTfNEdeQTNqfXXhBM50a+5jO/oDvAOg= Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-4c24993965eso195687407b3.12 for ; Wed, 11 Jan 2023 08:29:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=4Lr8tSm6MqUPgF/LWfHDA9iNzXlwa0xD0GVdK5cZd9g=; b=Yzh3gZKn1mLa2Za1k9SYRxbcKca9L17S5JQFl3qF9blmNHMcuOBgj4kMQW7wplK6Lx e8zBR6KI/RCHR++bGrQjGNn9B4FFj/zDTtccI3A0ugVo6eZmh4MPBQ2aGoOno0fhGxHl XjSlsW50U1m7j2YKUXjIDerEEAjp1e6UR8rEeqNUlp5Y5hg5hABLOUW+1+WYMuW+wjLD P6i3bApuhlQn2xaOuXEWwh7+Hr3Bhk7riQ8Ggwa18xpE6h0rgfqlX7mjzO50d0PlgXLA xih+3oKx3c2hbNzmL+L4GpJpGcz1WIyS/pKI84+Dlxo53T9P+/2BNhkVLDIOei55vmrr Vozw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4Lr8tSm6MqUPgF/LWfHDA9iNzXlwa0xD0GVdK5cZd9g=; b=ItzcMf665A/RgwuC46FHUICdKJoqEsJ1NIlR1zfLTV9Mf3ykSDkd9y5frGgNHwART9 rORhVle6nF6ju4XH6LiAnVfZr+cWCFljICYsT/95wD2ZlVqq/SmaAF48EYn+8gKY6l+d pNkfje53SDiY2YFyjyf+sNLiMnqO2gyBCin0f/qkLM4l66NAvUddaFtqDIlwskW0aDJd JaL2DKetqvgSWIIJ6o0SKfV60y6LsPvNDAdFFDD3psCsGyUiF9PpsJ3tn2UOFZ7qhGqQ hZHa/GUxFSFxaaGTL5XHY0KtGKhaW6gVAomIzRZOc9DznRq5tqxmEHlzVa0XzUfbTYfO qMLw== X-Gm-Message-State: AFqh2krO0sYeFfW9p9Ofd5G358uLac9ZLqYxvD2WJRa93dhG63o9JpqV aHteUDWtaRbmBAu7wYnKQF/Vg1w1zd8dU+m/+orfng== X-Google-Smtp-Source: AMrXdXvLgK6W7lAuuCYwgiArrtAg97gzYPQSMPDbpaiV/C+O44LDuwgcKcWpyW8gYaBkcIY/p7HDYgSic7XqJ1wpyfU= X-Received: by 2002:a81:190a:0:b0:3dc:fd91:ef89 with SMTP id 10-20020a81190a000000b003dcfd91ef89mr2162583ywz.347.1673454540467; Wed, 11 Jan 2023 08:29:00 -0800 (PST) MIME-Version: 1.0 References: <20230109205336.3665937-1-surenb@google.com> <20230109205336.3665937-9-surenb@google.com> <20230111001331.cxdeh52vvta6ok2p@offworld> <6be809f5554a4faaa22c287ba4224bd0@AcuMS.aculab.com> In-Reply-To: <6be809f5554a4faaa22c287ba4224bd0@AcuMS.aculab.com> From: Suren Baghdasaryan Date: Wed, 11 Jan 2023 08:28:49 -0800 Message-ID: Subject: Re: [PATCH 08/41] mm: introduce CONFIG_PER_VMA_LOCK To: David Laight Cc: Ingo Molnar , Michal Hocko , "michel@lespinasse.org" , "joelaf@google.com" , "songliubraving@fb.com" , "leewalsh@google.com" , "david@redhat.com" , "peterz@infradead.org" , "bigeasy@linutronix.de" , "peterx@redhat.com" , "dhowells@redhat.com" , "linux-mm@kvack.org" , "edumazet@google.com" , "jglisse@google.com" , "punit.agrawal@bytedance.com" , "arjunroy@google.com" , "minchan@google.com" , "x86@kernel.org" , "hughd@google.com" , "willy@infradead.org" , "gurua@google.com" , "laurent.dufour@fr.ibm.com" , "linux-arm-kernel@lists.infradead.org" , "rientjes@google.com" , "axelrasmussen@google.com" , "kernel-team@android.com" , "soheil@google.com" , "paulmck@kernel.org" , "jannh@google.com" , "liam.howlett@oracle.com" , "shakeelb@google.com" , "luto@kernel.org" , "gthelen@google.com" , "ldufour@linux.ibm.com" , "vbabka@suse.cz" , "posk@google.com" , "lstoakes@gmail.com" , "peterjung1337@gmail.com" , "linuxppc-dev@lists.ozlabs.org" , "kent.overstreet@linux.dev" , "hughlynch@google.com" , "linux-kernel@vger.kernel.org" , "hannes@cmpxchg.org" , "akpm@linux-foundation.org" , "tatashin@google.com" Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Rspamd-Queue-Id: BA27410000E X-Rspamd-Server: rspam01 X-Stat-Signature: kewqc4smm9z43frqbnnxz8hq4yi5kz3g X-HE-Tag: 1673454541-925680 X-HE-Meta: U2FsdGVkX1+3lc+XQlJtVGW05rPEx346ujPj1EPf0OYiL1ky+mqx40Ufl2hMteVnrPuKoOnn80XC2pDTtzI9AWAFW1LWtoUigfNSIu7HxIrm6kxyPR7/xi3F4tH0BzCnENh+drLdNPwO/5Pi0w4NmfWUqKUmzJB29wKbZpfXgFhfRYmhNzPwOqzTEEElJZXZaEef7YLVajx+jLBuBcsXDTGZ/Ad4Z0L3oz5xDA64p6/kAnNwbzH68+nSZmDdY7BhM4C8DE2/oJaKoK52axPl2DfZiA46hLoHVQ+87/FHqX8YJ+bSSvi9to5cs0ML5lFkj1cRIUN3L4Joe0gU7d7dYe9woJGcTKozN40dCYd4D744VnMOfB+1kqgLFIZA5G65gHzR47mSWsyVtzbAN5i6ycNd3Rz2X4o53SBsFXWljKXcQXnwlh1ZEU8W9kEmLPIEDZoCcvIFAHhY/ruOS//vGOZyAYKS22vZhNDg1dDm27yBvqf8fzrgPfhzLrA4UxrPaQO/kzwaKkabTTAr92Sd9z9mqWmzf+VYxBWaFTd9sv16GXnZC6mNKEq/ovGSFQgEfi4nQ5WyUYRFtw16tX8qBo1cPFpLhtw9XQ4IzR3nNkdejdmYO8K+AtaMgl4aQOtIRcf3UHP+fNSWLCNB0S7xdVBXeJXy0l/v0t8jGIjM6nP3OujyZLSzVdP80xVYs5YPK8+VfGLw+EEV+8hgkexn0FqesbuRWexZX1RDndj53UjFW/VEFeg1z87tiBtQNSPX4sK7yBWYoYs1aoWn3GNIyXMCfH3bLbV6B4ZK3Uw5QEOgppLQWrKT5437I5TXXbtoPRdWjAx13qsqF3wWdLhP592S7Ce76NopnrmHYXIkt6GaWLmmqQXd1v3fx35x+C3DMuvQMCjhL0qzbnms/xxapLccNuIQfM0zhX8QwSwPlQ5uRd37l6O9GC+1xR5UjFmUNDHmCZiQBXgwpcj0Zhy fQ0aI2ll +QZDBCHyWVohmqTh11MBrhJj5AQtzEbF5bdbnwfWak+2PD3ZHJk6BZAQOy73yIrT+2Lbp8F8Rq3bXRZJJjxtM9ahS907rdeUXAEG9Bg4a3C79lig= 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: On Wed, Jan 11, 2023 at 2:03 AM David Laight wrote: > > From: Ingo Molnar > > Sent: 11 January 2023 09:54 > > > > * Michal Hocko wrote: > > > > > On Tue 10-01-23 16:44:42, Suren Baghdasaryan wrote: > > > > On Tue, Jan 10, 2023 at 4:39 PM Davidlohr Bueso wrote: > > > > > > > > > > On Mon, 09 Jan 2023, Suren Baghdasaryan wrote: > > > > > > > > > > >This configuration variable will be used to build the support for VMA > > > > > >locking during page fault handling. > > > > > > > > > > > >This is enabled by default on supported architectures with SMP and MMU > > > > > >set. > > > > > > > > > > > >The architecture support is needed since the page fault handler is called > > > > > >from the architecture's page faulting code which needs modifications to > > > > > >handle faults under VMA lock. > > > > > > > > > > I don't think that per-vma locking should be something that is user-configurable. > > > > > It should just be depdendant on the arch. So maybe just remove CONFIG_PER_VMA_LOCK? > > > > > > > > Thanks for the suggestion! I would be happy to make that change if > > > > there are no objections. I think the only pushback might have been the > > > > vma size increase but with the latest optimization in the last patch > > > > maybe that's less of an issue? > > > > > > Has vma size ever been a real problem? Sure there might be a lot of those > > > but your patch increases it by rwsem (without the last patch) which is > > > something like 40B on top of 136B vma so we are talking about 400B in > > > total which even with wild mapcount limits shouldn't really be > > > prohibitive. With a default map count limit we are talking about 2M > > > increase at most (per address space). > > > > > > Or are you aware of any specific usecases where vma size is a real > > > problem? Well, when fixing the cacheline bouncing problem in the initial design I was adding 44 bytes to 152-byte vm_area_struct (CONFIG_NUMA enabled) and pushing it just above 192 bytes while allocating these structures from cache-aligned slab (keeping the lock in a separate cacheline to prevent cacheline bouncing). That would use the whole 256 bytes per VMA and it did make me nervous. The current design with no need to cache-align vm_area_structs and with 44-byte overhead trimmed down to 16 bytes seems much more palatable. > > > > 40 bytes for the rwsem, plus the patch also adds a 32-bit sequence counter: > > > > + int vm_lock_seq; > > + struct rw_semaphore lock; > > > > So it's +44 bytes. Correct. > > Depend in whether vm_lock_seq goes into a padding hole or not > it will be 40 or 48 bytes. > > But if these structures are allocated individually (not an array) > then it depends on how may items kmalloc() fits into a page (or 2,4). Yep. Depends on how we arrange the fields. Anyhow. Sounds like the overhead of the current design is small enough to remove CONFIG_PER_VMA_LOCK and let it depend only on architecture support? Thanks, Suren. > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) >