Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp277789rdb; Mon, 22 Jan 2024 04:05:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3sar0DrNQfX0Irc274wrNuQosafpqL310TjB5Wil/GicldOr8IA1CVwR+G3QZAlAtdUFW X-Received: by 2002:a05:6a00:a8e:b0:6da:af47:95f0 with SMTP id b14-20020a056a000a8e00b006daaf4795f0mr5311146pfl.27.1705925119767; Mon, 22 Jan 2024 04:05:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705925119; cv=pass; d=google.com; s=arc-20160816; b=nE+UFoEYsXRyE3Gi1+K9BvLJ4pURfjrxQJjObScnMzNsqPidggVKTErFhQHem0UiP9 euEHSSygr5ALpmui/1lnCHwPg+oxSWaZrKUy865vcXSlLdzHuNsS/w7S1QiTlqsD4Ot9 O4ZWSr1TgP3vaHAyEhHLCPt+VmntBJzGwHSW3mbRs2W2V/Zvq9ihMhZPq+iJJ2g6gjpV dnf5+vEfKseSqAsj9sh8UDSdFre8TWFJXgWBMlR/vGXvxcXqtF8+ezo09y1yWxmU6X/e crs/yE3TFl5lcaHAM/D0ewH9HyoaMKBeS8k6t5NFH9Gx3aGGQkRkmDwwgjQHPIrhIqcH HYsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=qSSVx10KQaY1fPXkVl6BPMMEjWncRpah42eY2WU1xOY=; fh=0xiuIgYwmqWERslX8T7WXvksK/H3CzUuWu1+0FDLmHM=; b=h52QwYLEFlELAbeOyRAt/VqJmlJPzQS5ZOrRxF66nHMhloebHPjrpjRdtzkPVg9zX0 RjGeOkBRo//rJy/8eBGy0NQvRCrwzRQ6DyXuK4yVJPsqZQ96si3ziMAC0k7j2FWjuu6U 0BhdSZx1YUFtWSKA2H2XWWgDht+ryI9ZJSpC98OLDRN3nKYoZL1I/MLJwuKWfPKzS7oG XxGp4YMEDGoQcxfQNOG/1+2oHO9bq73htTpuvJZo6Lwe/yceGRD6RG6H9fzBN956upIc 0ntIE/X8LgoV3riF7cvMVtxRMg8KAgjE/4n57M+OkTSM8uPV86iUBtvKxZuLwADMZCvd mRfA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OfDn2SAb; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-32958-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32958-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id r36-20020a635d24000000b005cf0ccc6287si7917949pgb.134.2024.01.22.04.05.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 04:05:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32958-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OfDn2SAb; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-32958-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32958-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B5BE52917B9 for ; Mon, 22 Jan 2024 11:48:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9FCF73AC0F; Mon, 22 Jan 2024 11:45:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="OfDn2SAb"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="LC97BSYx" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 CBC5E3A8C6 for ; Mon, 22 Jan 2024 11:45:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705923908; cv=none; b=QuZrY+vEvT7o0o6q9MwdQ/0Yij+ZpsxUSEhND62V0uWc31KkYdPl62f1MzADTDuOgqb/zNMTf/RfAP3MqT6epMHEjaH37a0ByWCMN/ZJm8JBl4L1f9R2jtpu3i8W+tQJFte/KT9nQbThG4S4jH/3kNnY4QQ/wXROEYnye9P6RHw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705923908; c=relaxed/simple; bh=gEPtLbsLKBRHvoc6SCpXFrEuTXD0330WyImOG5O0OBo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=q/rW182V+27O9F34pebxZIjPEMiwm+zpfhvUNSp/Ri55iXLZ+XnTmyvyYi1phVEDH6qVWyqwnkKppMcmdxaOxqQ4eOr/uy7OMPchY9pt3ZCvQ0/t4YVh5TET60TYk6wwSD7SI6Pg/+C8EgoWxlxCp0zj72/U2Yj4wjX/DZNHgNc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=OfDn2SAb; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=LC97BSYx; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1705923904; h=from:from:reply-to:subject:subject: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=qSSVx10KQaY1fPXkVl6BPMMEjWncRpah42eY2WU1xOY=; b=OfDn2SAbU7w3pxO3N9wLqrSXbuHDBXOdbu/gHc35+ciZVD/SbSfSAz+f8r6w7PWxdkgvgy /zl8L4tGeic3l1IjxujkkCNmbFabT22I50aG79uLkO5Rv66ZEY7aKnAaWqvCD9hihVXiUm 34+WiWwNGm81lFwxWV4qGHhpRW76zPu0PjfiT3X3bwdarjk0vtjonWX8FvUeJCFYMSM8bB YLg0Ztnhv7snvCXK8dfsLQGSDRKdEZWRFDIv5NNCHegnvKViCAhOQnIXVdASI/Cx3ZtwbY UoFeFoPo+Jbf+2a/m2V5m4My3fh5Hn4iL0WPc1csaYaUVwEV3nQbYIvRo23FRg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1705923904; h=from:from:reply-to:subject:subject: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=qSSVx10KQaY1fPXkVl6BPMMEjWncRpah42eY2WU1xOY=; b=LC97BSYxOyn2gDZJHPaHcNdNrq/7wCjSKb0kvpvFGT9GCZ6soRcjl4Qk5m7M5zou8mQhfn 7rRekrppNZvRGxDA== To: Frederic Weisbecker 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() In-Reply-To: References: <20240115143743.27827-1-anna-maria@linutronix.de> <20240115143743.27827-4-anna-maria@linutronix.de> Date: Mon, 22 Jan 2024 12:45:03 +0100 Message-ID: <87ttn5y4lc.fsf@somnus> 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=utf-8 Content-Transfer-Encoding: quoted-printable Frederic Weisbecker writes: > Le Mon, Jan 15, 2024 at 03:37:26PM +0100, Anna-Maria Behnsen a =C3=A9crit= : >> @@ -889,12 +884,41 @@ static ktime_t tick_nohz_next_event(struct tick_sc= hed *ts, int cpu) >> static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu) >> { >> struct clock_event_device *dev =3D __this_cpu_read(tick_cpu_device.evt= dev); >> + unsigned long basejiff =3D ts->last_jiffies; >> u64 basemono =3D ts->timer_expires_base; >> - u64 expires =3D ts->timer_expires; >> + bool timer_idle; >> + u64 expires; >>=20=20 >> /* Make sure we won't be trying to stop it twice in a row. */ >> ts->timer_expires_base =3D 0; >>=20=20 >> + /* >> + * 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 =3D 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 m= aking a > behavioural change: if base->is_idle was previously set and the next time= r 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? It was intended to keep tick_stopped and base->is_idle in sync. So when tick_stopped is set also base->is_idle needs to be set and dropping it before tick_stopped is dropped will break the plan to keep it in sync. >> + * will be retained on the next idle iteration when the tick >> + * expired earlier than expected. > > I'm a bit confused by this sentence. Me too :) It is there because of a previous version and I didn't cleaned it up properly. >> + */ >> + expires =3D basemono + TICK_NSEC; > > Do you need this line? No. After revisiting it once more, it is not required, as it should be set properly by the return value of timer_base_try_to_set_idle(). So I should be able to completely drop this first part of the if statement. > >> @@ -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. I can do this. >> - /* >> - * Undo the effect of get_next_timer_interrupt() called from >> - * tick_nohz_next_event(). >> - */ >> - timer_clear_idle(); >> } > > Thanks. Thanks, Anna-Maria