From patchwork Wed May 25 17:51:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 68636 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1362775qge; Wed, 25 May 2016 11:18:53 -0700 (PDT) X-Received: by 10.98.26.205 with SMTP id a196mr7842614pfa.46.1464200333618; Wed, 25 May 2016 11:18:53 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e16si158888pfj.131.2016.05.25.11.18.53; Wed, 25 May 2016 11:18:53 -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=@linaro.org; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755714AbcEYSSu (ORCPT + 30 others); Wed, 25 May 2016 14:18:50 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:33418 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755424AbcEYSSt (ORCPT ); Wed, 25 May 2016 14:18:49 -0400 Received: by mail-pa0-f54.google.com with SMTP id xk12so19957079pac.0 for ; Wed, 25 May 2016 11:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=lcuIOS5+k+JtA6W59QaR/7T09KeJguSXzaxsz6hsLrE=; b=HyhESUK9c/P6kF2bwAdL5WHQtUS6D7wq/upFIJtqo1CnhaHW04c+KdEkUStCymCkQa cC/vWflcFLN5QGRl0hGNQWjobYHPpPUzcQbm/nVhIIhPIo6Yx8Ms3FeeTx+hOouO1N4v qWVzEUwL+jTa8CzYeuqezis0se+lK63r9r1wU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lcuIOS5+k+JtA6W59QaR/7T09KeJguSXzaxsz6hsLrE=; b=nHZzmnGOwEM8HnbhAfOgdc17bEWfD54Rjr2qnMV/F8rtZIAQTN+JuLP4j9OTdgdW4d OhevRIG8oj1n9IKk/GsTjCYeomuXNBL+vDt2m/1rq3QSeEyW99MntPcZU82sjpih6tYE 7PhKr7Y0a7Tc+UPn9jcHp0ns0eZv2II4XGDwCi0153AcgAVKgybuijs1A0vQqeEPHsZJ jAlptRSBu5RP+DfD2HlS+Ja1fvb3KK8uaSRD+nFCm83TH+IVlA/g+BvqRGaF7g+kS7Cs nTANy4ghy5NVfjN2cbnCWbprDcM5q+zfF3TYS5iA3GtocHF4ArC/nGT9tIdc87Fr5hrb w+gQ== X-Gm-Message-State: ALyK8tKQ4Cx/ApBkB47w50soK2/nxceWTru+tOBBmPm5ptgUzYQp1dQDGunvGNt4NJQxkli9 X-Received: by 10.66.220.7 with SMTP id ps7mr7746389pac.77.1464200328515; Wed, 25 May 2016 11:18:48 -0700 (PDT) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id r73sm143075pfi.4.2016.05.25.11.18.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 May 2016 11:18:47 -0700 (PDT) From: Yang Shi To: akpm@linux-foundation.org, iamjoonsoo.kim@lge.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org Subject: [PATCH] mm: use early_pfn_to_nid in page_ext_init Date: Wed, 25 May 2016 10:51:29 -0700 Message-Id: <1464198689-23458-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org page_ext_init() checks suitable pages with pfn_to_nid(), but pfn_to_nid() depends on memmap which will not be setup fully until page_alloc_init_late() is done. Use early_pfn_to_nid() instead of pfn_to_nid() so that page extension could be still used early even though CONFIG_ DEFERRED_STRUCT_PAGE_INIT is enabled and catch early page allocation call sites. Suggested by Joonsoo Kim [1], this fix basically undoes the change introduced by commit b8f1a75d61d8405a753380c6fb17ba84a5603cd4 ("mm: call page_ext_init() after all struct pages are initialized") and fixes the same problem with a better approach. [1] http://lkml.kernel.org/r/CAAmzW4OUmyPwQjvd7QUfc6W1Aic__TyAuH80MLRZNMxKy0-wPQ@mail.gmail.com CC: Joonsoo Kim Signed-off-by: Yang Shi --- init/main.c | 3 +-- mm/page_ext.c | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) -- 2.0.2 diff --git a/init/main.c b/init/main.c index bc0f9e0..4c17fda 100644 --- a/init/main.c +++ b/init/main.c @@ -607,6 +607,7 @@ asmlinkage __visible void __init start_kernel(void) initrd_start = 0; } #endif + page_ext_init(); debug_objects_mem_init(); kmemleak_init(); setup_per_cpu_pageset(); @@ -1003,8 +1004,6 @@ static noinline void __init kernel_init_freeable(void) sched_init_smp(); page_alloc_init_late(); - /* Initialize page ext after all struct pages are initializaed */ - page_ext_init(); do_basic_setup(); diff --git a/mm/page_ext.c b/mm/page_ext.c index 2d864e6..44a4c02 100644 --- a/mm/page_ext.c +++ b/mm/page_ext.c @@ -390,8 +390,10 @@ void __init page_ext_init(void) * We know some arch can have a nodes layout such as * -------------pfn--------------> * N0 | N1 | N2 | N0 | N1 | N2|.... + * + * Take into account DEFERRED_STRUCT_PAGE_INIT. */ - if (pfn_to_nid(pfn) != nid) + if (early_pfn_to_nid(pfn) != nid) continue; if (init_section_page_ext(pfn, nid)) goto oom;