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,URIBL_BLOCKED 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 5FC3DC2D0E4 for ; Mon, 23 Nov 2020 12:19:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 090262076E for ; Mon, 23 Nov 2020 12:19:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="Q4MvfuOY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729381AbgKWMSr (ORCPT ); Mon, 23 Nov 2020 07:18:47 -0500 Received: from mx2.suse.de ([195.135.220.15]:44824 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729308AbgKWMSq (ORCPT ); Mon, 23 Nov 2020 07:18:46 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1606133924; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=t1n0bl10c6m95DWi5xYuSHqG3jOj8hN5IrXcSggafl0=; b=Q4MvfuOYSyYXHmAEGGhUA8ePzEEjpQCH1lmDmkV0EqMYWNawqsy3dwuH/chm2yyk8gy7Qg chZmckVej9kuKiVnE3781b6jlxYlUbX3iGni3+AIYZ7r7IajfNmuNexEqg8KMtLz+rb7/l chij4NlD0xKRhO9yBZx2MKSNkhPl9Dw= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 76399AFC1; Mon, 23 Nov 2020 12:18:44 +0000 (UTC) Date: Mon, 23 Nov 2020 13:18:42 +0100 From: Michal Hocko To: Muchun Song Cc: 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 , Matthew Wilcox , 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: <20201123121842.GM27488@dhcp22.suse.cz> References: <20201120131129.GO3200@dhcp22.suse.cz> <20201123074046.GB27488@dhcp22.suse.cz> <20201123094344.GG27488@dhcp22.suse.cz> <20201123104258.GJ27488@dhcp22.suse.cz> <20201123113208.GL27488@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 23-11-20 20:07:23, Muchun Song wrote: > On Mon, Nov 23, 2020 at 7:32 PM Michal Hocko 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 > > > > > > Yeah, you are right. But it may not be a problem for HugeTLB pages. > > > Because in most cases, we only read the tail struct page and get the > > > head struct page through compound_head() when the pfn is within > > > a HugeTLB range. Right? > > > > Many pfn walkers would encounter the head page first and then skip over > > the rest. Those should be reasonably safe. But there is no guarantee and > > the fact that you need a valid page->compound_head which might get > > scribbled over once you have the struct page makes this extremely > > subtle. > > In this patch series, we can guarantee that the page->compound_head > is always valid. Because we reuse the first tail page. Maybe you need to > look closer at this series. Thanks. I must be really terrible exaplaining my concern. Let me try one last time. It is really _irrelevant_ what you do with tail pages. The underlying problem is that you are changing struct pages under users without any synchronization. What used to be a valid struct page will turn into garbage as soon as you remap vmemmap page tables. -- Michal Hocko SUSE Labs