From nobody Fri Jun 12 21:33: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 426183A48C6 for ; Tue, 12 May 2026 14:03:12 +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=1778594594; cv=none; b=X9dvvwWxnKRJEYuX/9yuRkDjiCaHiVR3cUKchowWzqN45zsPV4XH/1BL8i3rQcBf7JWUOMrzfWEyGh1pzeZGouOlSqs1ZKfpVkE0qNlbwVWuW3nFHxh/jUcfpTsRkwAnX3Np+htvIT4Iqz2qwFjm/tOgoOof0xViqAU0x1qURZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778594594; c=relaxed/simple; bh=sKQwdKKL/JMpRHTTOh3jn4xUyP5t5QnoujPIwQmXG34=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ne5hcEja5dH+zROuGsBO5eQdDjCxYo4LCcNzklqiwZ7C2DHhm2+rE77EzWLZWQH5S1tuYpCJJ+0xwCcG/K2+YJ4MgBnDdObzL2I9wqsmBPfCiadD6Lm03XvH5wjQxQjc6+2dMiU3KWWqeLK77B/DuXYAw+ZY3cvEhlAv7KXrBYc= 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=drD1PAkj; 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="drD1PAkj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778594592; 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=srBIRipIOpUCo0r8OoyxLtPUrnK6wFC7oQvN0EhexUM=; b=drD1PAkjZMD3u97uitSEfZh1uqJgAoiQzxkMIiDZcw1kVf20sZISYfybsTT6E3rEt69/M3 oHCSX2LDpKfILE2qeE1H5F3I0qWaInaTRfFreiEl+dZlx4l7J4v6eRGt+kwkmNWq0m/RMZ 9DikRTIky6Bh3N/yPmv+qzFLKb3J3EY= 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-512-HoSHA4RrPa2qp1yvx0DXZA-1; Tue, 12 May 2026 10:03:03 -0400 X-MC-Unique: HoSHA4RrPa2qp1yvx0DXZA-1 X-Mimecast-MFC-AGG-ID: HoSHA4RrPa2qp1yvx0DXZA_1778594582 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 24C7A1800367; Tue, 12 May 2026 14:03:00 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.34.139]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0707D1800591; Tue, 12 May 2026 14:02:56 +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 1/9] rv: Fix __user specifier usage in extract_params() Date: Tue, 12 May 2026 16:02:42 +0200 Message-ID: <20260512140250.262190-2-gmonaco@redhat.com> In-Reply-To: <20260512140250.262190-1-gmonaco@redhat.com> References: <20260512140250.262190-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") Signed-off-by: Gabriele Monaco Reviewed-by: Wen Yang --- 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 Fri Jun 12 21:33: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 DB9793A599D for ; Tue, 12 May 2026 14:03:13 +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=1778594595; cv=none; b=M+QzluE4a6CnuAuha/R4IJzh9AZEVXVgrKLXtghCgAjBbm2XH+t7AfSLHLUikw+UyPsgOljAzferqhIrrHBQ4J7cBMJdcO2vkyt6wUgcKiu/+uq3SwEfZ5E5Tgtjc2RNfZNlEkCpZd0v0rHK0a+1KGHKvBIf5oHXJjszuj5oSR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778594595; c=relaxed/simple; bh=KiLKwPoJlA2vEfRaq9M95ZmvMaQej3NzbE2j+tTZLcI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UcheX0xIfLFwtYU5J8QDG2DOmwCkLCsQTGywA6PDfcajOUnosw/z9ZBXuULsQlHCKnDS1rQm9ouFHolAWm3iUfvOm52FpPGL+sx+FLQ0LHWnA9NMUrqrAdKODrzWeNtPTnifT9lHI/Ywir/wRU4+dtWIx3y1ISRI5N64SXnm7bM= 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=XiSNx2uC; 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="XiSNx2uC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778594593; 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=aHElBfRuNx3SycBITv8R/wJt3ZRVorE+97ws8GUTNok=; b=XiSNx2uCgTMiclnMvi7XFer1v+IYrnfy56IHRTHDdpnPN8j5gi/A3DBIBRmP901x4Mks4I 7O+TwSrROTiB7cAZnJHsj1iQYJFkTnEEuH2MdM5pg5oajv5GqTcg5D4tPJLPdxDwzRlF2Y AiflPyvKaSCglJo4cSb8fcK4OGJXTH8= 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-655-PFzwYH41Ph2PfyKtBmClNQ-1; Tue, 12 May 2026 10:03:05 -0400 X-MC-Unique: PFzwYH41Ph2PfyKtBmClNQ-1 X-Mimecast-MFC-AGG-ID: PFzwYH41Ph2PfyKtBmClNQ_1778594584 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 9AE2B1955F03; Tue, 12 May 2026 14:03:03 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.34.139]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3DA8A1800240; Tue, 12 May 2026 14:03:00 +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 2/9] rv: Fix read_lock scope in per-task DA cleanup Date: Tue, 12 May 2026 16:02:43 +0200 Message-ID: <20260512140250.262190-3-gmonaco@redhat.com> In-Reply-To: <20260512140250.262190-1-gmonaco@redhat.com> References: <20260512140250.262190-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") Signed-off-by: Gabriele Monaco Reviewed-by: Wen Yang --- 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 Fri Jun 12 21:33: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 3DEA83A7D98 for ; Tue, 12 May 2026 14:03:15 +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=1778594596; cv=none; b=hcyAgMC3DKzU3q7M4fpxrh5MPakuwdSaBs244vR0mzkGFd+AnbX/Tx1LJ9eLebZApivYdnih8C1M1S7YwnKbn1IFP+b1vmROIQNSHRDmSwF28aDtYEaAhvUxGegLfc/ppBDCpoz2Gc2du7NvjncyD4/Sqt2d9qv8o+wEJmrbWO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778594596; c=relaxed/simple; bh=G2dxhYV8b68zGT1Hgku5dCKmGIEML0IemM2I2YbedU4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fgE381WYIf6HURpWyhTbGkH92awdXjG7mD3wC3eUls3v99zdSz51H6nWEhAWrLwB1wwZMZpMZf0NWDbeCbnwNyO4DqueVn6bypE2zjkCAA7rRqhPu/oQGF9X2NFW8yRq1GcVpxE/sb/7DkkEKKiA0+lYxVYlY+uC7VmRuhifsfU= 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=feNycSn2; 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="feNycSn2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778594594; 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=EvfKR93hyiPppA7Uwohf3hx+XK0GIX0z8gBzIkmsYw0=; b=feNycSn2AD6s6OxsNh7NDfOUQDFVo2K5lpLjZsxxG3DueYRUIptzyRBmhpoW7+6IbNvEvC EGcSdZDoCn1l4yPeSYisz9Z631ep8MgdDGmEIw8ITtXJorS4GVoZVb2zA6EcNFmEpZ4GdY bGph61ktiDKAJLaLVp70wx0cDqeHgKA= 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-687-zXTRIZvPMROC5j3VunenFQ-1; Tue, 12 May 2026 10:03:09 -0400 X-MC-Unique: zXTRIZvPMROC5j3VunenFQ-1 X-Mimecast-MFC-AGG-ID: zXTRIZvPMROC5j3VunenFQ_1778594587 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 D885F19560AF; Tue, 12 May 2026 14:03:06 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.34.139]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A3D441800465; Tue, 12 May 2026 14:03:04 +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 3/9] rv: Reset per-task DA monitors before releasing the slot Date: Tue, 12 May 2026 16:02:44 +0200 Message-ID: <20260512140250.262190-4-gmonaco@redhat.com> In-Reply-To: <20260512140250.262190-1-gmonaco@redhat.com> References: <20260512140250.262190-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: 30984ccf31b7f ("rv: Refactor da_monitor to minimise macros") Fixes: 792575348ff70 ("rv/include: Add deterministic automata monitor defin= ition via C macros") Signed-off-by: Gabriele Monaco Reviewed-by: Wen Yang --- 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 Fri Jun 12 21:33: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 4AC7F3AB482 for ; Tue, 12 May 2026 14:03:18 +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=1778594601; cv=none; b=mWI9gDfske9kbp9Hqmi2oLF2gtdMtlYgggDqwXhYXPdZVtX49u7Fh7l6cYLY+datOt2DCrbx5UDH2Tr3IOEzKXuKKjo0t4WL+6hlQdFgEnk1Qr2CK+0XdO4iqv6Q7/jG3PnwswHvsUXlsFb4tzAjUZEM5CZWsXaK/umJi29oyHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778594601; c=relaxed/simple; bh=N1apW1tBvb0a/mnB0ObiEYuE3Fuc0xbXMl1UEGlCu8I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gaxZeWK6GNiIES/uVzIyBkulPXbQwIKkFiT1inENPCy9PkGFE9dZqV5aSFrBttO/y62S+yCVy1G/+VEcrMEY8Pk6+SdUvPxOGXzNYZxpxtpYzNKUMB7VYbgPcUZWCC4j/q+OwzvF9UER54yPHfI6Xwj6ZtSY86yMQ8arCd9ajBo= 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=KwuquXQf; 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="KwuquXQf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778594597; 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=owPVbqfN1q1NzH+2NJbTR29TZuwOEggaR1L0dz2AxsQ=; b=KwuquXQfjojBmvBJLMT5yjyZQW3ZQhIpHlrTkG6vhRif+QBLsXdYbikcp3WGPRS8B5Xj8j co14jDOpncEdte5/ETJjJIbh5Msp2kBqJmjWWSTLplWQt+1H/O+OCk8L7xitcYOAztb95o qdqV0kd5CUyo4Z12ULvnfSrmLrHkPXA= 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-449-n4iYhkE4MF65Po6Md3w9rA-1; Tue, 12 May 2026 10:03:12 -0400 X-MC-Unique: n4iYhkE4MF65Po6Md3w9rA-1 X-Mimecast-MFC-AGG-ID: n4iYhkE4MF65Po6Md3w9rA_1778594590 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 74F951800367; Tue, 12 May 2026 14:03:10 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.34.139]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E62AC180058F; Tue, 12 May 2026 14:03:07 +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 4/9] rv: Prevent task migration while handling per-CPU events Date: Tue, 12 May 2026 16:02:45 +0200 Message-ID: <20260512140250.262190-5-gmonaco@redhat.com> In-Reply-To: <20260512140250.262190-1-gmonaco@redhat.com> References: <20260512140250.262190-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. Signed-off-by: Gabriele Monaco Reviewed-by: Wen Yang --- 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 Fri Jun 12 21:33: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 46B473AB470 for ; Tue, 12 May 2026 14:03:21 +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=1778594602; cv=none; b=ewnp+JzZsucCWtbxuOwPxZGcbkacnZ//Rw6oOurI6ORkQ7mMNgJoITweXIic38wf4X4zJhsA+U6LIs1oEFIfF41NdcSC4T+nA56059AMD6UxLYTpgYKvYylKiVA9EcwxkkeWG8eHZkhz5xZxwoDHFlQya471m9Nc0BinOTJvpmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778594602; c=relaxed/simple; bh=dtRzpASfbz4qs7QnMxiUBF7GyWMlODsA475dPUppOUA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IZSslBdTtHgGzF8RSWq9/t3SYgEX2P1mdWCSQS4kan1oAHTkFIr9a4PITnOsGCy1Q1QySDzNXJvIKcbyAIfdFsr9gkocD+bqnzPPTEMvrZfktSpWoBWclPrrPpA6vaPrnWtKIU6qEyJnt55Af0Y4qRn9gFCemOXxyRJ2Od8e2/E= 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=QtQXlCac; 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="QtQXlCac" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778594600; 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=oVbHQ3XoNdxH14KbuMU+vAw7+4kZhF6YmDtmf6L30ys=; b=QtQXlCacLyNLScJigkM3q5U3sdAZHD7ToE0Q/If/urKu4NZXUdKIwVvKqGJSs4dWMS6UOj Dmic2fqqTdqoKsdU1iF6UgrtaRF0DlcdxtmBkZJIvlKhye9CPMFc5ipQmZRCH8kgtDBGX0 EkyDbZgvxvZN4eMhzn3dMWAn38W+e7M= 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-450-NW9Np98XOke5eNMLG3x8oA-1; Tue, 12 May 2026 10:03:15 -0400 X-MC-Unique: NW9Np98XOke5eNMLG3x8oA-1 X-Mimecast-MFC-AGG-ID: NW9Np98XOke5eNMLG3x8oA_1778594593 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 880AB1955F38; Tue, 12 May 2026 14:03:13 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.34.139]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5FA06180058F; Tue, 12 May 2026 14:03:11 +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 5/9] rv: Ensure all pending probes terminate on per-obj monitor destroy Date: Tue, 12 May 2026 16:02:46 +0200 Message-ID: <20260512140250.262190-6-gmonaco@redhat.com> In-Reply-To: <20260512140250.262190-1-gmonaco@redhat.com> References: <20260512140250.262190-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") Signed-off-by: Gabriele Monaco Reviewed-by: Wen Yang --- 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 a9fd284195ee..a4a13b62d1a4 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -515,9 +515,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 Fri Jun 12 21:33: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 D1C2B3ABD8B for ; Tue, 12 May 2026 14:03:24 +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=1778594608; cv=none; b=fnwJiUVYeBH5D9sMsqdy9aMfEnAP0o8ljBdKRPVsNXTWFNcHrmhSKvRGWKEn2qTQstHJom9/BJ5SAqvxzXlukKTNWbHAxtI/u+h2Xqiua4oCKZzE0tbO8h2HFXHFLJDuaTbQsMU5LZ2uL2bgAml/afUGw4Q85OuBDN3A8mfUzCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778594608; c=relaxed/simple; bh=CMvDRt0DeiW6fF3ZAWGefoLNZkapLo3tVmsf4T9vfH4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O+olvnV7Nt6fIBJ20E9KsmZPFXBWjsGuLnyXG3mJ08WzSjukrrMhM7B/EnCnDnIAf4ETbnV91OxybuwiDCIfFjjKfKh1nVkCdwOTXpGJGLWfxomNCQJ76P80tCDcOgC4RJ+6TtTUmDwyf3Y/13P4mI3IBN7aAS1TH8hCEHNRRWo= 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=g8yfu2Z4; 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="g8yfu2Z4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778594603; 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=3DGmMMzpxQnJTgG2CrsqckzfULPpTAcPaW5CCkRQL0s=; b=g8yfu2Z4CwdW9UUKFinBE5FFuSQJw2QyU3csJbR3Jxl3NrIIMuMKZ17WDfHv3rGQq4RFdc KSznvy9HeIlItHfGRabrqrJB5OXftDg+GrmKvjgETS02L5flTQQFQr59eZCXAESs+PIvmb wxVsCrmwR7aeUR+bsL1h1qhH1g0y2rI= 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-252-c3BNwK4KN8WRg7Eu6Q9q4g-1; Tue, 12 May 2026 10:03:19 -0400 X-MC-Unique: c3BNwK4KN8WRg7Eu6Q9q4g-1 X-Mimecast-MFC-AGG-ID: c3BNwK4KN8WRg7Eu6Q9q4g_1778594597 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 3D4E718005B5; Tue, 12 May 2026 14:03:17 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.34.139]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BC0C21800465; Tue, 12 May 2026 14:03:14 +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 6/9] rv: Ensure synchronous cleanup for HA monitors Date: Tue, 12 May 2026 16:02:47 +0200 Message-ID: <20260512140250.262190-7-gmonaco@redhat.com> In-Reply-To: <20260512140250.262190-1-gmonaco@redhat.com> References: <20260512140250.262190-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. 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 | 23 +++++++++++++++++++---- include/rv/ha_monitor.h | 18 ++++++++++++++++-- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index a4a13b62d1a4..402d3b935c08 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 @@ -179,6 +188,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 @@ -232,6 +242,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 @@ -319,6 +330,7 @@ static inline void da_monitor_destroy(void) } =20 da_monitor_reset_all(); + da_monitor_sync_hook(); =20 rv_put_task_monitor_slot(task_mon_slot); task_mon_slot =3D RV_PER_TASK_MONITOR_INIT; @@ -497,10 +509,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) @@ -516,13 +527,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..47ff1a41febe 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,25 @@ 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; + + if (unlikely(!da_monitor_handling_event(&ha_mon->da_mon))) + return; =20 + guard(rcu)(); + curr_state =3D READ_ONCE(ha_mon->da_mon.curr_state); + 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 Fri Jun 12 21:33: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 90DC33A599E for ; Tue, 12 May 2026 14:03:29 +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=1778594611; cv=none; b=YY2xDF2iIJma1tj+hlKaWMRg0XY5MCymRlSg2rd3Apeltef5cppSFR+JIGrcoKT8dKNSXGVUWSatAJRnh5qWEWcC0mrjlJljvlJ+Xe6Zq0wJhiTzLtbm5fIXyQEw9X3pHXevRHvmZugb48EXv39vczHCFzO5tjE35ac88lz2JHA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778594611; c=relaxed/simple; bh=GqmOOXiZ4Sw6hB5sOcbJyLBH+U2OPWqH6Rch/tgYZtE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ai8bGxUmSS6s0aF6o3hgUf6xa8ajXPY003COOr/lcTYplj+4U32StvvHpLA6zKFCFbCIAR+y3AzioObqm+P8bJB+NDIlAP4xrE2/AIVlDutRSCSPKRt2K19E3rCppFUT8J18Ss4nGOswVzb6ITWfMkbNemxtEWs1jaPWaY7Q6KU= 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=KcSD5bmj; 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="KcSD5bmj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778594608; 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=YcWlDHY2UKsARXUo4F85F1K8+bqt3pAPESRTfWgsXBk=; b=KcSD5bmj6s9TbWBrFinlEYPUxy3rSLMYC4P/7vnK2PU0CfiJg1yX4d/hT2nnHwkbTAkHiq WaeUFHym+7BobpNl6Pm9v3aByFMWx9clyVZnTnhaK8AargwW256K4a6FIx9LpwKaJzSsbv KwMC/wik4Iuhlh/+yCbY+UXppU00URM= 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-482-mHfxql_GM_i1CJ8HmFjyhQ-1; Tue, 12 May 2026 10:03:23 -0400 X-MC-Unique: mHfxql_GM_i1CJ8HmFjyhQ-1 X-Mimecast-MFC-AGG-ID: mHfxql_GM_i1CJ8HmFjyhQ_1778594601 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 771DF1956089; Tue, 12 May 2026 14:03:21 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.34.139]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C2571180034E; Tue, 12 May 2026 14:03:18 +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 7/9] rv: Do not rely on clean monitor when initialising HA Date: Tue, 12 May 2026 16:02:48 +0200 Message-ID: <20260512140250.262190-8-gmonaco@redhat.com> In-Reply-To: <20260512140250.262190-1-gmonaco@redhat.com> References: <20260512140250.262190-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") Signed-off-by: Gabriele Monaco Reviewed-by: Wen Yang --- 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 47ff1a41febe..11ae85bad492 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 Fri Jun 12 21:33: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 A2AD53ADBBA for ; Tue, 12 May 2026 14:03:30 +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=1778594612; cv=none; b=arbO9fIJVx3e9UI6OkUcO2uLtPuRtASRiHU3hRcERPLqklihU8HszFCKslBkWry+SYS/55C6laBdXAV3mXvMFj1jvhu2BefKGAWgAssWmVuQM3cyBuh9rT3sPJVIqLO8aa4tznwbNXBU0VrjVyg7GCs2/7/lAtDRJQbTDcbzb6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778594612; c=relaxed/simple; bh=GAomGDFN+V8Bk7b2EiA0gaFkeifiLuHq+9BUu3PJp2U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fn8Xm+YCW4AGjLZLUDUwqcfJkz4hUgumLmuYibUXHMuPmdmTCVdzDY9ywLwT4ruliBDae3KrZUtQGrgaF2FteGMihtZGDS6NZx1xMJkfl4iGBcmJtEvYXU9ktpUTq0gA1ptq0vxpjT9u3oWGHijTqBJ/reI6r1qTsVoCG8R5rBU= 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=YD2t7JIx; 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="YD2t7JIx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778594609; 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=CUIyfZL4degM0iStc9eEuLhlJ1lbfvR/WbnZNVjPTkY=; b=YD2t7JIxTbaneekJG/vROchEpETYgz0H/62bUyynOAHlYj4jb/YiQ3RokQQ2DpGvT90N6O OB/hwkH5LDbTMhFNCAHDxWEnNza7j7eHVN7bIJHzsaGgECmIVTcfHoYidziAgHOfYSc1jo 4cmuxsEB6dQxMq+s8gQfVZt+4FyBk0Q= 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-595-T5Hf88CuOiGy_6ngOOv5FA-1; Tue, 12 May 2026 10:03:26 -0400 X-MC-Unique: T5Hf88CuOiGy_6ngOOv5FA-1 X-Mimecast-MFC-AGG-ID: T5Hf88CuOiGy_6ngOOv5FA_1778594604 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 C8B9B19560A5; Tue, 12 May 2026 14:03:24 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.34.139]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6E1A91800465; Tue, 12 May 2026 14:03:22 +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 8/9] rv: Add automatic cleanup handlers for per-task HA monitors Date: Tue, 12 May 2026 16:02:49 +0200 Message-ID: <20260512140250.262190-9-gmonaco@redhat.com> In-Reply-To: <20260512140250.262190-1-gmonaco@redhat.com> References: <20260512140250.262190-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 | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/include/rv/ha_monitor.h b/include/rv/ha_monitor.h index 11ae85bad492..1bdf866e9c63 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() +#define ha_monitor_disable_hook() +#endif + #include #include =20 @@ -124,12 +145,14 @@ static int ha_monitor_init(void) =20 ha_mon_initializing =3D true; ret =3D da_monitor_init(); + 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 +253,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 /* @@ -455,6 +490,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. @@ -506,6 +545,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 @@ -516,6 +559,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 Fri Jun 12 21:33: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 3CE5E3B1006 for ; Tue, 12 May 2026 14:03:37 +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=1778594618; cv=none; b=FcC4bxR1ROl6l5DGGokqzP7Dv9F1TCkM9eksuBXUeVDhg40ilKu5I8t2jKCvefQfT1UVHvig+Suwvr/o7303cVwX1QSO+BRpL2P81lWexosaRA9JVhKqr8PRnX0SToHy1Mhd8At+/4azbL+GZyhYiwZuoOI30j5b0kliutffL/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778594618; c=relaxed/simple; bh=MGsCy6a/03Tru/K86yGXtlI7rW3UZ+q9/pItj6ioCRg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r66Pjz3Q+hrAsj/fLU5Rr5PdcZzSL7xGdyr+jq9hCDPq0jYIaZ81N2hfepUZEXFbbR7jAtcjZGEYJ69ra5Ov7uihh4mQCU4DNpguk6dH9CNfjdTUu59kg1er+I+yBlQAv9i1Ct0KAlkUEfpCPmAjD3TFyw5rMYyW3mbiYCorK10= 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=JS68If2v; 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="JS68If2v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778594616; 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=34iVkgyuSbdZIlP4LocXZUjRKrJSBP3FogRNdoHZkhI=; b=JS68If2vgh0S8jPnFJV1zGRkSiUxROwjOWz9zBKPmuuB261qcPSDqfqpPxhBn624t2WlhS 6aeAowxEyoWE1ycJbosUuwlUZN9jlUHQ6OEOKLwjinan8PQy9MQtws/6cNzViCOIMFa6nW itvvPlEkCRHOwJOs8ctq2bOZSNtfXl8= 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-6U-3kSpCOMeKNOesZbgryw-1; Tue, 12 May 2026 10:03:30 -0400 X-MC-Unique: 6U-3kSpCOMeKNOesZbgryw-1 X-Mimecast-MFC-AGG-ID: 6U-3kSpCOMeKNOesZbgryw_1778594608 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 72EDC1956062; Tue, 12 May 2026 14:03:28 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.34.139]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D8D341800465; Tue, 12 May 2026 14:03:25 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , Masami Hiramatsu , linux-trace-kernel@vger.kernel.org Cc: Nam Cao , Wen Yang Subject: [PATCH 9/9] rv: Mandate deallocation for per-obj monitors Date: Tue, 12 May 2026 16:02:50 +0200 Message-ID: <20260512140250.262190-10-gmonaco@redhat.com> In-Reply-To: <20260512140250.262190-1-gmonaco@redhat.com> References: <20260512140250.262190-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 per-object monitors use a hash tables and dynamic allocation of the monitor storage, functions to clean a monitor that is no longer needed are provided but nothing ensures the monitor actually uses them. Remove the inline specifier on the deallocation function to let the compiler warn in case it isn't referenced. If the monitor really doesn't need one (for instance because instances will never cease to exist before disabling the monitor), the da_skip_deallocation() helper macro can be used to silence the warning. Signed-off-by: Gabriele Monaco --- include/rv/da_monitor.h | 14 +++++++++++++- kernel/trace/rv/monitors/deadline/deadline.h | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index 402d3b935c08..378d23ab7dfb 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -489,8 +489,11 @@ static inline monitor_target da_get_target_by_id(da_id= _type id) * locks. * This function includes an RCU read-side critical section to synchronise * against da_monitor_destroy(). + * NOTE: inline is omitted on purpose to let the compiler warn if this fun= ction + * is never referenced. For monitors that don't require a deallocation hoo= k, + * da_skip_deallocation() can be used. */ -static inline void da_destroy_storage(da_id_type id) +static void da_destroy_storage(da_id_type id) { struct da_monitor_storage *mon_storage; =20 @@ -504,6 +507,15 @@ static inline void da_destroy_storage(da_id_type id) kfree_rcu(mon_storage, rcu); } =20 +/* + * da_skip_deallocation - explicitly mark a deallocation function as not r= equired + * + * Only use when you are absolutely sure the monitor doesn't require a + * deallocation hook (i.e. it's not possible for an object to finish exist= ing + * when the monitor is still running). + */ +#define da_skip_deallocation(hook) ((void)hook) + static void da_monitor_reset_all(void) { struct da_monitor_storage *mon_storage; diff --git a/kernel/trace/rv/monitors/deadline/deadline.h b/kernel/trace/rv= /monitors/deadline/deadline.h index 78fca873d61e..c39fd79148c2 100644 --- a/kernel/trace/rv/monitors/deadline/deadline.h +++ b/kernel/trace/rv/monitors/deadline/deadline.h @@ -194,7 +194,10 @@ static void __maybe_unused handle_newtask(void *data, = struct task_struct *task, da_create_storage(EXPAND_ID_TASK(task), NULL); } =20 -static void __maybe_unused handle_exit(void *data, struct task_struct *p, = bool group_dead) +/* + * Deallocation hook, use da_skip_deallocation() when not necessary + */ +static void handle_exit(void *data, struct task_struct *p, bool group_dead) { if (p->policy =3D=3D SCHED_DEADLINE) da_destroy_storage(get_entity_id(&p->dl, DL_TASK, DL_TASK)); --=20 2.54.0