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=-8.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 D3626C1975A for ; Thu, 12 Mar 2020 13:55:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9970C206E7 for ; Thu, 12 Mar 2020 13:55:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fotRuyy4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9970C206E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 33A6B6B0007; Thu, 12 Mar 2020 09:55:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2EA456B0008; Thu, 12 Mar 2020 09:55:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 226166B000A; Thu, 12 Mar 2020 09:55:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0042.hostedemail.com [216.40.44.42]) by kanga.kvack.org (Postfix) with ESMTP id 0873E6B0007 for ; Thu, 12 Mar 2020 09:55:03 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id CCA0E246B for ; Thu, 12 Mar 2020 13:55:02 +0000 (UTC) X-FDA: 76586856444.29.coat69_2c0421f8c9f4b X-HE-Tag: coat69_2c0421f8c9f4b X-Filterd-Recvd-Size: 4152 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Thu, 12 Mar 2020 13:55:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584021301; h=from:from:reply-to:subject:subject: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=qPmvRjIYfa2TuLrWzxiz6LwZ3SWvS2fMU9bF8WC9teY=; b=fotRuyy4vpdrj9esGwyRTEC9Q0Sb2LiCnuOaSVhO/9Qjo5ZFSnxYLunWbWzIFjtcYHhGwG baq4GvqpF7U5SmXSqT9hydJ+6auHK+OVlCMechBaFei8rAvmvI+YpqcseniWnkf6U5d+Lk AKur0hKW9InjlboOvLS+lrTyl1uSixc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-46-D3zU0jFfPo-qyw89vffB5g-1; Thu, 12 Mar 2020 09:54:54 -0400 X-MC-Unique: D3zU0jFfPo-qyw89vffB5g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D2A4A801E72; Thu, 12 Mar 2020 13:54:52 +0000 (UTC) Received: from localhost (ovpn-12-43.pek2.redhat.com [10.72.12.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 89CEF7386F; Thu, 12 Mar 2020 13:54:49 +0000 (UTC) Date: Thu, 12 Mar 2020 21:54:46 +0800 From: Baoquan He To: Matthew Wilcox Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.com, akpm@linux-foundation.org, david@redhat.com, richard.weiyang@gmail.com Subject: Re: [PATCH v2] mm/sparse.c: Use kvmalloc_node/kvfree to alloc/free memmap for the classic sparse Message-ID: <20200312135446.GK27711@MiWiFi-R3L-srv> References: <20200312130822.6589-1-bhe@redhat.com> <20200312133416.GI22433@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200312133416.GI22433@bombadil.infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 03/12/20 at 06:34am, 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. kvmalloc_node has added __GFP_NOWARN internally when try to allocate continuous pages. I will remove it. > Also, I'd use array_size(sizeof(struct page), PAGES_PER_SECTION). It's fine to me, even though we know it has no risk to overflow. I will use array_size. Thanks.