From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 75E50367F3C for ; Mon, 20 Jul 2026 11:31:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784547079; cv=none; b=mgnRPnE+pS58HFuoIxAr9E+frk7QOaE86A/0BW+spMVKa+tN1Z0Z6fYiiDug9bYw7RDM3eIY9E8iu978gtd4gg8igSjy1dB+wr0Uo29S1m/1OD6fDKIJd5q02xgqqukipy2/0xqsxBOcdlHUA87MxJ+nG5vm2KisZfuWHddWtUo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784547079; c=relaxed/simple; bh=me2JHLwREIQooQxmTWmyYSkvWXQsh7Zdt5yRwdHd2v8=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=Jv/RYITrQXWGlKr7lQaqnMNKKSFJpPyH4UvpGe4mT25VNF0j6AY93UyNeTI/WmhQ/73FTDIMxWkZtzUURicREcKNhLLYSPvb/T2Iug5Hb4+/qUYh0VHWkCUXYd2ZsnZqLvxa2PIv7Jo5ZIfcxzdU64Jpw9XAG+brqtuYoGyIRS0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iqWMDRzt; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ew8Z8L39; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iqWMDRzt"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ew8Z8L39" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784547076; 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:autocrypt:autocrypt; bh=ngia2IWrtrwxveKhYtY6GWjBabJZjK51gxqV7R56nIA=; b=iqWMDRztA0NrOrXpWqFdmcsGd1XyLdfRcfsvPVPJJ37ApmVDrZcxJSkVOh01XcJtovhjaG 9HCsykmg1xb+LVVpwAVqio3+J/Z9VoSqpq6XMlWNCK6RIJ6MMW7CDZWYWZlUYzFcaioaTK QygkwEpBQCpFg/FgxElr8lS7ZRr/of4= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-287-z-pHI9a8O_yquz28fr7P9Q-1; Mon, 20 Jul 2026 07:31:15 -0400 X-MC-Unique: z-pHI9a8O_yquz28fr7P9Q-1 X-Mimecast-MFC-AGG-ID: z-pHI9a8O_yquz28fr7P9Q_1784547074 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-6986557937eso5640197a12.3 for ; Mon, 20 Jul 2026 04:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1784547074; x=1785151874; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:content-type :autocrypt:references:in-reply-to:date:cc:to:from:subject:message-id :from:to:cc:subject:date:message-id:reply-to:content-type; bh=ngia2IWrtrwxveKhYtY6GWjBabJZjK51gxqV7R56nIA=; b=Ew8Z8L39dyAuDcBsDhGcjdjacg/XEojFR0FkWhssBwmiWN2fVZ5+qozKGOr/A8k/Ms +CR5t4IynzgZE4wU/SSSvqjISmhUKJp+fhoZbVxsKbaXv6A5rhf7XYwZNoo5X/q+FEfC ZAjNdA7QIKvNJVCSvOZf8YHsaBWTleCtKyjwAan7cKfZM+spNp1aFR9ri1KohZeK7Qij iQf7HH7fb/FqR90pv4EgIU4M4vpPCiT5X9TCo7agExp7SYwGd+Y4DU8OmTL55mJeL9gU F3sx9oW9jrEjSk8XaTQ1Lly5DIpEL/2Eiw9rfjRa7G4lISLTvYVyIZe9QFrgvlOsz2r0 AgFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784547074; x=1785151874; h=mime-version:user-agent:content-transfer-encoding:content-type :autocrypt:references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=ngia2IWrtrwxveKhYtY6GWjBabJZjK51gxqV7R56nIA=; b=bBd8Y1vBoHsFLiekX07/jb5dZH2zw4YSQYxicgYDK148f/syuMDespDbArfT2JbXwy C1git8zd6EezcM378kN9Uq7vMYVOEZKw5IYXZu2/BSaVVmdvyF/xejioXHiMr3QYEFop Fo7Lenr+JKPbeyLE/DwkvwfUZ+p7MI6wPQF2J+t4S6DW4uayTMIb8wBJQnEfnAM3a24l R12k2OwxtMtR2LRj5UL6BehHFAxofIOXiTDe1EEJ0K3YQhrfZwL5ZM5XgK/yw5E9EEVI POhN1gQChS0OKvKb4WFBMat69VuBxUhCrkMPEFtMSaOjiBiAq0FWgDfnG5TVLBlJ/eHW zcAw== X-Forwarded-Encrypted: i=1; AHgh+Rr8aA+Z4V/nAXtRkFB5IRqb/fKdouEkcV4fhHbCbTfBjA3B2vAMIq4cq+KqIRZBMiQr+m0TOlN5heDf8DU=@vger.kernel.org X-Gm-Message-State: AOJu0YzZu+d8SGqHGXhIjNgmgg8+f/9jSgO8Hr2JmBT2VfAeibPgAhvD rXNxHy+IRV6XGQCQ7GVilvFINKeNY01D7Szgedfh7xbrSaFIKiqlywfw0KGgEwPXoBH9BoXtinD WZfYm7KNZcutL9JAZV0jnTs9X4vGaFqwQJO5dzmMZXYBfAfyRGxRHY+pIwgo5KCkQSwgzZ3dVJl GE X-Gm-Gg: AfdE7clmoXqAqvzVWHhCcrG7Sv3rFLexCXHiyRLl3HPcZu7+NLWun7TyJLb1Pm+Ang4 xAPdueUsgQkllKxD3Fn13x59RBy+jd3Y65xvgz0wgneuEAMpPjQzLpKHZWsgkmooVJPW4LPjMJI vVgpmwrH/J4f8mxeD7b9G0a/2V/j/y5DYtGYJsj+Lt+uxI6MgYk9UvbMeTTBZgBqDDyK7p+SOzW LH562xzsN+zd4FrUMZTX8eW7T/VTNuBkAQj6C89S0ke/CzlflNwwkATYcZCA5KeKg5JI/4nJPRe uCqWjCSPonkVhU+iN3trsj2hY6VeqsjXN/u+0TiGX15D7uIEKg7fV7iK0QDjEACmAPbdfjNhjij dxBUAsmc+tSW1Y64bV5Yua3p4HX0Z8f85RrX2RL2ynWamUmCJa0ljZZZ3t5UDI1jdb2FLng== X-Received: by 2002:a05:6402:a0ca:b0:699:6415:750a with SMTP id 4fb4d7f45d1cf-69e652ddf67mr4596351a12.23.1784547073658; Mon, 20 Jul 2026 04:31:13 -0700 (PDT) X-Received: by 2002:a05:6402:a0ca:b0:699:6415:750a with SMTP id 4fb4d7f45d1cf-69e652ddf67mr4596338a12.23.1784547073243; Mon, 20 Jul 2026 04:31:13 -0700 (PDT) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (212-8-243-115.hosted-by-worldstream.net. [212.8.243.115]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-69e6ffd0eeesm4510736a12.20.2026.07.20.04.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 04:31:12 -0700 (PDT) Message-ID: <00f7a7c20cf8d29aa650bf7b2c5a392c15345989.camel@redhat.com> Subject: Re: [PATCH v4 4/8] rv/ha: fix ha_invariant_passed_ns silent bypass of invariant check From: Gabriele Monaco To: wen.yang@linux.dev Cc: Nam Cao , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 20 Jul 2026 13:31:11 +0200 In-Reply-To: References: Autocrypt: addr=gmonaco@redhat.com; prefer-encrypt=mutual; keydata=mDMEZuK5YxYJKwYBBAHaRw8BAQdAmJ3dM9Sz6/Hodu33Qrf8QH2bNeNbOikqYtxWFLVm0 1a0JEdhYnJpZWxlIE1vbmFjbyA8Z21vbmFjb0BrZXJuZWwub3JnPoiZBBMWCgBBFiEEysoR+AuB3R Zwp6j270psSVh4TfIFAmjKX2MCGwMFCQWjmoAFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgk Q70psSVh4TfIQuAD+JulczTN6l7oJjyroySU55Fbjdvo52xiYYlMjPG7dCTsBAMFI7dSL5zg98I+8 cXY1J7kyNsY6/dcipqBM4RMaxXsOtCRHYWJyaWVsZSBNb25hY28gPGdtb25hY29AcmVkaGF0LmNvb T6InAQTFgoARAIbAwUJBaOagAULCQgHAgIiAgYVCgkICwIEFgIDAQIeBwIXgBYhBMrKEfgLgd0WcK eo9u9KbElYeE3yBQJoymCyAhkBAAoJEO9KbElYeE3yjX4BAJ/ETNnlHn8OjZPT77xGmal9kbT1bC1 7DfrYVISWV2Y1AP9HdAMhWNAvtCtN2S1beYjNybuK6IzWYcFfeOV+OBWRDQ== Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-1.fc44) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Wed, 2026-07-08 at 23:38 +0800, wen.yang@linux.dev wrote: > From: Wen Yang >=20 > When env_store is U64_MAX (its initial sentinel value), > ha_invariant_passed_ns() returns 0 immediately without initializing > env_store to the current clock.=C2=A0 Subsequent calls to > ha_check_invariant_ns() then find env_store still at U64_MAX, causing > the elapsed comparison to wrap and always report the invariant as > satisfied, silently masking any violations. >=20 > Fix by calling ha_reset_clk_ns() to establish the guard on the first > invocation instead of returning early.=C2=A0 Apply the same fix to > ha_invariant_passed_jiffy(). >=20 > Signed-off-by: Wen Yang While this looks alright, I have something else in mind for the env variabl= es lifecycle. After [1] is merged, I'd like to merge [2] which is basically inspired on your idea of resetting variables on start, just it's embedded i= n the framework (and requires [1] to get rid of the double representation for env variables). This is probably going to happen after the next merge window. I believe you can keep this patch for now and your model wouldn't need chan= ge after adding [2] instead. Thoughts? Thanks, Gabriele [1] - https://lore.kernel.org/lkml/c0f600dcbf3d8b487c944406851a39146f4d91fa.17818= 47583.git.namcao@linutronix.de/ [2] - https://web.git.kernel.org/pub/scm/linux/kernel/git/gmonaco/linux.git/commi= t/?h=3Drv_hybrid_automata_enq_lark&id=3Dd7c5c40c81d9b928aa9f86c4115429bffd2= 23a8c > --- > =C2=A0include/rv/ha_monitor.h | 8 ++++---- > =C2=A01 file changed, 4 insertions(+), 4 deletions(-) >=20 > diff --git a/include/rv/ha_monitor.h b/include/rv/ha_monitor.h > index 83199f90afe8..dddf5694bcc8 100644 > --- a/include/rv/ha_monitor.h > +++ b/include/rv/ha_monitor.h > @@ -375,12 +375,12 @@ static inline bool ha_check_invariant_ns(struct > ha_monitor *ha_mon, > =C2=A0static inline u64 ha_invariant_passed_ns(struct ha_monitor *ha_mon,= enum envs > env, > =C2=A0 =C2=A0=C2=A0 u64 expire, u64 time_ns) > =C2=A0{ > - u64 passed =3D 0; > + u64 passed; > =C2=A0 > =C2=A0 if (env < 0 || env >=3D ENV_MAX_STORED) > =C2=A0 return 0; > =C2=A0 if (ha_monitor_env_invalid(ha_mon, env)) > - return 0; > + ha_reset_clk_ns(ha_mon, env, time_ns); > =C2=A0 passed =3D ha_get_env(ha_mon, env, time_ns); > =C2=A0 ha_set_invariant_ns(ha_mon, env, expire - passed, time_ns); > =C2=A0 return passed; > @@ -414,12 +414,12 @@ static inline bool ha_check_invariant_jiffy(struct > ha_monitor *ha_mon, > =C2=A0static inline u64 ha_invariant_passed_jiffy(struct ha_monitor *ha_m= on, enum > envs env, > =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u64 expire, u64 time_ns) > =C2=A0{ > - u64 passed =3D 0; > + u64 passed; > =C2=A0 > =C2=A0 if (env < 0 || env >=3D ENV_MAX_STORED) > =C2=A0 return 0; > =C2=A0 if (ha_monitor_env_invalid(ha_mon, env)) > - return 0; > + ha_reset_clk_jiffy(ha_mon, env); > =C2=A0 passed =3D ha_get_env(ha_mon, env, time_ns); > =C2=A0 ha_set_invariant_jiffy(ha_mon, env, expire - passed); > =C2=A0 return passed;