Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp488371rdb; Wed, 17 Jan 2024 08:03:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZxJD584QmuqncV+rf6y4DWPjZ2XwmHkznk4YruodVYr3RDdf08fPqpGD5dGM2kDEdvJPL X-Received: by 2002:a05:6402:1d12:b0:559:9588:1bd4 with SMTP id dg18-20020a0564021d1200b0055995881bd4mr1577606edb.25.1705507397295; Wed, 17 Jan 2024 08:03:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705507397; cv=pass; d=google.com; s=arc-20160816; b=c+YMNyoQ1S9yeG7fS/dXUEUPddDa3NgG7e5SBMuAkHU96ZfSaL3a72Hp1zmcbXAN7s K2bIArwtJYOSn7m/qEn4kHKWZNbFqR0Qk4q2rVDwfDxVSpAH8MwYcV9tkERnTg4dS24Q wwQVpPaHNbI2JNxnz/y/q9v5vFqonalNzbSRl+QN70fr9wmkSRGyNWoph3dUwSGr72ni 1QD3cd6WlpdZzJH/vt8HeKBA9lQeW+NrbZF9DeGDhQkyii1oe7Gua/1EhaWM9fsYGxfJ Do8MO/2tY2xTQhWYto9hpnjEa7ZG/XU7TZxsuB8FEOISZXGiNuuN1YWpJpcOFsaseya6 hWDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WfCdp/PfZZvx1ZbBsW9UR1wtGALU4WoZ0x93tWbL8Z8=; fh=rlwn4pxNjzZxzAe0OFpEm5XldgGOhioyoE/W5GSrSmE=; b=QstZNTX2PFfxTNje1pYUKHlecNSqqIoVCIjc0+97DdDkzoXt3MSaITWsc2OaFjnYWC eZsorYd6qdDALeBo8a/MEOeJqMty4DJJugNjPbhyZ8Zr8+0pyR+fc1eIr8Tm+oqbNCwN xFul+ZSpJ0xqoxBvpBhfiXaVy2JlPQ9RS1/Fykp5KG+ZmdSzoSxcxXhLsTa3NM6fgtvO L8OTvuvle/QfL1oDkqcbS6UvT5wO+CE1Go0a/CETGJzt4d4/MhiYgLhFzNW8xQlpqO7v MlGFAobSdGMYaY2sPf0R+4om9e8DmWskpi9C08nUCeLnvA+KCyTF3qUqEAr9D3GqYapT TsUg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cg8q5AwX; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29182-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c97-20020a509fea000000b00559d93db1d2si730044edf.23.2024.01.17.08.03.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 08:03:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29182-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cg8q5AwX; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29182-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0E09E1F24763 for ; Wed, 17 Jan 2024 16:03:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27136224C1; Wed, 17 Jan 2024 16:02:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cg8q5AwX" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A6C62209F for ; Wed, 17 Jan 2024 16:02:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705507352; cv=none; b=fRErBmNKsZYTjzeSHDzYA5hDA/BB+SVcOMOIMtUkHYM2rrbkqRbxuqplr7Yfpp546zQl2+yYCR3MKqMhmb3bBGxW+RqbBKHEDpMh1Ukl7bi0VQvTn1KNvpglwh1KX9GU+Rb7JXXgetN7nZ1orHOEQ7AamuESuU+U1oLrMz1lHLs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705507352; c=relaxed/simple; bh=jqy1DdjlJGDyd/SGVsfNqCnPGorjXpxaG+GQG8uwcAo=; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; b=no6iZyvgwcaCZHnM7kAe3fLc409sfpP0vRldo69Bw1MFYGpnN+lfR1qt1TzosvP8XLIFIeYTjP3ciFglR8lu/7s85RbtLTEjI2fITh/S9rmdKjbyPviVSsC/d7jkvQnzO2pL11d2NEFGX0GGptuUmL9YA75xApsI6yFoHxQjGsc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cg8q5AwX; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52595C433F1; Wed, 17 Jan 2024 16:02:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705507350; bh=jqy1DdjlJGDyd/SGVsfNqCnPGorjXpxaG+GQG8uwcAo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cg8q5AwXagCTazHnxNumnwrFf+WAgr5sBDZUiY8ezKNAtrKILSqRxMR+CndQ9Ifhh eNyBTx61B6tDNXVm26Bn/phc+03OQoOr/1U5dbLUq9RzCFMdcUFOS0Y1R9KnzS+Mau SWNckPA2Wv8SxIkDuCnmGEAXRlyuPCA70xZKwI+g4u4WVDARrKVNThMfwiy7n1OKxP 1p4xF9TYod++8bOnI2ZXjHaZN1Oy5YC3CF1+HIHJ7YSQ2P7MiDLftpLJ+yXkavLd9t FZtVCtou57+4dsJwoGRlweTS8jzGHfWkEppK2lnZUqDWKAVa4qHF6ps9HQcmP1yKms ZVMVg8dchurng== Date: Wed, 17 Jan 2024 17:02:27 +0100 From: Frederic Weisbecker To: Anna-Maria Behnsen Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , John Stultz , Thomas Gleixner , Eric Dumazet , "Rafael J . Wysocki" , Arjan van de Ven , "Paul E . McKenney" , Rik van Riel , Steven Rostedt , Sebastian Siewior , Giovanni Gherdovich , Lukasz Luba , "Gautham R . Shenoy" , Srinivas Pandruvada , K Prateek Nayak Subject: Re: [PATCH v10 03/20] timers: Move marking timer bases idle into tick_nohz_stop_tick() Message-ID: References: <20240115143743.27827-1-anna-maria@linutronix.de> <20240115143743.27827-4-anna-maria@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240115143743.27827-4-anna-maria@linutronix.de> Le Mon, Jan 15, 2024 at 03:37:26PM +0100, Anna-Maria Behnsen a ?crit : > @@ -889,12 +884,41 @@ static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu) > static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu) > { > struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); > + unsigned long basejiff = ts->last_jiffies; > u64 basemono = ts->timer_expires_base; > - u64 expires = ts->timer_expires; > + bool timer_idle; > + u64 expires; > > /* Make sure we won't be trying to stop it twice in a row. */ > ts->timer_expires_base = 0; > > + /* > + * Now the tick should be stopped definitely - so the timer base needs > + * to be marked idle as well to not miss a newly queued timer. > + */ > + expires = timer_base_try_to_set_idle(basejiff, basemono, &timer_idle); > + if (!timer_idle) { > + /* > + * Do not clear tick_stopped here when it was already set - it Can that really happen? Looking at __get_next_timer_interrupt(), you're making a behavioural change: if base->is_idle was previously set and the next timer is now below/equal a jiffy, base->is_idle is not going to be cleared by __get_next_timer_interrupt(). Therefore you shouldn't observe ts->tick_stopped && !timer_idle But I'm assuming that behavioural change wasn't intended? > + * will be retained on the next idle iteration when the tick > + * expired earlier than expected. I'm a bit confused by this sentence. > + */ > + expires = basemono + TICK_NSEC; Do you need this line? > @@ -1147,11 +1175,6 @@ void tick_nohz_idle_stop_tick(void) > void tick_nohz_idle_retain_tick(void) > { > tick_nohz_retain_tick(this_cpu_ptr(&tick_cpu_sched)); Looks like the content of tick_nohz_retain_tick() can move here now. > - /* > - * Undo the effect of get_next_timer_interrupt() called from > - * tick_nohz_next_event(). > - */ > - timer_clear_idle(); > } Thanks.