Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3780064rwl; Mon, 10 Apr 2023 00:30:20 -0700 (PDT) X-Google-Smtp-Source: AKy350bNYhJOPMorcpfbuKoU/aIp9Nd1IluRR9UA5zhZDgzVG4a8Ol9OvBZd8wKvxZNSolQWQi9U X-Received: by 2002:a17:906:4e95:b0:94a:5c39:fdce with SMTP id v21-20020a1709064e9500b0094a5c39fdcemr4215488eju.24.1681111820222; Mon, 10 Apr 2023 00:30:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681111820; cv=none; d=google.com; s=arc-20160816; b=XWu0klxHglTGUKBtjV9ERKSgCEepYP5efZVXy235RswzqF6bkgRPdfamW0UFJbomXD /MNYjGB3A+L/0aXNMP7b4aPm4xyI3CPAZM+e4A2SiCCzCWya+fKoi2w193POIOyifKLE +vRk5OLd82ju045KPWkHq1AUItFrFyE1R9s0OKvwT0oBWdHwhPUtPI9v8wUpVvbgfar5 vZConLfN5o4zAb0yyQ3WcDpJredWBWKCZyU0C/8me8rURjbwj5Uj1bx9ULn8KpHK2rUm ikIw+/ThhkyauGvZOnei2Xl7a9XSxgj07uD/V7p15DvUPhWoUbHri95mxfPRy8sE80a4 1fdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id; bh=3PEgdTHCCCG2ks7lrbokL3PbxzRNqEMB76mBuZZKtKg=; b=uwh6r4be+3Py3b5eBDDWxtvyvRlp+Q0T0E+mEUmrqgE6vFA+ThO5DZmANckHHkhLS+ 5nVjvz+GiD972PQ4BxoMNEoFYZai0l7EunVbmGZLdkgSSBFBcGzSWFwTOSezlaJKuBt6 oAzDemrJbsDal2kGprVlnseZwKjL+n75i7XKgQT2xOs+6ETGaVIW40zEwBvTiuCTpBWP bwsAUoBJF62Bac/+renmpZZqHWUESkxBA1yfN334f03yvIdXEkoDIdIaWYqsWH48HAob GTdoSA6idKjemAE5t+P8MtM6aioGBja965w0rCTImW0UOhPeT1mGw8DinNZ+5TFvTe1t i6Zw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs2-20020a1709073e8200b0094a53055e0fsi4491468ejc.67.2023.04.10.00.29.55; Mon, 10 Apr 2023 00:30:20 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229596AbjDJHG1 (ORCPT + 99 others); Mon, 10 Apr 2023 03:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229502AbjDJHGZ (ORCPT ); Mon, 10 Apr 2023 03:06:25 -0400 Received: from out28-197.mail.aliyun.com (out28-197.mail.aliyun.com [115.124.28.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B2222682 for ; Mon, 10 Apr 2023 00:06:22 -0700 (PDT) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.1172227|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_regular_dialog|0.116084-0.0867191-0.797196;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047201;MF=victor@allwinnertech.com;NM=1;PH=DS;RN=6;RT=6;SR=0;TI=SMTPD_---.SBpE3u7_1681110375; Received: from 192.168.220.144(mailfrom:victor@allwinnertech.com fp:SMTPD_---.SBpE3u7_1681110375) by smtp.aliyun-inc.com; Mon, 10 Apr 2023 15:06:16 +0800 Message-ID: <32b53d3c-b026-fbda-511f-9d2b4274a364@allwinnertech.com> Date: Mon, 10 Apr 2023 15:06:15 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH] tick/broadcast: Do not set oneshot_mask except was_periodic was true Content-Language: en-US From: Victor Hassan To: Frederic Weisbecker Cc: fweisbec@gmail.com, tglx@linutronix.de, mingo@kernel.org, jindong.yue@nxp.com, linux-kernel@vger.kernel.org References: <20230328063629.108510-1-victor@allwinnertech.com> <87857a82-99af-a941-9374-3bbe373ff74a@allwinnertech.com> In-Reply-To: <87857a82-99af-a941-9374-3bbe373ff74a@allwinnertech.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.9 required=5.0 tests=NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY 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 4/7/2023 2:51 PM, Victor Hassan wrote: > > > On 4/4/2023 8:21 PM, Frederic Weisbecker wrote: >> 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. > > Hi Frederic, >   Yes, I think that make sense :) Hi Frederic, If we have reached a consensus, may I add "Reviewed-by: Frederic" in the next patch? > > >> >> Does it make more sense? There might be more simple scenario of course. >> >> Thanks. >