From patchwork Wed Aug 22 03:07:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10572563 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5FF16921 for ; Wed, 22 Aug 2018 03:07:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5286D2A4CB for ; Wed, 22 Aug 2018 03:07:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4367B2B399; Wed, 22 Aug 2018 03:07:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2314A2B393 for ; Wed, 22 Aug 2018 03:07:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DEC16B2220; Tue, 21 Aug 2018 23:07:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2639C6B2221; Tue, 21 Aug 2018 23:07:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DFE76B2222; Tue, 21 Aug 2018 23:07:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id BB6906B2220 for ; Tue, 21 Aug 2018 23:07:50 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id h5-v6so357935pgs.13 for ; Tue, 21 Aug 2018 20:07:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=qB8wQLRm567sPd0BwIEEQEjYlqnBOl4UOSs2cGebjxQ=; b=g31b3OVmoXniNG4PWWD4em4JmmNPMgv63syDsnkft/GmzR0r+lfZihdnsumhkMDtB3 ht3ZzyefjkhquQ7JLyOKN7Odf73hjHM1jBoQDAkR0OJaGt/6BAlr2tn0kLZsS8MkCGKL vCg1nKLID6D2qB/Qyw/KTfFXtP/PUMGtI2A+t08ko3YQxqxFGS+T2UqN2nHlwDqL0xC0 GgSLl0kb/f9MPRMH7Qf9UkVu+yPY8303++N4jGFKvm7tor8XNgzdsUvE7oJWCSsMfLAI N6UdmZKt7vmZXrxjfFq9wBiXFdluImMwZY0De4d//8SGWpfjtDORdTw6BiFF2W1fvI/v vLow== X-Gm-Message-State: AOUpUlFU/WPnXSnEpSsk8yBhcea58gPAFU5OYxqA6hd02p4CGxZzJu1n 47Q+UTPms73VB5mv6oNXtCc/fX4I4MCfqa5pGYcJqtCJBXwDdsqPO2dOYSLvtbevYunVZ20U+ax km6+n9YHZufbPridzkftPo1DFTN14oOTB2Wk+S95vHXLNlPBqO6oWPQCTgdO9MelN8wREZHcS6O k3wt7RUFTmVz3s78jsvbLxxX3FRfeE4L46zYjCWwwcqJeWeuBVl1N4OowQHcX2huf82pK/mpK51 DTHB3gV75xkmFImAJAF3V+V2B9mXNjl9LYBABnlgRTpi2mOPSY/ojKOWc2IEw1ZvzvWrSr8MOqI w0KbS1JFIYVDIpyFD9BpM3o0oH+OgjP1O5NPGkmqB593DpNy5308knhzH+D+QiDCZKoSSyQhagT b X-Received: by 2002:a17:902:8541:: with SMTP id d1-v6mr53024275plo.81.1534907270407; Tue, 21 Aug 2018 20:07:50 -0700 (PDT) X-Received: by 2002:a17:902:8541:: with SMTP id d1-v6mr53024237plo.81.1534907269656; Tue, 21 Aug 2018 20:07:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534907269; cv=none; d=google.com; s=arc-20160816; b=Wxsh2FKvpF+KT3DdPytcOxSLz91p6ZwzZTJLPWUCtW+KC2LR7MfUfN4S4LGY4w6SEH aaLRQazgXJGP9WZ0kqDoK+rJpWWhx+zvHphUDcz0IHIZTRV+3MDnErCmXS38/orNTLVw Jtblbo8vDL3YPc01OlVBVZecyqQoZw8hID3zL2sAPLjDCdNo45rdlT5d1U7pFr7AWc2C 8DU2D9Fz6b3GDYNNe4VpSUvJmyhx7U6buSA+4lCF7AXo9QKeW5wgLicPcuzh3CSkp1nN ZB/Wd766yc+0tRPqxN8hbpdWT++AbmZfV+Mb+j89ChLkqo0O575O1zD11KlM8aFuT+M3 1Ymg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=qB8wQLRm567sPd0BwIEEQEjYlqnBOl4UOSs2cGebjxQ=; b=YqYntuv3Q5TkP7o40jbOA9h04/nQmOhqqUbIMJEgODoa+Us6GWfdkm1k0cQ9G3/bSS GXM9ntyEXTJGefs2guRIPdVelJlvtnloXFZV9GU/rogmiG6EAmszAf1rTgQeYDJZla4M bTplqFnWAzGnvHRaaS2S1VQwIn57hVmZXf5ol6PeZHO4Em6OfRSQgZX5w9UteuJDzqyo 8T2uzxqcNnTRzrGL7/rIyHE258T6GkToSIrdraTP+J5MQMXPRWpeD8Hve6lz/MqsDZ4X p+CdGEyftv76O1Qmfdw5OpezVJ+TV8r9S7xvFkV+mep5uLZSD/o9eXDAQwp10Ol2hir5 U1sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="P/PJBkwE"; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d33-v6sor129664pgb.146.2018.08.21.20.07.49 for (Google Transport Security); Tue, 21 Aug 2018 20:07:49 -0700 (PDT) Received-SPF: pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="P/PJBkwE"; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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=qB8wQLRm567sPd0BwIEEQEjYlqnBOl4UOSs2cGebjxQ=; b=P/PJBkwEPMZUsM7aFZSoSuMyZ+ESKprPlOZTIvj+YyTLkNr053ypWmVga5VMc06/2c CR7+mhHGvNik5HsqSTOAxkq1GeZG0sVfo+S2jxkIr91Z4gB91raZ4efl4oEKTLvxc+6T AazzPIqEiuuzu3meJfA1z183Fmn7DymWkBSlrhml//oJ8A0LytS5b3RDIth6VZizrenq fzHYl+0CvECgT+OoM97SsDKLkOpItmsbEzbU2zlnpsz9ms6SqABXr3vO92lbxAYdhtbW 9O1Gye0QNq7JVhqpgqcLppc9JRgbtbLCtC3qAky/acYd7plrEAkAM/+HSGrGyrPVEa/Q 9nHQ== X-Google-Smtp-Source: AA+uWPzJBdDsbSrchc52klfb1DQ0wJelNefkYjsYYabOmrVH5TFk/ERFhQ9F0GfOux4D49sKOkvVLA== X-Received: by 2002:a63:4005:: with SMTP id n5-v6mr10897866pga.221.1534907269416; Tue, 21 Aug 2018 20:07:49 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id q7-v6sm440165pfq.43.2018.08.21.20.07.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 20:07:48 -0700 (PDT) From: Jia He X-Google-Original-From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Cc: Wei Yang , Kees Cook , Laura Abbott , Vladimir Murzin , Philip Derrin , AKASHI Takahiro , James Morse , Steve Capper , Gioh Kim , Vlastimil Babka , Mel Gorman , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , Daniel Jordan , Daniel Vacek , Eugeniu Rosca , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jia He Subject: [PATCH v11 1/3] arm: arm64: introduce CONFIG_HAVE_MEMBLOCK_PFN_VALID Date: Wed, 22 Aug 2018 11:07:15 +0800 Message-Id: <1534907237-2982-2-git-send-email-jia.he@hxt-semitech.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534907237-2982-1-git-send-email-jia.he@hxt-semitech.com> References: <1534907237-2982-1-git-send-email-jia.he@hxt-semitech.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP Make CONFIG_HAVE_MEMBLOCK_PFN_VALID a new config option so it can move memblock_next_valid_pfn to generic code file. All the latter optimizations are based on this config. The memblock initialization time on arm/arm64 can benefit from this. Signed-off-by: Jia He Reviewed-by: Pavel Tatashin --- arch/arm/Kconfig | 1 + arch/arm64/Kconfig | 1 + mm/Kconfig | 3 +++ 3 files changed, 5 insertions(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 843edfd..d3c7705 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1641,6 +1641,7 @@ config ARCH_SELECT_MEMORY_MODEL config HAVE_ARCH_PFN_VALID def_bool ARCH_HAS_HOLES_MEMORYMODEL || !SPARSEMEM + select HAVE_MEMBLOCK_PFN_VALID config HAVE_GENERIC_GUP def_bool y diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 42c090c..d4119e6 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -777,6 +777,7 @@ config ARCH_SELECT_MEMORY_MODEL config HAVE_ARCH_PFN_VALID def_bool ARCH_HAS_HOLES_MEMORYMODEL || !SPARSEMEM + select HAVE_MEMBLOCK_PFN_VALID config HW_PERF_EVENTS def_bool y diff --git a/mm/Kconfig b/mm/Kconfig index 94af022..28fcf54 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -137,6 +137,9 @@ config HAVE_MEMBLOCK_NODE_MAP config HAVE_MEMBLOCK_PHYS_MAP bool +config HAVE_MEMBLOCK_PFN_VALID + bool + config HAVE_GENERIC_GUP bool From patchwork Wed Aug 22 03:07:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10572567 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AED6F1579 for ; Wed, 22 Aug 2018 03:08:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A60602B113 for ; Wed, 22 Aug 2018 03:08:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 991FA2B179; Wed, 22 Aug 2018 03:08:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 631662B113 for ; Wed, 22 Aug 2018 03:08:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 74A3C6B2223; Tue, 21 Aug 2018 23:08:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6D0066B2224; Tue, 21 Aug 2018 23:08:03 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 598616B2225; Tue, 21 Aug 2018 23:08:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 162B26B2223 for ; Tue, 21 Aug 2018 23:08:03 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id 186-v6so357437pgc.12 for ; Tue, 21 Aug 2018 20:08:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=FZQVcSjva4KqT1QnxQl07tGVuHDUFsqtAvdlpz1t47Q=; b=uKRS9xzvcsZ1nYF2GA1XTOT3T9O8Zky0nYsAYziLabtGFtkigGL0/WZEPouZ1pM7y1 MfcuOj+OIJhEPgtr8kesQIREsOkHXMx+GcdKvi2y3UAoubU39PGpi94STWkOoG2CLa/r e1MQCrR3E3OFV2VLlhwKm8GzKCYNFlm9fx1ZJOBdAFnuJO/SrTE1iSXMi5B3AGgB5bGq ju+ZEWHe9RLQ2xJpKVDL8OagyZX6Uu9zYKiyg1+qM6tLqPUjU+Uo/juc9Ze/wKDx4vQ4 h8ZzNhZhOjxJ5j/eCtXmNmvXah3Joc60YE2qKzCLxyBAErTSZnK9jfIO8PPUzNneIw4r rEzA== X-Gm-Message-State: AOUpUlE/Sbx9aCShYKvO/nY04KJWD6VEBG1SZ4G7nPoi0RUwCynI8wCk zqI7ydzIwSLKKnlXaZL25oFcVMEmORhwktFoe3QVJb5HG/KhZkM2kNTToTeeZyxoCBhZ2AYwcLB AcQqgxxldN2/fd/1g/fpiivF7jRp5kroUC7mXGxAvK6uo32RFH6DS9KrIf5Qd4Qfs4fkxYjtvh9 OXEKxnWeLU2a5iislsUgacVEngkNIK0xVd4lRFXXsZ/JZaGVxd6cl8xsYM355opdxdVXY3sEDJ/ GrFefOOvf9xEMCJtaZLB6q2whHYwB32YuqBeOq//guTrDdffrS4uTwkwZ8aHm9Gt3F69T5b7kHi S/gtPdNv+eE/PmNGMGn7Z+XssIr0noRh5NKYadtyRRXtSf5KHKJiBqlwDEwsg93dqtYw/qwNvTd 4 X-Received: by 2002:a63:d80f:: with SMTP id b15-v6mr49743049pgh.347.1534907282680; Tue, 21 Aug 2018 20:08:02 -0700 (PDT) X-Received: by 2002:a63:d80f:: with SMTP id b15-v6mr49743003pgh.347.1534907281483; Tue, 21 Aug 2018 20:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534907281; cv=none; d=google.com; s=arc-20160816; b=AcMQlLIkiI/6m9QTb9eYlHRwgmFTsx2Y5ytDq+NLOXs/Y8HvTPoJbelAMJh0hFS/FZ eGdIhl5AG2iywkgA3s9x8y2pQS8Y7j3zEoVDGj9bBloC+9vrYdAn2ARlaOyAqBIxA/lr kPdhOJXJizJCQEKe66cXLHy1iOojm5OtCC/xkdMgi51x9sfFePNZ3H2pqnxJ/8auNlvr qf4nu3cqs2bFg7PikmHViqUvaoH1w1xDZHkofFZffEf3at2JJsOUdOfv+vfw0ALNpGMA zPa0pFUbSvS4SZY3UODrCOK33PEwTqDoR/UMfpjbeMf6l0rG6A2b0F+ucD9np64ER4em OTBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=FZQVcSjva4KqT1QnxQl07tGVuHDUFsqtAvdlpz1t47Q=; b=ysPm+LEtDOohDMTs5Yp5l9lbRPgdsuGSrnrRzpZd9RZUv7QYYlD5SQaFFa9omXCnVr ewR+Mx+Wl7NMFqUltuexba33Gwd5Uvr94a201N4Nxtq93w7a2Yvyp9vHgb5dSkLxxkHy gTgDeV+WbRHGqIsf+qkclwgYG7QUbbnoibi/lExpGqJaiWoApt98TVBMDGJk/am0Ox+T AfoIhwBPcAdFgYeEjFuobrwztM5koTj3GQ4DdxgZSba7sHavp41KMnrzJpG8avaf9jXW LeO1KTNYezBMNjpHDhi1WIzuZ59SW67CRvSVJdQ4qbalhrOXP7UjkBEOoGp7zLsa81+c dMwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dUBGkRw4; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c41-v6sor170008plj.24.2018.08.21.20.08.01 for (Google Transport Security); Tue, 21 Aug 2018 20:08:01 -0700 (PDT) Received-SPF: pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dUBGkRw4; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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=FZQVcSjva4KqT1QnxQl07tGVuHDUFsqtAvdlpz1t47Q=; b=dUBGkRw4fQaiMecEzf8cFWCp6lhVcwMzGzSJuhJ/kDZkOS/u/pcLbU9y5Xf1q1j77r dtL/gCMhC9eqDMKxzYrXtYRlA5a94kZIwjuX+W8VHjreqVs9v6Dscjei2XBBlnncnM4p n73u1ktG72mHDkQonOkyTO1/t4u/t1qqLjVMvDj7/lvdikAWO7X+SCQYDPl7U2GSVlfJ M2ft/3Qfgwnj4P1+9mUHj4676Eku6rYRBV32xYXzPBdGb0x3G/XnuydXMwFf72akSOpp 7Krekn3z/4ghm2DDp1SZzdN5QUHqpfUvUf0gya3hnJ/6JYU5XPlrKy0IN3wXa46RWS/6 MJeA== X-Google-Smtp-Source: AA+uWPx7O8adWCfcvaXiGqLDUgNNylojl01bhH+g/Gjqes6HLwaxhGQ5ncYX6Lz40i2yhizGHITgng== X-Received: by 2002:a17:902:42e2:: with SMTP id h89-v6mr51827967pld.69.1534907281175; Tue, 21 Aug 2018 20:08:01 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id q7-v6sm440165pfq.43.2018.08.21.20.07.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 20:08:00 -0700 (PDT) From: Jia He X-Google-Original-From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Cc: Wei Yang , Kees Cook , Laura Abbott , Vladimir Murzin , Philip Derrin , AKASHI Takahiro , James Morse , Steve Capper , Gioh Kim , Vlastimil Babka , Mel Gorman , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , Daniel Jordan , Daniel Vacek , Eugeniu Rosca , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jia He Subject: [PATCH v11 2/3] mm: page_alloc: remain memblock_next_valid_pfn() on arm/arm64 Date: Wed, 22 Aug 2018 11:07:16 +0800 Message-Id: <1534907237-2982-3-git-send-email-jia.he@hxt-semitech.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534907237-2982-1-git-send-email-jia.he@hxt-semitech.com> References: <1534907237-2982-1-git-send-email-jia.he@hxt-semitech.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP Commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns where possible") optimized the loop in memmap_init_zone(). But it causes possible panic bug. So Daniel Vacek reverted it later. But as suggested by Daniel Vacek, it is fine to using memblock to skip gaps and finding next valid frame with CONFIG_HAVE_ARCH_PFN_VALID. Daniel said: "On arm and arm64, memblock is used by default. But generic version of pfn_valid() is based on mem sections and memblock_next_valid_pfn() does not always return the next valid one but skips more resulting in some valid frames to be skipped (as if they were invalid). And that's why kernel was eventually crashing on some !arm machines." About the performance consideration: As said by James in b92df1de5, "I have tested this patch on a virtual model of a Samurai CPU with a sparse memory map. The kernel boot time drops from 109 to 62 seconds." Thus it would be better if we remain memblock_next_valid_pfn on arm/arm64. Suggested-by: Daniel Vacek Signed-off-by: Jia He --- include/linux/mmzone.h | 9 +++++++++ mm/memblock.c | 30 ++++++++++++++++++++++++++++++ mm/page_alloc.c | 5 ++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 32699b2..8e5e20b 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1266,6 +1266,10 @@ static inline int pfn_present(unsigned long pfn) #endif #define early_pfn_valid(pfn) pfn_valid(pfn) +#ifdef CONFIG_HAVE_MEMBLOCK_PFN_VALID +extern unsigned long memblock_next_valid_pfn(unsigned long pfn); +#define next_valid_pfn(pfn) memblock_next_valid_pfn(pfn) +#endif void sparse_init(void); #else #define sparse_init() do {} while (0) @@ -1287,6 +1291,11 @@ struct mminit_pfnnid_cache { #define early_pfn_valid(pfn) (1) #endif +/* fallback to default definitions*/ +#ifndef next_valid_pfn +#define next_valid_pfn(pfn) (pfn + 1) +#endif + void memory_present(int nid, unsigned long start, unsigned long end); /* diff --git a/mm/memblock.c b/mm/memblock.c index 3d03866..077ca62 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1140,6 +1140,36 @@ int __init_memblock memblock_set_node(phys_addr_t base, phys_addr_t size, } #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ +#ifdef CONFIG_HAVE_MEMBLOCK_PFN_VALID +unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn) +{ + struct memblock_type *type = &memblock.memory; + unsigned int right = type->cnt; + unsigned int mid, left = 0; + phys_addr_t addr = PFN_PHYS(++pfn); + + do { + mid = (right + left) / 2; + + if (addr < type->regions[mid].base) + right = mid; + else if (addr >= (type->regions[mid].base + + type->regions[mid].size)) + left = mid + 1; + else { + /* addr is within the region, so pfn is valid */ + return pfn; + } + } while (left < right); + + if (right == type->cnt) + return -1UL; + else + return PHYS_PFN(type->regions[right].base); +} +EXPORT_SYMBOL(memblock_next_valid_pfn); +#endif /*CONFIG_HAVE_MEMBLOCK_PFN_VALID*/ + static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, phys_addr_t align, phys_addr_t start, phys_addr_t end, int nid, ulong flags) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index cd3c7b9..607deff 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5485,8 +5485,11 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, if (context != MEMMAP_EARLY) goto not_early; - if (!early_pfn_valid(pfn)) + if (!early_pfn_valid(pfn)) { + pfn = next_valid_pfn(pfn) - 1; continue; + } + if (!early_pfn_in_nid(pfn, nid)) continue; if (!update_defer_init(pgdat, pfn, end_pfn, &nr_initialised)) From patchwork Wed Aug 22 03:07:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10572571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28569921 for ; Wed, 22 Aug 2018 03:08:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BE982B113 for ; Wed, 22 Aug 2018 03:08:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B9172B179; Wed, 22 Aug 2018 03:08:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55DEF2B113 for ; Wed, 22 Aug 2018 03:08:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 266326B2225; Tue, 21 Aug 2018 23:08:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1EF326B2226; Tue, 21 Aug 2018 23:08:15 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 068E36B2227; Tue, 21 Aug 2018 23:08:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id B4B206B2225 for ; Tue, 21 Aug 2018 23:08:14 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id c8-v6so393634pfn.2 for ; Tue, 21 Aug 2018 20:08:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=k6L7V60tgYGv+lfJrTEz7C2h3jQjmVlNf+2CpL355Uw=; b=G3lmUURoBor56vta8BFaw63ytUiM9jUjsJaSbvY1etTzGQiLCiMrLNFswjQAm1sobx 3YkBVXoxHn4QMk5+yb9lO2Z5gmAWtEP/XgNmj0nI4hG0LjuhAR36b3s9VmyhuoT2Rb4a Eq9Nq+NUfKSw2Elq64l9nNdOrqydtO1hNgF0ge9cxB6TUcwmzcRutt0fBTntLLhUkpVc UOqZnflp/Tk3HuJT4viF+UdDVh9LgRevpBgUqM+VCg0CZY8mBQ4NOh47WIfrDL8UQ5N3 O/GtvGCmJRcnN/6c3sTKdRhhG5/A958EevaJk0tvO8gmPYOzJbjhY/LIvel/htU7zh5F Wmmw== X-Gm-Message-State: AOUpUlF68vlvEvsGMaMWr9eH3s3ULBKTqL9a7FQmgpsHrFquieN+too1 Dn2XpU9AWi8HAsE7I93/S+JHvHaZtMWL/FUw8SlAPMDiXrfAhPEeNDyDKwZp2iDGfdIDbCo0AYY 3kJsVzqyPeCh3gzBPqr6Z2iL5wjXBrUskiuzxgoAFzJoC6A+qODXY6R8WPVZ0fSacCVY0JN45i0 L/m8yNXeAteex0UmPnI9BgiIV+NQj10SLbUiObLkvOC7rplTfAZwv/s0591yXSYzMQ6ixU41Wab HJzxvdHfxFqBDC3hfmUNN4pf+svscRSkQ6QSx0+qE7Aj6B23jIINyr0illp4fET5EDIWk85N/SD 8wB0hNiLvSr417mb0iiBKbHXzbqDSeB7kUlEJLFTnywL9PkmxxNUvmyO5pUudSQQBRZlRnq1igJ z X-Received: by 2002:a62:6003:: with SMTP id u3-v6mr33145196pfb.114.1534907294244; Tue, 21 Aug 2018 20:08:14 -0700 (PDT) X-Received: by 2002:a62:6003:: with SMTP id u3-v6mr33145136pfb.114.1534907293315; Tue, 21 Aug 2018 20:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534907293; cv=none; d=google.com; s=arc-20160816; b=gurUb2K/GN6RBwDo0XolrFzQKKSDk5DCmlG5KIn76gCtKEj0//xmCpAAdS7QV9tpGf mpuTZtEhOBr8aGtIq+EC2Hxd8bVjeF9yn+SWwEvaIQdS5103Hah7mx6fRc45JMZ3pCpJ HWsL6WsWJ0Ru7ykfKiaPhlqVmRD3XbomlpZamolOG0niBbGKYzwq9RHhEwcB+kGMSbN/ AE7Z1ds6Bh1ZPTpfnTro8KnFECwv841XGOhA8w08yHbu8eCy2xdSB679vXoHv+z+XBrb JjdAUfp7bSUXgh9KhQwC+NhmqcEUwJp8N/hIXUu1er8qHQgPSBhfWf8iXtw2AntVqDgG CpWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=k6L7V60tgYGv+lfJrTEz7C2h3jQjmVlNf+2CpL355Uw=; b=qapSmP0R6rXVPrUuEekfcvpTmAYvpc29T63Ti0MbSZJCRXhCoX4XJsu3x0WHRr2UQD 8SVRFSqWabRJWOKAUdjpROLHC5cznvyEPbKvltXpib8oDJyVx0d2+JKvwBfwVn4dHPxT zVIp6rzZftWlX0OF2RXI2FxOnV8V8id4azKpkyNtVD2+zb6XKM4fOYFm82ONPZBD3Iw8 /meP1tzPrJ/oR3fWW5TOYZRBIaYiIwJIRpS8MmwiYlJxjVdubQ9PukY8axugDPsSiCG1 P+RXrHk2jIx5ZOT8ZWUhdy9AGnusD/I5C5RPMqqQT7ZUoqWZq4rr+HkTtZ3Us4DjS9v+ BRVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CClWurYY; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p7-v6sor120213pgm.389.2018.08.21.20.08.13 for (Google Transport Security); Tue, 21 Aug 2018 20:08:13 -0700 (PDT) Received-SPF: pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CClWurYY; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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=k6L7V60tgYGv+lfJrTEz7C2h3jQjmVlNf+2CpL355Uw=; b=CClWurYYhPZP1b+a7/UxW5hDMp0ivher8C5m4yrUKdrW9DeAia5nUZUldiFJtXv5u+ U51mRFG9CE0yXAjhinVdbewB1QO01ag8L6Wz0o8Qge3pwIDs7q+2C+hxvx7zo33vnJWx FlG++ASu0bEoNy1mTdNFNBYGwLSy4NGnluNaAjlZOHk5ZZ0jl+92GM1yoqoqKgcKIz2N WiWmcbtGZn4Bs1GWACMcQan/c5QDpVdBECNSdax+UKkz9N3x/PdJYUaoa0Bdxu6o6y9Z vsKFnZ7ZrfSArJq1vOw0NGWuGSfXiqzE3UsdTS4wRy41PmYfVU3zI2a6WzoodQ0iAJmO d9vQ== X-Google-Smtp-Source: AA+uWPxV31z1jy7Bm6/N+EN8CZpSzp3X6Sr/3HvKeDlgpaJshLexqp3C8dErWomwKpKdjQ81IiuOyg== X-Received: by 2002:a65:6551:: with SMTP id a17-v6mr50379577pgw.132.1534907292982; Tue, 21 Aug 2018 20:08:12 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id q7-v6sm440165pfq.43.2018.08.21.20.08.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 20:08:12 -0700 (PDT) From: Jia He X-Google-Original-From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Cc: Wei Yang , Kees Cook , Laura Abbott , Vladimir Murzin , Philip Derrin , AKASHI Takahiro , James Morse , Steve Capper , Gioh Kim , Vlastimil Babka , Mel Gorman , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , Daniel Jordan , Daniel Vacek , Eugeniu Rosca , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jia He Subject: [PATCH v11 3/3] mm: page_alloc: reduce unnecessary binary search in memblock_next_valid_pfn Date: Wed, 22 Aug 2018 11:07:17 +0800 Message-Id: <1534907237-2982-4-git-send-email-jia.he@hxt-semitech.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534907237-2982-1-git-send-email-jia.he@hxt-semitech.com> References: <1534907237-2982-1-git-send-email-jia.he@hxt-semitech.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP 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. if pfn and pfn+1 are in the same memblock region, we can simply pfn++ instead of doing the binary search in memblock_next_valid_pfn. Furthermore, if the pfn is in a gap of two memory region, skip to next region directly if possible. Attached the memblock region information in my server. [ 0.000000] Zone ranges: [ 0.000000] DMA32 [mem 0x0000000000200000-0x00000000ffffffff] [ 0.000000] Normal [mem 0x0000000100000000-0x00000017ffffffff] [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000000200000-0x000000000021ffff] [ 0.000000] node 0: [mem 0x0000000000820000-0x000000000307ffff] [ 0.000000] node 0: [mem 0x0000000003080000-0x000000000308ffff] [ 0.000000] node 0: [mem 0x0000000003090000-0x00000000031fffff] [ 0.000000] node 0: [mem 0x0000000003200000-0x00000000033fffff] [ 0.000000] node 0: [mem 0x0000000003410000-0x00000000034fffff] [ 0.000000] node 0: [mem 0x0000000003500000-0x000000000351ffff] [ 0.000000] node 0: [mem 0x0000000003520000-0x000000000353ffff] [ 0.000000] node 0: [mem 0x0000000003540000-0x0000000003e3ffff] [ 0.000000] node 0: [mem 0x0000000003e40000-0x0000000003e7ffff] [ 0.000000] node 0: [mem 0x0000000003e80000-0x0000000003ecffff] [ 0.000000] node 0: [mem 0x0000000003ed0000-0x0000000003ed5fff] [ 0.000000] node 0: [mem 0x0000000003ed6000-0x0000000006eeafff] [ 0.000000] node 0: [mem 0x0000000006eeb000-0x000000000710ffff] [ 0.000000] node 0: [mem 0x0000000007110000-0x0000000007f0ffff] [ 0.000000] node 0: [mem 0x0000000007f10000-0x0000000007faffff] [ 0.000000] node 0: [mem 0x0000000007fb0000-0x000000000806ffff] [ 0.000000] node 0: [mem 0x0000000008070000-0x00000000080affff] [ 0.000000] node 0: [mem 0x00000000080b0000-0x000000000832ffff] [ 0.000000] node 0: [mem 0x0000000008330000-0x000000000836ffff] [ 0.000000] node 0: [mem 0x0000000008370000-0x000000000838ffff] [ 0.000000] node 0: [mem 0x0000000008390000-0x00000000083a9fff] [ 0.000000] node 0: [mem 0x00000000083aa000-0x00000000083bbfff] [ 0.000000] node 0: [mem 0x00000000083bc000-0x00000000083fffff] [ 0.000000] node 0: [mem 0x0000000008400000-0x000000000841ffff] [ 0.000000] node 0: [mem 0x0000000008420000-0x000000000843ffff] [ 0.000000] node 0: [mem 0x0000000008440000-0x000000000865ffff] [ 0.000000] node 0: [mem 0x0000000008660000-0x000000000869ffff] [ 0.000000] node 0: [mem 0x00000000086a0000-0x00000000086affff] [ 0.000000] node 0: [mem 0x00000000086b0000-0x00000000086effff] [ 0.000000] node 0: [mem 0x00000000086f0000-0x0000000008b6ffff] [ 0.000000] node 0: [mem 0x0000000008b70000-0x0000000008bbffff] [ 0.000000] node 0: [mem 0x0000000008bc0000-0x0000000008edffff] [ 0.000000] node 0: [mem 0x0000000008ee0000-0x0000000008ee0fff] [ 0.000000] node 0: [mem 0x0000000008ee1000-0x0000000008ee2fff] [ 0.000000] node 0: [mem 0x0000000008ee3000-0x000000000decffff] [ 0.000000] node 0: [mem 0x000000000ded0000-0x000000000defffff] [ 0.000000] node 0: [mem 0x000000000df00000-0x000000000fffffff] [ 0.000000] node 0: [mem 0x0000000010800000-0x0000000017feffff] [ 0.000000] node 0: [mem 0x000000001c000000-0x000000001c00ffff] [ 0.000000] node 0: [mem 0x000000001c010000-0x000000001c7fffff] [ 0.000000] node 0: [mem 0x000000001c810000-0x000000007efbffff] [ 0.000000] node 0: [mem 0x000000007efc0000-0x000000007efdffff] [ 0.000000] node 0: [mem 0x000000007efe0000-0x000000007efeffff] [ 0.000000] node 0: [mem 0x000000007eff0000-0x000000007effffff] [ 0.000000] node 0: [mem 0x000000007f000000-0x00000017ffffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000000200000-0x00000017ffffffff] [ 0.000000] On node 0 totalpages: 25145296 [ 0.000000] DMA32 zone: 16376 pages used for memmap [ 0.000000] DMA32 zone: 0 pages reserved [ 0.000000] DMA32 zone: 1028048 pages, LIFO batch:31 [ 0.000000] Normal zone: 376832 pages used for memmap [ 0.000000] Normal zone: 24117248 pages, LIFO batch:31 Signed-off-by: Jia He Reviewed-by: Pavel Tatashin --- mm/memblock.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index 077ca62..46cb6be 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1144,28 +1144,49 @@ int __init_memblock memblock_set_node(phys_addr_t base, phys_addr_t size, unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn) { struct memblock_type *type = &memblock.memory; + struct memblock_region *regions = type->regions; unsigned int right = type->cnt; unsigned int mid, left = 0; + unsigned long start_pfn, end_pfn, next_start_pfn; phys_addr_t addr = PFN_PHYS(++pfn); + static int early_region_idx __initdata_memblock = -1; + /* fast path, return pfn+1 if next pfn is in the same region */ + if (early_region_idx != -1) { + start_pfn = PFN_DOWN(regions[early_region_idx].base); + end_pfn = PFN_DOWN(regions[early_region_idx].base + + regions[early_region_idx].size); + + if (pfn >= start_pfn && pfn < end_pfn) + return pfn; + + early_region_idx++; + next_start_pfn = PFN_DOWN(regions[early_region_idx].base); + + if (pfn >= end_pfn && pfn <= next_start_pfn) + return next_start_pfn; + } + + /* slow path, do the binary searching */ do { mid = (right + left) / 2; - if (addr < type->regions[mid].base) + if (addr < regions[mid].base) right = mid; - else if (addr >= (type->regions[mid].base + - type->regions[mid].size)) + else if (addr >= (regions[mid].base + regions[mid].size)) left = mid + 1; else { - /* addr is within the region, so pfn is valid */ + early_region_idx = mid; return pfn; } } while (left < right); if (right == type->cnt) return -1UL; - else - return PHYS_PFN(type->regions[right].base); + + early_region_idx = right; + + return PHYS_PFN(regions[early_region_idx].base); } EXPORT_SYMBOL(memblock_next_valid_pfn); #endif /*CONFIG_HAVE_MEMBLOCK_PFN_VALID*/