From patchwork Thu Sep 10 04:27:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tangchen X-Patchwork-Id: 7150741 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4E6B99F72C for ; Thu, 10 Sep 2015 04:30:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7A15A209DE for ; Thu, 10 Sep 2015 04:30:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E72A209E7 for ; Thu, 10 Sep 2015 04:30:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752812AbbIJE3n (ORCPT ); Thu, 10 Sep 2015 00:29:43 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:60199 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750813AbbIJE3d (ORCPT ); Thu, 10 Sep 2015 00:29:33 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100549491" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Sep 2015 12:32:27 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8A4THom014067; Thu, 10 Sep 2015 12:29:17 +0800 Received: from tangchen.g08.fujitsu.local (10.167.226.71) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 10 Sep 2015 12:29:30 +0800 From: Tang Chen To: , , , , , , , , , , , , CC: , , , , Subject: [PATCH v2 1/7] x86, numa: Move definition of find_near_online_node() forward. Date: Thu, 10 Sep 2015 12:27:43 +0800 Message-ID: <1441859269-25831-2-git-send-email-tangchen@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1441859269-25831-1-git-send-email-tangchen@cn.fujitsu.com> References: <1441859269-25831-1-git-send-email-tangchen@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.71] Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Will call this function earlier in next coming patches. So simply move its definition forward. And also, add comments for it. Signed-off-by: Tang Chen --- arch/x86/mm/numa.c | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 4053bb5..fea387a 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -78,6 +78,35 @@ EXPORT_SYMBOL(node_to_cpumask_map); DEFINE_EARLY_PER_CPU(int, x86_cpu_to_node_map, NUMA_NO_NODE); EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_node_map); +/** + * find_near_online_node - Find the best near online node of a node. + * @node: NUMA node ID of the current node. + * + * Find the best near online node of @node, based on node_distance[] array. + * The best near online node is the backup node for memory allocation on + * one node. + * + * RETURNS: + * The best near online node ID on success, -1 on failure. + */ +static __init int find_near_online_node(int node) +{ + int n, val; + int min_val = INT_MAX; + int near_node = -1; + + for_each_online_node(n) { + val = node_distance(node, n); + + if (val < min_val) { + min_val = val; + near_node = n; + } + } + + return near_node; +} + void numa_set_node(int cpu, int node) { int *cpu_to_node_map = early_per_cpu_ptr(x86_cpu_to_node_map); @@ -702,24 +731,6 @@ void __init x86_numa_init(void) numa_init(dummy_numa_init); } -static __init int find_near_online_node(int node) -{ - int n, val; - int min_val = INT_MAX; - int best_node = -1; - - for_each_online_node(n) { - val = node_distance(node, n); - - if (val < min_val) { - min_val = val; - best_node = n; - } - } - - return best_node; -} - /* * Setup early cpu_to_node. *