Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1224106rdb; Mon, 19 Feb 2024 08:05:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWAaBlRi00y+JUVMeHBHZdN7OaGkHAwQkKEewwMrm4ihfBLgtqjHO3HL8hboK4TPGLC/Tw+bgOoTvhSXlfypzqpx80TJpU1OYuHtK986A== X-Google-Smtp-Source: AGHT+IFvS2PJADoNOgJzbRu1aHHIoAWEGJLaNpvC89e8cS3Ji+Z6a9V3Q0o8yGtHozgTJi1CH5XY X-Received: by 2002:a17:90b:118e:b0:299:29e1:d0e7 with SMTP id gk14-20020a17090b118e00b0029929e1d0e7mr8780569pjb.8.1708358728259; Mon, 19 Feb 2024 08:05:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708358728; cv=pass; d=google.com; s=arc-20160816; b=yHLeIKRzraL42vHPMR4ghp6R3PVZ+iyiCsvcH6gYrD6ddlmRJn3422UZjJPKoIhnX1 fWuOr/cwkGUa8tptSq0wlhZVw5NBszL+aC9fY+3bVAZt/GyMiaNxRTHBElKXGT8m0RXl RvlC/9DKu6a1/8vCQyAuENlcwHYnUDHRrGFyL1kbJr4LumkQNTYX07x/vq+jzBS2uwUM g7rl7P/Utc86Ikj+Ji/0L85ehy9kajSWzaVjypILieTUHlIwNvboQp8VRrkZIp/uGHla OCVC04TrfQJL2tg2AABRIe0WjD+2wCQkE7RgC52KRq3xqyduqbt29bMIClihWE3T+POc qCZg== 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=hZ5965Uw7U8tFhV/88+f+Klb7NSFmAKLW6NsMyTlYnQ=; fh=QyFQKP6oUC5BMxKSbj1igiPGcDU2iV4v+4l4LbWsRVo=; b=cC2Es9cZeC2Ohnx5NJP8utdmqIYo+UTcql40xWVFCrSY3hB+AVZjRYEOl21bgPbkV+ X/s/J6JAfPTfuXXTy3CUQVKFDAXD57uBAnNUu+t1JSMIa7H1VbY44eSk6AIc5x2hcnz4 eWD2eo5Qd/4cWS3DsbnPV2Il6mE5ngZ+P7/K8FDbK2ba0R2joeA+/e0VJAa9QhrCIh/H lYXMrwZZkHNkHoUbIyiqV6Xfls9AVy0o4H/6SZEkr5uT2wiSEuZs5miNUjQjIERcHYX9 SngmmqhZPnensUSrr4PwBdQaYjNnqoFJuCTuudB0MRjvCGkz68IAHsCZCKlp5XKU7GIl tJuw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q7kcpoHl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71636-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b11-20020a6567cb000000b005dc82fb4b3bsi4596038pgs.742.2024.02.19.08.05.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 08:05:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q7kcpoHl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71636-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 086672831B6 for ; Mon, 19 Feb 2024 16:05:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 688E03B18E; Mon, 19 Feb 2024 16:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q7kcpoHl" 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 96DE73308A for ; Mon, 19 Feb 2024 16:05:01 +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=1708358701; cv=none; b=R9GiNHEd5NinyZY901VzvGCbpaq/KDCMIlP2goXg4jZCBa2aerLSZt0mpK9B1VhafxVGHMxtlM3ekbQkanpSoFnVSkOhstFmGVysJkuBDDhjd7TqNQHKpLbfs9J05yQDjux4gZOPMgKp7+GcZp7s0ngRchrEYvQDlAulVQ2tY5c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708358701; c=relaxed/simple; bh=QSQhFzqyHvdSBslDmpugOpRWw2G2U/ioWUEnLCdRQaM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=a2BuZZylYL08JuTRUSHJZsMJrTThN4rDCJ8kayPbRN6fpq6vaXJlsRnwoVLpthQBjGVN1w2szwpo45fxLFqJNTOK6vo8NwGAal6LdZbJOZQarV7yuBb37y0rlCFcmZvbRmvcy4wVxZ+fF84T2I4h50ffgzp7PsJ1Qfo5XvtiXOg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q7kcpoHl; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A47C0C433C7; Mon, 19 Feb 2024 16:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708358701; bh=QSQhFzqyHvdSBslDmpugOpRWw2G2U/ioWUEnLCdRQaM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=q7kcpoHlgsbbngSSNe5KCyP4JbREt2a3SmvVj1ufDyge68StNJNRgRIjEjZjhPXTq 37dCRdT+LKBsXXTPus9E8Vgi0LAmdbCBnl4GbP2JtjDuSmtL8Nfn30V5WtoHqeV2wM E3DVSWYnjKUp0FEv8Bppk+Xg38ZIFbgZuvVcNDkXn8JjeKTgUFymz5VeGlbjO7C4Qi 50cIyf+0J4n40e2Tu/JsM6HECwDXcI/ZeJJRGKos8C5lAJqyYYWe6MsEgsRW7ScJWm Ypfq+motK7Q1itoStAtmX8qEV/CcM7VbcF1hHPzyJbz4fYmwK0MirmlaHBfdhSjVlx 31f+rM/ReYgZg== Date: Mon, 19 Feb 2024 17:04:56 +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 , Frederic Weisbecker Subject: Re: [PATCH v10 13/20] timers: Add get next timer interrupt functionality for remote CPUs Message-ID: References: <20240115143743.27827-1-anna-maria@linutronix.de> <20240115143743.27827-14-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-14-anna-maria@linutronix.de> Le Mon, Jan 15, 2024 at 03:37:36PM +0100, Anna-Maria Behnsen a ?crit : > +# ifdef CONFIG_SMP > +/** > + * fetch_next_timer_interrupt_remote() - Store next timers into @tevt > + * @basej: base time jiffies > + * @basem: base time clock monotonic > + * @tevt: Pointer to the storage for the expiry values > + * @cpu: Remote CPU > + * > + * Stores the next pending local and global timer expiry values in the > + * struct pointed to by @tevt. If a queue is empty the corresponding > + * field is set to KTIME_MAX. If local event expires before global > + * event, global event is set to KTIME_MAX as well. > + * > + * Caller needs to make sure timer base locks are held (use > + * timer_lock_remote_bases() for this purpose). > + */ > +void fetch_next_timer_interrupt_remote(unsigned long basej, u64 basem, > + struct timer_events *tevt, > + unsigned int cpu) > +{ > + struct timer_base *base_local, *base_global; > + > + /* Preset local / global events */ > + tevt->local = tevt->global = KTIME_MAX; > + > + base_local = per_cpu_ptr(&timer_bases[BASE_LOCAL], cpu); > + base_global = per_cpu_ptr(&timer_bases[BASE_GLOBAL], cpu); > + > + lockdep_assert_held(&base_local->lock); > + lockdep_assert_held(&base_global->lock); > + > + fetch_next_timer_interrupt(basej, basem, base_local, base_global, tevt); If the next timer is global and it is <= jiffies + 1, the result will be returned in tevt.local only and not on tevt.global. So a remote fetch may miss it. For this to work on both local and remote fetch, you may need: diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 320eb4ceafa2..64ce9a7760f5 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -2004,6 +2007,8 @@ static unsigned long fetch_next_timer_interrupt(unsigned long basej, u64 basem, if (time_before(nextevt, basej)) nextevt = basej; tevt->local = basem + (u64)(nextevt - basej) * TICK_NSEC; + if (!local_first) + tevt->global = tevt->local; return nextevt; }