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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6477FC19F21 for ; Thu, 28 Jul 2022 09:25:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08DA48E0001; Thu, 28 Jul 2022 05:25:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 03D8C6B0072; Thu, 28 Jul 2022 05:25:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E48D98E0001; Thu, 28 Jul 2022 05:25:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D61A66B0071 for ; Thu, 28 Jul 2022 05:25:11 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id AA26181393 for ; Thu, 28 Jul 2022 09:25:11 +0000 (UTC) X-FDA: 79735974822.01.F6A0DC5 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf06.hostedemail.com (Postfix) with ESMTP id 1300E1800A5 for ; Thu, 28 Jul 2022 09:25:10 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0A782B82380 for ; Thu, 28 Jul 2022 09:25:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DC3DC43144 for ; Thu, 28 Jul 2022 09:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659000307; bh=7pq/2Z60GYWXwFYneAORoRndD27DanVgbiYGcaR6gLk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ffMQFUj302iUtf3No5xdZTKyr38PfuNjv35jUAOBYxbQpNOaYu5z1qie/PPrwudVp rbor1vghIWM3G77lJrAH1ar/K9X8EzGnc9e8/UWwcqBQUJClCdBAXm5ooTEhvWwumk nqWNMZknE4HIUKhEpEMEaSDf5b46pcxY5XBNcKVtb9D7GXve33Rx3pdiwh9bXodyFe XEg3bRfmARBEBSYJiMwKWc/Xd5bITzO99wuWYIPrtYKdWbh4BZVGGcGNj9G+JeF806 5OBqXWTaqiT/tRN1vGY4LeozcX0cGiLJGgnRmws4Ijuhc3+ZSH82D/StYdeoCaOheq jGKkfn69WhEcg== Received: by mail-vs1-f48.google.com with SMTP id 125so1084481vsd.5 for ; Thu, 28 Jul 2022 02:25:07 -0700 (PDT) X-Gm-Message-State: AJIora/d21Hk/QofgsGnxDj7q3uH/UTtM7U+D3y3I3zR0hQbs0sEO1O6 m9D5EFrSKGXUfyEuh++OIeHsck2dTCus6jTzm9U= X-Google-Smtp-Source: AGRyM1vyH+nsbqzZjGAJ6qBx3wXBi1+dUz0jOf3JsHZ5+CvaVM8g+iopMUmY8qoZiCb4cLiRSfo3Wa34/mRjVsyJuuo= X-Received: by 2002:a67:d599:0:b0:358:6371:4cfb with SMTP id m25-20020a67d599000000b0035863714cfbmr6080587vsj.78.1659000306050; Thu, 28 Jul 2022 02:25:06 -0700 (PDT) MIME-Version: 1.0 References: <20220721130419.1904711-1-chenhuacai@loongson.cn> <20220721130419.1904711-4-chenhuacai@loongson.cn> <20220722091604.GD18125@willie-the-truck> In-Reply-To: <20220722091604.GD18125@willie-the-truck> From: Huacai Chen Date: Thu, 28 Jul 2022 17:24:52 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V5 3/4] mm/sparse-vmemmap: Generalise vmemmap_populate_hugepages() To: Will Deacon Cc: Huacai Chen , Arnd Bergmann , Thomas Bogendoerfer , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Catalin Marinas , loongarch@lists.linux.dev, linux-arch , Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , Andrew Morton , Linux-MM , "open list:MIPS" , LKML , linux-arm-kernel , Feiyang Chen Content-Type: text/plain; charset="UTF-8" ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ffMQFUj3; spf=pass (imf06.hostedemail.com: domain of chenhuacai@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=chenhuacai@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659000311; a=rsa-sha256; cv=none; b=0hnp3GFeL7GsmenmzxUfEyQ/wZHfga7wxmlXJmrTK/tHvJJniXPY9cRmiDeoI/lSMRUAgB kBgDKXCX+F/mkrUVVqYiFJrs0Ysz2+uD563tiDUs2wAFSjQpxJbbHowV7vkt+Ds5EBJ+70 mC7fuwjf9PPrbO48Twag3YCLsq1pBZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659000311; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XruQTAIXB54uT74eDcOv4O3zNRNSQhd+MtvV4CDXSwc=; b=HgPCR7re+au63t9mU+SxumyrNXwXCNCdICVyvAJsoOzg5gCK/F6XEaMZRngf4IZWe5Cybc sBNc7G/Xq/pwKnDPgfJKNhcnZjrIfTAqaQ+Whw3mfNWFpM0RriMNLiODMaW1q/VK3rgMPA sikdWV1oWhq6cpC7j7WCcZN2VPZoUwI= X-Rspamd-Server: rspam10 X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ffMQFUj3; spf=pass (imf06.hostedemail.com: domain of chenhuacai@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=chenhuacai@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: eqcm5pq3ciu5kq9i3s44zxsr5qyjr5ji X-Rspamd-Queue-Id: 1300E1800A5 X-HE-Tag: 1659000310-725617 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, Will, On Fri, Jul 22, 2022 at 5:16 PM Will Deacon wrote: > > On Thu, Jul 21, 2022 at 09:04:18PM +0800, Huacai Chen wrote: > > diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c > > index 0abcb0a5f1b5..eafd084b8e19 100644 > > --- a/mm/sparse-vmemmap.c > > +++ b/mm/sparse-vmemmap.c > > @@ -694,6 +694,69 @@ int __meminit vmemmap_populate_basepages(unsigned long start, unsigned long end, > > return vmemmap_populate_range(start, end, node, altmap, NULL); > > } > > > > +void __weak __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node, > > + unsigned long addr, unsigned long next) > > +{ > > +} > > + > > +int __weak __meminit vmemmap_check_pmd(pmd_t *pmd, int node, unsigned long addr, > > + unsigned long next) > > +{ > > + return 0; > > +} > > + > > +int __meminit vmemmap_populate_hugepages(unsigned long start, unsigned long end, > > + int node, struct vmem_altmap *altmap) > > +{ > > + unsigned long addr; > > + unsigned long next; > > + pgd_t *pgd; > > + p4d_t *p4d; > > + pud_t *pud; > > + pmd_t *pmd; > > + > > + for (addr = start; addr < end; addr = next) { > > + next = pmd_addr_end(addr, end); > > + > > + pgd = vmemmap_pgd_populate(addr, node); > > + if (!pgd) > > + return -ENOMEM; > > + > > + p4d = vmemmap_p4d_populate(pgd, addr, node); > > + if (!p4d) > > + return -ENOMEM; > > + > > + pud = vmemmap_pud_populate(p4d, addr, node); > > + if (!pud) > > + return -ENOMEM; > > + > > + pmd = pmd_offset(pud, addr); > > + if (pmd_none(READ_ONCE(*pmd))) { > > + void *p; > > + > > + p = vmemmap_alloc_block_buf(PMD_SIZE, node, altmap); > > + if (p) { > > + vmemmap_set_pmd(pmd, p, node, addr, next); > > + continue; > > + } else if (altmap) { > > + /* > > + * No fallback: In any case we care about, the > > + * altmap should be reasonably sized and aligned > > + * such that vmemmap_alloc_block_buf() will always > > + * succeed. If there is no more space in the altmap > > + * and we'd have to fallback to PTE (highly unlikely). > > Can you tweak the last couple of sentences please, as they don't make sense > to me? To be specific, I'd suggest replacing: > > "If there is no more space in the altmap and we'd have to fallback to PTE > (highly unlikely). That could indicate an altmap-size configuration > issue." > > with something like: > > "For consistency with the PTE case, return an error here as failure could > indicate a configuration issue with the size of the altmap." > > With that: > > Acked-by: Will Deacon OK, I will send V5, thanks. Huacai > > Will