Message ID | ZNZcBkiVkm87+Tvr@p100 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1222584vqi; Fri, 11 Aug 2023 09:46:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGp2UbSmI0WGNXhkff3ROeQeYDds8FTcSYsz8/7tos9ONMIpHX5sj76Qjf2HlcWY3bycu72 X-Received: by 2002:a17:903:32cd:b0:1bc:2d43:c747 with SMTP id i13-20020a17090332cd00b001bc2d43c747mr3151049plr.38.1691772362426; Fri, 11 Aug 2023 09:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691772362; cv=none; d=google.com; s=arc-20160816; b=vZdx7TRuRykmaCbVy6IXr3oKvhE0CpxkhX3l/DtyJySQao7YATUawgpZYE6TYnyMBH AvqwJH7jxvIqZTV5jMBCsBjxABtPonMTcIXlat1Bl3/lYxqwZvsEdSA39iqx/0DyDR+J ykGWD/rIrWj1Vscxu0cBCaBHNdj04heuMLiZ+wWYdr1JUi1Nal/WU7JfEg92jplGjUKX t8QE5CrzgcMxoEJCInHuXBqtZtxuG22qJ6hyHAC7GFzAxNHuh18EMR9oSjGBymtCoIb1 xnoawwOMLviQNSSOsWJeGW3JbmXCmlHb4gDHTOvD0Y+mWIkjhXVsAr0TKVJ3VZmHKah1 zrww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:ui-outboundreport :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=VZ/zXYi/0GR4tUlXleI8OJBA/k4u+3BDgpoUHGIZfoY=; fh=CDBSBJk/1k8qRPQGEtL1zM4790a3Cs/UEc9WPSeoBG0=; b=yUlIpbBjxTKKnH0hNDzqldIlXnkV/ofX5HB61SEQJ+xCQsKoh2kVViY+mYo6tvq+QQ /87AAUzclHFtkJqo5GViQhz8PT8VTzympubuIAZvElNsCH3gjKAr8+TcBeJotzeadPPc R7AEtcZm/sHvu0/59sf8weLm1VHRQAgdQtPkabn1ZdqoYwj9uM71K/5j6LxsRN9RV4cF +Y+uNIi4IKuj1R8C+0eMQId0VTy5o2wcslKfnjPbW+vFXMzy7NBObStwjB2kMUZtC0v8 KY+bDiN1dU0Fhwm1ImAxN61WiJQSLJRc35PBMOzzCXmplei6UAFpj4653+zMCfbf/DxE V5ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=uZYblYq+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g2-20020a170902e38200b001b9d335175asi3521530ple.292.2023.08.11.09.45.43; Fri, 11 Aug 2023 09:46:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=uZYblYq+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234354AbjHKQE1 (ORCPT <rfc822;lanlanxiyiji@gmail.com> + 99 others); Fri, 11 Aug 2023 12:04:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjHKQE0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 11 Aug 2023 12:04:26 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25B34E58; Fri, 11 Aug 2023 09:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1691769864; x=1692374664; i=deller@gmx.de; bh=l5mnkz2k1a6F+R0c1XAKS+SjI6mLnDCae5GSDV64zGI=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject; b=uZYblYq+QAUR6iLGwSJbpku4LpL/qb4ecQnUit29FrHTi9u18sbxsCuMNLtys4pe4Isrgkt StdV21Bl+r0xetTjB0T9RNgN/GBeYKW1jCPynqaDRDOJh8mktS9TQ9/MK/HmJMCCHg+fmLFYH 6gS2y/rvLKdSHWZib6D2pb0xITYeUGrviUnhp8Xr1hhFDWuVIns6Ip5+kO4+jIXg/gUHcdR6E pJo9yNJPqL7jtPLtAMT7SXBFrWP14HYNmg85LAbyrRZDlb1PtfUcNfVmY16dCiiCn6likcJmQ CSLtWR/fsMk5Sn5zSAd9ydfYu7VkV+IPyphiDlIuaeK2GTcYL6eQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from p100 ([94.134.154.87]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MiaY9-1ppdlQ44NL-00fi2W; Fri, 11 Aug 2023 18:04:24 +0200 Date: Fri, 11 Aug 2023 18:04:22 +0200 From: Helge Deller <deller@gmx.de> To: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org Cc: linux-parisc@vger.kernel.org Subject: [PATCH] init: Add lockdep annotation to kthreadd_done completer Message-ID: <ZNZcBkiVkm87+Tvr@p100> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Provags-ID: V03:K1:sVs2lL9kx55kJx/JfBa6k0AR9UXRwIyujuUX/Dw7vmKICNRJJct JDV4T4yUVK43jOOunqRKV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aNb7G+U+wtPDTIYhRyyOwSd TyYmxG+tZstidUmTcXJu3HBGU2ceQrC34Mp91mA0FKQ/KIRIZOMkv7CX61HY7IYLtSPAUad9V cQc6qg== Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773951897040862856 X-GMAIL-MSGID: 1773951897040862856 |
Series |
init: Add lockdep annotation to kthreadd_done completer
|
|
Commit Message
Helge Deller
Aug. 11, 2023, 4:04 p.m. UTC
Add the missing lockdep annotation to avoid this warning:
INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe
you didn't initialize this object before use?
turning off the locking correctness validator.
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.5.0-rc5+ #681
Hardware name: 9000/785/C3700
Backtrace:
[<000000004030bcd0>] show_stack+0x74/0xb0
[<0000000041469c7c>] dump_stack_lvl+0x104/0x180
[<0000000041469d2c>] dump_stack+0x34/0x48
[<000000004040e5b4>] register_lock_class+0xd24/0xd30
[<000000004040c21c>] __lock_acquire.isra.0+0xb4/0xac8
[<000000004040cd60>] lock_acquire+0x130/0x298
[<000000004146df54>] _raw_spin_lock_irq+0x60/0xb8
[<0000000041472044>] wait_for_completion+0xa0/0x2d0
[<000000004146b544>] kernel_init+0x48/0x3a8
[<0000000040302020>] ret_from_kernel_thread+0x20/0x28
Signed-off-by: Helge Deller <deller@gmx.de>
Comments
On Fri, 11 Aug 2023 18:04:22 +0200 Helge Deller <deller@gmx.de> wrote: > Add the missing lockdep annotation to avoid this warning: > > INFO: trying to register non-static key. > The code is fine but needs lockdep annotation, or maybe > you didn't initialize this object before use? > turning off the locking correctness validator. > CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.5.0-rc5+ #681 > Hardware name: 9000/785/C3700 > Backtrace: > [<000000004030bcd0>] show_stack+0x74/0xb0 > [<0000000041469c7c>] dump_stack_lvl+0x104/0x180 > [<0000000041469d2c>] dump_stack+0x34/0x48 > [<000000004040e5b4>] register_lock_class+0xd24/0xd30 > [<000000004040c21c>] __lock_acquire.isra.0+0xb4/0xac8 > [<000000004040cd60>] lock_acquire+0x130/0x298 > [<000000004146df54>] _raw_spin_lock_irq+0x60/0xb8 > [<0000000041472044>] wait_for_completion+0xa0/0x2d0 > [<000000004146b544>] kernel_init+0x48/0x3a8 > [<0000000040302020>] ret_from_kernel_thread+0x20/0x28 > > ... > > --- a/init/main.c > +++ b/init/main.c > @@ -682,6 +682,8 @@ noinline void __ref __noreturn rest_init(void) > struct task_struct *tsk; > int pid; > > + init_completion(&kthreadd_done); > + > rcu_scheduler_starting(); > /* > * We need to spawn init first so that it obtains pid 1, however This is pretty old code, as is the page_alloc_init_late() change. Do we know why this warning has just turned up lately? I'll add cc:stable to these, but might take that away again if we can answer the above. btw, please don't forget the "^---$" between changelog and patch.
On 8/11/23 18:43, Andrew Morton wrote: > On Fri, 11 Aug 2023 18:04:22 +0200 Helge Deller <deller@gmx.de> wrote: > >> Add the missing lockdep annotation to avoid this warning: >> >> INFO: trying to register non-static key. >> The code is fine but needs lockdep annotation, or maybe >> you didn't initialize this object before use? >> turning off the locking correctness validator. >> CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.5.0-rc5+ #681 >> Hardware name: 9000/785/C3700 >> Backtrace: >> [<000000004030bcd0>] show_stack+0x74/0xb0 >> [<0000000041469c7c>] dump_stack_lvl+0x104/0x180 >> [<0000000041469d2c>] dump_stack+0x34/0x48 >> [<000000004040e5b4>] register_lock_class+0xd24/0xd30 >> [<000000004040c21c>] __lock_acquire.isra.0+0xb4/0xac8 >> [<000000004040cd60>] lock_acquire+0x130/0x298 >> [<000000004146df54>] _raw_spin_lock_irq+0x60/0xb8 >> [<0000000041472044>] wait_for_completion+0xa0/0x2d0 >> [<000000004146b544>] kernel_init+0x48/0x3a8 >> [<0000000040302020>] ret_from_kernel_thread+0x20/0x28 >> >> ... >> >> --- a/init/main.c >> +++ b/init/main.c >> @@ -682,6 +682,8 @@ noinline void __ref __noreturn rest_init(void) >> struct task_struct *tsk; >> int pid; >> >> + init_completion(&kthreadd_done); >> + >> rcu_scheduler_starting(); >> /* >> * We need to spawn init first so that it obtains pid 1, however > > This is pretty old code, as is the page_alloc_init_late() change. Do > we know why this warning has just turned up lately? I haven't debugged in depth yet, but here is what I believe is the reason why I do see those lockdep warnings and others not. I'm building & testing on the parisc platform. Just recently I added lockdep support to parisc for kernel 6.4 and backported it to v6.0+. Since then I've seen the warnings. And I think the main reason why I see those warnings on parisc and others on other platforms don't, is that parisc is the only architecture where __ARCH_SPIN_LOCK_UNLOCKED_VAL is NOT zero (0x1a46 actually). The reason is that parisc offers only one assembler instruction which operates atomicly on memory, and which we use to lock spinlocks: ldcw ("load and clear word"). So, a "zero" spinlock word means the lock is locked, while non-zero means it's unlocked. For other platforms it's the other way around. So, for a structure in e.g. __initdata[] which is pre-initialized by the compiler, the spinlocks are locked by default (lockword = 0) on parisc, if they haven't been initialized correctly, and thus the kernel will complain at runtime. Now, maybe lockdep doesn't use spinlocks per se. I have't checked in depth yet, but I'm sure it's somehow related to the odd __ARCH_SPIN_LOCK_UNLOCKED_VAL value of parisc. I wonder if the same bug appears if you use a non-zero __ARCH_SPIN_LOCK_UNLOCKED_VAL on other platforms too (if it's possible). > I'll add cc:stable to these, but might take that away again if we can > answer the above. Thanks for adding the patches. I did sent two other patches as well: for watchdog and devtmpfs.. > btw, please don't forget the "^---$" between changelog and patch. Ok. Helge
Hi Andrew, On 8/11/23 19:44, Helge Deller wrote: > On 8/11/23 18:43, Andrew Morton wrote: >> On Fri, 11 Aug 2023 18:04:22 +0200 Helge Deller <deller@gmx.de> wrote: >> >>> Add the missing lockdep annotation to avoid this warning: >>> >>> INFO: trying to register non-static key. >>> The code is fine but needs lockdep annotation, or maybe >>> you didn't initialize this object before use? >>> turning off the locking correctness validator. >>> CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.5.0-rc5+ #681 >>> Hardware name: 9000/785/C3700 >>> Backtrace: >>> [<000000004030bcd0>] show_stack+0x74/0xb0 >>> [<0000000041469c7c>] dump_stack_lvl+0x104/0x180 >>> [<0000000041469d2c>] dump_stack+0x34/0x48 >>> [<000000004040e5b4>] register_lock_class+0xd24/0xd30 >>> [<000000004040c21c>] __lock_acquire.isra.0+0xb4/0xac8 >>> [<000000004040cd60>] lock_acquire+0x130/0x298 >>> [<000000004146df54>] _raw_spin_lock_irq+0x60/0xb8 >>> [<0000000041472044>] wait_for_completion+0xa0/0x2d0 >>> [<000000004146b544>] kernel_init+0x48/0x3a8 >>> [<0000000040302020>] ret_from_kernel_thread+0x20/0x28 >>> >>> ... >>> >>> --- a/init/main.c >>> +++ b/init/main.c >>> @@ -682,6 +682,8 @@ noinline void __ref __noreturn rest_init(void) >>> struct task_struct *tsk; >>> int pid; >>> >>> + init_completion(&kthreadd_done); >>> + >>> rcu_scheduler_starting(); >>> /* >>> * We need to spawn init first so that it obtains pid 1, however >> >> This is pretty old code, as is the page_alloc_init_late() change. Do >> we know why this warning has just turned up lately? [dropped Helge's assumptions that it's related to parisc's unusual __ARCH_SPIN_LOCK_UNLOCKED_VAL value. It turned out to be wrong. Now I was able to trace down why I see those lockdep warnings on parisc. The short answer is: On parisc the _initdata section lies outside of the usual kernel _stext ... _end range. Lockdep calls static_obj() which currently assumes that __initdata is inside that range and thus returns "false". That's why lockdep then reports INFO: trying to register non-static key. which is wrong. Please drop those 3 lockdep patches from your mm-queue: mm-add-lockdep-annotation-to-pgdat_init_all_done_comp-completer.patch init-add-lockdep-annotation-to-kthreadd_done-completer.patch watchdog-fix-lockdep-warning.patch I'll send one single patch which fixes static_obj() instead. Thanks, Helge
diff --git a/init/main.c b/init/main.c index ad920fac325c..11870ca752de 100644 --- a/init/main.c +++ b/init/main.c @@ -682,6 +682,8 @@ noinline void __ref __noreturn rest_init(void) struct task_struct *tsk; int pid; + init_completion(&kthreadd_done); + rcu_scheduler_starting(); /* * We need to spawn init first so that it obtains pid 1, however