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 X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A1F4C433C1 for ; Sat, 20 Mar 2021 01:56:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F3E3B6197F for ; Sat, 20 Mar 2021 01:56:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3E3B6197F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 84FAD6B008A; Fri, 19 Mar 2021 21:56:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 80B026B008C; Fri, 19 Mar 2021 21:56:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A0676B0092; Fri, 19 Mar 2021 21:56:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0132.hostedemail.com [216.40.44.132]) by kanga.kvack.org (Postfix) with ESMTP id 4F4BC6B008A for ; Fri, 19 Mar 2021 21:56:36 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 08C1A8249980 for ; Sat, 20 Mar 2021 01:56:36 +0000 (UTC) X-FDA: 77938588350.27.F003658 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf04.hostedemail.com (Postfix) with ESMTP id 8C0473C1 for ; Sat, 20 Mar 2021 01:56:35 +0000 (UTC) Received: by mail-pl1-f182.google.com with SMTP id w11so3749906ply.6 for ; Fri, 19 Mar 2021 18:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=//Emk3f8izjfdM0COtAWlTm2lGZVkPT29Ha1cVdjcAw=; b=I8HbqTpjmp02qEGn6oYI1vLbQopQ04WxNNZJUbaKkT8gce0w/gT2YhcuOwWcnRvAq6 i47DcTiOf5xZLtZPVwvO6uLF9nLZ1Fj/9CQsG/+HRdPC4McO44WXU2ygDtOKit8miLY1 yHCvNx8ocySuR3kREuk6abuwjKoqstpJ3/oBNOHFpZPK80Xn3i2jSz6B8s+S3cFeqUvx PREx89FEzu8rUToN+1Pes5WbXuUDiGYZmktpeKjA+D5Y4TJ6650FCEbx4XDNOGPvaQV/ 1JvybJue834+DU0K9mcDk1N5jZHtDxj1WmhhXaKVX11wm7AVsC7JSOSq7s69bp66hkTM mzLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=//Emk3f8izjfdM0COtAWlTm2lGZVkPT29Ha1cVdjcAw=; b=mp09GHfOlPsa+9B9s0duPDkb+yJz4UKgP9IxdgH6aGvgcOanmKTOXWamYyJQbkQA5O NMPbHbLP74T+ZTbcF/lioACT4PaWMpYj9Jt4/KigGlBxf1nw29z1UN7Dg5OKhvsipsIY sF3Co2C/fxvrBGUNR+lvWU/v0sF81IepUCRH85AVMC8aRWCcxxx+WM4McsdQFvEQZQoK ctawh5L3/d44OQpYhxeJZANePiYaaQFM9NVV6jYalNhS27YQQAYX3pZ/B9ziliinaR+a jQaPPsU2OjBdmuOyAYZhhyR2WusCqQ2ObOcamX/usWmOKQzleR6ugvcdQmocGdcorhaf k2lg== X-Gm-Message-State: AOAM533K5gUHgSMxTmXgVaM93qSJ70x1kV2pTsqPJSiHbLjZ1pjz0wsJ oc8k2dagjDzgYm63yhrDLuM= X-Google-Smtp-Source: ABdhPJzB3GxtP9ZaN78edYo61ib4NuHTcwhLwMMdftAyGslYGz2faRt7N3XkYZWAnpVQHcoRxb0IBA== X-Received: by 2002:a17:90a:1f49:: with SMTP id y9mr1409696pjy.69.1616205394490; Fri, 19 Mar 2021 18:56:34 -0700 (PDT) Received: from localhost ([103.250.185.142]) by smtp.gmail.com with ESMTPSA id cv3sm6587959pjb.9.2021.03.19.18.56.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 18:56:33 -0700 (PDT) Date: Sat, 20 Mar 2021 12:56:26 +1100 From: Balbir Singh To: David Hildenbrand Cc: Vlastimil Babka , Linux Memory Management List , Minchan Kim , Matthew Wilcox , Rik van Riel , Michal Hocko , Andrea Arcangeli , Peter Xu Subject: Re: Page zapping and page table reclaim Message-ID: <20210320015626.GC77072@balbir-desktop> References: <20210318235347.GA3346@balbir-desktop> <6f6a0e7b-4b61-cab4-cf8b-7437d7149b21@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6f6a0e7b-4b61-cab4-cf8b-7437d7149b21@redhat.com> X-Stat-Signature: gcfumqxkiix6ezauqqr9977h1airs1u5 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8C0473C1 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf04; identity=mailfrom; envelope-from=""; helo=mail-pl1-f182.google.com; client-ip=209.85.214.182 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616205395-396578 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 Fri, Mar 19, 2021 at 01:44:55PM +0100, David Hildenbrand wrote: > On 19.03.21 00:53, Balbir Singh wrote: > > On Thu, Mar 18, 2021 at 05:57:06PM +0100, Vlastimil Babka wrote: > > > On 3/11/21 7:14 PM, David Hildenbrand wrote: > > > > Hi folks, > > > > > > > > I was wondering, is there any mechanism that reclaims basically empty page > > > > tables in a running process? > > > > > > > > Like: When I MADV_DONTNEED a huge range, there could be plenty of basically > > > > empty (e.g., all entries invalid) page tables we could reclaim. As soon as we > > > > zap a complete PMD we could reclaim (depending on the architecture) a whole page. > > > > > > > > Zapping on the PMD level might make most impact I guess. > > > > > > > > For 1 GB, we need 262144 4k pages. If we assume each PTE is 8 bytes, we need a > > > > total of 8 MB for the lowest level page tables (PTE). > > > > > > > > OTOH, we would need 512 PMD entries - a single 4k page. Zapping 1 TB would mean > > > > we can free up another 4MB - rather a corner case and we can live with that. > > > > > > > > > > > > Of course, the same might apply to other cases where we can restore all page > > > > table content from the VMA again. One example would be after MADV_FREE zapped a > > > > whole range of entries we marked. > > > > > > I don't think we have such mechanism, but IIRC I've heard the idea mentioned > > > before, probably from Michal Hocko. Definitely an interesting research project > > > idea to evaluate the cost vs benefits of that. > > > > > > > It might lead to interesting interactions with lockless page table walking > > with implications on the mmap_lock as well. > > > > I think if lockless page table walks have to be able with THP code swapping > populated page tables by a PMD back and forth, swapping an unpopulated page > table by an invalid PMD entry might be quite similar. At least it feels like > both approaches would rely on similar mechanisms / locking. :) > Yes, but then I suspect you always need destruct page tables by RCU. > I'm planning on looking into this, but not sure when I'll have time to > prototype something up. > > Thanks, Balbir Singh.