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=unavailable 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 0DB00C18E5B for ; Mon, 16 Mar 2020 12:41:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BD17320663 for ; Mon, 16 Mar 2020 12:41:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GU/asRSi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD17320663 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 619446B0003; Mon, 16 Mar 2020 08:41:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CAC36B0005; Mon, 16 Mar 2020 08:41:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E1276B0007; Mon, 16 Mar 2020 08:41:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id 3331C6B0003 for ; Mon, 16 Mar 2020 08:41:11 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F338940D6 for ; Mon, 16 Mar 2020 12:41:10 +0000 (UTC) X-FDA: 76601185500.10.dad90_447c99d081b45 X-HE-Tag: dad90_447c99d081b45 X-Filterd-Recvd-Size: 4454 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Mar 2020 12:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584362470; 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=fcAZwGWS+0RpVKIFFUi8FSdQbOhSVmHnkXWx/lxohog=; b=GU/asRSiWEkNyp9Sokts+P++jEhRaSK+e4pnjIzkTBIBGRhxpyC499lIxBmeEKHmj9w39W jfRzkBlBdNuAxRCk11My5SndTeanYP5SV+0X0fHOkinNQQU8COQMY46t0dPOsOMtOIF+1z ipZVgnUFQ5B2XHJqPze07ZjTmdDwjeY= 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-151-ewh3LtoUOzC0UL7GGYiLqg-1; Mon, 16 Mar 2020 08:41:02 -0400 X-MC-Unique: ewh3LtoUOzC0UL7GGYiLqg-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 B71038017DF; Mon, 16 Mar 2020 12:41:00 +0000 (UTC) Received: from localhost (ovpn-12-129.pek2.redhat.com [10.72.12.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 23B387A411; Mon, 16 Mar 2020 12:40:57 +0000 (UTC) Date: Mon, 16 Mar 2020 20:40:54 +0800 From: Baoquan He To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.com, akpm@linux-foundation.org, willy@infradead.org, richard.weiyang@gmail.com, vbabka@suse.cz Subject: Re: [PATCH v4 1/2] mm/sparse.c: Use kvmalloc/kvfree to alloc/free memmap for the classic sparse Message-ID: <20200316124054.GF3486@MiWiFi-R3L-srv> References: <20200316102150.16487-1-bhe@redhat.com> <1f5b22ac-283e-3b69-f443-528f09edaf60@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1f5b22ac-283e-3b69-f443-528f09edaf60@redhat.com> 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/16/20 at 12:00pm, David Hildenbrand wrote: > On 16.03.20 11:21, Baoquan He wrote: > > This change makes populate_section_memmap()/depopulate_section_memmap > > much simpler. > > > > Suggested-by: Michal Hocko > > Signed-off-by: Baoquan He > > Reviewed-by: David Hildenbrand > > Acked-by: Michal Hocko > > --- > > v3->v4: > > Split the old v3 into two patches, to carve out the using 'nid' > > as preferred node to allocate memmap into a separate patch. This > > is suggested by Michal, and the carving out is put in patch 2. > > > > v2->v3: > > Remove __GFP_NOWARN and use array_size when calling kvmalloc_node() > > per Matthew's comments. > > http://lkml.kernel.org/r/20200312141749.GL27711@MiWiFi-R3L-srv > > > > mm/sparse.c | 27 +++------------------------ > > 1 file changed, 3 insertions(+), 24 deletions(-) > > > > diff --git a/mm/sparse.c b/mm/sparse.c > > index e747a238a860..d01d09cc7d99 100644 > > --- a/mm/sparse.c > > +++ b/mm/sparse.c > > @@ -719,35 +719,14 @@ static int fill_subsection_map(unsigned long pfn, unsigned long nr_pages) > > 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(array_size(sizeof(struct page), > > + PAGES_PER_SECTION), GFP_KERNEL); > > FWIW, this is what I meant: > > return kvmalloc(array_size(sizeof(struct page), > PAGES_PER_SECTION), GFP_KERNEL); Since there's another parameter, I didn't indent it with sizeof. But Pankaj and Matthew have added other two votes on this, I will change it, thanks.