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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 D4F86C6379D for ; Mon, 23 Nov 2020 13:12:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81F8E20575 for ; Mon, 23 Nov 2020 13:12:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="eeEoYa3p" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387445AbgKWMqn (ORCPT ); Mon, 23 Nov 2020 07:46:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387411AbgKWMps (ORCPT ); Mon, 23 Nov 2020 07:45:48 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35831C0613CF; Mon, 23 Nov 2020 04:45:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=D/+uQXuYCHVJTryMNhtIQ0wirxLovQ10MM/7dftfXjA=; b=eeEoYa3psy1tQ0tTz+3MV500iq llvX2Sq8XRxLgLc4WkoFbfknD5IuMj5jxeQbAoExJ8GueJ5c7jbEdBYzy4ZAv5TgoNvzjoYcaAJE2 NY3ZUBdJMTt+QbgdfbWC0Blm/oZq+tJsp7r6NZhWe6bK11IlKbXjWJCKokcbLb6f0r0ZWuw98vK33 /NgveDC9KrZI+yM1PMYnsRCLpwGDyj5/6DHqZ7Skbu8j1mhFfbLHoFlwy5JPoK7PbBKu1/LoDzr5h M35LHR3GTV8EJpVz41HDlLhuiX/y/RVJPHyPje9sA5X1J9Nwv4d+N89FUyEUsROJ6Ktf+W7q8/u/m 6jp0E+bQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1khBDV-0000hM-8q; Mon, 23 Nov 2020 12:45:13 +0000 Date: Mon, 23 Nov 2020 12:45:13 +0000 From: Matthew Wilcox To: Michal Hocko Cc: Muchun Song , Jonathan Corbet , Mike Kravetz , Thomas Gleixner , mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, Peter Zijlstra , viro@zeniv.linux.org.uk, Andrew Morton , paulmck@kernel.org, mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com, Randy Dunlap , oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, Mina Almasry , David Rientjes , Oscar Salvador , "Song Bao Hua (Barry Song)" , Xiongchun duan , linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel Subject: Re: [External] Re: [PATCH v5 00/21] Free some vmemmap pages of hugetlb page Message-ID: <20201123124513.GI4327@casper.infradead.org> References: <20201120064325.34492-1-songmuchun@bytedance.com> <20201120084202.GJ3200@dhcp22.suse.cz> <20201120131129.GO3200@dhcp22.suse.cz> <20201123074046.GB27488@dhcp22.suse.cz> <20201123094344.GG27488@dhcp22.suse.cz> <20201123104258.GJ27488@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201123104258.GJ27488@dhcp22.suse.cz> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 23, 2020 at 11:42:58AM +0100, Michal Hocko wrote: > On Mon 23-11-20 18:36:33, Muchun Song wrote: > > > No I really mean that pfn_to_page will give you a struct page pointer > > > from pages which you release from the vmemmap page tables. Those pages > > > might get reused as soon sa they are freed to the page allocator. > > > > We will remap vmemmap pages 2-7 (virtual addresses) to page > > frame 1. And then we free page frame 2-7 to the buddy allocator. > > And this doesn't really happen in an atomic fashion from the pfn walker > POV, right? So it is very well possible that > > struct page *page = pfn_to_page(); > // remapping happens here > // page content is no longer valid because its backing memory can be > // reused for whatever purpose. pfn_to_page() returns you a virtual address. That virtual address remains a valid pointer to exactly the same contents, it's just that the page tables change to point to a different struct page which has the same compound_head().