From nobody Mon Jun 8 19:42:34 2026 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 8784A1F130B for ; Wed, 27 May 2026 06:23:41 +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=1779863022; cv=none; b=avDMPNIGzYsz8Vs/wWrIXZChY33EOqybo8wpHbc+0hoGDTXKF+MqZhub93Zuqk++2quogO0AQNaGu2jJXQKv1e15Xy/2uxdwtsC6qofYbiq6zrGKbEvF4MyKWf3q+IGxc2OOp2bIMyI5BR2X9qKai1YeA/RF2Dw0xT/QvuxVZqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863022; c=relaxed/simple; bh=/BQ/E0mDfOUgpiZiAckjd3M+EtXR2g3jD2R/osZBSkE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nF0gLu1LoBEOdlObSCn0r9lBLNo7BqkRW5PX1is+Vh3DfUQ4rxb9M3aqfjz4SjqMXhZ0nMoEvgQYBQwmsp4zVV1zwq0t9yoJhd61+s3ORM5+AQskQQyujQwqVon9F68nluFGE7bTgE+QUWvQXkFCE3eZ/tYEd8/VKXtXc666zK0= 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=hFmJGVQb; 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="hFmJGVQb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779863020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4+lfnvHsemjEBYbRo7zqOy4YlMSao2Yfnsg9e7Il7LE=; b=hFmJGVQbhRlGgdUTqb72P1tHqqbNRGzVNd3JvxcAbew9NyohO52PHlNyfRug9ebwsvcZ+o QYnrl8QgwYZJaqy49xMfSeY3Zh3+EovsHglBSegF9YVcpBFQHpLw+W3pne5M57r/eilATX YeZdSzmPNAnRqQ9Jxlm7NBz8k8ZC6Bk= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-681-rb85mRc2MUuNE8IRkhJjBQ-1; Wed, 27 May 2026 02:23:36 -0400 X-MC-Unique: rb85mRc2MUuNE8IRkhJjBQ-1 X-Mimecast-MFC-AGG-ID: rb85mRc2MUuNE8IRkhJjBQ_1779863015 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0142E19560BB; Wed, 27 May 2026 06:23:35 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.32.86]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A5484180034E; Wed, 27 May 2026 06:23:31 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , Masami Hiramatsu , Nam Cao , linux-trace-kernel@vger.kernel.org Cc: kernel test robot , Wen Yang Subject: [PATCH v2 01/12] rv: Fix __user specifier usage in extract_params() Date: Wed, 27 May 2026 08:23:01 +0200 Message-ID: <20260527062313.39908-2-gmonaco@redhat.com> In-Reply-To: <20260527062313.39908-1-gmonaco@redhat.com> References: <20260527062313.39908-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" The attributes variables extracted from syscalls in the helper are both defined with the __user specifier although only the actual pointer to user data should be marked. Remove the __user specifier from attr. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202604150820.Ny143u6X-lkp@int= el.com Fixes: b133207deb72 ("rv: Add nomiss deadline monitor") Reviewed-by: Wen Yang Signed-off-by: Gabriele Monaco Reviewed-by: Nam Cao --- kernel/trace/rv/monitors/deadline/deadline.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/trace/rv/monitors/deadline/deadline.h b/kernel/trace/rv= /monitors/deadline/deadline.h index 0bbfd2543329..78fca873d61e 100644 --- a/kernel/trace/rv/monitors/deadline/deadline.h +++ b/kernel/trace/rv/monitors/deadline/deadline.h @@ -95,7 +95,8 @@ static inline u8 get_server_type(struct task_struct *tsk) static inline int extract_params(struct pt_regs *regs, long id, pid_t *pid= _out) { size_t size =3D offsetofend(struct sched_attr, sched_flags); - struct sched_attr __user *uattr, attr; + struct sched_attr __user *uattr; + struct sched_attr attr; int new_policy =3D -1, ret; unsigned long args[6]; =20 --=20 2.54.0 From nobody Mon Jun 8 19:42:34 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 813301E32D6 for ; Wed, 27 May 2026 06:23:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863026; cv=none; b=jpnfOIjsnEDhQ+q4IINd7BQYojQGd+Umvp1U7v8e0IK5j7JOJ9XK4Il/1eE+KF2RbUzQ5Do12Q7LWlsZ8NaWL6UbkbslLXv3iy5mwQCFtZyOZf7uc4itzus4xObMH/+uJ45G/XaaIjrEo3zuoIkDfoTyvgseU9lkxIvuqGM/YwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863026; c=relaxed/simple; bh=0WvukjNb7+6J250sUTZeFAglCempKiB453zxn8PCmiA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EVCq1ebKelHecDmnAuu9iR1GquueorZPrruD8a9BxpwO8hQl7VZBWzAGYBDASORFg4ERkQzeEQolB9OMeQ/vEkUaKpZOzsEnGZ0Qw7zdQECO4Vn2SpQ2wwt4q3nM1VJI0yTtWzBhdMNYSc4ds+kFRLB68ks4RxRJVeNw3VEcuJs= 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=OI1sjvEw; arc=none smtp.client-ip=170.10.133.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="OI1sjvEw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779863024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iXiwCnyMX/kUwxnsk5xQt1kVR84WvuI8YoIYMs0mVNw=; b=OI1sjvEwe6IbTqNz2pJFSpGf6KiTF3qrAvYvtwtU00v+4eIylRM/QgpY+oXEliuyUmY+Vn RJs5Bgsmna0FLEfn8XAlgYtFNTy8vVhNV5k3fNYLpRVPtd88wasAlC04Fwrz2Of5rDAd2O ruS4tR+EjiU+ds15smXHwb5ibs8+WmY= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-134-Agvs4bcnM8moVnIvSbZu_g-1; Wed, 27 May 2026 02:23:40 -0400 X-MC-Unique: Agvs4bcnM8moVnIvSbZu_g-1 X-Mimecast-MFC-AGG-ID: Agvs4bcnM8moVnIvSbZu_g_1779863019 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A8C5719560A5; Wed, 27 May 2026 06:23:38 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.32.86]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2272F1800465; Wed, 27 May 2026 06:23:35 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , Nam Cao , linux-trace-kernel@vger.kernel.org Cc: Wen Yang Subject: [PATCH v2 02/12] rv: Fix read_lock scope in per-task DA cleanup Date: Wed, 27 May 2026 08:23:02 +0200 Message-ID: <20260527062313.39908-3-gmonaco@redhat.com> In-Reply-To: <20260527062313.39908-1-gmonaco@redhat.com> References: <20260527062313.39908-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" The da_monitor_reset_all() function for per-task monitors takes tasklist_lock while iterating over tasks, then keeps it also while iterating over idle tasks (one per CPU). The latter is not necessary since the lock needs to guard only for_each_process_thread(). Use a scoped_guard for more compact syntax and adjust the scope only where the lock is necessary. Fixes: 30984ccf31b7f ("rv: Refactor da_monitor to minimise macros") Fixes: 8259cb14a7068 ("rv: Reset per-task monitors also for idle tasks") Reviewed-by: Wen Yang Signed-off-by: Gabriele Monaco Reviewed-by: Nam Cao --- include/rv/da_monitor.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index 39765ff6f098..250888812125 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -272,12 +272,12 @@ static void da_monitor_reset_all(void) struct task_struct *g, *p; int cpu; =20 - read_lock(&tasklist_lock); - for_each_process_thread(g, p) - da_monitor_reset(da_get_monitor(p)); + scoped_guard(read_lock, &tasklist_lock) { + for_each_process_thread(g, p) + da_monitor_reset(da_get_monitor(p)); + } for_each_present_cpu(cpu) da_monitor_reset(da_get_monitor(idle_task(cpu))); - read_unlock(&tasklist_lock); } =20 /* --=20 2.54.0 From nobody Mon Jun 8 19:42:34 2026 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 1A77931195C for ; Wed, 27 May 2026 06:23:45 +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=1779863027; cv=none; b=imqObJArwhqxinBEPmkdg73tPVkRDp707wumCay/nzWpK9H0GfAFTbz+bUB8iGcICwe6E+3KFHnApqbdbdXEEw6AfgjqjCB0we8fMraq4bXWs3BStW1JOYSaZqPjp3dVdNHM7fWGDbTBigVpfSWAZfotNsSEi86x/8eLFYBRaQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863027; c=relaxed/simple; bh=eikqB3Erq24n5lHU9BNiKCLEGJRJzBTNr2LoDc87s5I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UKIkdvPD8cX+BQ/UWZPNYV0/l6hJ0sm7CYUqm/mmlgeWmnPRwN85x4MmB66uWQzxGFZ+F33KmdMesHfFVu9GBQUP38Cf+8PQcT4BKTI00BrHwuG6m5nVzsHo5Eko/Pi3iXmxXiLS4E0PfCpeVofHqmWlM9n8SPPYRyMhcyq3Dvk= 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=bIO3TavZ; 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="bIO3TavZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779863025; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LEdohwFEX/u4pMwStfP944VErCxUAuNDwNExysb2NsQ=; b=bIO3TavZVQ1j9t9lfDf/1uLVFr+x2EDXfW8t8V9ruvp1R9HR7kvajgCYsQpFlltiAyus2Y fbXh7gAeRCz9LKV5YvoOK+VpxtCPK007L6rQZ9mJBgiRZjtwtPtk+QjvEr2v9c59b28fjM dPPNVvgfho3uRPpMIKlS9CLrqdfnIyM= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-45-K865yf4JPVKtcAs8xQRkuw-1; Wed, 27 May 2026 02:23:43 -0400 X-MC-Unique: K865yf4JPVKtcAs8xQRkuw-1 X-Mimecast-MFC-AGG-ID: K865yf4JPVKtcAs8xQRkuw_1779863022 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2BA161956080; Wed, 27 May 2026 06:23:42 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.32.86]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A90A01800465; Wed, 27 May 2026 06:23:39 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , Nam Cao , linux-trace-kernel@vger.kernel.org Cc: Wen Yang Subject: [PATCH v2 03/12] rv: Reset per-task DA monitors before releasing the slot Date: Wed, 27 May 2026 08:23:03 +0200 Message-ID: <20260527062313.39908-4-gmonaco@redhat.com> In-Reply-To: <20260527062313.39908-1-gmonaco@redhat.com> References: <20260527062313.39908-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Per-task monitors use task_mon_slot to determine which slot in the array to use for the monitor. During destruction, this slot is returned but this is done before resetting the monitor. As a result, the monitor's reset is in fact resetting a slot that is outside of the array (RV_PER_TASK_MONITOR_INIT). Release the slot only after the reset to avoid out-of-bound memory access. Fixes: f5587d1b6ec93 ("rv: Add Hybrid Automata monitor type") Suggested-by: Wen Yang Reviewed-by: Wen Yang Signed-off-by: Gabriele Monaco Reviewed-by: Nam Cao --- include/rv/da_monitor.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index 250888812125..0b7028df08fb 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -309,10 +309,11 @@ static inline void da_monitor_destroy(void) WARN_ONCE(1, "Disabling a disabled monitor: " __stringify(MONITOR_NAME)); return; } - rv_put_task_monitor_slot(task_mon_slot); - task_mon_slot =3D RV_PER_TASK_MONITOR_INIT; =20 da_monitor_reset_all(); + + rv_put_task_monitor_slot(task_mon_slot); + task_mon_slot =3D RV_PER_TASK_MONITOR_INIT; } =20 #elif RV_MON_TYPE =3D=3D RV_MON_PER_OBJ --=20 2.54.0 From nobody Mon Jun 8 19:42:34 2026 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 796891E32D6 for ; Wed, 27 May 2026 06:23:52 +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=1779863034; cv=none; b=DA98kNyDm/dhH/iMvUI/ypNSpPyGH4BkOoVUmD2cLe/HDWxSqc2EwYQrP4KYv1sYFctDrq0wFu8DPUgiEczgP8WVFjE60IPOTi2fTY1BRkH+gtuyPapGLUHTJh4Uv3IETR56NA+8NPdHgihiJDhSkpZuHkaupFs/M3+w7jWRsKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863034; c=relaxed/simple; bh=8pD24vWsf0Oic32L+LWKN5iw6F9KGR5tawzGI3vksjI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=slpmPEj0Hz3Nr6t7Upyn1gBhTK4Y6qsR96KB+3yW/LCew27fguTc6/HF3ualCXnbe09/KEj7+S7BVi+fYdja05PdW84BE8X+hK5wauBYqeCTkPok6XwmLleMbYCkyrFBopy+lF8LNbYVkZdiYGC9dmOsOFr2VIhAVgTFVPXilS8= 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=OCCKxFzA; 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="OCCKxFzA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779863031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UVDYJtpxlDAh1CQeGepsebT4DWf9Iwm9B4gpcIcekmM=; b=OCCKxFzAORzG2R2AQ+++BwvMEYuY4rZJtpHPftboFA315h0jqLLIIUiUgQBTUv1EWSCcUq NQUa/zZKaFm+HkcvIZoq+vUH4uyWViKks+wkAoMPwrDbZIQnoKczseTKckNmetkHqcZeWm glRoWiDj9lJduuEoR76ABu3ZF+RfxtQ= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-191-mtBPWrYCNEaw-_9mjBJZjA-1; Wed, 27 May 2026 02:23:47 -0400 X-MC-Unique: mtBPWrYCNEaw-_9mjBJZjA-1 X-Mimecast-MFC-AGG-ID: mtBPWrYCNEaw-_9mjBJZjA_1779863026 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 40B331800603; Wed, 27 May 2026 06:23:46 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.32.86]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 433001800465; Wed, 27 May 2026 06:23:42 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , linux-trace-kernel@vger.kernel.org Cc: Wen Yang , Nam Cao Subject: [PATCH v2 04/12] rv: Prevent task migration while handling per-CPU events Date: Wed, 27 May 2026 08:23:04 +0200 Message-ID: <20260527062313.39908-5-gmonaco@redhat.com> In-Reply-To: <20260527062313.39908-1-gmonaco@redhat.com> References: <20260527062313.39908-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Tracepoint handlers are now fully preemptible. When a per-CPU monitor handles an event, it retrieves the monitor state using a per-CPU pointer. If the event itself doesn't disable preemption, the task can migrate to a different CPU and we risk updating the wrong monitor. Mitigate this by explicitly disabling task migration before acquiring the monitor pointer. This cannot guarantee the monitor runs on the correct CPU but reduces the race condition window and prevents warnings. Reviewed-by: Wen Yang Signed-off-by: Gabriele Monaco Reviewed-by: Nam Cao --- include/rv/da_monitor.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index 0b7028df08fb..a9fd284195ee 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -181,6 +181,10 @@ static inline void da_monitor_destroy(void) da_monitor_reset_all(); } =20 +#ifndef da_implicit_guard +#define da_implicit_guard() +#endif + #elif RV_MON_TYPE =3D=3D RV_MON_PER_CPU /* * Functions to define, init and get a per-cpu monitor. @@ -230,6 +234,10 @@ static inline void da_monitor_destroy(void) da_monitor_reset_all(); } =20 +#ifndef da_implicit_guard +#define da_implicit_guard() guard(migrate)() +#endif + #elif RV_MON_TYPE =3D=3D RV_MON_PER_TASK /* * Functions to define, init and get a per-task monitor. @@ -677,6 +685,7 @@ static inline bool __da_handle_start_run_event(struct d= a_monitor *da_mon, */ static inline void da_handle_event(enum events event) { + da_implicit_guard(); __da_handle_event(da_get_monitor(), event, 0); } =20 @@ -692,6 +701,7 @@ static inline void da_handle_event(enum events event) */ static inline bool da_handle_start_event(enum events event) { + da_implicit_guard(); return __da_handle_start_event(da_get_monitor(), event, 0); } =20 @@ -703,6 +713,7 @@ static inline bool da_handle_start_event(enum events ev= ent) */ static inline bool da_handle_start_run_event(enum events event) { + da_implicit_guard(); return __da_handle_start_run_event(da_get_monitor(), event, 0); } =20 --=20 2.54.0 From nobody Mon Jun 8 19:42:34 2026 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 B44CB32ABC0 for ; Wed, 27 May 2026 06:23:55 +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=1779863037; cv=none; b=qL5UaZxDKtjcCdk/k/56CtgGdf4MfcIVxEisrWI+fMjSebohvFLpS0144QtutzVRWH+WljGQNYTn8nw46JQFg2VSkA3oyU8gbCJbwXSnYoaSHOX0p/Sk61+iQiwjbMQcqROqw5VND4I+mKZY/1pGridPPmVD8gCMMXZ+9E4E0lA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863037; c=relaxed/simple; bh=rNassdAisJNl4nQAZn1wm+0/7C0SH5ZTaL4ainiidjc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tkUJ59WkFsQ5uIdv0OWpWJYks78bcxv9doJXfpnfDMjKTsEkzlh4eCaE3N2pAyMOfZxTYYSZNK13bNZ9c3djlOLv2iZc711N99tz1srylzqzFqlD11PAqqkxpWnaniy2wtKo3XRHOhy2VhI0R95Q0Njfv4ptmIWXLrsGfMGVzgE= 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=ZqYGiBOQ; 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="ZqYGiBOQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779863034; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SSsuFDsLUHgAw7G8Z5t1gaV3ukEOz/iBoYqKHZicEKA=; b=ZqYGiBOQpy9d7EXOuDhWrjwT+NmmXn6L8ieEm3y+XcXef8K+RHTkHSdhzn7/7ee3eok7zY j8/XEnfS9dSenXBzeEancNdzV74AR4766xWcb7WXalKzqzPfb7YMMNXRa+eeL+SztAOJWf p2oPvbTrzNKQ8NzfT/Z+0HE8LsdvxGY= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-355-O9oO2cdoPmuDzXe8ZHa8Dw-1; Wed, 27 May 2026 02:23:51 -0400 X-MC-Unique: O9oO2cdoPmuDzXe8ZHa8Dw-1 X-Mimecast-MFC-AGG-ID: O9oO2cdoPmuDzXe8ZHa8Dw_1779863030 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E915F19560B2; Wed, 27 May 2026 06:23:49 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.32.86]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 64F55180034E; Wed, 27 May 2026 06:23:47 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , Nam Cao , linux-trace-kernel@vger.kernel.org Cc: Wen Yang Subject: [PATCH v2 05/12] rv: Prevent in-flight per-task handlers from using invalid slots Date: Wed, 27 May 2026 08:23:05 +0200 Message-ID: <20260527062313.39908-6-gmonaco@redhat.com> In-Reply-To: <20260527062313.39908-1-gmonaco@redhat.com> References: <20260527062313.39908-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Per-task monitors use a slot in the task_struct->rv[] array and store that locally (e.g. task_mon_slot), this slot is returned during the destruction process but currently hanlers can be running while that slot is returning and this race may lead to accessing an invalid slot. Synchronise with all in-flight tracepoint handlers using tracepoint_synchronize_unregister() before returning the slot. Fixes: f5587d1b6ec9 ("rv: Add Hybrid Automata monitor type") Fixes: a9769a5b9878 ("rv: Add support for LTL monitors") Suggested-by: Wen Yang Signed-off-by: Gabriele Monaco Reviewed-by: Nam Cao --- include/rv/da_monitor.h | 4 ++++ include/rv/ltl_monitor.h | 1 + 2 files changed, 5 insertions(+) diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index a9fd284195ee..446a4d53d99c 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -310,6 +310,9 @@ static int da_monitor_init(void) =20 /* * da_monitor_destroy - return the allocated slot + * + * Wait for all in-flight handlers before returning the slot to avoid + * out-of-bound accesses. */ static inline void da_monitor_destroy(void) { @@ -320,6 +323,7 @@ static inline void da_monitor_destroy(void) =20 da_monitor_reset_all(); =20 + tracepoint_synchronize_unregister(); rv_put_task_monitor_slot(task_mon_slot); task_mon_slot =3D RV_PER_TASK_MONITOR_INIT; } diff --git a/include/rv/ltl_monitor.h b/include/rv/ltl_monitor.h index eff60cd61106..38e792401f76 100644 --- a/include/rv/ltl_monitor.h +++ b/include/rv/ltl_monitor.h @@ -77,6 +77,7 @@ static void ltl_monitor_destroy(void) { rv_detach_trace_probe(name, task_newtask, handle_task_newtask); =20 + tracepoint_synchronize_unregister(); rv_put_task_monitor_slot(ltl_monitor_slot); ltl_monitor_slot =3D RV_PER_TASK_MONITOR_INIT; } --=20 2.54.0 From nobody Mon Jun 8 19:42:34 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 5DDF9313520 for ; Wed, 27 May 2026 06:23:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863041; cv=none; b=TU3NZct1DAMTW6Ow9IyZEzO0x+bPSfzLlzwVALqYSXokOaVnrm8bBnUB08CFWjba5CARba1I1TzWnd0HCoFzOH4rbIAXPB3H29yOROU7cypE28+Bsbpa9iqxyrjt4CGGI6A9Febktjnes4tL44JPzRDBDPysu1TrVIqeBXn49SE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863041; c=relaxed/simple; bh=yXavbOgJGAdUlQEGS1RBEw+jkgQmb76OwhKj/lFQJqk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lmOsjDsSzPeIpLg++r+1sZp0pKsNw3vXTzW1/lx8LSv9HI5bpGpEXj6c2ziQ/BJKjI9oRnMX7GDm/ZX286v0nJL6UNfHg3cwMjh8X5zs7Fa/XV+Td8Ix9gTMbgQNlO4tAZ3WDuo/wFLRsHyccX0eeWRG+sCs35bxiIzkzFmudM8= 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=TGWrZtzY; arc=none smtp.client-ip=170.10.133.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="TGWrZtzY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779863038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UA0PFohOj15Jgq9Y3jQIIxa6b/L9rthaIIUjUoXjxGU=; b=TGWrZtzY9OIk6lcqkxAGDCpJ4jZpCez42xgD0jzTZ2lrUclhMQ6xd2RcJ4kuc9DKZTH2Wd W1Dz31eKSPukOI2Sbh0HD23HVGtjDKYauiBd+RZRlrnaEAFVxD1bKWQXbEMAlDStpPkjXk i860B6Ym/oa3Bu4+xbc50Dw5xmRjvpQ= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-98-o-lGshGEMwqorcMa_nz3hg-1; Wed, 27 May 2026 02:23:54 -0400 X-MC-Unique: o-lGshGEMwqorcMa_nz3hg-1 X-Mimecast-MFC-AGG-ID: o-lGshGEMwqorcMa_nz3hg_1779863033 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 391C318002CB; Wed, 27 May 2026 06:23:53 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.32.86]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E8F381800576; Wed, 27 May 2026 06:23:50 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , Nam Cao , linux-trace-kernel@vger.kernel.org Cc: Wen Yang Subject: [PATCH v2 06/12] rv: Ensure all pending probes terminate on per-obj monitor destroy Date: Wed, 27 May 2026 08:23:06 +0200 Message-ID: <20260527062313.39908-7-gmonaco@redhat.com> In-Reply-To: <20260527062313.39908-1-gmonaco@redhat.com> References: <20260527062313.39908-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" The monitor disable/destroy sequence detaches all probes and resets the monitor's data, however it doesn't wait for pending probes. This is an issue with per-object monitors, which free the monitor storage. Call tracepoint_synchronize_unregister() to make sure to wait for all pending probes before destroying the monitor storage. Fixes: 4a24127bd6cb ("rv: Add support for per-object monitors in DA/HA") Reviewed-by: Wen Yang Signed-off-by: Gabriele Monaco Reviewed-by: Nam Cao --- include/rv/da_monitor.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index 446a4d53d99c..5f790e1694b4 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -519,9 +519,10 @@ static inline void da_monitor_destroy(void) struct hlist_node *tmp; int bkt; =20 + tracepoint_synchronize_unregister(); /* - * This function is called after all probes are disabled, we need only - * worry about concurrency against old events. + * This function is called after all probes are disabled and no longer + * pending, we can safely assume no concurrent user. */ synchronize_rcu(); hash_for_each_safe(da_monitor_ht, bkt, tmp, mon_storage, node) { --=20 2.54.0 From nobody Mon Jun 8 19:42:34 2026 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 51646318B96 for ; Wed, 27 May 2026 06:24:03 +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=1779863046; cv=none; b=bJ3+INfQDKKgyJmiwIFBn8Wm+TX+Ukkl71zLY1GVjihYeLme2a43eJAJdc2CUvzifJ8P26H9LujeSE8BYDc6C7kYbbFFTDD3Y8gHhjusiJLtnraS10mC6iXtEp4A7OWpzGp1gd3Nz5z7jDYApLeJNAQT4sOExXHFbfWz5sD1lqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863046; c=relaxed/simple; bh=/zZEHbloB4KIm41CbIFCOsq8dMiIdjmYYvO2/ZvjP2U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qfiSK5NEu5+M5JIvaznrtAjWLbW54ChPDWR26YQ85WCskDXAZ332hPD4IghzhAL35f82gvYc3XUneAO6Ox1xOaiUpvXtUzrMehMtfC2hmgerUcWLsiDAuUceCalcXccqKen5zNHSqgUv3yLqbG1+0sWgAxoMbaJotZmyS6lzyQc= 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=UXMxEhBc; 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="UXMxEhBc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779863043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4ePIHO+8NmGJdHjX2JRgFQZjZfpbWrkjo/nsSfZaWdU=; b=UXMxEhBc+AWl0fg1x8VtiZ0JCDo3Fu5afAaYQdY1PHKzTCDb1MD1huNdvvvJKYITr8jXoY e/9rQAT+T66nhed3fRxMZgRsNHrbk0LJX+MqQe/k8mZ4zf7vHdE5ezA9ph7/hLQfmk/yxm wsNzp9FYO0lehzIHut0CtrNVVnEoy6k= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-Ehw2r_IgPnOKd0xeTn8akw-1; Wed, 27 May 2026 02:23:58 -0400 X-MC-Unique: Ehw2r_IgPnOKd0xeTn8akw-1 X-Mimecast-MFC-AGG-ID: Ehw2r_IgPnOKd0xeTn8akw_1779863037 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1D4D4195608B; Wed, 27 May 2026 06:23:57 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.32.86]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 519F71800465; Wed, 27 May 2026 06:23:54 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , linux-trace-kernel@vger.kernel.org Cc: Wen Yang , Nam Cao Subject: [PATCH v2 07/12] rv: Fix monitor start ordering and memory ordering for monitoring flag Date: Wed, 27 May 2026 08:23:07 +0200 Message-ID: <20260527062313.39908-8-gmonaco@redhat.com> In-Reply-To: <20260527062313.39908-1-gmonaco@redhat.com> References: <20260527062313.39908-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" From: Wen Yang da_monitor_start() set monitoring=3D1 before calling da_monitor_init_hook(), may racing with the sched_switch handler: da_monitor_start() sched_switch handler ------------------------- --------------------------------- da_mon->monitoring =3D 1; if (da_monitoring(da_mon)) /* true */ ha_start_timer_ns(...); /* hrtimer->base =3D=3D NULL, crash = */ da_monitor_init_hook(da_mon); /* hrtimer_setup() sets base */ Fix the ordering and pair with release/acquire semantics: da_monitor_init_hook(da_mon); smp_store_release(&da_mon->monitoring, 1); /* da_monitor_start() */ return smp_load_acquire(&da_mon->monitoring); /* da_monitoring() */ On ARM64 a plain STR + LDR does not form a release-acquire pair, so the load can observe monitoring=3D1 while hrtimer->base is still NULL. The plain accesses are also data races under KCSAN. Use WRITE_ONCE for the monitoring=3D0 store in da_monitor_reset() to cover the reset path. Fixes: 792575348ff7 ("rv/include: Add deterministic automata monitor defini= tion via C macros") Signed-off-by: Wen Yang Reviewed-by: Gabriele Monaco Signed-off-by: Gabriele Monaco Reviewed-by: Nam Cao --- include/rv/da_monitor.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index 5f790e1694b4..c1e347f9deaf 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -82,7 +82,7 @@ static void react(enum states curr_state, enum events eve= nt) static inline void da_monitor_reset(struct da_monitor *da_mon) { da_monitor_reset_hook(da_mon); - da_mon->monitoring =3D 0; + WRITE_ONCE(da_mon->monitoring, 0); da_mon->curr_state =3D model_get_initial_state(); } =20 @@ -95,8 +95,9 @@ static inline void da_monitor_reset(struct da_monitor *da= _mon) static inline void da_monitor_start(struct da_monitor *da_mon) { da_mon->curr_state =3D model_get_initial_state(); - da_mon->monitoring =3D 1; da_monitor_init_hook(da_mon); + /* Pairs with smp_load_acquire in da_monitoring(). */ + smp_store_release(&da_mon->monitoring, 1); } =20 /* @@ -104,7 +105,8 @@ static inline void da_monitor_start(struct da_monitor *= da_mon) */ static inline bool da_monitoring(struct da_monitor *da_mon) { - return da_mon->monitoring; + /* Pairs with smp_store_release in da_monitor_start(). */ + return smp_load_acquire(&da_mon->monitoring); } =20 /* --=20 2.54.0 From nobody Mon Jun 8 19:42:34 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 145CA31ED83 for ; Wed, 27 May 2026 06:24:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863053; cv=none; b=mxDlvnBhmRr4Z8mrys6Vax+TO0oQVYY0XLwExKLpED6/uUVvLIuwlhZJZWSM7eNHVcqx/uUqbBeai5NWW2NJxDCGuarvkngX5ghcRaPrLJeTaEZAYIzcU0n/ZrdHDDC5W8y32dNZpgD+LNWONLLn6Zf8T6u92RUeYyrWPzKFzZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863053; c=relaxed/simple; bh=/x40mWTn6nztNyI+oLewjk2qt6XhtAUTtlMdIIP4R9A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jFAJrzGDi2Jmw8ZbAeEZvOewR93f42Fne2Kp56BEYU0px1UPt3N7D234nGKLeSxYoN6ehfFl5uyJjJS0UsDpIpN9TAv5GzmiMS5fZk7dnDewJ3aP8+flNfCo6MUQzRfZqVzmaMdcp6pI9YOPuQR3HI34DXs6qRk0yJjRlPi2ynI= 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=G49IQ5XW; arc=none smtp.client-ip=170.10.133.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="G49IQ5XW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779863048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bhkp474uVy2O7GAwccoJEEMfZ0nFtAPtJP8pbK3dLS4=; b=G49IQ5XWFz12phz40rpuuJM8cxRuBMIUVT05SopY5lECXSUaQwmtBJhC+97DyatU6UKzBc yrv8ubWq0XpODzFzv+uhHyCK/WCPVTLCq2aMZm2lto9a9r2NYqbYI1rXOLl2B3QGfDp855 pFZJPw88i2KsrE79M8aglN+NmLFrEvA= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-472-Gjr14VVDOou_0f8bXM37cw-1; Wed, 27 May 2026 02:24:02 -0400 X-MC-Unique: Gjr14VVDOou_0f8bXM37cw-1 X-Mimecast-MFC-AGG-ID: Gjr14VVDOou_0f8bXM37cw_1779863041 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DD6831956095; Wed, 27 May 2026 06:24:00 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.32.86]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 69400180034E; Wed, 27 May 2026 06:23:58 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , Nam Cao , linux-trace-kernel@vger.kernel.org Cc: Wen Yang Subject: [PATCH v2 08/12] rv: Ensure synchronous cleanup for HA monitors Date: Wed, 27 May 2026 08:23:08 +0200 Message-ID: <20260527062313.39908-9-gmonaco@redhat.com> In-Reply-To: <20260527062313.39908-1-gmonaco@redhat.com> References: <20260527062313.39908-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" HA monitors may start timers, all cleanup functions currently stop the timers asynchronously to avoid sleeping in the wrong context. Nothing makes sure running callbacks terminate on cleanup. Run the entire HA timer callback in an RCU read-side critical section, this way we can simply synchronize_rcu() with any pending timer and are sure any cleanup using kfree_rcu() runs after callbacks terminated. Additionally make sure any unlikely callback running late won't run any code if the monitor is marked as disabled. Use memory barriers to serialise with racing resets. Fixes: f5587d1b6ec9 ("rv: Add Hybrid Automata monitor type") Fixes: 4a24127bd6cb ("rv: Add support for per-object monitors in DA/HA") Signed-off-by: Gabriele Monaco --- include/rv/da_monitor.h | 26 +++++++++++++++++++++----- include/rv/ha_monitor.h | 19 +++++++++++++++++-- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index c1e347f9deaf..268f22933663 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -57,6 +57,15 @@ static struct rv_monitor rv_this; #define da_monitor_reset_hook(da_mon) #endif =20 +/* + * Hook to allow the implementation of hybrid automata: define it with a + * function that waits for the termination of all monitors background + * activities (e.g. all timers). This hook can sleep. + */ +#ifndef da_monitor_sync_hook +#define da_monitor_sync_hook() +#endif + /* * Type for the target id, default to int but can be overridden. * A long type can work as hash table key (PER_OBJ) but will be downgraded= to @@ -83,7 +92,8 @@ static inline void da_monitor_reset(struct da_monitor *da= _mon) { da_monitor_reset_hook(da_mon); WRITE_ONCE(da_mon->monitoring, 0); - da_mon->curr_state =3D model_get_initial_state(); + /* Pair with load in __ha_monitor_timer_callback */ + smp_store_release(&da_mon->curr_state, model_get_initial_state()); } =20 /* @@ -181,6 +191,7 @@ static inline int da_monitor_init(void) static inline void da_monitor_destroy(void) { da_monitor_reset_all(); + da_monitor_sync_hook(); } =20 #ifndef da_implicit_guard @@ -234,6 +245,7 @@ static inline int da_monitor_init(void) static inline void da_monitor_destroy(void) { da_monitor_reset_all(); + da_monitor_sync_hook(); } =20 #ifndef da_implicit_guard @@ -324,6 +336,7 @@ static inline void da_monitor_destroy(void) } =20 da_monitor_reset_all(); + da_monitor_sync_hook(); =20 tracepoint_synchronize_unregister(); rv_put_task_monitor_slot(task_mon_slot); @@ -503,10 +516,9 @@ static void da_monitor_reset_all(void) struct da_monitor_storage *mon_storage; int bkt; =20 - rcu_read_lock(); + guard(rcu)(); hash_for_each_rcu(da_monitor_ht, bkt, mon_storage, node) da_monitor_reset(&mon_storage->rv.da_mon); - rcu_read_unlock(); } =20 static inline int da_monitor_init(void) @@ -522,13 +534,17 @@ static inline void da_monitor_destroy(void) int bkt; =20 tracepoint_synchronize_unregister(); + scoped_guard(rcu) { + hash_for_each_rcu(da_monitor_ht, bkt, mon_storage, node) { + da_monitor_reset_hook(&mon_storage->rv.da_mon); + } + } + da_monitor_sync_hook(); /* * This function is called after all probes are disabled and no longer * pending, we can safely assume no concurrent user. */ - synchronize_rcu(); hash_for_each_safe(da_monitor_ht, bkt, tmp, mon_storage, node) { - da_monitor_reset_hook(&mon_storage->rv.da_mon); hash_del_rcu(&mon_storage->node); kfree(mon_storage); } diff --git a/include/rv/ha_monitor.h b/include/rv/ha_monitor.h index d59507e8cb30..661631bc933a 100644 --- a/include/rv/ha_monitor.h +++ b/include/rv/ha_monitor.h @@ -36,6 +36,7 @@ static bool ha_monitor_handle_constraint(struct da_monito= r *da_mon, #define da_monitor_event_hook ha_monitor_handle_constraint #define da_monitor_init_hook ha_monitor_init_env #define da_monitor_reset_hook ha_monitor_reset_env +#define da_monitor_sync_hook() synchronize_rcu() =20 #include #include @@ -237,12 +238,26 @@ static bool ha_monitor_handle_constraint(struct da_mo= nitor *da_mon, return false; } =20 +/* + * __ha_monitor_timer_callback - generic callback representation + * + * This callback runs in an RCU read-side critical section to allow the + * destruction sequence to easily synchronize_rcu() with all pending timer + * after asynchronously disabling them. + */ static inline void __ha_monitor_timer_callback(struct ha_monitor *ha_mon) { - enum states curr_state =3D READ_ONCE(ha_mon->da_mon.curr_state); DECLARE_SEQ_BUF(env_string, ENV_BUFFER_SIZE); - u64 time_ns =3D ha_get_ns(); + enum states curr_state; + u64 time_ns; + + guard(rcu)(); + /* Ensure consistent curr_state if we race with da_monitor_reset */ + curr_state =3D smp_load_acquire(&ha_mon->da_mon.curr_state); + if (unlikely(!da_monitor_handling_event(&ha_mon->da_mon))) + return; =20 + time_ns =3D ha_get_ns(); ha_get_env_string(&env_string, ha_mon, time_ns); ha_react(curr_state, EVENT_NONE, env_string.buffer); ha_trace_error_env(ha_mon, model_get_state_name(curr_state), --=20 2.54.0 From nobody Mon Jun 8 19:42:34 2026 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 0F0F7346FB5 for ; Wed, 27 May 2026 06:24:09 +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=1779863053; cv=none; b=R+W60YZ87FPNGiI3kOrcEYf7HuIyHPu5InoEVp+2fkzo5kfbUUGaEp+9Ndp2yfrzknJxQFUQQLZAggYiRko2cGQ2Wl7JPIew+tnIZpFc12z6vVpd/vcMRiIzlEd4nHUvubj4Mkh3Mvi38y9UZZ/Mx4SVznHpwYCKIa80IqFgWgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863053; c=relaxed/simple; bh=pQqK/nTllFF/lgQApFakASHAhLjuYYbO/SY9VM1t3n0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=encEDFW3du8jR/lrFYNNMJLRODF44Oropon8wdX+iGRL4E+h9Tv360WiTBlMMhbZcOTMNw15CJ/ZUNEP5JXmLYlioEI70jpUua/GPPWiqHW3fcNfXePYXDfBdLcZwVFieZx0quy2ZpGprv1U8nCmiVnoPUBa+NbHtKxVyqjZTQc= 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=f4zv2LAs; 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="f4zv2LAs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779863048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dm4PsB8N/JeNdEnQ2n2Jt0U7OzBLeT8fzkcwV89DULM=; b=f4zv2LAsrmo4O0mCPlZbT4EVcpPHYg1NK5ECyE+/lg56ebZx7WJ5aTAvtBUQfLgCka5zZk jw94miIkMlFt/6AyW8KRaFJZ26USaHg/mYUBegCY2DRMMTgQlgZpJAtc2NEajtc1NuZUAL OEKg6uHgzYKDVSC+1pyHhPMzodopN2I= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-139-85hdFIq1N2OMlI5hk2Q09g-1; Wed, 27 May 2026 02:24:06 -0400 X-MC-Unique: 85hdFIq1N2OMlI5hk2Q09g-1 X-Mimecast-MFC-AGG-ID: 85hdFIq1N2OMlI5hk2Q09g_1779863045 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3A0BD180047F; Wed, 27 May 2026 06:24:05 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.32.86]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 80D4D1800465; Wed, 27 May 2026 06:24:02 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , Masami Hiramatsu , Nam Cao , linux-trace-kernel@vger.kernel.org Cc: Wen Yang Subject: [PATCH v2 09/12] rv: Do not rely on clean monitor when initialising HA Date: Wed, 27 May 2026 08:23:09 +0200 Message-ID: <20260527062313.39908-10-gmonaco@redhat.com> In-Reply-To: <20260527062313.39908-1-gmonaco@redhat.com> References: <20260527062313.39908-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Hybrid Automata monitors hook into the DA implementation when doing da_monitor_reset(). This function is called both on initialisation and teardown, HA monitors try to cancel a timer only when it's initialised relying on the da_mon->monitoring flag. This flag could however be corrupted during initialisation. This happens for instance on per-task monitors that share the same storage with different type of monitors like LTL or in case of races during a previous teardown. Stop relying on the monitoring flag during initialisation, assume that can have any value, so skip timer cancellation in any case when a local flag is set. New monitors (e.g. new tasks) are always zero-initialised so they are safe. Reported-by: Wen Yang Closes: https://lore.kernel.org/lkml/d02c656aada7d071f083460a5c9a454363669b= 61.1778522945.git.wen.yang@linux.dev Fixes: f5587d1b6ec9 ("rv: Add Hybrid Automata monitor type") Reviewed-by: Wen Yang Signed-off-by: Gabriele Monaco --- include/rv/ha_monitor.h | 31 ++++++++++++++++++- kernel/trace/rv/monitors/nomiss/nomiss.c | 4 +-- kernel/trace/rv/monitors/opid/opid.c | 4 +-- kernel/trace/rv/monitors/stall/stall.c | 4 +-- .../rvgen/rvgen/templates/dot2k/main.c | 4 +-- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/include/rv/ha_monitor.h b/include/rv/ha_monitor.h index 661631bc933a..2d7187c16f55 100644 --- a/include/rv/ha_monitor.h +++ b/include/rv/ha_monitor.h @@ -116,6 +116,35 @@ static enum hrtimer_restart ha_monitor_timer_callback(= struct hrtimer *hrtimer); #define ha_get_ns() 0 #endif /* HA_CLK_NS */ =20 +static bool ha_mon_initializing; + +static int ha_monitor_init(void) +{ + int ret; + + ha_mon_initializing =3D true; + ret =3D da_monitor_init(); + ha_mon_initializing =3D false; + return ret; +} + +static void ha_monitor_destroy(void) +{ + da_monitor_destroy(); +} + +/* + * ha_monitor_uninitialized - are fields like the timer initialized? + * + * On a clean monitor, we can assume an active monitor (monitoring) is + * initialized, however the monitoring field cannot be trusted during + * initialization. + */ +static inline bool ha_monitor_uninitialized(struct da_monitor *da_mon) +{ + return ha_mon_initializing || !da_monitoring(da_mon); +} + /* Should be supplied by the monitor */ static u64 ha_get_env(struct ha_monitor *ha_mon, enum envs env, u64 time_n= s); static bool ha_verify_constraint(struct ha_monitor *ha_mon, @@ -160,7 +189,7 @@ static inline void ha_monitor_reset_env(struct da_monit= or *da_mon) struct ha_monitor *ha_mon =3D to_ha_monitor(da_mon); =20 /* Initialisation resets the monitor before initialising the timer */ - if (likely(da_monitoring(da_mon))) + if (likely(!ha_monitor_uninitialized(da_mon))) ha_cancel_timer(ha_mon); } =20 diff --git a/kernel/trace/rv/monitors/nomiss/nomiss.c b/kernel/trace/rv/mon= itors/nomiss/nomiss.c index 31f90f3638d8..8ead8783c29f 100644 --- a/kernel/trace/rv/monitors/nomiss/nomiss.c +++ b/kernel/trace/rv/monitors/nomiss/nomiss.c @@ -227,7 +227,7 @@ static int enable_nomiss(void) { int retval; =20 - retval =3D da_monitor_init(); + retval =3D ha_monitor_init(); if (retval) return retval; =20 @@ -263,7 +263,7 @@ static void disable_nomiss(void) rv_detach_trace_probe("nomiss", sched_switch, handle_sched_switch); rv_detach_trace_probe("nomiss", sched_wakeup, handle_sched_wakeup); =20 - da_monitor_destroy(); + ha_monitor_destroy(); } =20 static struct rv_monitor rv_this =3D { diff --git a/kernel/trace/rv/monitors/opid/opid.c b/kernel/trace/rv/monitor= s/opid/opid.c index 4594c7c46601..2922318c6112 100644 --- a/kernel/trace/rv/monitors/opid/opid.c +++ b/kernel/trace/rv/monitors/opid/opid.c @@ -73,7 +73,7 @@ static int enable_opid(void) { int retval; =20 - retval =3D da_monitor_init(); + retval =3D ha_monitor_init(); if (retval) return retval; =20 @@ -90,7 +90,7 @@ static void disable_opid(void) rv_detach_trace_probe("opid", sched_set_need_resched_tp, handle_sched_nee= d_resched); rv_detach_trace_probe("opid", sched_waking, handle_sched_waking); =20 - da_monitor_destroy(); + ha_monitor_destroy(); } =20 /* diff --git a/kernel/trace/rv/monitors/stall/stall.c b/kernel/trace/rv/monit= ors/stall/stall.c index 9ccfda6b0e73..3c38fb1a0159 100644 --- a/kernel/trace/rv/monitors/stall/stall.c +++ b/kernel/trace/rv/monitors/stall/stall.c @@ -103,7 +103,7 @@ static int enable_stall(void) { int retval; =20 - retval =3D da_monitor_init(); + retval =3D ha_monitor_init(); if (retval) return retval; =20 @@ -120,7 +120,7 @@ static void disable_stall(void) rv_detach_trace_probe("stall", sched_switch, handle_sched_switch); rv_detach_trace_probe("stall", sched_wakeup, handle_sched_wakeup); =20 - da_monitor_destroy(); + ha_monitor_destroy(); } =20 static struct rv_monitor rv_this =3D { diff --git a/tools/verification/rvgen/rvgen/templates/dot2k/main.c b/tools/= verification/rvgen/rvgen/templates/dot2k/main.c index bf0999f6657a..889446760e3c 100644 --- a/tools/verification/rvgen/rvgen/templates/dot2k/main.c +++ b/tools/verification/rvgen/rvgen/templates/dot2k/main.c @@ -35,7 +35,7 @@ static int enable_%%MODEL_NAME%%(void) { int retval; =20 - retval =3D da_monitor_init(); + retval =3D %%MONITOR_CLASS%%_monitor_init(); if (retval) return retval; =20 @@ -50,7 +50,7 @@ static void disable_%%MODEL_NAME%%(void) =20 %%TRACEPOINT_DETACH%% =20 - da_monitor_destroy(); + %%MONITOR_CLASS%%_monitor_destroy(); } =20 /* --=20 2.54.0 From nobody Mon Jun 8 19:42:34 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 71ED631DD97 for ; Wed, 27 May 2026 06:24:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863057; cv=none; b=ulfn4Td2iDO6cw0ydgvt8wjE6o9xY0p/vQm+2v86bOIvYScf+aT0/PdyQ41CBL3mXYWg5PAMIUuI1prQKE64pxicgh4qoswT4f3LG6qIFycMT0fYQRfwor2hKyqPRhGVdpoj5xFdtR+mTa7itu0BF9miJiZ7hM9AVQgOYE/IB6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863057; c=relaxed/simple; bh=KAB3uHGRFOkPEu4Za3teW3oTV4PlC3OgrbcOogXz/a4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z8qqcTUDltWJXk+Qn4SMKCDCzs8ab9MVN+jSt9sr4EKYx0lSDHevRJ3WrT6riIbzxZLdIiDb31f/CjZ5OVHvl54iDt2cCAXlvwlVuDyFKyPqFkOSMkTJ1sVPPlG4LDu7GzkdVu44Lxxmf+zE/6rtueWqgm90SDXMF3CFYcXwOYQ= 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=a8gcVRXg; arc=none smtp.client-ip=170.10.133.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="a8gcVRXg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779863051; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fBb8SPdmZX6C/eeUu4Za00zt1HH8qUbYwYSKQs8ksR8=; b=a8gcVRXgps4j8OluGtcxi62EhVKBuK4q+jALkIaTIKqQ+qGkGC6T0TvjQVeF2vwf0eNxBV A9FOyGq4daJ812+cAQZBok2v9AEIPbZ8gW+FF9e14Dwqqdglct0damxBww/mGKUVRu4zRK otUlbjcSfwS8ls4b3gy7/tbXI1kHhCc= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-338-a3hBaCCLOhqvxsrOIDUsfQ-1; Wed, 27 May 2026 02:24:09 -0400 X-MC-Unique: a3hBaCCLOhqvxsrOIDUsfQ-1 X-Mimecast-MFC-AGG-ID: a3hBaCCLOhqvxsrOIDUsfQ_1779863048 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9BF001956048; Wed, 27 May 2026 06:24:08 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.32.86]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2FE14180034E; Wed, 27 May 2026 06:24:05 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , Nam Cao , linux-trace-kernel@vger.kernel.org Cc: Wen Yang Subject: [PATCH v2 10/12] rv: Add automatic cleanup handlers for per-task HA monitors Date: Wed, 27 May 2026 08:23:10 +0200 Message-ID: <20260527062313.39908-11-gmonaco@redhat.com> In-Reply-To: <20260527062313.39908-1-gmonaco@redhat.com> References: <20260527062313.39908-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Hybrid automata monitors may start timers, depending on the model, these may remain active on an exiting task and cause false positives or even access freed memory. Add an enable/disable hook in the HA code, currently only populated by the per-task handler for registration and deregistration. This hooks to the sched_process_exit event and ensures the timer is stopped for every exiting task. The handler is enabled automatically but may be disabled, for instance if the monitor uses the event for another purpose (but should still manually ensure timers are stopped). Fixes: f5587d1b6ec9 ("rv: Add Hybrid Automata monitor type") Signed-off-by: Gabriele Monaco --- include/rv/ha_monitor.h | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/include/rv/ha_monitor.h b/include/rv/ha_monitor.h index 2d7187c16f55..df67d5e9d132 100644 --- a/include/rv/ha_monitor.h +++ b/include/rv/ha_monitor.h @@ -28,6 +28,7 @@ static inline void ha_monitor_init_env(struct da_monitor = *da_mon); static inline void ha_monitor_reset_env(struct da_monitor *da_mon); static inline void ha_setup_timer(struct ha_monitor *ha_mon); static inline bool ha_cancel_timer(struct ha_monitor *ha_mon); +static inline void ha_cancel_timer_sync(struct ha_monitor *ha_mon); static bool ha_monitor_handle_constraint(struct da_monitor *da_mon, enum states curr_state, enum events event, @@ -38,6 +39,26 @@ static bool ha_monitor_handle_constraint(struct da_monit= or *da_mon, #define da_monitor_reset_hook ha_monitor_reset_env #define da_monitor_sync_hook() synchronize_rcu() =20 +#if !defined(HA_SKIP_AUTO_CLEANUP) && RV_MON_TYPE =3D=3D RV_MON_PER_TASK +/* + * Automatic cleanup handlers for per-task HA monitors, only skip if you k= now + * what you are doing (e.g. you want to implement cleanup manually in anot= her + * handler doing more things). + */ +static void ha_handle_sched_process_exit(void *data, struct task_struct *p, + bool group_dead); + +#define ha_monitor_enable_hook() = \ + rv_attach_trace_probe(__stringify(MONITOR_NAME), sched_process_exit, \ + ha_handle_sched_process_exit) +#define ha_monitor_disable_hook() = \ + rv_detach_trace_probe(__stringify(MONITOR_NAME), sched_process_exit, \ + ha_handle_sched_process_exit) +#else +#define ha_monitor_enable_hook() ((void)0) +#define ha_monitor_disable_hook() ((void)0) +#endif + #include #include =20 @@ -124,12 +145,15 @@ static int ha_monitor_init(void) =20 ha_mon_initializing =3D true; ret =3D da_monitor_init(); + if (ret =3D=3D 0) + ha_monitor_enable_hook(); ha_mon_initializing =3D false; return ret; } =20 static void ha_monitor_destroy(void) { + ha_monitor_disable_hook(); da_monitor_destroy(); } =20 @@ -230,6 +254,18 @@ static inline void ha_trace_error_env(struct ha_monito= r *ha_mon, { CONCATENATE(trace_error_env_, MONITOR_NAME)(id, curr_state, event, env); } + +#if !defined(HA_SKIP_AUTO_CLEANUP) && RV_MON_TYPE =3D=3D RV_MON_PER_TASK +static void ha_handle_sched_process_exit(void *data, struct task_struct *p, + bool group_dead) +{ + struct da_monitor *da_mon =3D da_get_monitor(p); + + if (likely(!ha_monitor_uninitialized(da_mon))) + ha_cancel_timer_sync(to_ha_monitor(da_mon)); +} +#endif + #endif /* RV_MON_TYPE */ =20 /* @@ -456,6 +492,10 @@ static inline bool ha_cancel_timer(struct ha_monitor *= ha_mon) { return timer_delete(&ha_mon->timer); } +static inline void ha_cancel_timer_sync(struct ha_monitor *ha_mon) +{ + timer_delete_sync(&ha_mon->timer); +} #elif HA_TIMER_TYPE =3D=3D HA_TIMER_HRTIMER /* * Helper functions to handle the monitor timer. @@ -507,6 +547,10 @@ static inline bool ha_cancel_timer(struct ha_monitor *= ha_mon) { return hrtimer_try_to_cancel(&ha_mon->hrtimer) =3D=3D 1; } +static inline void ha_cancel_timer_sync(struct ha_monitor *ha_mon) +{ + hrtimer_cancel(&ha_mon->hrtimer); +} #else /* HA_TIMER_NONE */ /* * Start function is intentionally not defined, monitors using timers must @@ -517,6 +561,7 @@ static inline bool ha_cancel_timer(struct ha_monitor *h= a_mon) { return false; } +static inline void ha_cancel_timer_sync(struct ha_monitor *ha_mon) { } #endif =20 #endif --=20 2.54.0 From nobody Mon Jun 8 19:42:34 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 DDD4C318140 for ; Wed, 27 May 2026 06:24:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863061; cv=none; b=rosLCI2sM6HO8ieadaqnGx+AKZOeqrlcTP3zuc5sdmx9/RfLQV9N2Xrk8tFYTWu6uB2AotSMv/eEJrU1TLpDJjkVzDyw0jjdFMNIsgYFQ2Il4FOzLaUqFCZ8zB9yEGP1OYKxxI9oAfvOoS0i5WWx6u/0/PFSMaROz91OE3Me3oY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863061; c=relaxed/simple; bh=BTzpTzJ08QU872+MH2u3Jn40ek6LGw/G1Kc1I1WaA3Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IrX6ecORlgVC0gBGB4o2nbxe0wJ+q2j2Es0lG2rIWMw7MRI4E+gedwp+f9jR8M9O/q6ctBXieuDjP9ekI6U6d1MvVBE+gXBpuaoboonmOwoStqebkfjAk/uNNP4ytN5Lat6c+j9OsKTtKP6pNkewMOf/a46w/CB/3yEEneCcmis= 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=N7SK0GE4; arc=none smtp.client-ip=170.10.133.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="N7SK0GE4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779863055; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gIHa1YBuPLeO03QUKPgMW16MNNm3YEqx/eZ3E2ynjTk=; b=N7SK0GE4Cl3cAadB01fumIkYqHwLNfU8hp0w1Yq6xRUAZpr7u4hBV5p0/QrhL9Vy9OifLq U5kWCMSijdvPK0ERdYOQGLvTAmxravCZLatLd3VFWxvFZySySg+/OA3D5xfxFQIFCXbTLP F/+BApwCD1m8R9znwpKemE7z45fkwzo= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-402-otFvdVdkMqKJ37yA6KcG_w-1; Wed, 27 May 2026 02:24:12 -0400 X-MC-Unique: otFvdVdkMqKJ37yA6KcG_w-1 X-Mimecast-MFC-AGG-ID: otFvdVdkMqKJ37yA6KcG_w_1779863051 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BD4D0195608F; Wed, 27 May 2026 06:24:11 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.32.86]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 74481180034E; Wed, 27 May 2026 06:24:09 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , linux-trace-kernel@vger.kernel.org Cc: Nam Cao , Wen Yang Subject: [PATCH v2 11/12] verification/rvgen: Generate cleanup hook for per-obj monitor Date: Wed, 27 May 2026 08:23:11 +0200 Message-ID: <20260527062313.39908-12-gmonaco@redhat.com> In-Reply-To: <20260527062313.39908-1-gmonaco@redhat.com> References: <20260527062313.39908-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Per-object monitors can allocate memory dynamically and such memory is required for the lifetime of the object, then it should be freed with the appropriate call. Force the generation scripts to add a cleanup function the user will need to wire to the appropriate event (e.g. sched_process_exit for tasks). This can be safely removed if the object will never cease to exist before disabling the monitor (e.g. if following only static variables). Signed-off-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/dot2k.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/verification/rvgen/rvgen/dot2k.py b/tools/verification/r= vgen/rvgen/dot2k.py index e6f476b903b0..a17294283a1f 100644 --- a/tools/verification/rvgen/rvgen/dot2k.py +++ b/tools/verification/rvgen/rvgen/dot2k.py @@ -17,6 +17,9 @@ from .automata import _EventConstraintKey, _StateConstrai= ntKey, AutomataError class dot2k(Monitor, Dot2c): template_dir =3D "dot2k" =20 + # only needed for the per-obj cleanup hook + cleanup_marker =3D "obj_cleanup" + def __init__(self, file_path, MonitorType, extra_params=3D{}): self.monitor_type =3D MonitorType Monitor.__init__(self, extra_params) @@ -56,18 +59,30 @@ class dot2k(Monitor, Dot2c): buff.append(f"\tda_{handle}({event}{self.enum_suffix});") buff.append("}") buff.append("") + if self.monitor_type =3D=3D "per_obj": + buff.append("/* XXX: obj is being destroyed, remove if not req= uired (e.g. obj is static) */") + buff.append(f"static void handle_{self.cleanup_marker}(void *d= ata, /* XXX: fill header */)") + buff.append("{") + buff.append("\tint id =3D /* XXX: how do I get the id? */;") + buff.append("\tda_destroy_storage(id);") + buff.append("}") + buff.append("") return '\n'.join(buff) =20 def fill_tracepoint_attach_probe(self) -> str: buff =3D [] for event in self.events: buff.append(f"\trv_attach_trace_probe(\"{self.name}\", /* XXX:= tracepoint */, handle_{event});") + if self.monitor_type =3D=3D "per_obj": + buff.append(f"\trv_attach_trace_probe(\"{self.name}\", /* XXX:= cleanup tracepoint */, handle_{self.cleanup_marker});") return '\n'.join(buff) =20 def fill_tracepoint_detach_helper(self) -> str: buff =3D [] for event in self.events: buff.append(f"\trv_detach_trace_probe(\"{self.name}\", /* XXX:= tracepoint */, handle_{event});") + if self.monitor_type =3D=3D "per_obj": + buff.append(f"\trv_detach_trace_probe(\"{self.name}\", /* XXX:= cleanup tracepoint */, handle_{self.cleanup_marker});") return '\n'.join(buff) =20 def fill_model_h_header(self) -> list[str]: --=20 2.54.0 From nobody Mon Jun 8 19:42:34 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 A55BD347BA7 for ; Wed, 27 May 2026 06:24:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863066; cv=none; b=tSBJUy5OA/voDOjXa0GL+v8CWPllL/VE/7ltGPIQREP3ADeTi50gNHx2vqVUrS8mug6RJJKol/o8aGSitHpn/0fchZiSdGtrXML1rUrE++Iha6dhRMGRmgH3dqZteRZ/FtXT1o1OP3CK+UaT6UZ5LvmokKlmwmMTTywXLJKu/HE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779863066; c=relaxed/simple; bh=ycbOGxAnuln/eZgsEbhzGMwVZ7toxRRhvRYiTsjvklA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IjUxaKp+KQt9CGn32o7mmIDj9i8Nih+fJsXav622t+Xs0ws9+NhYb2DkD5eWucY73mDYI2evcNIY+oNDhTkBELSPMbPlfhby3jrMEuaPG4xwEtXkCWKUPHu4dWc5P6QJv3ENPe50zctzkm8xdiml4GQPf+l2vnKmZIcOvpsC8E4= 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=gGFDq5Yb; arc=none smtp.client-ip=170.10.133.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="gGFDq5Yb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779863059; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ppGbxUPvKHnT6F0AzjMFxgh+dzLoqNuAQdSjdw0IdxI=; b=gGFDq5Ybbl4fT89m84FRn6KYM6BgqXLH4J/eshcYRkVbYkd20zERKJE7PPveyJlSPzjRKc zeuJGQezAzEPjBL2grsaH+NEyJ34N0HHbX72GVwB2CAzhksLwgKr6YBHed/6DcjI1yB4Pp y/fR02O1j34JkhewFFIW7AR8nkvKbbA= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-512-kMgp5VTJO4ayLqWU7iuJwQ-1; Wed, 27 May 2026 02:24:16 -0400 X-MC-Unique: kMgp5VTJO4ayLqWU7iuJwQ-1 X-Mimecast-MFC-AGG-ID: kMgp5VTJO4ayLqWU7iuJwQ_1779863055 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3C36019560AA; Wed, 27 May 2026 06:24:15 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.32.86]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BBEF81800465; Wed, 27 May 2026 06:24:12 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , Nam Cao , linux-trace-kernel@vger.kernel.org Cc: Wen Yang Subject: [PATCH v2 12/12] verification/rvgen: Fix suffix strip in dot2k Date: Wed, 27 May 2026 08:23:12 +0200 Message-ID: <20260527062313.39908-13-gmonaco@redhat.com> In-Reply-To: <20260527062313.39908-1-gmonaco@redhat.com> References: <20260527062313.39908-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" __start_to_invariant_check() and __get_constraint_env() parse the environment variable's name from sources that have it padded with the monitor name. This is removed using rstrip(), which is not meant to strip a substring but rather a set of characters. Use removesuffix() to actually get rid of the trailing _. Fixes: a82adadb16894 ("verification/rvgen: Add support for Hybrid Automata") Signed-off-by: Gabriele Monaco --- tools/verification/rvgen/rvgen/dot2k.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/verification/rvgen/rvgen/dot2k.py b/tools/verification/r= vgen/rvgen/dot2k.py index a17294283a1f..3060aa4b945d 100644 --- a/tools/verification/rvgen/rvgen/dot2k.py +++ b/tools/verification/rvgen/rvgen/dot2k.py @@ -230,14 +230,14 @@ class ha2k(dot2k): def __get_constraint_env(self, constr: str) -> str: """Extract the second argument from an ha_ function""" env =3D constr.split("(")[1].split()[1].rstrip(")").rstrip(",") - assert env.rstrip(f"_{self.name}") in self.envs + assert env.removesuffix(f"_{self.name}") in self.envs return env =20 def __start_to_invariant_check(self, constr: str) -> str: # by default assume the timer has ns expiration env =3D self.__get_constraint_env(constr) clock_type =3D "ns" - if self.env_types.get(env.rstrip(f"_{self.name}")) =3D=3D "j": + if self.env_types.get(env.removesuffix(f"_{self.name}")) =3D=3D "j= ": clock_type =3D "jiffy" =20 return f"return ha_check_invariant_{clock_type}(ha_mon, {env}, tim= e_ns)" --=20 2.54.0