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,URIBL_BLOCKED, 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 6ACDEC4CECE for ; Sat, 14 Mar 2020 00:53:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0970D2074B for ; Sat, 14 Mar 2020 00:53:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Qc4jITuZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0970D2074B 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 6172C6B0003; Fri, 13 Mar 2020 20:53:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C60D6B0006; Fri, 13 Mar 2020 20:53:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B47D6B0007; Fri, 13 Mar 2020 20:53:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0162.hostedemail.com [216.40.44.162]) by kanga.kvack.org (Postfix) with ESMTP id 308E26B0003 for ; Fri, 13 Mar 2020 20:53:47 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 07B7D180AD838 for ; Sat, 14 Mar 2020 00:53:47 +0000 (UTC) X-FDA: 76592145294.21.push81_20ff0eeb68033 X-HE-Tag: push81_20ff0eeb68033 X-Filterd-Recvd-Size: 5100 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Sat, 14 Mar 2020 00:53:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584147226; 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=y9gJ39nM22R6BINLHw3+oLq/uGsj2PXaZMR61+u7WNg=; b=Qc4jITuZLTLcceffr8qlQBt7qEX6k51YGSq+343f2TUuOTD/BiWMusDDiIMSLTSwgLfcrc eN2v/3VIVwrdJs3XhIPZjnvxrkzg3oKpJQfrwEipO/E8hsBEXJz4+w/sRRAXGwWxWo/YE3 ANk6wrnuyxL8Y4+pWoy/+YZS7X5cijY= 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-150-ezN-Em1yPKWNPoaIkECnTA-1; Fri, 13 Mar 2020 20:53:42 -0400 X-MC-Unique: ezN-Em1yPKWNPoaIkECnTA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC6AE477; Sat, 14 Mar 2020 00:53:40 +0000 (UTC) Received: from localhost (ovpn-12-20.pek2.redhat.com [10.72.12.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 89D335DA2C; Sat, 14 Mar 2020 00:53:37 +0000 (UTC) Date: Sat, 14 Mar 2020 08:53:34 +0800 From: Baoquan He To: Michal Hocko Cc: linux-kernel@vger.kernel.org, willy@infradead.org, linux-mm@kvack.org, akpm@linux-foundation.org, david@redhat.com, richard.weiyang@gmail.com Subject: Re: [PATCH v3] mm/sparse.c: Use kvmalloc_node/kvfree to alloc/free memmap for the classic sparse Message-ID: <20200314005334.GO27711@MiWiFi-R3L-srv> References: <20200312130822.6589-1-bhe@redhat.com> <20200312141749.GL27711@MiWiFi-R3L-srv> <20200313145619.GD21007@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200313145619.GD21007@dhcp22.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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/13/20 at 03:56pm, Michal Hocko wrote: > On Thu 12-03-20 22:17:49, Baoquan He wrote: > > This change makes populate_section_memmap()/depopulate_section_memmap > > much simpler. > > Not only and you should make it more explicit. It also tries to allocate > memmaps from the target numa node so this is a functional change. I > would prefer to have that in a separate patch in case we hit some weird > NUMA setups which would choke on memory less nodes and similar horrors. Yes, splitting sounds more reasonable, I would love to do that. One question is I noticed Andrew had picked this into -mm tree, if I post a new patchset including these two small patches, whether it's convenient to drop the old one and get these two merged. Sorry, I don't know very well how this works in mm maintaining. > > > Suggested-by: Michal Hocko > > Signed-off-by: Baoquan He > > I do not see any reason this shouldn't work. Btw. did you get to test > it? > > Feel free to add > Acked-by: Michal Hocko > to both patches if you go and split. > > > --- > > v2->v3: > > Remove __GFP_NOWARN and use array_size when calling kvmalloc_node() > > per Matthew's comments. > > > > mm/sparse.c | 27 +++------------------------ > > 1 file changed, 3 insertions(+), 24 deletions(-) > > > > diff --git a/mm/sparse.c b/mm/sparse.c > > index bf6c00a28045..bb99633575b5 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(array_size(sizeof(struct page), > > + PAGES_PER_SECTION), GFP_KERNEL, nid); > > } > > > > static void depopulate_section_memmap(unsigned long pfn, unsigned long nr_pages, > > struct vmem_altmap *altmap) > > { > > - struct page *memmap = pfn_to_page(pfn); > > - > > - if (is_vmalloc_addr(memmap)) > > - vfree(memmap); > > - else > > - free_pages((unsigned long)memmap, > > - get_order(sizeof(struct page) * PAGES_PER_SECTION)); > > + kvfree(pfn_to_page(pfn)); > > } > > > > static void free_map_bootmem(struct page *memmap) > > -- > > 2.17.2 > > > > -- > Michal Hocko > SUSE Labs >