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 677DDD41C13 for ; Wed, 13 Nov 2024 08:19:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9AAD6B0098; Wed, 13 Nov 2024 03:19:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E22226B00C2; Wed, 13 Nov 2024 03:19:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9A186B00C3; Wed, 13 Nov 2024 03:19:37 -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 A4DEA6B0098 for ; Wed, 13 Nov 2024 03:19:37 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 60E9780900 for ; Wed, 13 Nov 2024 08:19:37 +0000 (UTC) X-FDA: 82780371534.22.D38A834 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by imf22.hostedemail.com (Postfix) with ESMTP id 65DFEC0005 for ; Wed, 13 Nov 2024 08:18:42 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=RSPIwVZd; spf=pass (imf22.hostedemail.com: domain of surenb@google.com designates 209.85.160.179 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=1731485781; 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=Cnx5/u7WVVRjL/g2O6lnbYtDQ1Q9FLDekhDrsRiOiw0=; b=O3K2Nfxg6ztxc/dHX7STzlWcnmH1PoWCcEIrpFYbqlSN7N8tlxoN+nClQJsJ64PZk60eYP g+YtpdS6KF/mfvDg8WvYX5GC3XibYQ1K9NiuftTsyuZwFZkS+wMttC7Dc3Fa4HbR2BkBm5 09iv978uBSW2vNoO2afTpC0ccSgGSZw= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=RSPIwVZd; spf=pass (imf22.hostedemail.com: domain of surenb@google.com designates 209.85.160.179 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=1731485781; a=rsa-sha256; cv=none; b=MQLtbGRJHd8wrvfbgyP8h+OctmcoxBvAd5ePn/iEXPxbLuvJk0PFSaCFTOMy5Y5s17Qc8C VzU64dA0zzfA+8K/3qIVC7c6zmuOSQuIzMiYjY3j3LuGKWhBQxU206gqxTV97mixWAcVjb VnoRBQ4x9QZVLZyQWJkF1pd7pwECVI4= Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-460a8d1a9b7so141121cf.1 for ; Wed, 13 Nov 2024 00:19:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731485974; x=1732090774; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Cnx5/u7WVVRjL/g2O6lnbYtDQ1Q9FLDekhDrsRiOiw0=; b=RSPIwVZdvRfEpqmzTctV81zb97J3+pulHzrpqhvY37H/rHDkH3//Yi6DUXdgvLGk4U FW43u8Pun17lELy3ZRR0u3ARQbI8e/uScBhCjbTExzRl5ZpwDGRYf5cGCjkgg/O3Y6ng M8nJ3coWsn7MEyv+jQFQ3SN4O7q4O2Bc18VjuuwC7suzMU8V/7ZArBj4mqptGbOmL8EV u9BNU76bKtP1MVqB9ItgJPLDjvf/NEcMpHuK50p6VTju8MksSBIG6r2WBB3u/F1KEeht 6fsRslLEjODNxXKGMDA5TuOGfrmUTyINMPSwEyQQCip+5c5h6EMYlsEe8cq83gI+0ddp lmxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731485974; x=1732090774; h=content-transfer-encoding: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=Cnx5/u7WVVRjL/g2O6lnbYtDQ1Q9FLDekhDrsRiOiw0=; b=pmoI/bNynObqMXVlvIzNeo/6xKIqIUAv3aMwO/fOizcYn8GCyVk1trvny/emTuG1lj p4aaNfaM+fR5i95bfB52rgWViT+zyfIKNe5ibspsegtf3xURNjq/a5JTPH3l3cXhax48 KOG7kcsc5KgBKpVJOyHAoWwPik3HU8PhidjGyhZeUtDQVlj41IPdisbTI+uLEhq6Oi+a 9jDprZ5UoR2Z/eKHDse61LsxsxzoM9M74/EEq2iGpP8dQSFcD4qyIIvXujMV3Xncf3Gc 2pH0gs7h5JImR2kwOTKLM1WyhsrGf8QtirPPZjtkj2ngTK6IbR6AFEQEQt10fc55e8NU exBQ== X-Forwarded-Encrypted: i=1; AJvYcCUPhitJi7WeLYyWoi67lSoIBzM6xLOZoUhwQDU6/EEYAE2p6Oo8Peu3u6a4wr9Y6BLteGnXU22ozg==@kvack.org X-Gm-Message-State: AOJu0Yxnt2QeBB5MCW24VMSnGmDYEJ4VvL3LAkwO226aqHJTZWDSM4+p TeKtPvRs8IFTJmaAm8N2L4BHylyC4erElag9wYBIcvPhES12z+pzRKhKx8kcaw/kiujOn2NW9om O5eiqmn7MDSNCvVU6RG1fEQIJ0yWxW0jAy1J4 X-Gm-Gg: ASbGncuu6+GdIg49dFrUr6I/U77lz8n0J5cZ4VOgCCX/s3DBAWeGoLgtjs+BoinFg75 +cbWZ4BkHoulF2WaoVXrHn4FMlUr7vdc= X-Google-Smtp-Source: AGHT+IGE+nQpUYoL6FDT1s86sWs+I0FvuajgY1+GilAavFJvfleccnErI/dSJ4HZqOpFIpDau9jUOQ/tmyOe1suyIyE= X-Received: by 2002:a05:622a:114:b0:461:70cc:3799 with SMTP id d75a77b69052e-4634cad9282mr1849331cf.21.1731485974244; Wed, 13 Nov 2024 00:19:34 -0800 (PST) MIME-Version: 1.0 References: <20241112194635.444146-1-surenb@google.com> <20241112194635.444146-5-surenb@google.com> <6d0c5c2d-2963-489a-2376-8edaeb064de3@google.com> <54394536-da24-d01d-e4a7-2ece22b1ddab@google.com> In-Reply-To: <54394536-da24-d01d-e4a7-2ece22b1ddab@google.com> From: Suren Baghdasaryan Date: Wed, 13 Nov 2024 00:19:23 -0800 Message-ID: Subject: Re: [PATCH v2 4/5] mm: make vma cache SLAB_TYPESAFE_BY_RCU To: Hugh Dickins 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, minchan@google.com, jannh@google.com, shakeel.butt@linux.dev, souravpanda@google.com, pasha.tatashin@soleen.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 65DFEC0005 X-Stat-Signature: c1q8er9hdb5e4wdmen5o6u7r1apnajbf X-Rspam-User: X-HE-Tag: 1731485922-921878 X-HE-Meta: U2FsdGVkX19N7e1d/BbXPyCqb/88DB0JS7WYGfMr2SRsmCciO3Ldt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LLr2RFT6jKy29dgRLhokE9gIL1QG8/WcN9dd1aeGYzM+GxBeJVUwwQHoDuhUnDHETMw6zxTzmk8VqSNAEIKQ7gqPOtelVj6q3AWgn5ytXGhhgW29pc5EfIZH0omwkz9PZjEFPXdw7PuS9Lav375r2m76YlJsK/mbkgywKSRe25OVY6iPcmAh7Andis4/I/ygcd6G4aY= 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 Tue, Nov 12, 2024 at 10:52=E2=80=AFPM Hugh Dickins wr= ote: > > On Tue, 12 Nov 2024, Suren Baghdasaryan wrote: > > On Tue, Nov 12, 2024 at 9:08=E2=80=AFPM Hugh Dickins = wrote: > > > On Tue, 12 Nov 2024, Suren Baghdasaryan wrote: > > > > > > > > Thinking about this some more, I don't think this works. I'm relyin= g > > > > on vma_start_read() to stabilize the vma, however the lock I'm taki= ng > > > > is part of the vma which can be reused from under us. So, the lock = I'm > > > > taking might be reinitialized after I take the lock... > > > > I need to figure out a way to stabilize the vma in some other manne= r > > > > before taking this lock. > > > > > > (I'm not paying attention and following the patches, I just happened > > > to notice this remark: forgive me if I'm out of context and have > > > misunderstood, but hope this might help:) > > > > > > But this is exactly the problem SLAB_TYPESAFE_BY_RCU was invented for= . > > > You just have to be careful that the locks are initialized only when = the > > > slab is first created (allocated from buddy), not reinitialized whene= ver > > > a new object is allocated from that slab. > > > > Hi Hugh! > > I'm looking into SLAB_TYPESAFE_BY_RCU implementation and trying to > > figure out if initializing the lock in the ctor() of the cache as > > mentioned in the comment here: > > https://elixir.bootlin.com/linux/v6.12-rc7/source/include/linux/slab.h#= L127 > > would help my case. I assume that's what you are hinting here? > > Yes, if I'm "hinting", it's because offhand I forget the right names: > "ctor", yes, that sounds right. Just wanted to make sure I understood you correctly. Thanks for confirmatio= n. > > Just grep around for examples of how it is used: there must be plenty > now. but anon_vma is what it was first used for. Yeah, there are plenty of examples now. > > But given the title of this patch, I'm surprised it's new to you. Thinking about issues arising from possible object reuse is indeed new to me, that's why I missed the lock reinitialization issue. I think I know how to fix that now. Thanks, Suren. > > Hugh