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 DBBC3C05027 for ; Mon, 23 Jan 2023 20:08:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FA426B0071; Mon, 23 Jan 2023 15:08:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6AAD16B0072; Mon, 23 Jan 2023 15:08:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54B496B0074; Mon, 23 Jan 2023 15:08:38 -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 4586B6B0071 for ; Mon, 23 Jan 2023 15:08:38 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 19C168190A for ; Mon, 23 Jan 2023 20:08:38 +0000 (UTC) X-FDA: 80387151516.13.EFC5502 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by imf25.hostedemail.com (Postfix) with ESMTP id 52836A0023 for ; Mon, 23 Jan 2023 20:08:36 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=RyYyVfXd; spf=pass (imf25.hostedemail.com: domain of surenb@google.com designates 209.85.128.44 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=1674504516; a=rsa-sha256; cv=none; b=Zhmo8VTuv1qLYaeWjcUTR39gB1dhIQYrnuGIlogvqrfjz0NwNTSzKlut2OmxG/sAYki75k C0pOwWx1mXfiLNBC2MC3GuLBJgFwbEUAy61/EX3UiE1aeSRY3fhTpBAQLbOh1ovrZC5A0I r5nLMrGv8kJwu1xefUA9Uboi4S9DU0A= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=RyYyVfXd; spf=pass (imf25.hostedemail.com: domain of surenb@google.com designates 209.85.128.44 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=1674504516; 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=Xx0+AS/R5cTFxTer1KPJhFwelUzEZqlaudVJ4C5UqlM=; b=4zsdFXn66JKnolIAVRtE+lTUF/YHbOhTG/KuznSZHaU974xpTTTVkoyfvbx6vkWvGnClvo 9iaHctxJ6G7oLaqvel9SR82veoGLujZirhG1pn64cNWztE/24Jtsq3xjINLBvjrw8NX8Jm VC/GSfaMmp1zKbfLEtEfNS6ZB3XJr1w= Received: by mail-wm1-f44.google.com with SMTP id j17so9973600wms.0 for ; Mon, 23 Jan 2023 12:08:36 -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=Xx0+AS/R5cTFxTer1KPJhFwelUzEZqlaudVJ4C5UqlM=; b=RyYyVfXdy0EOGXtjgeoYEX0CSfXeDuawJy3LtwRKGEXH7xPRUd7FzH5vM0ZD/5/uNP fWBSe/Vuek0fbxHy7ulBo2tzxgjytQXIhDoKjaRk3SO4pUlWanXPzUwdk9sCfPJMgGQV p18xwdky3Y0ZFWjj2oRsWB1r8iCofsyuM+DRRi3eBUWKYZ0nN2FXeurkdZEHXIwEXyHo 0hKaiu62QCi9O+hzr1ZvTjmsOHLWnqe2N/6m1fgfhTobQv9HYlX2hUiV/odvHm54lxez NCc0aIPRkybQcRORZZdU5UX7FU9qwPmbIdE06KG8aUUiUZFG2ePpUffvAsR6tWHeElFT rYKg== 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=Xx0+AS/R5cTFxTer1KPJhFwelUzEZqlaudVJ4C5UqlM=; b=mh912MaOp+/JGh22SaDDiGXkJ8new8QJlHe/8bH9tdnhR5AoJRg/AvzMnttqEn8y/E +O2TnhzN7HkY7FSD+Rs4BIoLK/wgAtm5t5Qy/KtWZFROZllY+a3B0HA6w9eBE7AH84XM czWV+V3alLYdAHV2XVIRB84C972v7088fSyxxBoG616hAqUndKEsC96xEOMFxoKVSK9b kdJMnkYd35Q9LQpwn5cVYX7uFk8gUIVXJ4Kaz596gHvtPRFPaIuGj8YZNsXpJ7wmsiXN h8CvWWCDEuD+rVNvXEk/eI374bAhUEbo287PXBdIUuRBYXSQsntYxIqpcpk8/IWVPZB5 U4rw== X-Gm-Message-State: AFqh2kqiNEY1l2HAi/nBnPvTAUz9ZJBr0gFm5tjJ+DHG7zbG0CRJ9+K9 8cB53WLvhoZyUrcFLTHEkeX7UFk83fexYMK8WwBDGQ== X-Google-Smtp-Source: AMrXdXsAYItHDpk4yH6h+tdfdbjpmDtWUNcVfzcOaPv8ocdm14en5egjG3x9mr/LGbfmiQJ1437Ba8Qp+R4Oyn+yujs= X-Received: by 2002:a05:600c:3412:b0:3d0:a619:c445 with SMTP id y18-20020a05600c341200b003d0a619c445mr1027494wmp.17.1674504514768; Mon, 23 Jan 2023 12:08:34 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Suren Baghdasaryan Date: Mon, 23 Jan 2023 12:08:21 -0800 Message-ID: Subject: Re: [PATCH 39/41] kernel/fork: throttle call_rcu() calls in vm_area_free To: Michal Hocko Cc: Matthew Wilcox , "Liam R. Howlett" , akpm@linux-foundation.org, michel@lespinasse.org, jglisse@google.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, peterz@infradead.org, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, paulmck@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, hughlynch@google.com, leewalsh@google.com, posk@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Rspamd-Queue-Id: 52836A0023 X-Rspamd-Server: rspam01 X-Stat-Signature: iiagwo4wrt9coq9t4n9utkjyc53j81tz X-HE-Tag: 1674504516-684274 X-HE-Meta: U2FsdGVkX1++76o1nply+qLQo12AxzBFGrhgvEt6DiOuoaFKsEIgGT9SrywUKcCgNvqVIfZWuarZkh1KuiYxTydWc/1mXEdv+yxDX3PncDU55K1y/FQMXNP5cL8nY/jc2b/F0UdUbaPbfD+9+Tjuhc9scb9QvoU4eSVIyQGEZ630kylDVMPv5TwBR9yIplMN+BNZcM1XNSIM1GMCrLgxbT8GE0pmCcT+V9sWWnDSCquZpSPdo47woYlcc6LvbIzeJOzEenojAePwyDVk0rvLOcREP41+lbmtBggqe/iE9klPJ0EXwVUIQKparq2RqAyAz5iD+5Trbe/FxlqMTe8nQzZYBL/Ep8Q3hwWUJ3OKRh+YgGD3hPwNH88cHTjc3Ao1ukMnpQqaBLPTcBgdre1/TRIrMMMsyQuQ1t+uOW0g9O+6VeKQ+5rmT7FqZRGSf4L9VLWMnXqXp36OE9vRx3lRwBMkZpmB4N4lOiSSX9oCRy8krD8dNnwWgzq+AXsx2vpOGKFmwLTkUQ2mu0bhTaNfEJwLvKjoQGIDJ/G/sCCPfWvGYwBbqZaIqIVGRn+6HNmzp1CVr8IGUNkyburYLescRiJaRVEJoWc3JlYhE+pLE2OZ93cY7kIVZhsgdORHtQGeY4CpcumlBioqOV+ZWTjjYejFGxhs+G+GZ1PsY1Du9tfagMN8Ia7UwObng6j75k8vd/hdtkWyJUOQN/UMXw/xu19G9b2Hpz9flFdXbVKVmVDFw8tgV8/ULRU56v6k3Ry7sjkglYLDgUZKE+fduQMoXlR9OiSEt+gIZ+c+baBzYLNK1aZdpm/nSNB7wGII0eKJuaaOawj6oB7Zkk64SbqEgCuzLf4k794+Xxajvw2kPe3I7O8uMsI/AcnVTMQSo+TTmMcZ3q1naiHRnbHzGg1S3kt9NEVGiBiYNMyXzGEzVkwoyj7ycsc2HLREnSmk+19aGf6eZAsE2/0G3mrpU10 8Wa6Og1I PuQJdT/0g7sMooXz4i1NFLT+TuDBk/vAO6rm+tbriugWcB6h++V9EKWObvXws7F0PmQmbNtTMIP/9MSBky5Xk/8GZkb0oUk2tm7D86K2vwYFm8h7lfbsdYjKxdo+8lnilBDrM5FiiA/qgDS8uPMmXIVpSZ6sbhgLnBjA6QA46temkJ5vWhbwHwAzLgaRWS1ScxgkVMadfwlfHKVYW7hRA1AdAisuTxVfVtoXBwwtrFtsaDmwrXNhKIB5fBaVBFCzcZXPQp4ZEjUAbcfFOXJ27AfCBYPlBfdDVR6xCAHe+kF0wKi270aJrNneoF5nt1fbUpv2iwDCuGfJ8WIN9Ae1N+D/ENDseXrsBnVvI 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 Mon, Jan 23, 2023 at 12:00 PM Michal Hocko wrote: > > On Mon 23-01-23 19:30:43, Matthew Wilcox wrote: > > On Mon, Jan 23, 2023 at 08:18:37PM +0100, Michal Hocko wrote: > > > On Mon 23-01-23 18:23:08, Matthew Wilcox wrote: > > > > On Mon, Jan 23, 2023 at 09:46:20AM -0800, Suren Baghdasaryan wrote: > > > [...] > > > > > Yes, batching the vmas into a list and draining it in remove_mt() and > > > > > exit_mmap() as you suggested makes sense to me and is quite simple. > > > > > Let's do that if nobody has objections. > > > > > > > > I object. We *know* nobody has a reference to any of the VMAs because > > > > you have to have a refcount on the mm before you can get a reference > > > > to a VMA. If Michal is saying that somebody could do: > > > > > > > > mmget(mm); > > > > vma = find_vma(mm); > > > > lock_vma(vma); > > > > mmput(mm); > > > > vma->a = b; > > > > unlock_vma(mm, vma); > > > > > > > > then that's something we'd catch in review -- you obviously can't use > > > > the mm after you've dropped your reference to it. > > > > > > I am not claiming this is possible now. I do not think we want to have > > > something like that in the future either but that is really hard to > > > envision. I am claiming that it is subtle and potentially error prone to > > > have two different ways of mass vma freeing wrt. locking. Also, don't we > > > have a very similar situation during last munmaps? > > > > We shouldn't have two ways of mass VMA freeing. Nobody's suggesting that. > > There are two cases; there's munmap(), which typically frees a single > > VMA (yes, theoretically, you can free hundreds of VMAs with a single > > call which spans multiple VMAs, but in practice that doesn't happen), > > and there's exit_mmap() which happens on exec() and exit(). > > This requires special casing remove_vma for those two different paths > (exit_mmap and remove_mt). If you ask me that sounds like a suboptimal > code to even not handle potential large munmap which might very well be > a rare thing as you say. But haven't we learned that sooner or later we > will find out there is somebody that cares afterall? Anyway, this is not > something I care about all that much. It is just weird to special case > exit_mmap, if you ask me. Up to Suren to decide which way he wants to > go. I just really didn't like the initial implementation of batching > based on a completely arbitrary batch limit and lazy freeing. I would prefer to go with the simplest sufficient solution. A potential issue with a large munmap might prove to be real but I think we know how to easily fix that with batching if the issue ever materializes (I'll have a fix ready implementing Michal's suggestion). So, I suggest going with Liam's/Matthew's solution and converting to Michal's solution if regression shows up anywhere else. Would that be acceptable? > -- > Michal Hocko > SUSE Labs