Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4703292rwb; Mon, 31 Jul 2023 10:48:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlEzId2d2LQDvP2X2QOqrCxFz4LgmjrwRCVWzgIX20nXrhk1mXMDGAsT7+3ExmKrkfeVQZ+Y X-Received: by 2002:a05:6402:180f:b0:522:30d5:6065 with SMTP id g15-20020a056402180f00b0052230d56065mr536656edy.21.1690825681780; Mon, 31 Jul 2023 10:48:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690825681; cv=none; d=google.com; s=arc-20160816; b=LbEfMIwkDTrlxnyrex5HFBtm9l5K5Sv6z/QzKBUzXO/reumEBNLyjFXWbnvj7E1LRD uNDP5amfm5J6MttoROXut3gqs6GRPhEG6W0VrzErURMmSlk+FizHv+nrSq1IhXBbF49g cXc3iVCX0XqOWFx6Q4oT9QUrUPK5YhIBUpp3psY/0uTST2jEvfUG/HM/rysaiMAL11+E utY4+PRhEDrNNPgke420qOMaFjkWnLRRmpimSV25Bl24SFMLOmirjp1YGFxUSobuZi5W xpcv9MWqRBzxUTfJm9bie9kxQoxZ+CS/JOM5lr8ZQU/Cye84vgLV6Qf2X42XSvRKHfqu rwqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature:dkim-signature; bh=qQs9wdHlrLhwCHhCKhiMFGg1nYsVa/Zj2WYMaePC1WA=; fh=vQkoesTsX5AZsznYr8Z17idubg3DQB+guYhiOTDCQa0=; b=REkcW6BVHttky7V/JcRUhpyZFLmu9c4kEA62AXW1RoJc4tvLCcU6fI0UkmR0LQfqEA xFoTTHM7QAZbZ72oZNeeCfx8xxmvGmyeRLSvM63/1AohPOJMLeKzwRNWNy89jBQvhCzs m/DAXY56AP5v6BPzJjY9lL2p4K3odLZ+jZlV/KXpsuIENJM1u2wNmzL7IgJLim25Vs7w EjDfI/yss+RvVbkLL8AP+cG5bJ+wLmMwY1lB9p2RAAi0ZxZ2pRi+zrl64xqf8g9WxFJe 11C3lVBnOmu5o6024LI8MAGEWELMA1VkamUwOj/MU8p2IcnfRZPZChqVF1KEFwfL6OMA DBmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Ey1zRaXB; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=macfYBb1; 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=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j5-20020aa7de85000000b00522ac23622dsi4282018edv.168.2023.07.31.10.47.37; Mon, 31 Jul 2023 10:48:01 -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=@suse.de header.s=susede2_rsa header.b=Ey1zRaXB; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=macfYBb1; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232960AbjGaQIh (ORCPT + 99 others); Mon, 31 Jul 2023 12:08:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233053AbjGaQIf (ORCPT ); Mon, 31 Jul 2023 12:08:35 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDFA61981; Mon, 31 Jul 2023 09:08:32 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 15A9B1F45F; Mon, 31 Jul 2023 16:08:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1690819711; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qQs9wdHlrLhwCHhCKhiMFGg1nYsVa/Zj2WYMaePC1WA=; b=Ey1zRaXBulEDJJXu0A8G9m07QKDcUMmlb3XQ5FzB2Ym1V8q6qMPkZT+1ojZQRYFliXzpWw s/XXEJRB1PxU8OVvS4ysosWisk1AYSGwLFren7+/SVwLPj5rfVTkpmqab+rJUN3JMPMstT UGYECBPPpj0DB8+IU+gt827R4wgJZKI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1690819711; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qQs9wdHlrLhwCHhCKhiMFGg1nYsVa/Zj2WYMaePC1WA=; b=macfYBb1CFMfpmvl7jPxMbvRiiXrZf9ZlE3jbB8Rgz6tSC6Z94CqsTykdLXiK7XlJWg8oV XusEAO7EP58FfhCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1632D1322C; Mon, 31 Jul 2023 16:08:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id p/8xA37cx2QCCwAAMHmgww (envelope-from ); Mon, 31 Jul 2023 16:08:30 +0000 Message-ID: <7ff2a2393d78275b14ff867f3af902b5d4b93ea2.camel@suse.de> Subject: Re: scheduler problems in -next (was: Re: [PATCH 6.4 000/227] 6.4.7-rc1 review) From: Roy Hopkins To: Peter Zijlstra , Guenter Roeck Cc: Joel Fernandes , paulmck@kernel.org, Pavel Machek , Greg Kroah-Hartman , stable@vger.kernel.org, patches@lists.linux.dev, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, akpm@linux-foundation.org, shuah@kernel.org, patches@kernelci.org, lkft-triage@lists.linaro.org, jonathanh@nvidia.com, f.fainelli@gmail.com, sudipm.mukherjee@gmail.com, srw@sladewatkins.net, rwarsow@gmx.de, conor@kernel.org, rcu@vger.kernel.org, Ingo Molnar Date: Mon, 31 Jul 2023 17:08:29 +0100 In-Reply-To: <20230731145232.GM29590@hirez.programming.kicks-ass.net> References: <2cfc68cc-3a2f-4350-a711-ef0c0d8385fd@paulmck-laptop> <3da81a5c-700b-8e21-1bde-27dd3a0b8945@roeck-us.net> <20230731141934.GK29590@hirez.programming.kicks-ass.net> <20230731143954.GB37820@hirez.programming.kicks-ass.net> <20230731145232.GM29590@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2023-07-31 at 16:52 +0200, Peter Zijlstra wrote: > On Mon, Jul 31, 2023 at 07:48:19AM -0700, Guenter Roeck wrote: >=20 > > > I've taken your config above, and the rootfs.ext2 and run-sh from x86= /. > > > I've then modified run-sh to use: > > >=20 > > > =C2=A0=C2=A0 qemu-system-x86_64 -enable-kvm -cpu host > > >=20 > > > What I'm seeing is that some boots get stuck at: > > >=20 > > > [=C2=A0=C2=A0=C2=A0 0.608230] Running RCU-tasks wait API self tests > > >=20 > > > Is this the right 'problem' ? > > >=20 > >=20 > >=20 > > Yes, exactly. >=20 > Excellent! Let me prod that with something sharp, see what comes > creeping out. In an effort to get up to speed with this area of the kernel, I've been pla= ying around with this too today and managed to reproduce the problem using the s= ame configuration. I'm completely new to this code but I think I may have found= the root of the problem. What I've found is that there is a race condition between starting the RCU = tasks grace-period thread in rcu_spawn_tasks_kthread_generic() and a subsequent c= all to synchronize_rcu_tasks_generic(). This results in rtp->tasks_gp_mutex bei= ng locked in the initial thread which subsequently blocks the newly started gr= ace- period thread. The problem is that although synchronize_rcu_tasks_generic() checks to see = if the grace-period kthread is running, it uses rtp->kthread_ptr to achieve th= is. This is only set in the thread entry point and not when the thread is creat= ed, meaning that it is set only after the creating thread yields or is preempte= d. If this has not happened before the next call to synchronize_rcu_tasks_generic= () then a deadlock occurs. I've created a debug patch that introduces a new flag in rcu_tasks that is = set when the kthread is created and used this in synchronize_rcu_tasks_generic(= ) in place of READ_ONCE(rtp->kthread_ptr). This fixes the issue in my test environment. I'm happy to have a go at submitting a patch for this if it helps.