From patchwork Thu Mar 7 02:47:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 2229471 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 F1BF03FCF6 for ; Thu, 7 Mar 2013 02:54:03 +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 1UDQtb-0008KO-5a; Thu, 07 Mar 2013 02:49:27 +0000 Received: from mail-pa0-f49.google.com ([209.85.220.49]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UDQtP-0008FT-LY for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2013 02:49:17 +0000 Received: by mail-pa0-f49.google.com with SMTP id kp6so70943pab.22 for ; Wed, 06 Mar 2013 18:49:13 -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=I3b6B79kRAS6vaugacejZ9vlr0BtIBrkHCJbfPJ68/E=; b=qPsJWIag2+91XvhqgNRXj2Ui8y1hW74sQNFXrPGLroJPGP8ublTpLFgX6YjjwgH3N4 7GZPudCYCxqpP8ThHs5/Axv34yyGy8wrB/udTeKp6fxoazVVK57Uc9YobimkfRiCubJp eL3iffpDZgF00yAGPofBRYlMiSkiWgrlX/Sg+xaC/2ULK0cDrQ2tTOvowQDfPy6z3BAP 4pAVfAXPcM2iBoe9ea82HgPBJL5Dqi+cZnCxHfzhQTjJ9LptjsdElEQlvcb9Z0TTerzq hru4JqnhyO9b694s+UM0LpwvauVt1x5GlNbGCYGnkzvQn8M9wnQVtVwBk1FsXqEU0uQC Lyqw== X-Received: by 10.66.170.42 with SMTP id aj10mr504598pac.88.1362624553867; Wed, 06 Mar 2013 18:49:13 -0800 (PST) Received: from localhost ([183.37.201.17]) by mx.google.com with ESMTPS id c6sm10145342pbm.45.2013.03.06.18.49.08 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 06 Mar 2013 18:49:13 -0800 (PST) From: Ming Lei To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH] ARM: keep __my_cpu_offset consistent with generic one Date: Thu, 7 Mar 2013 10:47:48 +0800 Message-Id: <1362624468-5451-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-20130306_214915_902571_D0DF537A X-CRM114-Status: GOOD ( 11.45 ) 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.49 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 , Tejun Heo , 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 test, but may cause __my_cpu_offset to return garbage value before it is initialized in cpu_init() called by setup_arch, so accessing a percpu variable before setup_arch may cause kernel hang. But the generic__my_cpu_offset always returns zero before percpu area is brought up. 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: Tejun Heo Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Rob Herring Cc: Will Deacon Cc: Nicolas Pitre Cc: Russell King Signed-off-by: Ming Lei --- 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..bc7ee4b 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 early to avoid hang + * caused by accessing percpu variable before percpu area is + * brought up + */ + set_my_cpu_offset(0); + printk(KERN_INFO "Booting Linux on physical CPU 0x%x\n", mpidr); }