Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2487148rdb; Mon, 5 Feb 2024 08:03:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFkyUCLEG8v+RYQb489XpTNcFRVyGeTPNKEY7RqA9K8ozxp8vLb4OydFjl69Zp0wSQCTPbn X-Received: by 2002:a17:907:7818:b0:a37:3abb:98e0 with SMTP id la24-20020a170907781800b00a373abb98e0mr4720497ejc.47.1707148986115; Mon, 05 Feb 2024 08:03:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707148986; cv=pass; d=google.com; s=arc-20160816; b=w2vJFiF+MwUYFNb3AZ+RKBGIpODvneco7FK9Aerf9JhaMrVeDKk4lHgubBn8cXrJ7u t9Jbni4D720wz2xvcQqIgTK8xvjHOHkqMdN0gTsfNXiyA6lR24MFu6jUTi3wJVmdoJCo +uxlyko4pyuEBcR00ZH43aQJSWVwSa5ZqQPl6VXJWJcW4f0ds3xu6zxI2fzRHWiBq699 s9G72sSmcfDzpJ3eq7wOthavAFP2WgVI4JEqPBZZTr7ihyh50e8cvorDscI79jkUqNSp QdDxyoNbra5TWNCAu97bbhmDCqcAmkpPU3ePDyeh80WflHeq1IZiYkcZQU2X8z96RKWg VnUQ== 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:in-reply-to :subject:cc:to:dkim-signature:dkim-signature:from; bh=3zgMOwdfmaBrPpJWcWaAk1Bv94XR6alX/vcC8fZQAHU=; fh=HGF/KiYjuTduz52ErIjeknQAcinT1iCamyZGJt6w8Kc=; b=ftq3XNfbrRMcyVz1sczKHb9HmUuAnmwDU23uXSiFxWL+AIMxhCk27KnLVgmYciwKZD GBoUyuQCX5eQ/WZyqO1WOxmluoNMRT1oFGIi0vyXQDP9dBZLNG2fpOB6Pydka9QeCvDZ 93jQr2SLs7PDSyy3q1XSgmCTwzRd53VHS+Uj64a6i8OGID4xdrIeNnOt6bxDOZcUrLgM KDeFqtuoxgCnVPOExAkcqTNFfupFebLaSKIAGkwNDpaFDRsD4V/Igr+JPHdfCbVTweGP xgEWb2ezbtkAPSX1sgL9YGdsDHzooQX9czahiY6RQ8mwUzOjUZK/qP9xxVPkYi6BNN8r yURw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eI4xyS1X; 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-52986-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52986-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=1; AJvYcCWvLyrwrHrsDe+DoKZvHVM3M7dVk+UMrXce/2WYv4xBsEsvTgrVAdJycurBNvFeIesR67N2Nnd48/IAX1DCGbx21Lt1I27ZqwdlNYeyUA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n10-20020a170906118a00b00a37a7edf748si1557689eja.1009.2024.02.05.08.03.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 08:03:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52986-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eI4xyS1X; 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-52986-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52986-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 am.mirrors.kernel.org (Postfix) with ESMTPS id AFFE21F23AB1 for ; Mon, 5 Feb 2024 16:03:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4EC945962; Mon, 5 Feb 2024 15:59:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="eI4xyS1X"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="VpWGz+Oq" 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 AE64F45957 for ; Mon, 5 Feb 2024 15:59:48 +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=1707148790; cv=none; b=ZGF+mfo99XwaKZKybX0213ujAb6nd5VMZSlmGs4LqO9+otvspzOMvZjxeMJnWn/giEzsNIP1lBhH6gf55xOGkurJROea6DiGeAfDsSiFkBk1v7hwRVZkr5dH3J3Hyo5aQHL0fi1cnO6k4K23UOXkKWXdIsoaetFh6O8hI/a5UGs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707148790; c=relaxed/simple; bh=mg90tXSKYlVnVzV9nqdFyuxOcFgebZX+SG1uwgUf5KE=; h=From:To:Cc:Subject:In-Reply-To:Date:Message-ID:MIME-Version: Content-Type; b=HMF+zJ1SgQjAjWrTqTPcxWcEdxNvhc/+DZE2Lm2YRQRlS+zdk3hE4+ZtCB45boy97Ej+Zv6tj9hNbLcVVj0NUjOhFRbs2HpLgxAQFTuYzZW8z2PXqTOg03pR5oa8fAU+qxLKK5J7obiuDYM4cGZBQIHhpXF0ize8JpYBAHrpGEY= 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=eI4xyS1X; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=VpWGz+Oq; 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=1707148786; 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; bh=3zgMOwdfmaBrPpJWcWaAk1Bv94XR6alX/vcC8fZQAHU=; b=eI4xyS1X8RgmniiqIwW3S82zQPcMwXBcBzgrJLEsUZwXILcLECkWRnf/0KoBZJ4bPxgkjV VJ4jBpugwZIZEvA0Bu9KAJ6NEf9F2JuCYe+H77iQM4MruyqNg3DIbsakH6e5693O/iqglk Ao6Agd7/E3hhnzZoewdGIzCPPqZmL4uC6r4/LU5a73QGq56kAyv8SHdniXsjiBOv7luh/B fxq8/evJ8aBe+UxibdjJWnaoppRZAOCa1ym9bB2JCJZ8cDwkgG2oNfeL34Cb2D3RSUvvqx vQbtHJIlWdTvPhvMl3C38JZcYp8ZNQj0iQKJv94hFOBfN+5aHnBXwnTyvRyXyA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707148786; 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; bh=3zgMOwdfmaBrPpJWcWaAk1Bv94XR6alX/vcC8fZQAHU=; b=VpWGz+Oq3aos67LcFt82JvOKLMHrKABlUS+kOVITHYwnWPGskL2RqHqlQF2ZYX6vY3MMlC WKIlKyY62SvjMQAA== 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 18/20] timers: Implement the hierarchical pull model In-Reply-To: Date: Mon, 05 Feb 2024 16:59:45 +0100 Message-ID: <871q9qucjy.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:41PM +0100, Anna-Maria Behnsen a =C3=A9crit= : >> +static bool tmigr_handle_remote_up(struct tmigr_group *group, >> + struct tmigr_group *child, >> + void *ptr) >> +{ >> + struct tmigr_remote_data *data =3D ptr; >> + u64 now, next =3D KTIME_MAX; >> + struct tmigr_event *evt; >> + unsigned long jif; >> + u8 childmask; >> + >> + jif =3D data->basej; >> + now =3D data->now; >> + >> + childmask =3D data->childmask; >> + >> +again: >> + /* >> + * Handle the group only if @childmask is the migrator or if the >> + * group has no migrator. Otherwise the group is active and is >> + * handled by its own migrator. >> + */ >> + if (!tmigr_check_migrator(group, childmask)) >> + return true; >> + >> + raw_spin_lock_irq(&group->lock); >> + >> + evt =3D tmigr_next_expired_groupevt(group, now); >> + >> + if (evt) { >> + unsigned int remote_cpu =3D evt->cpu; >> + >> + raw_spin_unlock_irq(&group->lock); >> + >> + next =3D tmigr_handle_remote_cpu(remote_cpu, now, jif); >> + >> + /* check if there is another event, that needs to be handled */ >> + goto again; >> + } else { >> + raw_spin_unlock_irq(&group->lock); >> + } >> + >> + /* >> + * Update of childmask for the next level and keep track of the expiry >> + * of the first event that needs to be handled >> + */ >> + data->childmask =3D group->childmask; >> + data->firstexp =3D next; > > So assume we have: > > [GRP1:0] > migrator =3D [GRP0:0] > active =3D [GRP0:0] > nextevt =3D TIMER3 > / \ > [GRP0:0] [GRP0:1] > migrator =3D CPU0 migrator =3D NONE > active =3D CPU0 active =3D NONE > nextevt =3D KTIME_MAX nextevt =3D TIMER3 > / \ / \ > 0 1 2 3 > idle idle idle idle (TIMER3) > > Then CPU 0 goes idle: > > [GRP1:0] > migrator =3D NONE > active =3D NONE > nextevt =3D TIMER3 > / \ > [GRP0:0] [GRP0:1] > migrator =3D NONE migrator =3D NONE > active =3D NONE active =3D NONE > nextevt =3D KTIME_MAX nextevt =3D TIMER3 > / \ / \ > 0 1 2 3 > idle idle idle idle (TIMER3) > > CPU 0 is the idle migrator and its tmc->wakeup is TIMER3. > But CPU 0 has a local timer that expires before TIMER3. > > When that timer interrupt fires, it raises the softirq, which > executes on IRQ tail. So CPU0 eventually calls tmigr_handle_remote() > before TIMER3 has expired. > > This leads to tmigr_next_expired_groupevt() to return NULL and then > data->firstexp =3D KTIME_MAX and then tmc->wakeup =3D KTIME_MAX. > > Later on, tmigr_new_timer() is called with a KTIME_MAX global > event and so tmc->wakeup stays with KTIME_MAX, ignoring TIMER3. > > It looks like you need to handle the tmigr_next_expired_groupevt() > case returning NULL. Yes. You are right. group->next_expiry is updated via tmigr_next_expired_groupevt(). So I should take this value to rely on for the firstevt. But with this, we do not need the return value of tmigr_handle_remote_cpu(). When the upperst level is inactive and there is a timer (e.g. propagated there by tmigr_handle_remote_cpu()), the return value of tmigr_handle_remote_cpu() is the next_expiry of the top level group. But this value is also noticed by walking the hierarchy up to the top level with tmigr_handle_remote_up(). Thanks, Anna-Maria