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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1A93C61DD3 for ; Tue, 1 Sep 2026 14:24:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iAcdWjHiY3dPSUjtPxFg5yUooaTvDtfuqyUkl5/EsG8=; b=cezcX/NwIelFMu VVB2m14XV/PHimXAbuFxUknXZSZ7P9O4rEj9psuttt6drDtJcXasxVmtFALhy64lUpUaUNZdWjLY+ I4boMgn8uwk2TEk68yM4HgOWb/2NttSIbC00nEg5wYDT/IQAs7yGGHhvzY0ut6pESVMKt54UPY0f6 MjuHa2gjavIEFR7j/Qir3twpwRFIwF49jjt7wGHIdrSdYy0cY2mppA+2+7gBXWQLyuiTg9J3s6awE En+K8bDB8cDj+kBU1Prke4vUeGQfx3bUKUd8XKB5qYUZ8OB6qcxJTRdqBQVRqa4e4mgQvcIuNTY9U zutdp6hKhgEcC0laO5Ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1PPM-0000000CKOx-2Nqs; Tue, 01 Sep 2026 14:24:16 +0000 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1PPJ-0000000CKNV-1fVa for linux-snps-arc@lists.infradead.org; Tue, 01 Sep 2026 14:24:15 +0000 Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-92e55b62640so311537385a.0 for ; Tue, 01 Sep 2026 07:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1788272651; x=1788877451; darn=lists.infradead.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=AMNw5MzyW2DJkQCetuS4jMUrMgDtCzVkmjImJH3QcQw=; b=CNBxLYgJP+8fneULJtygmwJKF57RMZRGoX3R9XfgEyJ7f4aHATM7dKrlYnyzrbOw3D hIVbjH43qsTIOR/179LE6drwoYIq/5bYS+InDOfL/5hoP+qNGmJ0kBqUaDVTQle41eou BljZcAZz0xX7S4jD19bjf6+Q6L+1P1PhoYroEei21lZG9JDZeOKDT+TLIyzazyxLaRow YtgwYwb9M8o2CwU4jdZPM+jdAVJpdxq6tmEIe9YDu+qtJGEXQ6lnXYOxALI7vG8ukLpJ goBpxKwXzhBz2Xw00tS2TlttdJkRLbi8yIH46F3Sah2ZGMmajA5e6UAeCZUvyDOIXNfT Jyig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788272651; x=1788877451; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=AMNw5MzyW2DJkQCetuS4jMUrMgDtCzVkmjImJH3QcQw=; b=FsQrLmkN67Mu/BlyZMlyJ4ywfVttslnBf4lhS1S5hI2K6avAjZfnVDRyHZIZ6a2pJ5 IW23vscl9c/vuvUTr9UBzn7b7OTWAM9Ou4m0uw+tkayQeTq3SX5J/g4Zy1d4I3t/fpVT 7WGACAIFprsUS4D1DixMuONSHRw78CxpxF/tydvCOfBEaACX7HEd+1OhpBZG5J5Btahi DEoNLUehI8WRuON/WIAuX/6QrDgYYzJCjYr+q1PufmYxvFU3Vc32U+aQTREa9FHujnbH mJuqzNXTB686ZXFk6bSFKcAVyeB21na9aa8PKBZ3tmoBCvoxs4aFBWy6xxLiujiwxpvk 0pGw== X-Forwarded-Encrypted: i=1; AHgh+RpqPeTyik1Sp9/4/9skZfm50EMt+tj06WOIvenALi5zYwMFziqWZSYWyTDFn1e8i5qM/5OgKXGdvOXEGZkOvQ==@lists.infradead.org X-Gm-Message-State: AFuF++lhKOnSRqyAE80jVnEtSz8ImnL4yfR1PrMC6kF14QYvFO+6aHwj N7IWlQDRRZSzUcrvCiCczcYs9swNtLe4q08J/eZHy0cre2qeA9zUUIHShJuAjdLrHRw= X-Gm-Gg: AR+sD10agKnzNmWb988lDOZh9ttYKr/VHE+w2f+HfTR47kxe1XjSlRTuY90Afr+zOSc 03mIwp2+NGPILTWgzGAonfMfHf69HDv2paF9zrhOej/dUyiFpHLThWVcx798Y/V8pm3OJYRHYJD Kssw7e3jepn8DMca1GoF4pMwfHS4cuX23qiXvUtQW4LIgBc4srJAzBobs5Vzwykyc8V9RaUuqbG Xlm7ZaKMZAsUkCuW8Q9TAc61WxH7qAilWigEC/sKbFgDg6s6EeEoIOvGCrrckk390mbrd2fOwBc bFK11DGlxbJYyOhWPnpPFnu78apeYfHwk7/Z39wemA4u/MJEFaWezl8yPHZ/jDJgEOmErlpbyhw 6IWH9rKtafjB+g1xs+tw+jf5BrqcRoir9OTEBoeSmiyZ4hRNGOOpagv+5ozOfMelwbBEg8FAbXf XqyN79GZ9yZUxTjKh0FUZWNrMX+qzOW8Uic0wT3xFTLSTux3ia28MF8xHJFWycMhq4nl2GBYcrl HZO5Vk2hV0kYYxznTwKjq1OfiNHadbKbOt/GLfvTALp6Q== X-Received: by 2002:a05:620a:29d4:b0:934:ab73:ac53 with SMTP id af79cd13be357-939134fe550mr3924451085a.0.1788272649971; Tue, 01 Sep 2026 07:24:09 -0700 (PDT) Received: from ziepe.ca (hlfxns010zw-159-2-239-150.pppoe-dynamic.high-speed.ns.bellaliant.net. [159.2.239.150]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93917012b65sm1040535485a.2.2026.09.01.07.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 07:24:09 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1x1PPE-0000000BgeE-10ID; Tue, 01 Sep 2026 11:24:08 -0300 Date: Tue, 1 Sep 2026 11:24:08 -0300 From: Jason Gunthorpe To: "Lorenzo Stoakes (ARM)" Cc: Kiryl Shutsemau , Andrew Morton , David Hildenbrand , Zi Yan , Baolin Wang , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Guo Ren , Brian Cain , Geert Uytterhoeven , Dinh Nguyen , Simon Schuster , Jonas Bonn , Stefan Kristiansson , Stafford Horne , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Russell King , Vineet Gupta , Michal Simek , Chris Zankel , Max Filippov , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , "David S. Miller" , Andreas Larsson , Richard Henderson , Matt Turner , Magnus Lindholm , Catalin Marinas , Mark Rutland , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Madhavan Srinivasan , Michael Ellerman , "Christophe Leroy (CS GROUP)" , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Richard Weinberger , Anton Ivanov , Johannes Berg , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Arnd Bergmann , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , John Hubbard , Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-openrisc@vger.kernel.org, linux-sh@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-snps-arc@lists.infradead.org, linux-arch@vger.kernel.org, sparclinux@vger.kernel.org, linux-alpha@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-um@lists.infradead.org, Hugh Dickins , Qi Zheng Subject: Re: [PATCH 01/12] mm/huge_memory: zap deposited page tables after an RCU grace period Message-ID: <20260901142408.GA56830@ziepe.ca> References: <20260901-rcu-pagetable-freeing-v1-0-5456a81c8212@kernel.org> <20260901-rcu-pagetable-freeing-v1-1-5456a81c8212@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260901_072413_547589_F82F6011 X-CRM114-Status: GOOD ( 17.24 ) X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+linux-snps-arc=archiver.kernel.org@lists.infradead.org On Tue, Sep 01, 2026 at 03:12:45PM +0100, Lorenzo Stoakes (ARM) wrote: > It won't be costly at the time of the calls obviously as its deferred. Maybe > increase some time spent in softirq but again is 512x that big of a deal? > > I'm not sure how you'd both defer the free and somehow utilise mmu_gather here > either really, certainly not without it becoming extremely messy. The less costly version is to thread the page to be freed onto the mmu_gather through a linked list in the struct page memory. This is super cheap since it is just a singly linked list operation. Then when the mmu_gather is flushed it does a single call_rcu using the rcu head of the struct page of the head of the list. The callback clears the entire linked list of pages. Since you have to tlb flush anyhow, it makes sense to always use the mmu_gather. For example the design I ended up with for iommupt accumulates all the invalidations and all the free-able memory into a gather then invalidates and frees. This allows maximizing the tlbi efficiency too. You can't do call_srcu until you flush the tlb and if you call once per table then you are also tlb flushing once per table too. So if the kernel really does want to clear out 512 leaf tables the optimal implementation is one range tlbi for 512 entries followed by one call_rcu to free the memory. Hence the gather.. Jason _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8386C624D4 for ; Tue, 1 Sep 2026 14:24:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AMNw5MzyW2DJkQCetuS4jMUrMgDtCzVkmjImJH3QcQw=; b=cAJWiKnFt47+8Olm+WnoLeggtJ rox06QnjaqhHTwraqbZ+eMKM6tO9bp9vcZlsHZ3jkj3ExjH6ZUnZorbN9XGZBBJEXXBtg6SXWUaK8 spOyTmoyaoNgZfB+4cKGiuE3JKsEkz6da6ODdW9XN4+kMffcb4NdPjQGh2683bWxFHrX9PkGuQLP6 IplowFiM3G7nfNgVxGi/w2spmiT7d3O/lcwnaD4wPcGZ7zEvEenmPdBavCJOmhoYJ7765dIn59nS7 7G6Ug3kLB+SwdvJ+ZIb6kEFRI71LaaV2eaDFLMeyJ45MMez7rr2xmFgYFCRnywmFt4reVwLyRx/vY IIwy1IPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1PPM-0000000CKP2-2enN; Tue, 01 Sep 2026 14:24:16 +0000 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1PPJ-0000000CKNX-1fri for linux-um@lists.infradead.org; Tue, 01 Sep 2026 14:24:15 +0000 Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-9391e3b21fbso295151685a.2 for ; Tue, 01 Sep 2026 07:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1788272651; x=1788877451; darn=lists.infradead.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=AMNw5MzyW2DJkQCetuS4jMUrMgDtCzVkmjImJH3QcQw=; b=CNBxLYgJP+8fneULJtygmwJKF57RMZRGoX3R9XfgEyJ7f4aHATM7dKrlYnyzrbOw3D hIVbjH43qsTIOR/179LE6drwoYIq/5bYS+InDOfL/5hoP+qNGmJ0kBqUaDVTQle41eou BljZcAZz0xX7S4jD19bjf6+Q6L+1P1PhoYroEei21lZG9JDZeOKDT+TLIyzazyxLaRow YtgwYwb9M8o2CwU4jdZPM+jdAVJpdxq6tmEIe9YDu+qtJGEXQ6lnXYOxALI7vG8ukLpJ goBpxKwXzhBz2Xw00tS2TlttdJkRLbi8yIH46F3Sah2ZGMmajA5e6UAeCZUvyDOIXNfT Jyig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788272651; x=1788877451; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=AMNw5MzyW2DJkQCetuS4jMUrMgDtCzVkmjImJH3QcQw=; b=MujbBBEVuj+CHjuV6s36itdfZxyZGjXzfPlSXH6eM0HPsQvsNtjFh8EGmEa0pvjNgC hU07E9g9SzxgS6HaX4XRmjD12R6V7FRlNXnz+I7AA+WxUCtRZUc3z9UaTmAbu7xq/KoX wSWHaG6B5xcWrdH2XA+jt+5cP6+K0irYQ0MGqaafEY+2g3/MuJFKnbO7aGhhrR7M8fm4 vTB7uhFhrG+OrCXwoPxtAf/67MzUNCQFFl1enrCmAqk95+0slw9Ri3fJaWD3xIGDh3BK 36QZpHHNhReH/z0p1OIV5lr6mJn3HLugivzKXjsVuSC0gBOI7wGTU3IT+W/2aDq2JkUN nk8g== X-Forwarded-Encrypted: i=1; AHgh+RpAsIJ6VmDe4TcIgrS+GgC7nrNOyzgcspZrHkvVz3A7GWz0HlBnyJadLfbYUXkgsEkHm3unvVqB+A==@lists.infradead.org X-Gm-Message-State: AFuF++koy+FX/zH02E55no9MCi9Xe1fmVl/TGELVis+3k7fVpPcQAPoj QFFQ8f0XH4z+8Kg3+l9VKWvcES+G6Lx2vFVqSCI/92CyYYMsG+g6TBDHBIKx2X9narY= X-Gm-Gg: AR+sD13lIDcRFss40JEwoA1XFtUpTPyDW/QPyINaZub69YjkQmC1BNZC4AFzsaX3zMz Bh1TyB2YP9KZaJvmwK7tRaOypZwFafgnSiW/iXvQMEaCdULs0ch+0h5KPkHcFoJ7odiH5LZ9w7u gW8PJeRvOu8+wUfPs90gUfRVm/sfn27aOuQmaFkpLcqavBe+aDcr1c5xGW8Hh6rxlLY50ScMNLK UEVoQHSxpp0Tj9PUyWMglPhARuz73e7vj7dmziGbFdDBxbooQh+Pc4jZsJRKfxvLlSrbgue94v4 Io5Ydr/u3iyGNwgYbNT3TABRznduOLfFbOYDVN8a/V7kerVGtawd0WsA7CQt4QxloOBRpaMML/6 WYcNg57X/Wy9gJflp9wBYxRwbLO5vptMumrRn+HxqLwS+x7rg9QvFE/6d33940uZooX3NSTioIn 71Br8eEdM3jh1pFnAJrsDhUaNaxJApKhtT6iDV4UKLf1E6xG9eSp5aSJMEIW6PaEgUzTDIfwcEc WpqyINrchuBWe9SXX4tpi3yHRBoGP9hwlEH5qdWaDjwXg== X-Received: by 2002:a05:620a:29d4:b0:934:ab73:ac53 with SMTP id af79cd13be357-939134fe550mr3924451085a.0.1788272649971; Tue, 01 Sep 2026 07:24:09 -0700 (PDT) Received: from ziepe.ca (hlfxns010zw-159-2-239-150.pppoe-dynamic.high-speed.ns.bellaliant.net. [159.2.239.150]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93917012b65sm1040535485a.2.2026.09.01.07.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 07:24:09 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1x1PPE-0000000BgeE-10ID; Tue, 01 Sep 2026 11:24:08 -0300 Date: Tue, 1 Sep 2026 11:24:08 -0300 From: Jason Gunthorpe To: "Lorenzo Stoakes (ARM)" Cc: Kiryl Shutsemau , Andrew Morton , David Hildenbrand , Zi Yan , Baolin Wang , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Guo Ren , Brian Cain , Geert Uytterhoeven , Dinh Nguyen , Simon Schuster , Jonas Bonn , Stefan Kristiansson , Stafford Horne , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Russell King , Vineet Gupta , Michal Simek , Chris Zankel , Max Filippov , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , "David S. Miller" , Andreas Larsson , Richard Henderson , Matt Turner , Magnus Lindholm , Catalin Marinas , Mark Rutland , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Madhavan Srinivasan , Michael Ellerman , "Christophe Leroy (CS GROUP)" , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Richard Weinberger , Anton Ivanov , Johannes Berg , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Arnd Bergmann , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , John Hubbard , Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-openrisc@vger.kernel.org, linux-sh@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-snps-arc@lists.infradead.org, linux-arch@vger.kernel.org, sparclinux@vger.kernel.org, linux-alpha@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-um@lists.infradead.org, Hugh Dickins , Qi Zheng Subject: Re: [PATCH 01/12] mm/huge_memory: zap deposited page tables after an RCU grace period Message-ID: <20260901142408.GA56830@ziepe.ca> References: <20260901-rcu-pagetable-freeing-v1-0-5456a81c8212@kernel.org> <20260901-rcu-pagetable-freeing-v1-1-5456a81c8212@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260901_072413_551304_F8BF4141 X-CRM114-Status: GOOD ( 17.17 ) X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+linux-um=archiver.kernel.org@lists.infradead.org On Tue, Sep 01, 2026 at 03:12:45PM +0100, Lorenzo Stoakes (ARM) wrote: > It won't be costly at the time of the calls obviously as its deferred. Maybe > increase some time spent in softirq but again is 512x that big of a deal? > > I'm not sure how you'd both defer the free and somehow utilise mmu_gather here > either really, certainly not without it becoming extremely messy. The less costly version is to thread the page to be freed onto the mmu_gather through a linked list in the struct page memory. This is super cheap since it is just a singly linked list operation. Then when the mmu_gather is flushed it does a single call_rcu using the rcu head of the struct page of the head of the list. The callback clears the entire linked list of pages. Since you have to tlb flush anyhow, it makes sense to always use the mmu_gather. For example the design I ended up with for iommupt accumulates all the invalidations and all the free-able memory into a gather then invalidates and frees. This allows maximizing the tlbi efficiency too. You can't do call_srcu until you flush the tlb and if you call once per table then you are also tlb flushing once per table too. So if the kernel really does want to clear out 512 leaf tables the optimal implementation is one range tlbi for 512 entries followed by one call_rcu to free the memory. Hence the gather.. Jason 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9F9AC624D4 for ; Tue, 1 Sep 2026 14:24:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mnbA1v44npj7pLnPIuT8rZyZczrYjefm/wTZFcwG+x0=; b=M/MT9J/jXBuX1c XXEp1ZAX17Pv9vKOYQfsApFfMWZDXhFmm56XBLO3laTsiGiL2OgjxoLc808mpZ7yjP5rS+wxp+VXl xlrQX42TB/A76d71fked4mRSXLi39Iw+dFmeXhCSkTourcIeFgpxHOycchwioRmoLR74qSVLrVufP IaeoEwMKFoLqvIH6Crgw5LobYI/wynrjFzDfo12EdJmPr1iyShO3lB1IrTE+hSXITn/VoJ1e4TNuk g6ewbq9NrlV6GF+RgwghN0u4XJOHZ9lPmr/Lzb55Ybz6OFqn/1a0UDqm9/cBaqKZ2LCbJ4cTq0qcr vOnwIq6cZwzLTa1gfUmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1PPM-0000000CKPG-2t2I; Tue, 01 Sep 2026 14:24:16 +0000 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1PPJ-0000000CKNW-1fVI for linux-riscv@lists.infradead.org; Tue, 01 Sep 2026 14:24:15 +0000 Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-9391e3b21fbso295150285a.2 for ; Tue, 01 Sep 2026 07:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1788272651; x=1788877451; darn=lists.infradead.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=AMNw5MzyW2DJkQCetuS4jMUrMgDtCzVkmjImJH3QcQw=; b=CNBxLYgJP+8fneULJtygmwJKF57RMZRGoX3R9XfgEyJ7f4aHATM7dKrlYnyzrbOw3D hIVbjH43qsTIOR/179LE6drwoYIq/5bYS+InDOfL/5hoP+qNGmJ0kBqUaDVTQle41eou BljZcAZz0xX7S4jD19bjf6+Q6L+1P1PhoYroEei21lZG9JDZeOKDT+TLIyzazyxLaRow YtgwYwb9M8o2CwU4jdZPM+jdAVJpdxq6tmEIe9YDu+qtJGEXQ6lnXYOxALI7vG8ukLpJ goBpxKwXzhBz2Xw00tS2TlttdJkRLbi8yIH46F3Sah2ZGMmajA5e6UAeCZUvyDOIXNfT Jyig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788272651; x=1788877451; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=AMNw5MzyW2DJkQCetuS4jMUrMgDtCzVkmjImJH3QcQw=; b=p6TFFeH9v9+b0OzX7epch6+GweB6XA/b6sl1OBZ1JAlDGCrFsbg6+9S+KZz2surofU zBXaUBjr/Udnmssf74qv93iNmjVQjl1LAqjAMZoh5wYFxXKV4dZyZZhmpmbnrS6AdV5F kNtONWr4GgP8QHiHStBDZcRBosxcLe1BoXlB2XMaGP3ZLqKBCKuTGbKM9xg0VGJnjuz+ JaZCjod5Iw8CQUWNaqcoueQ88IVmv4u3TTTI8bt5Ob3CI8mteZiEbl6My7bM3Tx96CqS kbF2rFCAlsrmV387zPYJweZVmzzW7kRal9Wm0BDHZc87dY6eODctKBcdt5QQt53Qq8iX 2e/w== X-Forwarded-Encrypted: i=1; AHgh+RrLNJRD62AvWjlO8eOZZJ/hw809xu27exp3pGcFmixtnKQ68qZhMlQMYj4ZKSsfUCL/vIDsbPC3ksbWHw==@lists.infradead.org X-Gm-Message-State: AFuF++lbY38danvhaxn9cKvIG4ow3s7WmIcYuNozDbYyeib1H1OYUb7q GhcD+drQHs9S1G3VZelSOeZz6Hwc9UWgwnxXtYXJV1CUMdEfoJCS1gXz/dvv+MJLKgc= X-Gm-Gg: AR+sD115p68tywabtqPc+0khbKaD2t6CMKuyP+0CSeuj699oLAZrU2yj7nGEytWg5Gd 8KBoONqbYRRF+AbEmF7EHXpz8Qd82l+rcQVX08D+lxksMQBQAXwHkXz2siFTIoeIbx+mxsrB8Jz 59zZtx+MAaOyVgU1w2cJ124iWA2rePeh36W/4kCWfkSfDtRiRGmmq0zN3lbHbjUyaHZqGSPQkYK gYs1+U5Uc/8xnH34O0NUUAZ31q2nG70oMoyiO4cpKcKn6jwt69+kSNMrnSub/JesOc0dZChLT1X T84xjc8hK28K+6S7BTIAeH45DKWAYteU8YJ0DFOJdLN8qkfb6P7ReSmDD3blTH9MgjMeJsdGNb6 brE7vw/XuS+ib5CrO82flFefJ81nczx1acbUgq6p6LC4Qg3fkyNxBC8Zf/jFS1pwkQAfQUfJhEB aZtNKmTH0fb19DNaauKTUx4i0cBDl9aP+CLUQuD/YTxednusL728ngEJ+5yMVYvupfyw7AuFCCG Ml9/F/OJ3uEzsqnKYJgapdPOf97I9clo4rKJw5XZ8YIpA== X-Received: by 2002:a05:620a:29d4:b0:934:ab73:ac53 with SMTP id af79cd13be357-939134fe550mr3924451085a.0.1788272649971; Tue, 01 Sep 2026 07:24:09 -0700 (PDT) Received: from ziepe.ca (hlfxns010zw-159-2-239-150.pppoe-dynamic.high-speed.ns.bellaliant.net. [159.2.239.150]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93917012b65sm1040535485a.2.2026.09.01.07.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 07:24:09 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1x1PPE-0000000BgeE-10ID; Tue, 01 Sep 2026 11:24:08 -0300 Date: Tue, 1 Sep 2026 11:24:08 -0300 From: Jason Gunthorpe To: "Lorenzo Stoakes (ARM)" Cc: Kiryl Shutsemau , Andrew Morton , David Hildenbrand , Zi Yan , Baolin Wang , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Guo Ren , Brian Cain , Geert Uytterhoeven , Dinh Nguyen , Simon Schuster , Jonas Bonn , Stefan Kristiansson , Stafford Horne , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Russell King , Vineet Gupta , Michal Simek , Chris Zankel , Max Filippov , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , "David S. Miller" , Andreas Larsson , Richard Henderson , Matt Turner , Magnus Lindholm , Catalin Marinas , Mark Rutland , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Madhavan Srinivasan , Michael Ellerman , "Christophe Leroy (CS GROUP)" , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Richard Weinberger , Anton Ivanov , Johannes Berg , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Arnd Bergmann , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , John Hubbard , Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-openrisc@vger.kernel.org, linux-sh@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-snps-arc@lists.infradead.org, linux-arch@vger.kernel.org, sparclinux@vger.kernel.org, linux-alpha@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-um@lists.infradead.org, Hugh Dickins , Qi Zheng Subject: Re: [PATCH 01/12] mm/huge_memory: zap deposited page tables after an RCU grace period Message-ID: <20260901142408.GA56830@ziepe.ca> References: <20260901-rcu-pagetable-freeing-v1-0-5456a81c8212@kernel.org> <20260901-rcu-pagetable-freeing-v1-1-5456a81c8212@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260901_072413_552701_DB2303D6 X-CRM114-Status: GOOD ( 17.24 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Tue, Sep 01, 2026 at 03:12:45PM +0100, Lorenzo Stoakes (ARM) wrote: > It won't be costly at the time of the calls obviously as its deferred. Maybe > increase some time spent in softirq but again is 512x that big of a deal? > > I'm not sure how you'd both defer the free and somehow utilise mmu_gather here > either really, certainly not without it becoming extremely messy. The less costly version is to thread the page to be freed onto the mmu_gather through a linked list in the struct page memory. This is super cheap since it is just a singly linked list operation. Then when the mmu_gather is flushed it does a single call_rcu using the rcu head of the struct page of the head of the list. The callback clears the entire linked list of pages. Since you have to tlb flush anyhow, it makes sense to always use the mmu_gather. For example the design I ended up with for iommupt accumulates all the invalidations and all the free-able memory into a gather then invalidates and frees. This allows maximizing the tlbi efficiency too. You can't do call_srcu until you flush the tlb and if you call once per table then you are also tlb flushing once per table too. So if the kernel really does want to clear out 512 leaf tables the optimal implementation is one range tlbi for 512 entries followed by one call_rcu to free the memory. Hence the gather.. Jason _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv