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=-3.8 required=3.0 tests=BAYES_00, 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 DFB08C4361B for ; Wed, 16 Dec 2020 22:25:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 70B9F2335A for ; Wed, 16 Dec 2020 22:25:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70B9F2335A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BB27D6B005D; Wed, 16 Dec 2020 17:25:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B62796B006C; Wed, 16 Dec 2020 17:25:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7A786B0070; Wed, 16 Dec 2020 17:25:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0223.hostedemail.com [216.40.44.223]) by kanga.kvack.org (Postfix) with ESMTP id 8A6CD6B005D for ; Wed, 16 Dec 2020 17:25:55 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 53EEA8249980 for ; Wed, 16 Dec 2020 22:25:55 +0000 (UTC) X-FDA: 77600579070.22.sofa06_331739d2742f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 30AB118038E68 for ; Wed, 16 Dec 2020 22:25:55 +0000 (UTC) X-HE-Tag: sofa06_331739d2742f X-Filterd-Recvd-Size: 3783 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Dec 2020 22:25:54 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5D02FAC90; Wed, 16 Dec 2020 22:25:53 +0000 (UTC) Date: Wed, 16 Dec 2020 23:25:49 +0100 From: Oscar Salvador To: Mike Kravetz Cc: Muchun Song , corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, paulmck@kernel.org, mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com, rdunlap@infradead.org, oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, almasrymina@google.com, rientjes@google.com, willy@infradead.org, mhocko@suse.com, song.bao.hua@hisilicon.com, david@redhat.com, duanxiongchun@bytedance.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v9 03/11] mm/hugetlb: Free the vmemmap pages associated with each HugeTLB page Message-ID: <20201216222549.GC3207@localhost.localdomain> References: <20201213154534.54826-1-songmuchun@bytedance.com> <20201213154534.54826-4-songmuchun@bytedance.com> <5936a766-505a-eab0-42a6-59aab2585880@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5936a766-505a-eab0-42a6-59aab2585880@oracle.com> 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 Wed, Dec 16, 2020 at 02:08:30PM -0800, Mike Kravetz wrote: > > + * vmemmap_rmap_walk - walk vmemmap page table > > I am not sure if 'rmap' should be part of these names. rmap today is mostly > about reverse mapping lookup. Did you use rmap for 'remap', or because this > code is patterned after the page table walking rmap code? Just think the > naming could cause some confusion. I also had the same feeling about the 'rmap' usage. > > + > > +static void vmemmap_pte_range(pmd_t *pmd, unsigned long addr, > > + unsigned long end, struct vmemmap_rmap_walk *walk) > > +{ > > + pte_t *pte; > > + > > + pte = pte_offset_kernel(pmd, addr); > > + do { > > + BUG_ON(pte_none(*pte)); > > + > > + if (!walk->reuse) > > + walk->reuse = pte_page(pte[VMEMMAP_TAIL_PAGE_REUSE]); > > It may be just me, but I don't like the pte[-1] here. It certainly does work > as designed because we want to remap all pages in the range to the page before > the range (at offset -1). But, we do not really validate this 'reuse' page. > There is the BUG_ON(pte_none(*pte)) as a sanity check, but we do nothing similar > for pte[-1]. Based on the usage for HugeTLB pages, we can be confident that > pte[-1] is actually a pte. In discussions with Oscar, you mentioned another > possible use for these routines. Without giving it much of a thought, I guess we could duplicate the BUG_ON for the pte outside the loop, and add a new one for pte[-1]. Also, since walk->reuse seems to not change once it is set, we can take it outside the loop? e.g: pte *pte; pte = pte_offset_kernel(pmd, addr); BUG_ON(pte_none(*pte)); BUG_ON(pte_none(pte[VMEMMAP_TAIL_PAGE_REUSE])); walk->reuse = pte_page(pte[VMEMMAP_TAIL_PAGE_REUSE]); do { .... } while... Or I am not sure whether we want to keep it inside the loop in case future cases change walk->reuse during the operation. But to be honest, I do not think it is realistic of all future possible uses of this, so I would rather keep it simple for now. -- Oscar Salvador SUSE L3