Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4105383rwe; Mon, 17 Apr 2023 08:03:32 -0700 (PDT) X-Google-Smtp-Source: AKy350b/SINn3GiZ///6d53REOC2u8a9e2PlybJM1dRFuj8N+gsdy/pAK12EQAODDhxSY+2am5sF X-Received: by 2002:a05:6a00:1349:b0:63d:3411:f9eb with SMTP id k9-20020a056a00134900b0063d3411f9ebmr114135pfu.1.1681743812439; Mon, 17 Apr 2023 08:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681743812; cv=none; d=google.com; s=arc-20160816; b=eIJdykNmz0g3EPNZs3erS+61qIy0zFeDaIJKW/nh9zsfLzMRmkRcF4T5+bkdd/+nnZ A3snjpx9VQ+GlhKgqdJ88+Sa2gc/L2Kl+Sule5z9kWd50lr485t23EtwunFABTuSspje +gQnwwbhDF3kLDUFtGMDkJ33Fg9sHxCG9P/gKGSBCk/U4Sqj3OoanBimIsFea3A78mdx KztGo3ZvExJyScjIVEJdUlDkQFt76NUt2uP2uwzht1kQxUkoljhlEnY5I2U0dxnpfJu5 BLcq6BMvgWS5Is8M7ndTGDsqSvMklnb+F52RBclhpZl9leNHQSeCgJDcLpbMve7eFbG3 EGhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Rq5umtFV6MX45lwq7FkKIp99lXPCXOmQw4MTnZBUj1k=; b=SXoaEhy79x4EfT32iiss9Ldue/XuQAp/qvidweBfzFc32dnQ/LYUogFLAYYs666MGD QmG4prI/6zZoKgwX8tKUpBdiYFppn5n1OvyVS3r3wY2tgeemQOyh0dKIFbfySI0f/bVk 7HjQNp4MX+HnBYDs7NpBiX7n8y0HtnObTURVJqa4ahdQ++fMIbOpE++FFMgMJZJGMpDp +du3VYKEB2aiat7JVPLaoTVh2v59n7sbpJXLVwNB8WjOLwqE5YLIeQMq1Japybuo5I1F gKe5telbEW7Oo1PbBPqdRLJd+dzsLEznAQGoK1jJp0JCgSxWvwXDQEso+RWvl9lB/AgD Rlkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QxkyT2sB; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z7-20020a6553c7000000b0050fa9bc63cbsi12140510pgr.432.2023.04.17.08.03.14; Mon, 17 Apr 2023 08:03:32 -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=@kernel.org header.s=k20201202 header.b=QxkyT2sB; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231213AbjDQPC2 (ORCPT + 99 others); Mon, 17 Apr 2023 11:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231228AbjDQPCY (ORCPT ); Mon, 17 Apr 2023 11:02:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9749B8A47 for ; Mon, 17 Apr 2023 08:02:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 32B45624C5 for ; Mon, 17 Apr 2023 15:02:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42F33C433D2; Mon, 17 Apr 2023 15:02:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681743737; bh=xcwq78tyDgeI0f4Jknw07jt4RTYi2M51ObHm98OuboY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QxkyT2sB8cYR3MyQz1PW40+lFB825poZW4xQ2XFF3OKtLPGenlrRv1lI1fYo05SmO 0v1j4L5FcNQDPXrXZuvc7q5XGTtOpS0E+I2AWLpiHvXhYq6XUaTig7f3FYBWorAMtW dcxrFBqCusQcmYJhorC6udZLVuPbvLb2kzi674RusSfo+H0249VmQOkgPuF43tak0C eklsavJgo60Z6qzru+RAXWOZSLW6GJ8CXFjrktWwC+wjZcq7Aoug5+TXEtnOxZu5vb zqn97A/XN2sa/Dh3aV76PxWIWR/QdCYsAQ9+h/QsSHKJOIgNehQIBu0VY4ZXZwMsso MSkJfqaKzzlJA== Date: Mon, 17 Apr 2023 17:02:14 +0200 From: Frederic Weisbecker To: Thomas Gleixner Cc: Victor Hassan , fweisbec@gmail.com, mingo@kernel.org, jindong.yue@nxp.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] tick/broadcast: Do not set oneshot_mask except was_periodic was true Message-ID: References: <20230412003425.11323-1-victor@allwinnertech.com> <87sfd0yi4g.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87sfd0yi4g.ffs@tglx> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 Le Sat, Apr 15, 2023 at 11:01:51PM +0200, Thomas Gleixner a ?crit : > From: Thomas Gleixner > Subject: tick/broadcast: Make broadcast device replacement work correctly > Date: Wed, 12 Apr 2023 08:34:25 +0800 > > When a tick broadcast clockevent device is initialized for one shot mode > then tick_broadcast_setup_oneshot() OR's the periodic broadcast mode > cpumask into the oneshot broadcast cpumask. > > This is required when switching from periodic broadcast mode to oneshot > broadcast mode to ensure that CPUs which are waiting for periodic > broadcast are woken up on the next tick. > > But it is subtly broken, when an active broadcast device is replaced and > the system is already in oneshot (NOHZ/HIGHRES) mode. Victor observed > this and debugged the issue. > > Then the OR of the periodic broadcast CPU mask is wrong as the periodic > cpumask bits are sticky after tick_broadcast_enable() set it for a CPU > unless explicitly cleared via tick_broadcast_disable(). > > That means that this sets all other CPUs which have tick broadcasting > enabled at that point unconditionally in the oneshot broadcast mask. > > If the affected CPUs were already idle and had their bits set in the > oneshot broadcast mask then this does no harm. But for non idle CPUs > which were not set this corrupts their state. > > On their next invocation of tick_broadcast_enable() they observe the bit > set, which indicates that the broadcast for the CPU is already set up. > As a consequence they fail to update the broadcast event even if their > earliest expiring timer is before the actually programmed broadcast > event. > > If the programmed broadcast event is far in the future, then this can > cause stalls or trigger the hung task detector. > > Avoid this by telling tick_broadcast_setup_oneshot() explicitly whether > this is the initial switch over from periodic to oneshot broadcast which > must take the periodic broadcast mask into account. In the case of > initialization of a replacement device this prevents that the broadcast > oneshot mask is modified. > > There is a second problem with broadcast device replacement in this > function. The broadcast device is only armed when the previous state of > the device was periodic. Any chance the patch could be cut in two then? Thanks.