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=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 67075C10DCE for ; Fri, 13 Mar 2020 14:57:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 32540206FA for ; Fri, 13 Mar 2020 14:57:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32540206FA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CDCFF6B0007; Fri, 13 Mar 2020 10:57:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8D8E6B0008; Fri, 13 Mar 2020 10:57:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA44B6B000A; Fri, 13 Mar 2020 10:57:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0003.hostedemail.com [216.40.44.3]) by kanga.kvack.org (Postfix) with ESMTP id 91C036B0007 for ; Fri, 13 Mar 2020 10:57:37 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3A3E12477 for ; Fri, 13 Mar 2020 14:57:37 +0000 (UTC) X-FDA: 76590642954.23.tray48_4277bcfc2cb27 X-HE-Tag: tray48_4277bcfc2cb27 X-Filterd-Recvd-Size: 4701 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Fri, 13 Mar 2020 14:57:36 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id s14so12489900wrt.8 for ; Fri, 13 Mar 2020 07:57:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=923AOhkC6CgfcnsEfd2Ewky7X/CQDVkHRNsMNS/03nE=; b=sWsq3d0n2UHmrOtUCv8ZuR7AnQc1FN87b3G/ujzUkvcP1AXS+x/a7ZSiJSb2uv6s/p je80Sy7OUYXnZ5fw7zfyhaj1PyP1atsC5fW4PD1opNbGlqcr9BpC7F4/Iz+INKnYFbtg Cy50ebwZKeQH4pEYjKCPPl6cCcGGZW7VHVtIN8TqZvtXqalWT4qGfOrXy+zvyqmhfsUZ Zw0z5R4xdQaI0NWNbxIElZtBo1YyG9CEb9VPyrtes3wzEmawK/5Z7akBjJCPjNYGyvIH 3ntg+BK/40V8Y/lKjVgCa+KnuyavoGuC46omNccXCu2PnR6WthGXjufPIoS4SdmvRwdp l0Cw== X-Gm-Message-State: ANhLgQ0gTBWP5CifAMzspWBcyFcEXyK2RMEVKRR2xRVIe+Fi+j9MwRup O5JwQkmr/oxyNv/tN+HXeQI= X-Google-Smtp-Source: ADFU+vt94FqhFJiatryexDq8ri3tlf1agQzN8HKR3zGTYttNBVVuywugylzVo2UdX9a/QZde4kAHiA== X-Received: by 2002:adf:8b1b:: with SMTP id n27mr9187015wra.349.1584111455610; Fri, 13 Mar 2020 07:57:35 -0700 (PDT) Received: from localhost (ip-37-188-247-35.eurotel.cz. [37.188.247.35]) by smtp.gmail.com with ESMTPSA id s7sm13606579wro.10.2020.03.13.07.57.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2020 07:57:34 -0700 (PDT) Date: Fri, 13 Mar 2020 15:57:33 +0100 From: Michal Hocko To: Wei Yang Cc: Matthew Wilcox , Baoquan He , linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, david@redhat.com Subject: Re: [PATCH v2] mm/sparse.c: Use kvmalloc_node/kvfree to alloc/free memmap for the classic sparse Message-ID: <20200313145733.GE21007@dhcp22.suse.cz> References: <20200312130822.6589-1-bhe@redhat.com> <20200312133416.GI22433@bombadil.infradead.org> <20200312141826.djb7osbekhcnuexv@master> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200312141826.djb7osbekhcnuexv@master> 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 Thu 12-03-20 14:18:26, Wei Yang wrote: > On Thu, Mar 12, 2020 at 06:34:16AM -0700, Matthew Wilcox wrote: > >On Thu, Mar 12, 2020 at 09:08:22PM +0800, Baoquan He wrote: > >> This change makes populate_section_memmap()/depopulate_section_memmap > >> much simpler. > >> > >> Suggested-by: Michal Hocko > >> Signed-off-by: Baoquan He > >> --- > >> v1->v2: > >> The old version only used __get_free_pages() to replace alloc_pages() > >> in populate_section_memmap(). > >> http://lkml.kernel.org/r/20200307084229.28251-8-bhe@redhat.com > >> > >> mm/sparse.c | 27 +++------------------------ > >> 1 file changed, 3 insertions(+), 24 deletions(-) > >> > >> diff --git a/mm/sparse.c b/mm/sparse.c > >> index bf6c00a28045..362018e82e22 100644 > >> --- a/mm/sparse.c > >> +++ b/mm/sparse.c > >> @@ -734,35 +734,14 @@ static void free_map_bootmem(struct page *memmap) > >> struct page * __meminit populate_section_memmap(unsigned long pfn, > >> unsigned long nr_pages, int nid, struct vmem_altmap *altmap) > >> { > >> - struct page *page, *ret; > >> - unsigned long memmap_size = sizeof(struct page) * PAGES_PER_SECTION; > >> - > >> - page = alloc_pages(GFP_KERNEL|__GFP_NOWARN, get_order(memmap_size)); > >> - if (page) > >> - goto got_map_page; > >> - > >> - ret = vmalloc(memmap_size); > >> - if (ret) > >> - goto got_map_ptr; > >> - > >> - return NULL; > >> -got_map_page: > >> - ret = (struct page *)pfn_to_kaddr(page_to_pfn(page)); > >> -got_map_ptr: > >> - > >> - return ret; > >> + return kvmalloc_node(sizeof(struct page) * PAGES_PER_SECTION, > >> + GFP_KERNEL|__GFP_NOWARN, nid); > > > >Use of NOWARN here is inappropriate, because there's no fallback. > > Hmm... this replacement is a little tricky. > > When you look into kvmalloc_node(), it will do the fallback if the size is > bigger than PAGE_SIZE. This means the change here may not be equivalent as > before if memmap_size is less than PAGE_SIZE. I do not understand your concern to be honest. Even if a sub page memmap size was possible (I haven't checked), I fail to see why kmalloc would fail to allocate while vmalloc would have a bigger chance to succeed. -- Michal Hocko SUSE Labs