Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2205785rdb; Fri, 8 Dec 2023 01:02:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEb8qC5shmf1rSdXNBz/YkK5hUYIGyjd8BTzIVzQaDnd1HNK/e/1gFa3wvRy0QLcUfBDpdY X-Received: by 2002:a17:90a:6649:b0:286:6cc0:8868 with SMTP id f9-20020a17090a664900b002866cc08868mr2933434pjm.85.1702026144418; Fri, 08 Dec 2023 01:02:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702026144; cv=none; d=google.com; s=arc-20160816; b=QOiAd5C78FapeLPQHBNt7LAbmVLaVgN1JQV3qpasnb8aMODaTNi2v1fGLOdCo2l7py VPRItKe3Z1TorgQv9SeZRrEVDLE6hHN8yvtml7llHIwZBSB39fu29xGGzOs/8bsf629h qKnz+4IACFr+xA4lqhxsIP3rQEuqh3KlK7zJyafMI1cXQ5zzAyLVds8iUf4AQRAYD1gE DtaEc3vPNZwMXUXhPq4yB7V2bVDOEQjBcPT36vmxBnNN03Lnr5+YyQO44+goNyv36BBy /ExlzhQVStx84qT45GRHWCF5EM+5ojCs2FBanLWLtBl3MEnWjGu6/V+HP4sJ3DYnpGKr md8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=CmRqxXj61KELQv47LOaO3sGoDuwnlNOMnlmAOuzslGQ=; fh=zngDPpHc9IOT4XyfACYkaIQBkMO1o2QUewR15pJChdQ=; b=fZa0CPUic+KnSgwxgAPSCkFes6iZlhHKV8ooKCH+atYRV9rpTZlYKHWx8DOdWd0chE 5mh+okrZYJn0W21cBj/ZtX8Ghc2+qVliUiuGTM1QE0/LjeD4Lxanmy2DBz9pJ1CezEGn +A/h/XNMpdni3P+AHcg+DT9aeBHuufG2yDVh2hWcGPvKmgTlvqEVYwGr8BiJ26PxcPy5 nRuLuKM1Agqa3pnQKNAcHENjCMeEjQqFSkcoDDj6io/bEXgsxHQZMJmMrqoNXZO2k7p5 FITM47hcXnhZy9pguzFoJs1eXag2tb7Ssc41Lof4Omnf/EEfNTMMgzDi6QGkGWD9+7en bn0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lwObnaLM; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=td9XBibe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id j12-20020a17090a318c00b00285fd6f078asi2596773pjb.142.2023.12.08.01.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 01:02:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lwObnaLM; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=td9XBibe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 7AC5B829AA35; Fri, 8 Dec 2023 01:02:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233227AbjLHJB5 (ORCPT + 99 others); Fri, 8 Dec 2023 04:01:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230390AbjLHJB4 (ORCPT ); Fri, 8 Dec 2023 04:01:56 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70CF510F9 for ; Fri, 8 Dec 2023 01:02:02 -0800 (PST) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702026120; 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=CmRqxXj61KELQv47LOaO3sGoDuwnlNOMnlmAOuzslGQ=; b=lwObnaLMKAeAMYt25DmXyG+oTyx1hmeZ46o9OuKqQ1GKwsF3ZDkU33CVS843ZpXTA+eWOG H532ihNpEv3+23QmKB/GHdIkAgm22fTyCIOf3kA272LChJJyNfn662W1EE6tpNlqQG6tpe xdWHNyLDCggWChDB22jMxQ725sdp0P1XpSEugmhLXNiloauEOLJNppt/DNO+IXvBaSambQ eZCAinGMi3Z/sw+t6bGFWkt58/r0yGL17xrufgeyZdDzB8sXOtoHlW+6qyLO26H4seVSLj GDc9DspUX5M1EqDyzzoIvXzsCclOfcC9rYeWUYNTE/NqN1qcQb4Stwe8CofLjA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702026120; 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=CmRqxXj61KELQv47LOaO3sGoDuwnlNOMnlmAOuzslGQ=; b=td9XBibe5SIOCQKq4SW1I7P/mKpM88EAjaxVvrYpWqdFvO6jsLBCfqJEP06wDxJ/n5ujZh /yypgUdjBXbHOuDQ== To: Sebastian Siewior Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , John Stultz , Thomas Gleixner , Eric Dumazet , "Rafael J . Wysocki" , Arjan van de Ven , "Paul E . McKenney" , Frederic Weisbecker , Rik van Riel , Steven Rostedt , Giovanni Gherdovich , Lukasz Luba , "Gautham R . Shenoy" , Srinivas Pandruvada , K Prateek Nayak Subject: Re: [PATCH v9 30/32] timers: Implement the hierarchical pull model In-Reply-To: <20231206163536.r9DcrsWQ@linutronix.de> References: <20231201092654.34614-1-anna-maria@linutronix.de> <20231201092654.34614-31-anna-maria@linutronix.de> <20231206163536.r9DcrsWQ@linutronix.de> Date: Fri, 08 Dec 2023 10:01:59 +0100 Message-ID: <878r652hko.fsf@somnus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 08 Dec 2023 01:02:19 -0800 (PST) Sebastian Siewior writes: > On 2023-12-01 10:26:52 [+0100], Anna-Maria Behnsen wrote: [...] >> diff --git a/kernel/time/timer.c b/kernel/time/timer.c >> index b6c9ac0c3712..ac3e888d053f 100644 >> --- a/kernel/time/timer.c >> +++ b/kernel/time/timer.c >> @@ -2103,6 +2104,64 @@ void timer_lock_remote_bases(unsigned int cpu) > =E2=80=A6 >> +static void timer_use_tmigr(unsigned long basej, u64 basem, >> + unsigned long *nextevt, bool *tick_stop_path, >> + bool timer_base_idle, struct timer_events *tevt) >> +{ >> + u64 next_tmigr; >> + >> + if (timer_base_idle) >> + next_tmigr =3D tmigr_cpu_new_timer(tevt->global); >> + else if (tick_stop_path) >> + next_tmigr =3D tmigr_cpu_deactivate(tevt->global); >> + else >> + next_tmigr =3D tmigr_quick_check(); >> + >> + /* >> + * If the CPU is the last going idle in timer migration hierarchy, make >> + * sure the CPU will wake up in time to handle remote timers. >> + * next_tmigr =3D=3D KTIME_MAX if other CPUs are still active. >> + */ >> + if (next_tmigr < tevt->local) { >> + u64 tmp; >> + >> + /* If we missed a tick already, force 0 delta */ >> + if (next_tmigr < basem) >> + next_tmigr =3D basem; >> + >> + tmp =3D div_u64(next_tmigr - basem, TICK_NSEC); > > Is this considered a hot path? Asking because u64 divs are nice if can > be avoided ;) It's the 'try to go idle path' - so no hot path. Please correct me if I'm wrong. > I guess the original value is from fetch_next_timer_interrupt(). But > then you only need it if the caller (__get_next_timer_interrupt()) has > the `idle' value set. Otherwise the operation is pointless. > Would it somehow work to replace > base_local->is_idle =3D time_after(nextevt, basej + 1); > > with maybe something like > base_local->is_idle =3D tevt.local > basem + TICK_NSEC > > If so you could avoid the `nextevt' maneuver. > This change could be done indepentant as an improvement on top of the queue as well. I will not improve it right now, if it's ok. >> + *nextevt =3D basej + (unsigned long)tmp; >> + tevt->local =3D next_tmigr; >> + } >> +} >> +# else Thanks for the other input - I already changed it for v10 of the queue. Thanks, Anna-Maria