Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3356396imm; Sun, 1 Jul 2018 19:33:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe5eFp91WXVDZRoI/I9fkzBYrTVf7H32tvWvHNG8mNO+UwJANUW84UN97eBoKgKiOtwsd1L X-Received: by 2002:a62:9d46:: with SMTP id i67-v6mr5958194pfd.46.1530498814435; Sun, 01 Jul 2018 19:33:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530498814; cv=none; d=google.com; s=arc-20160816; b=Qpop7CN6pWltkXV2qMbgNQ/LvFpsGHINQs8CwiJIjfSafOq3IXFnuq/L64WqdmOIxp eX+KzsCG3xvm8t+zx/tl9qkQM64zcbexjbl2RlERAaanbCOGHdUCGWusd5m5W810PyUH Pg/UgqU6f8c/PAsdEYlHqnL4kKDj8uFO8itrQWK8FYH0hevH1uHpiG5NHzgXlYzp8+V7 owzbBLBHEgjrnZeMV0Ckev1uHU+gWOUws9PItN/zNEGD+d2u3+EM9GTrFahY+1WgzemD XIcWTlgH3sJPj8E3plQUe3IVO1wAoAQIe1dM7wnoKcAuGIRLbH0HBP7Lut3UKl3f9tNy WzsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=YP7ul3t/It2J1rswZTKfZf9HoX8tXX6DVboVUa8bVdo=; b=xXCGmi4ZnrunAHdmW+O7QVCoBKWqurfF88F8nou5Ob4+r+gtzCzn1mK85aAMXRwlZZ SH6O/tjnwTGtxpBZibNsciQfs9vQKEMQhqmKFI6/m9Zi5hUGTtjf/yK9tShg+rEvu9fU QNgrMbAboE22N/BXnrwK3jQR7tBrBn1Xn0+viUfW0pVfIDkP+BVKhiFFYoipRh48PQBS 0vy+HuiyXd0sjzQsFHIwbx8LzD2so9rM8EyECy6D5X1U0jf9mclqR22kuIhLvKa9MIrR P5uQ6bz8UCR/LxgoTapBhQ30/Z9tyadjKAD3T1hKS2jpEiTU2gEqnHeZluJ9FtIfTjrJ JQ9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d18-v6si13022301pgp.214.2018.07.01.19.33.19; Sun, 01 Jul 2018 19:33:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932879AbeGBBj3 (ORCPT + 99 others); Sun, 1 Jul 2018 21:39:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56914 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932839AbeGBBjY (ORCPT ); Sun, 1 Jul 2018 21:39:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BAC0168801; Mon, 2 Jul 2018 01:39:23 +0000 (UTC) Received: from localhost (ovpn-8-16.pek2.redhat.com [10.72.8.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD08B2026D66; Mon, 2 Jul 2018 01:39:22 +0000 (UTC) Date: Mon, 2 Jul 2018 09:39:18 +0800 From: Baoquan He To: Pavel Tatashin Cc: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, mhocko@suse.com, linux-mm@kvack.org, dan.j.williams@intel.com, jack@suse.cz, jglisse@redhat.com, jrdr.linux@gmail.com, gregkh@linuxfoundation.org, vbabka@suse.cz, richard.weiyang@gmail.com, dave.hansen@intel.com, rientjes@google.com, mingo@kernel.org, osalvador@techadventures.net Subject: Re: [PATCH v2 2/2] mm/sparse: start using sparse_init_nid(), and remove old code Message-ID: <20180702013918.GJ3223@MiWiFi-R3L-srv> References: <20180630030944.9335-1-pasha.tatashin@oracle.com> <20180630030944.9335-3-pasha.tatashin@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180630030944.9335-3-pasha.tatashin@oracle.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 02 Jul 2018 01:39:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 02 Jul 2018 01:39:23 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'bhe@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/29/18 at 11:09pm, Pavel Tatashin wrote: > Change sprase_init() to only find the pnum ranges that belong to a specific > node and call sprase_init_nid() for that range from sparse_init(). > > Delete all the code that became obsolete with this change. > void __init sparse_init(void) > { > - unsigned long pnum; > - struct page *map; > - struct page **map_map; > - unsigned long *usemap; > - unsigned long **usemap_map; > - int size, size2; > - int nr_consumed_maps = 0; > - > - /* see include/linux/mmzone.h 'struct mem_section' definition */ > - BUILD_BUG_ON(!is_power_of_2(sizeof(struct mem_section))); > + unsigned long pnum_begin = first_present_section_nr(); > + int nid_begin = sparse_early_nid(__nr_to_section(pnum_begin)); > + unsigned long pnum_end, map_count = 1; > > - /* Setup pageblock_order for HUGETLB_PAGE_SIZE_VARIABLE */ > - set_pageblock_order(); > + for_each_present_section_nr(pnum_begin + 1, pnum_end) { > + int nid = sparse_early_nid(__nr_to_section(pnum_end)); > > - /* > - * map is using big page (aka 2M in x86 64 bit) > - * usemap is less one page (aka 24 bytes) > - * so alloc 2M (with 2M align) and 24 bytes in turn will > - * make next 2M slip to one more 2M later. > - * then in big system, the memory will have a lot of holes... > - * here try to allocate 2M pages continuously. > - * > - * powerpc need to call sparse_init_one_section right after each > - * sparse_early_mem_map_alloc, so allocate usemap_map at first. > - */ > - size = sizeof(unsigned long *) * nr_present_sections; > - usemap_map = memblock_virt_alloc(size, 0); > - if (!usemap_map) > - panic("can not allocate usemap_map\n"); > - alloc_usemap_and_memmap(sparse_early_usemaps_alloc_node, > - (void *)usemap_map, > - sizeof(usemap_map[0])); > - > - size2 = sizeof(struct page *) * nr_present_sections; > - map_map = memblock_virt_alloc(size2, 0); > - if (!map_map) > - panic("can not allocate map_map\n"); > - alloc_usemap_and_memmap(sparse_early_mem_maps_alloc_node, > - (void *)map_map, > - sizeof(map_map[0])); > - > - /* The numner of present sections stored in nr_present_sections > - * are kept the same since mem sections are marked as present in > - * memory_present(). In this for loop, we need check which sections > - * failed to allocate memmap or usemap, then clear its > - * ->section_mem_map accordingly. During this process, we need > - * increase 'nr_consumed_maps' whether its allocation of memmap > - * or usemap failed or not, so that after we handle the i-th > - * memory section, can get memmap and usemap of (i+1)-th section > - * correctly. */ > - for_each_present_section_nr(0, pnum) { > - struct mem_section *ms; > - > - if (nr_consumed_maps >= nr_present_sections) { > - pr_err("nr_consumed_maps goes beyond nr_present_sections\n"); > - break; > - } > - ms = __nr_to_section(pnum); > - usemap = usemap_map[nr_consumed_maps]; > - if (!usemap) { > - ms->section_mem_map = 0; > - nr_consumed_maps++; > - continue; > - } > - > - map = map_map[nr_consumed_maps]; > - if (!map) { > - ms->section_mem_map = 0; > - nr_consumed_maps++; > + if (nid == nid_begin) { > + map_count++; > continue; > } > - > - sparse_init_one_section(__nr_to_section(pnum), pnum, map, > - usemap); > - nr_consumed_maps++; > + sparse_init_nid(nid, pnum_begin, pnum_end, map_count); ~~~ Here, node id passed to sparse_init_nid() should be 'nid_begin', but not 'nid'. When you found out the current section's 'nid' is diferent than 'nid_begin', handle node 'nid_begin', then start to next node 'nid'. > + nid_begin = nid; > + pnum_begin = pnum_end; > + map_count = 1; > } > - > + sparse_init_nid(nid_begin, pnum_begin, pnum_end, map_count); > vmemmap_populate_print_last(); > - > - memblock_free_early(__pa(map_map), size2); > - memblock_free_early(__pa(usemap_map), size); > } > > #ifdef CONFIG_MEMORY_HOTPLUG > -- > 2.18.0 >