From patchwork Fri Aug 4 21:54:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 9882117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A4CA60360 for ; Fri, 4 Aug 2017 21:54:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19B4228911 for ; Fri, 4 Aug 2017 21:54:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B5A728948; Fri, 4 Aug 2017 21:54:29 +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=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8117C28911 for ; Fri, 4 Aug 2017 21:54:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752012AbdHDVy2 (ORCPT ); Fri, 4 Aug 2017 17:54:28 -0400 Received: from mout.gmx.net ([212.227.15.19]:51259 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751685AbdHDVy1 (ORCPT ); Fri, 4 Aug 2017 17:54:27 -0400 Received: from p100.box ([193.159.17.37]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M4nt7-1dRiuO1z3t-00yz2d; Fri, 04 Aug 2017 23:54:21 +0200 Date: Fri, 4 Aug 2017 23:54:19 +0200 From: Helge Deller To: linux-parisc@vger.kernel.org, James Bottomley , John David Anglin Subject: [PATCH] parisc: Static initialization of spinlocks in perf and unwind code Message-ID: <20170804215419.GA9373@p100.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:tzU3Wa7ve+x2RQMNzpkSSLtEJ/9FiBdJ5/yjqb8fuI1UhEo/liD 7fmrNQR1HlyGnb2gkuu/Iu3hNCRj0j1Uk60r1n7vt4BHq/ERGK5vDaGc+lu/TmJYmnsd9b4 DKULyrmNPbWTuoNyFH3mGxf9W4aeGRckr7lb9IWzQqLWGmWoPfGf4T8CzhV62ot7kWbIDQ/ jNIRINiTj0xB77EIbxA5Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:2z7ObCFLkKA=:dYzIY0r8QGAntgUUGbpPHg j2CTAhiJD5kYbO5nTyVKtUF+njJDmpzFtnOvfArGpdXwskPo9VOpK54NZQ0LAtwTKOLW+mZox wh6aTqkyRYAu54wDG4Cl0Yn18GsK95DXy9ZgcotclzXRQniGGz2oEZEfJIokYilVc5FyWuVjF zOArOAvNE03zj6/Rhy/kQREx3ra0HKRY1YEy+ipcP0FUxwpzZ3k+cxV/d4iENN0PY6ByDSdNo MY6Ily/sZvUG5JDG4fXXIIG3P/FljytgnKkkrUK4l7Fw6RtSwaOvkqD1usu5GjTQGNS/PYrxH AfmVBT961jcSupaUmUYwasvyyhL0XgzSJP7GIhnyN8VTAYOm4cdyMxZvCltECyfF1mz82tklS 41tSmr/r2FZ/Gv6tasAvddNCuAo7rZhofoVmzzvYXdvZqrmDuq3r7CwBZwk5tlYuOXwtrZ+rO 5KC2LZMXSeLSa29LEfCqoaloInQQ2MUiAKcneoCW1Ld7Is7C9uQPdKkwnRAIMjeD54VRFARim JekJB8gzsPa3nZs8uT8ERSrtflqVCQrArymWT4nDytoS5lJk5RWWewnl7BOasSeC35x4g7DHE DgqYFRCJt52r18NGEtqLldC2pPMRjo/tlob/MGeiQoJa9mxremOPe66pZVkfS+5d62sDVXSaG mskEa5i/L47ki2X6Nap9mdBr8k/do0irkezwx8QdckV/Zl8xZAThr+ogrLxu6EJPWwyer/zXP S2CidavU2Sq/+z4QKdiu2ilzy6wKn2m2MOc1nVCHNXvZjqTO4xz6EOUI0gDCvasUhphLpxHBo wfXEw6F0u20IPyuymlkCeKerONsFA== Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While testing UBSAN I saw this BUG: BUG: spinlock bad magic on CPU#0, swapper/0 in unwind code. Let's avoid that by static initialization. Signed-off-by: Helge Deller --- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c index 6017a5a..08133590 100644 --- a/arch/parisc/kernel/perf.c +++ b/arch/parisc/kernel/perf.c @@ -69,7 +69,7 @@ struct rdr_tbl_ent { static int perf_processor_interface __read_mostly = UNKNOWN_INTF; static int perf_enabled __read_mostly; -static spinlock_t perf_lock; +static DEFINE_SPINLOCK(perf_lock); struct parisc_device *cpu_device __read_mostly; /* RDRs to write for PCX-W */ @@ -533,8 +533,6 @@ static int __init perf_init(void) /* Patch the images to match the system */ perf_patch_images(); - spin_lock_init(&perf_lock); - /* TODO: this only lets us access the first cpu.. what to do for SMP? */ cpu_device = per_cpu(cpu_data, 0).dev; printk("Performance monitoring counters enabled for %s\n", diff --git a/arch/parisc/kernel/unwind.c b/arch/parisc/kernel/unwind.c index 1b73690..48dc7d4 100644 --- a/arch/parisc/kernel/unwind.c +++ b/arch/parisc/kernel/unwind.c @@ -34,7 +34,7 @@ extern struct unwind_table_entry __start___unwind[]; extern struct unwind_table_entry __stop___unwind[]; -static spinlock_t unwind_lock; +static DEFINE_SPINLOCK(unwind_lock); /* * the kernel unwind block is not dynamically allocated so that * we can call unwind_init as early in the bootup process as @@ -181,8 +181,6 @@ int __init unwind_init(void) start = (long)&__start___unwind[0]; stop = (long)&__stop___unwind[0]; - spin_lock_init(&unwind_lock); - printk("unwind_init: start = 0x%lx, end = 0x%lx, entries = %lu\n", start, stop, (stop - start) / sizeof(struct unwind_table_entry));