From patchwork Thu Mar 7 13:35:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 2232201 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 26CB13FC8F for ; Thu, 7 Mar 2013 13:46:48 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UDb4K-0004Xg-6k; Thu, 07 Mar 2013 13:41:13 +0000 Received: from mail-pa0-f42.google.com ([209.85.220.42]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UDazX-0002x3-Nr for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2013 13:36:18 +0000 Received: by mail-pa0-f42.google.com with SMTP id kq12so475131pab.29 for ; Thu, 07 Mar 2013 05:36:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=gOC6XScY6CGy6wcLLXAchM6wmc02Ayp4bPGBIxX+SMM=; b=F+ps88iq8mSC1kFyuwmJH7HipEkhoKbzuOrDgQWdBl8YKRDoGSApbDP50fzZ/T35Lh hZgF8xnYyjTsJTC7Mz7ynRrkv27FgmSkDnMFvVvSOLmnb7W9xRRaTY9ZzMGXaRh5YiT4 v7fIqVre3GhcD6czWJ+3iSYwpAoEwwXObTQN+OrzP4CF3tQ7GwVZGXJYIpdHnwZ5ADd4 S8vjuSIjyEPaA8nLa2WBmyKe3zbT7IOA4R53P5qYZCDx0REIRQ6TH9I63r7VzCoaob4f OZwqtptxUFjuR4MsFDA0ZO+mFBq0N6GNP8Z0HPF7dqTFxsu6eESv692y93SIHovZ5siO kk5A== X-Received: by 10.66.154.161 with SMTP id vp1mr2978753pab.132.1362663372716; Thu, 07 Mar 2013 05:36:12 -0800 (PST) Received: from localhost ([183.37.214.52]) by mx.google.com with ESMTPS id 1sm1743019pbg.18.2013.03.07.05.36.05 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 07 Mar 2013 05:36:11 -0800 (PST) From: Ming Lei To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v1] ARM: keep __my_cpu_offset consistent with generic one Date: Thu, 7 Mar 2013 21:35:56 +0800 Message-Id: <1362663356-21151-1-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130307_083616_377643_17858028 X-CRM114-Status: GOOD ( 10.94 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.42 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tom.leiming[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Nicolas Pitre , Peter Zijlstra , Ming Lei , Will Deacon , linux-kernel@vger.kernel.org, Rob Herring , Ingo Molnar , Russell King X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Commit 14318efb(ARM: 7587/1: implement optimized percpu variable access) introduces arm's __my_cpu_offset to optimize percpu vaiable access, which really works well on hackbench, but will cause __my_cpu_offset to return garbage value before it is initialized in cpu_init() called by setup_arch, so accessing percpu variable before setup_arch may cause kernel hang. But generic __my_cpu_offset always returns zero before percpu area is brought up, and won't hang kernel. So the patch tries to clear __my_cpu_offset on boot CPU early to avoid boot hang. At least now percpu variable is accessed by lockdep before setup_arch(), and enabling CONFIG_LOCK_STAT or CONFIG_DEBUG_LOCKDEP can trigger kernel hang. Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Rob Herring Cc: Will Deacon Cc: Nicolas Pitre Cc: Russell King Signed-off-by: Ming Lei --- V1: - documents lockdep uses percpu variable early arch/arm/kernel/setup.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 3f6cbb2..1a9dc21 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -439,6 +439,13 @@ void __init smp_setup_processor_id(void) for (i = 1; i < nr_cpu_ids; ++i) cpu_logical_map(i) = i == cpu ? 0 : i; + /* + * clear __my_cpu_offset on boot CPU to avoid hang caused by + * using percpu variable early, for example, lockdep will + * access percpu variable inside lock_release + */ + set_my_cpu_offset(0); + printk(KERN_INFO "Booting Linux on physical CPU 0x%x\n", mpidr); }