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 9504FC433DB for ; Thu, 18 Mar 2021 23:53:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1AB3664E81 for ; Thu, 18 Mar 2021 23:53:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1AB3664E81 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 9AD816B006E; Thu, 18 Mar 2021 19:53:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 95CE86B0071; Thu, 18 Mar 2021 19:53:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7FD316B0072; Thu, 18 Mar 2021 19:53:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0153.hostedemail.com [216.40.44.153]) by kanga.kvack.org (Postfix) with ESMTP id 6463E6B006E for ; Thu, 18 Mar 2021 19:53:58 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1D3C71801C427 for ; Thu, 18 Mar 2021 23:53:58 +0000 (UTC) X-FDA: 77934650556.31.E6F204A Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf15.hostedemail.com (Postfix) with ESMTP id D6CE6A00064A for ; Thu, 18 Mar 2021 23:53:54 +0000 (UTC) Received: by mail-pf1-f176.google.com with SMTP id x126so4607065pfc.13 for ; Thu, 18 Mar 2021 16:53:54 -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=OsjNEaZYAsBspLsLwqWGDpyMKRtGTzKDI2nHgpaRlO4=; b=Ra8D1UJrb79VPsZf16ZXKMrTlC6CNAa42hCPijdchtu0rN/3jJG12d0kS8YnmbYMMr XaBqm6NZBloKwFZc21vTJu/xEP8Itr9cjRTs9967qneM3gJCIl8GieD8ny94M6vQhU0d 562TcBY+5Jd46FlZqMnJsus9kdC+1T3oNHXiTqj9FgUxeI7J4f6CBMbVxsN7CUrc/Joo CVKEO2RiW84+Re9n6wBNX5XWh8npuwhvI29KUwx24dwtVXZIKcW+nfpCK6/pPA8AYQVy abubq/NrK2QCpx5v4jQVA3BKIYxBtJRZhz5mMpyd0uZtgDzmYDBLD/hGWy2htqn7aeJK 1IEQ== 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=OsjNEaZYAsBspLsLwqWGDpyMKRtGTzKDI2nHgpaRlO4=; b=KQljyeF65hHFJKfQAMhz+jKxqNgqTycDvzTvIzohCv/pEYmWxTch0Y3iezngHcn2ir RlDfWVdUwwQq30Q5GO215+UDQkj6MmFGzKwE/Y/VFHM1B0Uj4nxilIxIlzqk2OwC0/6Y mwk2ikz6I9T39LXzjtCn0ODPDUa76O9k034QlML5GwhLDfsZyLyGuqEVgj2cGWEG+I/a tZE1TtyJORhlwAa3XZLqsGrF7T8bkaxJLESXHP7Ih6zHXAQQjgjS2q8V3aa8Dzn3HQye 5t+TtIuUJfc7U/uDwNhu1MmmYfYhSt+UTtfqjEdw1OVVaNCv5WTEUuq3UHmd9jOwI/7+ wnlQ== X-Gm-Message-State: AOAM531hGzeBvPFf/SAghVkWRrKNmDUj01yjz3eG3Zr7GUeZmLHE/Qmr PdIXRD/mst939TkrIfwsRGo= X-Google-Smtp-Source: ABdhPJx6F10/eUBDxcTZh48pG1BbhHV3j/vqapVS/d/gj9Ys8ClfDxMVwtwgYa3b9m45A/wThpWadA== X-Received: by 2002:a63:4848:: with SMTP id x8mr8824688pgk.447.1616111633195; Thu, 18 Mar 2021 16:53:53 -0700 (PDT) Received: from localhost (121-45-173-48.tpgi.com.au. [121.45.173.48]) by smtp.gmail.com with ESMTPSA id z4sm3090460pgv.73.2021.03.18.16.53.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 16:53:51 -0700 (PDT) Date: Fri, 19 Mar 2021 10:53:47 +1100 From: Balbir Singh To: Vlastimil Babka Cc: David Hildenbrand , 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: <20210318235347.GA3346@balbir-desktop> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: 5kc9a9gamgufsj3nkuw7y3thipui8wzh X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D6CE6A00064A Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf15; identity=mailfrom; envelope-from=""; helo=mail-pf1-f176.google.com; client-ip=209.85.210.176 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616111634-893413 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 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. Balbir