Received: by 10.213.65.68 with SMTP id h4csp371267imn; Tue, 27 Mar 2018 00:17:14 -0700 (PDT) X-Google-Smtp-Source: AG47ELtF6i2BXP7jwsaBP095Ui8IokbirpxJa5rWSEQaUQRO+v+P3O3TLjXK+/d9K+94brOMxHPA X-Received: by 10.99.152.68 with SMTP id l4mr30027894pgo.75.1522135034204; Tue, 27 Mar 2018 00:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522135034; cv=none; d=google.com; s=arc-20160816; b=R7gDj6dSeaE1E8LmibudfyJgzJIRZoMq1dY0JwQFjQR4KySIaH9tizw1Fco0SxwW/O IgYvlX9YCiN0O/tPfofu+3Cur4xgpDpUWsEhZMriCfSCQgU8f4Jd8TtmseD4pQP65bun 9dTANXONs7Myu88dnI2FleEuEbhgcn+DlnMsTkEdRhhxCJK+WqkrNZ9t16uznG1ojfiq 3bc/18kJXfKV9vYX/t8j3A/YIsCjFsAi4r/4AHFGvqpLP04hIo/2nSMZ+65gCWjMc/ZC 7IFwLfWhyeXyHKKCe9JHTyszB0zHgYzR7OyZduLgIJtSqQZBaAvL3HKdLhngP69SR9E7 Zulw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject:dkim-signature:arc-authentication-results; bh=H/q+9no0wGRLhn6S7BjvVfu9GzWSF+gvNsNL2eOEIH0=; b=qKx8x5NgFSi2FKc7QBEo58Idwue4XG54+mFG03YTJDK+ObVGvtOULTsh96tcJfrBKZ GKtiKX+cQ4aNn6MK8FiZECqt0q0p9dr3vd2xnpk4XdXPGJS/GFlsG4+JYQT4s7oAq8Do H/eGl8uA8ggH3YXk4VGjcc6/QiYx7LFAFv2fm2PHNddqB5R5Drwi9tocMoZKtF31gKak l35kx7xo3QEusOqazs9DyJlDUIj0zULrWyrSJi7ti9UNLnIiftS6AwP6wfEqNzH3GtbB XMcmrB6eUI2VGl4zFfXxEkXHmgcizTzriQ68OVz+cYh6TpeyCsQw6y4xk1agcpNKviuZ JfmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hJgxq6Sl; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u22-v6si678624plk.608.2018.03.27.00.17.00; Tue, 27 Mar 2018 00:17:14 -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=@gmail.com header.s=20161025 header.b=hJgxq6Sl; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751713AbeC0HPi (ORCPT + 99 others); Tue, 27 Mar 2018 03:15:38 -0400 Received: from mail-it0-f47.google.com ([209.85.214.47]:53217 "EHLO mail-it0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751196AbeC0HPg (ORCPT ); Tue, 27 Mar 2018 03:15:36 -0400 Received: by mail-it0-f47.google.com with SMTP id k135-v6so13836310ite.2 for ; Tue, 27 Mar 2018 00:15:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=H/q+9no0wGRLhn6S7BjvVfu9GzWSF+gvNsNL2eOEIH0=; b=hJgxq6SloTXfwcSMR5+W03Bjs8J7rjaOt4U6ePdjMBgXYdOPEIYoKCM2KPh8e7wmFg 3KsBSjQhiFMBWbjXrLRZGqK76SO20yMpNNY9IomSN7oFmREk/Pdu9lMrNPZq4a0QRPwj jRBVrpWXNYkbO6DFYrAcono5UH6YOjFginGbCfcIjdM3KeV7cn+iFO7W3duKHo9cisZK f6naq8JGvEJR/kI3XH1YbksVUB9cQCb6gBHtaBdFy0JTX8/dD7MstQY16sBRGm7Lrnzm KSMXySujf2IV9k87iBL06p7IR5mV1/80sWb1fGOxqTk7VgxFsbHHxjtwbzPjDaY2LN/B 62vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=H/q+9no0wGRLhn6S7BjvVfu9GzWSF+gvNsNL2eOEIH0=; b=hRPGkfoJeGqp6Kp3csjeR9fKW+Wl4ufUYhCsXvGOj8P2JLbaGelVhF3Zcpw2esf6Dx tEng3alwfVIVCfz6/0lU/67+skUC57GRfPQsZONg31SRU0vjVblkR5WnWu8hsog50k5H XTMsGZYvWsJuwF8wX4Zp8T7uvxrwqhpiVEDIWaSMpaJp5wHXkndb41ZYleHPBuaUhuW+ 4GZ9OjVVLQkZCL5mzA6w0UKNDao3Prbxf37jcv5V6HPAwLpPJMA7oPekSB2PKDtxcvul kF2kQU1M211kAUBnN6eUDi3zmSb3Y5Dizlx+r0uot7nQB+pd+X3xSrFlg6hX8slouZDO DcyQ== X-Gm-Message-State: AElRT7GM9R+crLlAu4FyWGIzhsawkb/SaZ9u5wBLZmj/FZMEGPVUYZS5 GTOzRk8WX0/p6ReI3ipvpXU= X-Received: by 2002:a24:1f15:: with SMTP id d21-v6mr25499390itd.71.1522134936282; Tue, 27 Mar 2018 00:15:36 -0700 (PDT) Received: from [0.0.0.0] (67.216.217.169.16clouds.com. [67.216.217.169]) by smtp.gmail.com with ESMTPSA id e99-v6sm606092itd.23.2018.03.27.00.15.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 00:15:35 -0700 (PDT) Subject: Re: [PATCH v3 0/5] optimize memblock_next_valid_pfn and early_pfn_valid To: Wei Yang Cc: Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , Will Deacon , Mark Rutland , Ard Biesheuvel , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Pavel Tatashin , Daniel Jordan , AKASHI Takahiro , Gioh Kim , Steven Sistare , Daniel Vacek , Eugeniu Rosca , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, James Morse , Steve Capper , x86@kernel.org, Greg Kroah-Hartman , Kate Stewart , Philippe Ombredanne , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov References: <1522033340-6575-1-git-send-email-hejianet@gmail.com> <20180327010213.GA80447@WeideMacBook-Pro.local> From: Jia He Message-ID: Date: Tue, 27 Mar 2018 15:15:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180327010213.GA80447@WeideMacBook-Pro.local> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/27/2018 9:02 AM, Wei Yang Wrote: > On Sun, Mar 25, 2018 at 08:02:14PM -0700, Jia He wrote: >> Commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns >> where possible") tried to optimize the loop in memmap_init_zone(). But >> there is still some room for improvement. >> >> Patch 1 remain the memblock_next_valid_pfn when CONFIG_HAVE_ARCH_PFN_VALID >> is enabled >> Patch 2 optimizes the memblock_next_valid_pfn() >> Patch 3~5 optimizes the early_pfn_valid(), I have to split it into parts >> because the changes are located across subsystems. >> >> I tested the pfn loop process in memmap_init(), the same as before. >> As for the performance improvement, after this set, I can see the time >> overhead of memmap_init() is reduced from 41313 us to 24345 us in my >> armv8a server(QDF2400 with 96G memory). >> >> Attached the memblock region information in my server. >> [ 86.956758] Zone ranges: >> [ 86.959452] DMA [mem 0x0000000000200000-0x00000000ffffffff] >> [ 86.966041] Normal [mem 0x0000000100000000-0x00000017ffffffff] >> [ 86.972631] Movable zone start for each node >> [ 86.977179] Early memory node ranges >> [ 86.980985] node 0: [mem 0x0000000000200000-0x000000000021ffff] >> [ 86.987666] node 0: [mem 0x0000000000820000-0x000000000307ffff] >> [ 86.994348] node 0: [mem 0x0000000003080000-0x000000000308ffff] >> [ 87.001029] node 0: [mem 0x0000000003090000-0x00000000031fffff] >> [ 87.007710] node 0: [mem 0x0000000003200000-0x00000000033fffff] >> [ 87.014392] node 0: [mem 0x0000000003410000-0x000000000563ffff] >> [ 87.021073] node 0: [mem 0x0000000005640000-0x000000000567ffff] >> [ 87.027754] node 0: [mem 0x0000000005680000-0x00000000056dffff] >> [ 87.034435] node 0: [mem 0x00000000056e0000-0x00000000086fffff] >> [ 87.041117] node 0: [mem 0x0000000008700000-0x000000000871ffff] >> [ 87.047798] node 0: [mem 0x0000000008720000-0x000000000894ffff] >> [ 87.054479] node 0: [mem 0x0000000008950000-0x0000000008baffff] >> [ 87.061161] node 0: [mem 0x0000000008bb0000-0x0000000008bcffff] >> [ 87.067842] node 0: [mem 0x0000000008bd0000-0x0000000008c4ffff] >> [ 87.074524] node 0: [mem 0x0000000008c50000-0x0000000008e2ffff] >> [ 87.081205] node 0: [mem 0x0000000008e30000-0x0000000008e4ffff] >> [ 87.087886] node 0: [mem 0x0000000008e50000-0x0000000008fcffff] >> [ 87.094568] node 0: [mem 0x0000000008fd0000-0x000000000910ffff] >> [ 87.101249] node 0: [mem 0x0000000009110000-0x00000000092effff] >> [ 87.107930] node 0: [mem 0x00000000092f0000-0x000000000930ffff] >> [ 87.114612] node 0: [mem 0x0000000009310000-0x000000000963ffff] >> [ 87.121293] node 0: [mem 0x0000000009640000-0x000000000e61ffff] >> [ 87.127975] node 0: [mem 0x000000000e620000-0x000000000e64ffff] >> [ 87.134657] node 0: [mem 0x000000000e650000-0x000000000fffffff] >> [ 87.141338] node 0: [mem 0x0000000010800000-0x0000000017feffff] >> [ 87.148019] node 0: [mem 0x000000001c000000-0x000000001c00ffff] >> [ 87.154701] node 0: [mem 0x000000001c010000-0x000000001c7fffff] >> [ 87.161383] node 0: [mem 0x000000001c810000-0x000000007efbffff] >> [ 87.168064] node 0: [mem 0x000000007efc0000-0x000000007efdffff] >> [ 87.174746] node 0: [mem 0x000000007efe0000-0x000000007efeffff] >> [ 87.181427] node 0: [mem 0x000000007eff0000-0x000000007effffff] >> [ 87.188108] node 0: [mem 0x000000007f000000-0x00000017ffffffff] > Hi, Jia > > I haven't taken a deep look into your code, just one curious question on your > memory layout. > > The log above is printed out in free_area_init_nodes(), which iterates on > memblock.memory and prints them. If I am not wrong, memory regions added to > memblock.memory are ordered and merged if possible. > > While from your log, I see many regions could be merged but are isolated. For > example, the last two region: > > node 0: [mem 0x000000007eff0000-0x000000007effffff] > node 0: [mem 0x000000007f000000-0x00000017ffffffff] > > So I am curious why they are isolated instead of combined to one. > > >From the code, the possible reason is the region's flag differs from each > other. If you have time, would you mind taking a look into this? > Hi Wei I thought these 2 have different flags [    0.000000] idx=30,region [7eff0000:10000]flag=4     <--- aka MEMBLOCK_NOMAP [    0.000000]   node   0: [mem 0x000000007eff0000-0x000000007effffff] [    0.000000] idx=31,region [7f000000:81000000]flag=0 <--- aka MEMBLOCK_NONE [    0.000000]   node   0: [mem 0x000000007f000000-0x00000017ffffffff] -- Cheers, Jia