Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3343536imm; Sun, 1 Jul 2018 19:11:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfW7fziL0ImE+hlXjmVwYpKnOOUWAX8Wb/l0cDNAVkpvR4wtCy3fx6n8r4EH0DAS9E79/I4 X-Received: by 2002:a17:902:a602:: with SMTP id u2-v6mr1256707plq.195.1530497482639; Sun, 01 Jul 2018 19:11:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530497482; cv=none; d=google.com; s=arc-20160816; b=wswnw3m5qpIKgT95ftGavAgUvQ3HEvD8A955TyxrKk5jaBBevqc2L30kiV+T5kTehc AZScH1wlC6AupfpoINU81e92jfDAWQRY5vbpneeJ6eHH722R0gl4A3S1dxOqfPCyG95s e204vLvfpcsHPOVDZpgcJQEQOxw8NCrn09O+KlZhFkoLhJjDa6cEzYi6DPR4BNBV18Vq jM+lh26Wfn+Dy5cljd61JjA8JuaC1L1R6+ul5lA7QOqIzX7UeibSZoF198lGOwEUjC6i wynjoqmcIE4tgt7CDSOCpSvNiK9kzl4lTmRvoaH2FSM3+h0kuIkwzO1CJJa/VXFtmHfI 8Kiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=VBm908lwr2tZcnhD9lGxnHhfnHbhW2LHZWsXVwGjU98=; b=a9HAvkEpTRgfqO7NkKN9Me27LHH348Gl0JKEF/BkcneeCR6lMYaUIbTE99vfitnckS it2p+b19KRMIFiPAYgqVwZXaGrDvueD9l/6jpVfywRlKNAkdQzw9dyZVfml4wxLg8Hyd rCUw8NNOoA9XQKldoCk6K/9zwaUBT34MzevJ0OvhnXYAezRhcip0tA3yRNjhVvugmtvH tex+TyGhv2/6Jh0MVdcDOIamXupSscExx65Z/dyHG1Z/1z28iE3CqdukJxJTuBn1BSdE DQTnbu1+r2hLzt6arEXMwHEIwZa21in5h1Ly4DX16XAUsckfFDDIyGjbQTTjRn4sNwx7 8sDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=ZLRRcQ35; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17-v6si14500207pff.173.2018.07.01.19.11.07; Sun, 01 Jul 2018 19:11:22 -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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=ZLRRcQ35; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932734AbeGBBpY (ORCPT + 99 others); Sun, 1 Jul 2018 21:45:24 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:58192 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932195AbeGBBpX (ORCPT ); Sun, 1 Jul 2018 21:45:23 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w621iQnI092323 for ; Mon, 2 Jul 2018 01:45:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : references : in-reply-to : from : date : message-id : subject : to : cc : content-type; s=corp-2017-10-26; bh=VBm908lwr2tZcnhD9lGxnHhfnHbhW2LHZWsXVwGjU98=; b=ZLRRcQ35uhW0DlZquyN9fFYflhZPHur3iR8wlvX8Zra+zOOE/RUDeSG+Zhydf8xYht5O jRdcxp3g9T9SXhqSdQizd9LMKiHz1uC0qJzFuFL0h/2AcrK2Vw8f8f9lgOyIM84uFmNW NkP0CwiEfaYdrCuqu4FjTGKa31C/LVDt3ETgaz0roN3Taif+Cxkjs7oD8WkbVfcf1XBS cMrb8W6YnVE92kPEd20XiMwb6T+K7LUTM/D61YrPmsHg+4DjFdEMrFUz49rnX7d1rQL3 g/+20RZrZUOjERH9bjaYEVbtKgZnyjGfCqxhdEMdwsz/kcjCS1BOStllDkCKUP3HJ/Jr 0g== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2jwyccjp8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 02 Jul 2018 01:45:23 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w621jMMa030991 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 2 Jul 2018 01:45:22 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w621jLPQ015348 for ; Mon, 2 Jul 2018 01:45:21 GMT Received: from mail-oi0-f41.google.com (/209.85.218.41) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 01 Jul 2018 18:45:21 -0700 Received: by mail-oi0-f41.google.com with SMTP id 13-v6so1048776ois.1 for ; Sun, 01 Jul 2018 18:45:21 -0700 (PDT) X-Gm-Message-State: APt69E0WFYN8IzfWlhQzPObnSqBP+JalUj0wVPAcd7cktCDuOglQ5M8h b2HVsKcsYGdIrXJDSRrLw6WiQ3SmOHlDo70pNv0= X-Received: by 2002:aca:e089:: with SMTP id x131-v6mr8123125oig.221.1530495920840; Sun, 01 Jul 2018 18:45:20 -0700 (PDT) MIME-Version: 1.0 References: <20180630030944.9335-1-pasha.tatashin@oracle.com> <20180630030944.9335-3-pasha.tatashin@oracle.com> <20180702013402.GI3223@MiWiFi-R3L-srv> In-Reply-To: <20180702013402.GI3223@MiWiFi-R3L-srv> From: Pavel Tatashin Date: Sun, 1 Jul 2018 21:44:44 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/2] mm/sparse: start using sparse_init_nid(), and remove old code To: bhe@redhat.com Cc: Steven Sistare , Daniel Jordan , LKML , Andrew Morton , kirill.shutemov@linux.intel.com, Michal Hocko , Linux Memory Management List , dan.j.williams@intel.com, jack@suse.cz, jglisse@redhat.com, Souptick Joarder , gregkh@linuxfoundation.org, Vlastimil Babka , Wei Yang , dave.hansen@intel.com, rientjes@google.com, mingo@kernel.org, osalvador@techadventures.net Content-Type: text/plain; charset="UTF-8" X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8941 signatures=668704 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=10 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807020019 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 1, 2018 at 9:34 PM Baoquan He wrote: > > Hi Pavel, > > 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. > > > @@ -617,87 +491,24 @@ void __init sparse_init_nid(int nid, unsigned long pnum_begin, > > */ > > 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(); > > Not very sure if removing set_pageblock_order() calling here is OK. What > if CONFIG_HUGETLB_PAGE_SIZE_VARIABLE is enabled? usemap_size() depends > on value of 'pageblock_order'. Hi Baoquan, Nice catch, you are right, I incorrectly removed this call, will add it back in the next version. Pavel > > Thanks > Baoquan > > > + 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); > > + 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 > > >