Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5896802rwl; Tue, 4 Apr 2023 05:23:17 -0700 (PDT) X-Google-Smtp-Source: AKy350a8Ffs+/grIQ9CIv1Pcat8GiY6KAduriLB/ykDFmEa3wxv7xNGJcO5Cv7ir9ATdfDn1U92v X-Received: by 2002:a05:6a20:4f1c:b0:da:4be2:caff with SMTP id gi28-20020a056a204f1c00b000da4be2caffmr1952761pzb.56.1680610997609; Tue, 04 Apr 2023 05:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680610997; cv=none; d=google.com; s=arc-20160816; b=dVCfiq37Xs+kHD8fzk2kLo8H0YeG+uy2IW+jQFhQabYQIZ+knEdk8oyxm0GfVPAsVa xXw0VjmRalH3cKM+w4p76ZVYL4eMrcKyt2VR5HeJVHLfzLss4eE+tPKkb3Rga+8QwasU FND5CZFWk95aSOW9dh0wnuGFiXWeEhPvjseRVllFwIkDf9U3IMXRtM6MffYdUrSdZSSz jHE8wPa89GlRiSlRZu+SXq717GVLZ05UESwi4xPpTt1awha0qtW/yZYZVmDSzqzpiBLb Q3RQNXR68flRSXAwNJfAYeUGUepLUcaQXl5GvKK7qe0f5vSojJSU9FK40DS87v93oFl2 ArSQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=C37CNHA3Zb8jVA/ygzKvAjSrYu/J0yvV+4ZcXV7Fpxc=; b=lntb5DmNRrxeD0IorNC70yaTLvrMzVpS9xx9hBJiUaZyGWACgBEXt0yU+wa3QDu730 4WbVnZd5KVW68U8tgK1PeWrKLEXyowp8S9df/LkL04drBUNPquwAK2AdZrKA21DO1ecS lm40vrjq35/MWN3zszfAYO5M+2qb/UZCzagrvSNysbM8E98d69/cz2ezzjlt3cOVbGZm uLnDGAmatSib3xm1jWWgbf1aKcpRcpdASE898EbfdpduDXIyw/4qON9RXc3g0d0PJDjD ETOFZ1HPlBfE5tUh6S5DYMAydK7Aewd8lxjXWBEA6w4lrg3JmDUK2nkxea+uTII6S2SJ OjiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TCsbsTES; 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 b11-20020a621b0b000000b0062dabeefa60si1499518pfb.277.2023.04.04.05.23.05; Tue, 04 Apr 2023 05:23:17 -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=TCsbsTES; 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 S234354AbjDDMWe (ORCPT + 99 others); Tue, 4 Apr 2023 08:22:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234758AbjDDMWN (ORCPT ); Tue, 4 Apr 2023 08:22:13 -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 687C246B2 for ; Tue, 4 Apr 2023 05:21:46 -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 337ED632DC for ; Tue, 4 Apr 2023 12:21:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13B9FC433D2; Tue, 4 Apr 2023 12:21:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680610904; bh=D+kOVIeVc8YgEs6zZB4OAQ3HDC8JkWUJQbH5kV7n+8E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TCsbsTESfMp+Y8BMSGc/iKIc7y5qj7oBTKJCcn0SGTyNN6wREmTpeTAhwGFSwcJvl g4KpPRKGY+Gh+57T9XpIUiZKf1Ga5L7E3Gmgh6tWmhsim47KJ9LEUXv7Jd5PcD9+cP UP4FC+oAMMnfm/dzilPblsf1c7mu5B9CF7/N82DclTi6qu8BUItZwNm7Df7dwl/Avj Oso3OgU6TAJuY2Bxzy3kXMdFFjstsoZlCCOpPPPgkpqTEQZWdKvgDpuq/Bvwbcg+5M LaB7nq6lzHtzNgcgn4tg/T40eXohVtlxeyda3RotJ4FPcYGfCB87wN+9ZFfB1dJLeZ qCV7BQbmTqIiA== Date: Tue, 4 Apr 2023 14:21:39 +0200 From: Frederic Weisbecker To: Victor Hassan Cc: fweisbec@gmail.com, tglx@linutronix.de, mingo@kernel.org, jindong.yue@nxp.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] tick/broadcast: Do not set oneshot_mask except was_periodic was true Message-ID: References: <20230328063629.108510-1-victor@allwinnertech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 Tue, Apr 04, 2023 at 07:37:06PM +0800, Victor Hassan wrote: > > > > Leading to such race: > > > > * CPU 1 stop its tick, next event is in one hour > > * CPU 0 registers new broadcast and sets CPU 1 in tick_broadcast_oneshot_mask > > * CPU 1 runs into cpuidle_enter_state(), and tick_broadcast_enter() is ignored because > > the CPU is already in tick_broadcast_oneshot_mask > > Yes. > > > * CPU 1 goes to sleep > > * CPU 0 runs the broadcast callback, sees that the next timer for CPU 1 > > is in one hour, program the broadcast to that deadline > > * CPU 1 gets an interrupt that enqueues a new timer expiring in the next jiffy > > * CPU 1 don't call tick_broadcast_exit and thus don't remove itself from > > tick_broadcast_oneshot_mask > > I'm not sure about this... Actually, I believe CPU 1 *will* call > tick_broadcast_exit in this condition because I cannot find a limitation on > this execution path. You're right, what I wrote doesn't make sense. Let me try again: * CPU 1 stop its tick, next event is in one hour. It calls tick_broadcast_enter() and goes to sleep. * CPU 1 gets an interrupt that enqueues a new timer expiring in the next jiffy (note it's not yet actually programmed in the tick device) * CPU 1 call tick_broadcast_exit(). * CPU 0 registers new broadcast device and sets CPU 1 in tick_broadcast_oneshot_mask * CPU 0 runs the broadcast callback, sees that the next timer for CPU 1 is in one hour (because the recently enqueued timer for CPU 1 hasn't been programmed yet), so it programs the broadcast to that 1 hour deadline. * CPU 1 runs tick_nohz_idle_stop_tick() which eventually writes and program dev->next_event to next jiffy * CPU 1 runs into cpuidle_enter_state(), and tick_broadcast_enter() is ignored because the CPU is already in tick_broadcast_oneshot_mask, so the dev->next_event change isn't propagated to broadcast. * CPU 1 goes to sleep for 1 hour. Does it make more sense? There might be more simple scenario of course. Thanks.