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=-5.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 88B3BC433DB for ; Thu, 11 Mar 2021 18:14:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0607764F94 for ; Thu, 11 Mar 2021 18:14:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0607764F94 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 691738D02DB; Thu, 11 Mar 2021 13:14:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 63FE68D02B2; Thu, 11 Mar 2021 13:14:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B9B18D02DB; Thu, 11 Mar 2021 13:14:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0027.hostedemail.com [216.40.44.27]) by kanga.kvack.org (Postfix) with ESMTP id 253728D02B2 for ; Thu, 11 Mar 2021 13:14:19 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D92E8181AEF3F for ; Thu, 11 Mar 2021 18:14:18 +0000 (UTC) X-FDA: 77908392996.25.5B786F3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf26.hostedemail.com (Postfix) with ESMTP id E9BEE40B8CE5 for ; Thu, 11 Mar 2021 18:14:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615486450; h=from:from: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; bh=ir3j7EAR+u7ObfsapF93GumkR/NBNA/QctAvG4qFbK0=; b=QH5A+enV/sAvUAFvyt1bValdVQ3jqV6uct4R0WXLD/b4owiDKlYBv3DLK4U8qyWPYd9eAR qMTvzj1K8rYCECY9En1DwBP7+tYabjfu6A0/Pl9TOoIsMQBpKU94Mi9VWZrb6zYKHfy0r3 J5P7VzeYiesLgNSOFSCH6CvVo6+K4kg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-262-nIlOiO8LPeiK49p2fCJAkQ-1; Thu, 11 Mar 2021 13:14:08 -0500 X-MC-Unique: nIlOiO8LPeiK49p2fCJAkQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B024B100C660; Thu, 11 Mar 2021 18:14:07 +0000 (UTC) Received: from [10.36.115.26] (ovpn-115-26.ams2.redhat.com [10.36.115.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 441F45D9F2; Thu, 11 Mar 2021 18:14:03 +0000 (UTC) To: Linux Memory Management List Cc: Minchan Kim , Matthew Wilcox , Rik van Riel , Michal Hocko , Andrea Arcangeli , Peter Xu From: David Hildenbrand Organization: Red Hat GmbH Subject: Page zapping and page table reclaim Message-ID: Date: Thu, 11 Mar 2021 19:14:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Stat-Signature: bdiuqp7obq7g4gkxqyjxno5x161edsxj X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: E9BEE40B8CE5 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf26; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=63.128.21.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615486448-917074 Content-Transfer-Encoding: quoted-printable 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: Hi folks, I was wondering, is there any mechanism that reclaims basically empty=20 page tables in a running process? Like: When I MADV_DONTNEED a huge range, there could be plenty of=20 basically empty (e.g., all entries invalid) page tables we could=20 reclaim. As soon as we zap a complete PMD we could reclaim (depending on=20 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=20 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=20 would mean we can free up another 4MB - rather a corner case and we can=20 live with that. Of course, the same might apply to other cases where we can restore all=20 page table content from the VMA again. One example would be after=20 MADV_FREE zapped a whole range of entries we marked. Looks like if we happen to zap a THP, we should already get what we want=20 (no page table, nothing to remove) I haven't immediately stumbled over anything, but could be I am missing=20 the obvious. I guess what would need some thought is concurrent=20 discards/pagefaults - but it feels like being similar to=20 collapsing/splitting a THP while there is other system activity. Maybe there is already something and I am just not aware of it. Thanks! --=20 Thanks, David / dhildenb