Received: by 10.213.65.68 with SMTP id h4csp89001imn; Fri, 30 Mar 2018 01:19:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx49y3ZoqmHOcH4+xnX5ZXirYuSWufdKGBr+h1/4N+C5pQES4lVaNk80TASVGn0FjW+XtOcMb X-Received: by 10.99.52.134 with SMTP id b128mr6584675pga.342.1522397954114; Fri, 30 Mar 2018 01:19:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522397954; cv=none; d=google.com; s=arc-20160816; b=AY3VTiekbNoukpt0HHnkBd1Pty7ymQO1KlfWDxg2u35+JTfYw2nMHeUTdoyRis+sPO LEJ68/Al4mre2Dbrkqmi1ZIcbIGTlBNTVjT8eSFecv77/TNJ9lun9iKFaToecD57EenR QoIWJ1gg+hXj8Kk3DwaErpvFuhs2dmGtNHyxkM2hCdFGDEq95EK41FdKu+wgT8gPpA49 5eAMBMcCvD7o9W85alNPdk4PdSzGgX1uF+4FG2W9r9wSp5jTCoyz8bJrkbjAY0yx9Uhz 7i6ms78OsQavAWmDVJmIRwhF72j4EiBuNfXkXKHvz+qd71hpNMW7e+iF+bEp+R+8oKib mtjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=6Xi2gqOglNMvtA6STOTHUjz4SQcQoRXbWivLVdbm/ts=; b=lFrLlwT9udn/5vA73E9sAwn2qOgHSi9mNEYhymCUJGLUSYk9Jxu74iVfHiFmSoLEqH 8vQYmavBKZPyZN/1hKbOJt5riFrJDpF1MSdmSqeZ2TdyQFQ5C1C3auI35a7tPBl64S46 oLwxts8A3LPEsGnoZqlqu6f6KzJqeSwtk16hk6O3u1wabeMRNKxoUKjblikn06lA5a+5 Q6Ie1wi7DF00Sb26V+KAHAqa/nos2ssoQN/rlUjN8c6YrT17D44PRLL2guUN/tx4QIM3 ZkNFN6OOACSLK55zq1OjOlleYGFQVkIkQWlYrucbOCmqSZQ5IaI0u1Xnj/OimDytgSIq lF4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E8z36mdG; 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 y128si6033581pfy.110.2018.03.30.01.19.00; Fri, 30 Mar 2018 01:19: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=E8z36mdG; 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 S1751642AbeC3IRc (ORCPT + 99 others); Fri, 30 Mar 2018 04:17:32 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:43610 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751215AbeC3IRa (ORCPT ); Fri, 30 Mar 2018 04:17:30 -0400 Received: by mail-pf0-f196.google.com with SMTP id j2so5014392pff.10 for ; Fri, 30 Mar 2018 01:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6Xi2gqOglNMvtA6STOTHUjz4SQcQoRXbWivLVdbm/ts=; b=E8z36mdGYR7NJw4cUIjTAb1DbgKCe+bZgRw+JZ6Szq6TKfgw/XmQI44/eKhm5hIExC kKsyXuhDRz3zdsPWW9m9Jhl4x4XFJ1hq3GUM7terULCdxUVcR9VDpY/GfqNFxWA2ljx7 /7EqM8mzze0e5Smuo1KgHD4YnAcQHTbwkxSuvJ3HKgzfilN8sQKqjwXhkGjpkfMFRao6 6mxN9sbVmEocXKnXaR4eadTsYN5Mr0SDAu/MQuYwiql8rhiQ4FxA7fc9TWdyx4Pes5Tc Xduh2omDJHwS3QRlEvcscbdJIvPmYsy/w4g8tm31GBw2wYxBfkRU6p8Ba2MyA56B+ZNs BSTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6Xi2gqOglNMvtA6STOTHUjz4SQcQoRXbWivLVdbm/ts=; b=IubxfY/hgNxHQZ5csYLa7BmujfJijVndavuorpFAunxjnU6s15GCtzDcvgLA6PQ1l1 ZtrnlA22wKpDlMYHkyoGlnDvOueCRCgn+x3N66G4d6tleVTLef/Nw3khRhVO4G8h48bk 8IbEKKI+Kt56noCWvLuDGi0RINY9UYu2cVcmneX42rAsFWSXP2N99Hd/UecT+Uv/iwOo BweEL1p/PWxpQMpTfFLTS47cnToVIFXkLuxztIh7hI1UdQRn5/ex8fzC7gOk5J3y+2c4 CEkpjGxaVzemyf17lckWdKDNsHYka4nystkpGMqydyfETfA8HwdgP9lLZHx92QYRqUPb 5QEg== X-Gm-Message-State: AElRT7H5oz9Phg79w8Dfm8lJcL++HUON+SnGBDd8c1uPKBBcsgEGnllY BrTg1e1GyX/MM6PPvcVu4Ts= X-Received: by 10.99.174.67 with SMTP id e3mr7816951pgp.139.1522397849447; Fri, 30 Mar 2018 01:17:29 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id l8sm4269837pff.126.2018.03.30.01.17.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Mar 2018 01:17:29 -0700 (PDT) From: Jia He To: Russell King , Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , Will Deacon , Mark Rutland , "H. Peter Anvin" Cc: 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 , Ard Biesheuvel , Steve Capper , Thomas Gleixner , Ingo Molnar , x86@kernel.org, Greg Kroah-Hartman , Kate Stewart , Philippe Ombredanne , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , richard.weiyang@gmail.com, Jia He , Jia He Subject: [PATCH v4 5/5] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid() Date: Fri, 30 Mar 2018 01:15:55 -0700 Message-Id: <1522397755-33393-6-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522397755-33393-1-git-send-email-hejianet@gmail.com> References: <1522397755-33393-1-git-send-email-hejianet@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns where possible") optimized the loop in memmap_init_zone(). But there is still some room for improvement. E.g. in early_pfn_valid(), if pfn and pfn+1 are in the same memblock region, we can record the last returned memblock region index and check check pfn++ is still in the same region. Currently it only improve the performance on arm64 and will have no impact on other arches. Signed-off-by: Jia He --- include/linux/mmzone.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index d797716..b68d22c 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1267,9 +1267,14 @@ static inline int pfn_present(unsigned long pfn) }) #else #define pfn_to_nid(pfn) (0) -#endif +#endif /*CONFIG_NUMA*/ +#ifdef CONFIG_HAVE_ARCH_PFN_VALID +#define early_pfn_valid(pfn) pfn_valid_region(pfn, &early_region_idx) +#else #define early_pfn_valid(pfn) pfn_valid(pfn) +#endif /*CONFIG_HAVE_ARCH_PFN_VALID*/ + void sparse_init(void); #else #define sparse_init() do {} while (0) -- 2.7.4