From nobody Sat Feb 7 19:04:22 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 B01BC221543 for ; Wed, 14 May 2025 08:43:36 +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=1747212218; cv=none; b=Yjmt6PInMK3yknLi50ICzAYj1LNXFq7gSM6JyJdduz6e9WGB4OShh7VNeP9DrMP0Ipo6i6peVl8y/bJtp5v0o++POxcS0ooVBMR7545nyT31C4wZgW4rTg2LnTeEODA5Pj9qF4Z3ROErIzq7BCIitZsTkwyYh+xso7YUQK2jUkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747212218; c=relaxed/simple; bh=xbba+HPd8MJ7D54Gm2+hTQ1NpiuwAK3ud94lCs8HFpw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=erHhazPsAth9gUJ8tYqkO3VVJbKX0xfNBOsSF7IHf1vUCxTZMy6XQp1Pz6S1ZLtUexMUjVGAZ/PocM8kbR92jvfF3A6Gu4Jesrt3juzYkMvGRK2cXDa52vuu3+YhcfuewQvtbMLYubhB3z9KN7wW04hpMa31n+ThHvVnvy+kYyI= 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=cGkhtOyK; 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="cGkhtOyK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747212215; 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=6P2sRzfZTL4Az26XMlLruEd1Y1bAoWFiw+u4PxoZUpc=; b=cGkhtOyKVmNfglnqAHtbH+bjUDebgMi7aX8Xxw9YYVmLgQM4baKUQIya6c743/XQ1VMNkT uegYny44bhbm5JUNzVBWCedHcdTHpW+GDZUBzihEmqC/prd1yRILwcNcWb1XdXUAFHzb0n ZrJIjmnjnbIHwuNHSqwVjblwGf9Y6Ew= 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-602-qovYGxfTOr2KeWauFONYew-1; Wed, 14 May 2025 04:43:32 -0400 X-MC-Unique: qovYGxfTOr2KeWauFONYew-1 X-Mimecast-MFC-AGG-ID: qovYGxfTOr2KeWauFONYew_1747212211 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 CD3541800446; Wed, 14 May 2025 08:43:30 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.com (unknown [10.44.32.189]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0A3BD1945CB4; Wed, 14 May 2025 08:43:25 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , linux-trace-kernel@vger.kernel.org Cc: Gabriele Monaco , Ingo Molnar , Peter Zijlstra , Nam Cao , Tomas Glozar , Juri Lelli Subject: [RFC PATCH v2 01/12] tools/rv: Do not skip idle in trace Date: Wed, 14 May 2025 10:43:03 +0200 Message-ID: <20250514084314.57976-2-gmonaco@redhat.com> In-Reply-To: <20250514084314.57976-1-gmonaco@redhat.com> References: <20250514084314.57976-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.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" Currently, the userspace RV tool skips trace events triggered by the RV tool itself, this can be changed by passing the parameter -s, which sets the variable config_my_pid to 0 (instead of the tool's PID). The current condition for per-task monitors (config_has_id) does not check that config_my_pid isn't 0 to skip. In case we pass -s, we show events triggered by RV but don't show those triggered by idle (PID 0). Fix the condition to account this scenario. Fixes: 6d60f89691fc ("tools/rv: Add in-kernel monitor interface") Signed-off-by: Gabriele Monaco --- tools/verification/rv/src/in_kernel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/verification/rv/src/in_kernel.c b/tools/verification/rv/= src/in_kernel.c index c0dcee795c0d..72b03bae021c 100644 --- a/tools/verification/rv/src/in_kernel.c +++ b/tools/verification/rv/src/in_kernel.c @@ -429,7 +429,7 @@ ikm_event_handler(struct trace_seq *s, struct tep_recor= d *record, =20 tep_get_common_field_val(s, trace_event, "common_pid", record, &pid, 1); =20 - if (config_has_id && (config_my_pid =3D=3D id)) + if (config_my_pid && config_has_id && (config_my_pid =3D=3D id)) return 0; else if (config_my_pid && (config_my_pid =3D=3D pid)) return 0; --=20 2.49.0 From nobody Sat Feb 7 19:04:22 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 D94562206BD for ; Wed, 14 May 2025 08:43: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=1747212224; cv=none; b=WcfXHrSf4jdtHQSumdtAwX5s4JrmdojBabDm0C7XAN2JrG+nzRyRLmtHV2FNrLXBRDP9jYlTWICj0k58li96JCucONoRCOdL9Qy3T/bwj8L3b0w0YG/0qMd5zY+s4B/L34Y1o0NWrSIopcZaMZg+GO2GR5Z/AKexULW2P3KDKK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747212224; c=relaxed/simple; bh=aa0yBCj5Uc8ViLkWVXhe6sm0SudMlPvZVxqhayesnFc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lXfhbk0GxeA4ghIPOqMeBc+WTslsh51UO41yOq6DJqi6FoVct8RTeMZ4pe5hH00V7gbnlafr0L8Tf7wIWSv5RXKGyoLisIP0WZLnCx2ehVHq9rIJ9tpPUxtTbnrUKj+JMxunH1MtOOeir1h+sKXvLvut1+1Oqe+RZaJH7fGVk8c= 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=Ymh9rx9S; 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="Ymh9rx9S" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747212220; 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=KUYsFBJRChIzXZJ15VUeSQZOoGnGxm1gqR07l2fP+ss=; b=Ymh9rx9SIBd03JBqqHnqJDw2g6y5n/4Bbl6pQs2QSnFoH87huHxfVc6pPENf3aHiy2HWZD sf82ceC5TNplWivq2ceWw6OB4wtCsKsh9wOfQ7eq0uSoJ/JE+MkE1cHM1IvXcWJmf3/iBG 1BMfRFuVCrNRp5J/USCOco7JNmRe2FE= 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-587-IP33Z__RPF6xpFXiY0taPA-1; Wed, 14 May 2025 04:43:37 -0400 X-MC-Unique: IP33Z__RPF6xpFXiY0taPA-1 X-Mimecast-MFC-AGG-ID: IP33Z__RPF6xpFXiY0taPA_1747212216 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 463C318004A7; Wed, 14 May 2025 08:43:36 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.com (unknown [10.44.32.189]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C705A1945CB4; Wed, 14 May 2025 08:43:31 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , linux-trace-kernel@vger.kernel.org Cc: Gabriele Monaco , Ingo Molnar , Peter Zijlstra , Nam Cao , Tomas Glozar , Juri Lelli Subject: [RFC PATCH v2 02/12] tools/rv: Stop gracefully also on SIGTERM Date: Wed, 14 May 2025 10:43:04 +0200 Message-ID: <20250514084314.57976-3-gmonaco@redhat.com> In-Reply-To: <20250514084314.57976-1-gmonaco@redhat.com> References: <20250514084314.57976-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.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" Currently the userspace RV tool starts a monitor and waits for the user to press Ctrl-C (SIGINT) to terminate and stop the monitor. This doesn't account for a scenario where a user starts RV in background and simply kills it (SIGTERM unless the user specifies differently). E.g.: # rv mon wip & # kill % Would terminate RV without stopping the monitor and next RV executions won't start correctly. Register the signal handler used for SIGINT also to SIGTERM. Signed-off-by: Gabriele Monaco --- tools/verification/rv/src/rv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/verification/rv/src/rv.c b/tools/verification/rv/src/rv.c index 239de054d1e0..b8fe24a87d97 100644 --- a/tools/verification/rv/src/rv.c +++ b/tools/verification/rv/src/rv.c @@ -191,6 +191,7 @@ int main(int argc, char **argv) * and exit. */ signal(SIGINT, stop_rv); + signal(SIGTERM, stop_rv); =20 rv_mon(argc - 1, &argv[1]); } --=20 2.49.0 From nobody Sat Feb 7 19:04:22 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 F423920D4F4 for ; Wed, 14 May 2025 08:43:50 +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=1747212233; cv=none; b=h2ocJf+FEU8uIb1gYna/nC1v1QZEfWIO93YO4YHOZ0STbCYcEwSe5opdcNsme03QRdMiLrbJQ6c62PWQ3NB8h2VaNvfJWavtIENECi4vGpdjnSuFESumPIRz2zHQ12zavPYB6Q+umku1Gyv8zsC+MoxpQ8BbVQumqR4a97NFfwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747212233; c=relaxed/simple; bh=t5YF7ZRNaz9q2EPYPyAIqR71z7VJx5Ztej15EcEYpVQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rf9BSLwQIWezwIiaHHy47PPIxDZ3QaNpF9epZD2L89Lq2JSHgBvDYuziB7+WMtD4jadF+oaV3gSSgAlSbkaAxFLEISF/4in4VHgmDOppYWio+PKBAFs6ujcgWFiRZXlKIKL81+pqQptkG55rjg19QsrH874+/wBHxp4/nVqs5lU= 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=YDKJ92gE; 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="YDKJ92gE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747212229; 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=KRoRGCXU3N75lAiWUaCzoWUZ/uQ4F+w7zRjkjVXsgqU=; b=YDKJ92gEOslmrysHhlNW8kpM0rtGiQ4CcirKnAA9SNnE5EiJ8kVbjSu2QgRm59JyGH1c51 ukNoDXHA1VFj29cmMhUWJvHX0Or8GOmbN2h+8JamAnT0qBtySnZZ6jxD11KDg0FnxvzCfC Rl8CB2pw45uZ2DhhXxjSJ5WF6HUi2gU= 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-335-6RD3GlvWNxm06YaGDXE5mA-1; Wed, 14 May 2025 04:43:45 -0400 X-MC-Unique: 6RD3GlvWNxm06YaGDXE5mA-1 X-Mimecast-MFC-AGG-ID: 6RD3GlvWNxm06YaGDXE5mA_1747212223 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 3DEF71800361; Wed, 14 May 2025 08:43:42 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.com (unknown [10.44.32.189]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 439F81953B80; Wed, 14 May 2025 08:43:36 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , linux-trace-kernel@vger.kernel.org Cc: Gabriele Monaco , Ingo Molnar , Peter Zijlstra , Nam Cao , Tomas Glozar , Juri Lelli Subject: [RFC PATCH v2 03/12] rv: Add da_handle_start_run_event_ to per-task monitors Date: Wed, 14 May 2025 10:43:05 +0200 Message-ID: <20250514084314.57976-4-gmonaco@redhat.com> In-Reply-To: <20250514084314.57976-1-gmonaco@redhat.com> References: <20250514084314.57976-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.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" The RV da_monitor API allows to start monitors in two ways: da_handle_start_event_NAME and da_handle_start_run_event_NAME. The former is used when the event is followed by the initial state of the module, so we ignore the event but we know the monitor is in the initial state and can start monitoring, the latter can be used if the event can only occur in the initial state, so we do handle the event as if the monitor was in the initial state. This latter API is defined for implicit monitors but not per-task ones. Define da_handle_start_run_event_NAME macro also for per-task monitors. Signed-off-by: Gabriele Monaco Reviewed-by: Nam Cao --- include/rv/da_monitor.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index 510c88bfabd4..215c3eb770cc 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -512,6 +512,30 @@ da_handle_start_event_##name(struct task_struct *tsk, = enum events_##name event) __da_handle_event_##name(da_mon, tsk, event); \ \ return 1; \ +} \ + \ +/* \ + * da_handle_start_run_event_##name - start monitoring and handle event = \ + * \ + * This function is used to notify the monitor that the system is in the = \ + * initial state, so the monitor can start monitoring and handling event. = \ + */ \ +static inline bool \ +da_handle_start_run_event_##name(struct task_struct *tsk, enum events_##na= me event) \ +{ \ + struct da_monitor *da_mon; \ + \ + if (!da_monitor_enabled_##name()) \ + return 0; \ + \ + da_mon =3D da_get_monitor_##name(tsk); \ + \ + if (unlikely(!da_monitoring_##name(da_mon))) \ + da_monitor_start_##name(da_mon); \ + \ + __da_handle_event_##name(da_mon, tsk, event); \ + \ + return 1; \ } =20 /* --=20 2.49.0 From nobody Sat Feb 7 19:04:22 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 1B9F62206BD for ; Wed, 14 May 2025 08:43:50 +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=1747212232; cv=none; b=ogrxmMEq5SCP0iO6R6FHkt5gYoHyuut9M2p6vqDwdvfeu7MN+wZL2RMBzHGZ3aED/DNRHkVIp6z2fLQ8HhxtaD1+qXceC+KoV4wVLI9EhiXjtaOoYnKkqQyHyduSzRWZTZ3E7jQkmbxGeM6g8sKwjpG+5O61NTcS3dgYXw3WGK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747212232; c=relaxed/simple; bh=G+9IP7Cs8Jo7ZSa30o+CwpfbmuKLC9oUpzOqhaPmJHQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Oes/b7cJ9WXFdVLrQWquOEkHofZ+3izjjDFcDTkjqiG/ZQqiZIhlkIk5JHQI4zFdCpsG5PV89xjou2ALfCOWtiEM3R2NeSQ5abOt7KA3FTmtsDej3IBA69EqFaqA+iTRMVYbo5Xb2iwrUF/pOCWiGl+rxjfZjyt20ndAZEPyrB0= 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=FFs4hotj; 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="FFs4hotj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747212230; 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=k/0B7e/+aQ9kS8s2xGVWyP08UCQLU1fjIy8kpl8V0mM=; b=FFs4hotjPp+fWKsfMdtxB+atIr9VHBNadC8SQZU8aKWpORHbg83hZGyRotEakbTkD1X8JU 2sSgn+YiE06prOPCIvmhgz2bMp0crJelT2asJjfkogQ+08VmOXnlVMLsyBZoeWaOU2zA4H 4NT58BjEWglGG+Es1HII5QMRAtHbySs= Received: from mx-prod-mc-02.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-219-MCkGd4VfO_a-qQqm9EYgDQ-1; Wed, 14 May 2025 04:43:48 -0400 X-MC-Unique: MCkGd4VfO_a-qQqm9EYgDQ-1 X-Mimecast-MFC-AGG-ID: MCkGd4VfO_a-qQqm9EYgDQ_1747212227 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5BEF5195608C; Wed, 14 May 2025 08:43:47 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.com (unknown [10.44.32.189]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 271DC1953B80; Wed, 14 May 2025 08:43:42 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Masami Hiramatsu , linux-trace-kernel@vger.kernel.org Cc: Gabriele Monaco , Ingo Molnar , Peter Zijlstra , Nam Cao , Tomas Glozar , Juri Lelli Subject: [RFC PATCH v2 04/12] rv: Remove trailing whitespace from tracepoint string Date: Wed, 14 May 2025 10:43:06 +0200 Message-ID: <20250514084314.57976-5-gmonaco@redhat.com> In-Reply-To: <20250514084314.57976-1-gmonaco@redhat.com> References: <20250514084314.57976-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.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" RV event tracepoints print a line with the format: "event_xyz: S0 x event -> S1 " "event_xyz: S1 x event -> S0 (final)" While printing an event leading to a non-final state, the line has a trailing white space (visible above before the closing "). Adapt the format string not to print the trailing whitespace if we are not printing "(final)". Signed-off-by: Gabriele Monaco Reviewed-by: Nam Cao --- kernel/trace/rv/rv_trace.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/trace/rv/rv_trace.h b/kernel/trace/rv/rv_trace.h index 422b75f58891..18fa0e358a30 100644 --- a/kernel/trace/rv/rv_trace.h +++ b/kernel/trace/rv/rv_trace.h @@ -29,11 +29,11 @@ DECLARE_EVENT_CLASS(event_da_monitor, __entry->final_state =3D final_state; ), =20 - TP_printk("%s x %s -> %s %s", + TP_printk("%s x %s -> %s%s", __entry->state, __entry->event, __entry->next_state, - __entry->final_state ? "(final)" : "") + __entry->final_state ? " (final)" : "") ); =20 DECLARE_EVENT_CLASS(error_da_monitor, @@ -90,12 +90,12 @@ DECLARE_EVENT_CLASS(event_da_monitor_id, __entry->final_state =3D final_state; ), =20 - TP_printk("%d: %s x %s -> %s %s", + TP_printk("%d: %s x %s -> %s%s", __entry->id, __entry->state, __entry->event, __entry->next_state, - __entry->final_state ? "(final)" : "") + __entry->final_state ? " (final)" : "") ); =20 DECLARE_EVENT_CLASS(error_da_monitor_id, --=20 2.49.0 From nobody Sat Feb 7 19:04:22 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 DC0FB221D94 for ; Wed, 14 May 2025 08:43:59 +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=1747212241; cv=none; b=ubIVodW8YwZok3ikMyIxpgUKA69fCzZTuppH+eRG1SmhTD+G+6cbG4jjT0cn0O80xIsoAPN8/xsu47zxKSzvzxRE6Yr/WPd1RmZ8Hzk13BcbXqSv/Q+fhE0CUrmkOP+33+ysfqZ+EvzhFY9kSkTiu872S5gj+FybvVofimT43qQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747212241; c=relaxed/simple; bh=Q/gmaZitNUy7PGKIGZr56MbVLDyPJQIGg3ovMHnqkSA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JSOcj5GOnndQHBHrqPXdX2Zadb5NamsoBADpgq2lEEK6buB/gd1aSFMkfHm8hCSS5qBn2F3BTePZ3gGywF+GMivAm6Q9m2gRd+/6wAj5PfH3jFX4qXyIhroehos1UbbX1De2Rya8ZU+QTqneimV1fnPOGVuO1OcUx9UztdpdTZI= 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=GlxNmBZ7; 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="GlxNmBZ7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747212238; 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=cjnDKvTuWk25Od1hNCNKL2cK4eQ0a+O0r9zXXkmS0OU=; b=GlxNmBZ75z/vOZ+neHDUiMNQF/OEevO992HgMycwN+VlBw1NIx4oW98APnzZ+/yJWD2E7E UFZbJz1EAMjiMoDtpHzF9ILxCf22cUaTfZ5oZaFUpDocdA1Ydf6s9YZUDju3w06MuVMxDM sRhZcjZKc+M00Fj97rkgl4IUhOWDeuc= 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-115-5QifaTuZPKWLrTAWafHBNQ-1; Wed, 14 May 2025 04:43:54 -0400 X-MC-Unique: 5QifaTuZPKWLrTAWafHBNQ-1 X-Mimecast-MFC-AGG-ID: 5QifaTuZPKWLrTAWafHBNQ_1747212233 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 4D6F11800361; Wed, 14 May 2025 08:43:53 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.com (unknown [10.44.32.189]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2178A1953B80; Wed, 14 May 2025 08:43:48 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Masami Hiramatsu , linux-trace-kernel@vger.kernel.org Cc: Gabriele Monaco , Ingo Molnar , Peter Zijlstra , Nam Cao , Tomas Glozar , Juri Lelli Subject: [RFC PATCH v2 05/12] rv: Return init error when registering monitors Date: Wed, 14 May 2025 10:43:07 +0200 Message-ID: <20250514084314.57976-6-gmonaco@redhat.com> In-Reply-To: <20250514084314.57976-1-gmonaco@redhat.com> References: <20250514084314.57976-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.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" Monitors generated with dot2k have their registration function (the one called during monitor initialisation) return always 0, even if the registration failed on RV side. This can hide potential errors. Return the value returned by the RV register function. Signed-off-by: Gabriele Monaco Reviewed-by: Nam Cao --- kernel/trace/rv/monitors/sched/sched.c | 3 +-- kernel/trace/rv/monitors/sco/sco.c | 3 +-- kernel/trace/rv/monitors/scpd/scpd.c | 3 +-- kernel/trace/rv/monitors/sncid/sncid.c | 3 +-- kernel/trace/rv/monitors/snep/snep.c | 3 +-- kernel/trace/rv/monitors/snroc/snroc.c | 3 +-- kernel/trace/rv/monitors/tss/tss.c | 3 +-- kernel/trace/rv/monitors/wip/wip.c | 3 +-- kernel/trace/rv/monitors/wwnr/wwnr.c | 3 +-- 9 files changed, 9 insertions(+), 18 deletions(-) diff --git a/kernel/trace/rv/monitors/sched/sched.c b/kernel/trace/rv/monit= ors/sched/sched.c index 905e03c3c934..d04db4b543f9 100644 --- a/kernel/trace/rv/monitors/sched/sched.c +++ b/kernel/trace/rv/monitors/sched/sched.c @@ -21,8 +21,7 @@ struct rv_monitor rv_sched =3D { =20 static int __init register_sched(void) { - rv_register_monitor(&rv_sched, NULL); - return 0; + return rv_register_monitor(&rv_sched, NULL); } =20 static void __exit unregister_sched(void) diff --git a/kernel/trace/rv/monitors/sco/sco.c b/kernel/trace/rv/monitors/= sco/sco.c index 4cff59220bfc..66f4639d46ac 100644 --- a/kernel/trace/rv/monitors/sco/sco.c +++ b/kernel/trace/rv/monitors/sco/sco.c @@ -71,8 +71,7 @@ static struct rv_monitor rv_sco =3D { =20 static int __init register_sco(void) { - rv_register_monitor(&rv_sco, &rv_sched); - return 0; + return rv_register_monitor(&rv_sco, &rv_sched); } =20 static void __exit unregister_sco(void) diff --git a/kernel/trace/rv/monitors/scpd/scpd.c b/kernel/trace/rv/monitor= s/scpd/scpd.c index cbdd6a5f8d7f..299703cd72b0 100644 --- a/kernel/trace/rv/monitors/scpd/scpd.c +++ b/kernel/trace/rv/monitors/scpd/scpd.c @@ -79,8 +79,7 @@ static struct rv_monitor rv_scpd =3D { =20 static int __init register_scpd(void) { - rv_register_monitor(&rv_scpd, &rv_sched); - return 0; + return rv_register_monitor(&rv_scpd, &rv_sched); } =20 static void __exit unregister_scpd(void) diff --git a/kernel/trace/rv/monitors/sncid/sncid.c b/kernel/trace/rv/monit= ors/sncid/sncid.c index f5037cd6214c..3e1ee715a0fb 100644 --- a/kernel/trace/rv/monitors/sncid/sncid.c +++ b/kernel/trace/rv/monitors/sncid/sncid.c @@ -79,8 +79,7 @@ static struct rv_monitor rv_sncid =3D { =20 static int __init register_sncid(void) { - rv_register_monitor(&rv_sncid, &rv_sched); - return 0; + return rv_register_monitor(&rv_sncid, &rv_sched); } =20 static void __exit unregister_sncid(void) diff --git a/kernel/trace/rv/monitors/snep/snep.c b/kernel/trace/rv/monitor= s/snep/snep.c index 0076ba6d7ea4..2adc3108d60c 100644 --- a/kernel/trace/rv/monitors/snep/snep.c +++ b/kernel/trace/rv/monitors/snep/snep.c @@ -79,8 +79,7 @@ static struct rv_monitor rv_snep =3D { =20 static int __init register_snep(void) { - rv_register_monitor(&rv_snep, &rv_sched); - return 0; + return rv_register_monitor(&rv_snep, &rv_sched); } =20 static void __exit unregister_snep(void) diff --git a/kernel/trace/rv/monitors/snroc/snroc.c b/kernel/trace/rv/monit= ors/snroc/snroc.c index bb1f60d55296..540e686e699f 100644 --- a/kernel/trace/rv/monitors/snroc/snroc.c +++ b/kernel/trace/rv/monitors/snroc/snroc.c @@ -68,8 +68,7 @@ static struct rv_monitor rv_snroc =3D { =20 static int __init register_snroc(void) { - rv_register_monitor(&rv_snroc, &rv_sched); - return 0; + return rv_register_monitor(&rv_snroc, &rv_sched); } =20 static void __exit unregister_snroc(void) diff --git a/kernel/trace/rv/monitors/tss/tss.c b/kernel/trace/rv/monitors/= tss/tss.c index 542787e6524f..0452fcd9edcf 100644 --- a/kernel/trace/rv/monitors/tss/tss.c +++ b/kernel/trace/rv/monitors/tss/tss.c @@ -74,8 +74,7 @@ static struct rv_monitor rv_tss =3D { =20 static int __init register_tss(void) { - rv_register_monitor(&rv_tss, &rv_sched); - return 0; + return rv_register_monitor(&rv_tss, &rv_sched); } =20 static void __exit unregister_tss(void) diff --git a/kernel/trace/rv/monitors/wip/wip.c b/kernel/trace/rv/monitors/= wip/wip.c index ed758fec8608..4b4e99615a11 100644 --- a/kernel/trace/rv/monitors/wip/wip.c +++ b/kernel/trace/rv/monitors/wip/wip.c @@ -71,8 +71,7 @@ static struct rv_monitor rv_wip =3D { =20 static int __init register_wip(void) { - rv_register_monitor(&rv_wip, NULL); - return 0; + return rv_register_monitor(&rv_wip, NULL); } =20 static void __exit unregister_wip(void) diff --git a/kernel/trace/rv/monitors/wwnr/wwnr.c b/kernel/trace/rv/monitor= s/wwnr/wwnr.c index 172f31c4b0f3..4145bea2729e 100644 --- a/kernel/trace/rv/monitors/wwnr/wwnr.c +++ b/kernel/trace/rv/monitors/wwnr/wwnr.c @@ -70,8 +70,7 @@ static struct rv_monitor rv_wwnr =3D { =20 static int __init register_wwnr(void) { - rv_register_monitor(&rv_wwnr, NULL); - return 0; + return rv_register_monitor(&rv_wwnr, NULL); } =20 static void __exit unregister_wwnr(void) --=20 2.49.0 From nobody Sat Feb 7 19:04:22 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 ADB622222D3 for ; Wed, 14 May 2025 08:44: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=1747212245; cv=none; b=Ma6Yi+e9OySSUHd27qUxrsDe50ic0jj39WYCx2ZFR3yxpJ8WU5qhMmZ4zkuW183HDFKcncd9HMgnYLS6Skg7B9GajzzzwTKnUL+WzUfUZXue+HJwddQDU1OUsj+vkpsfPXq2boVMGCnU8Ao93l9/5ZuOhi+lyLFog7nxJat4stA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747212245; c=relaxed/simple; bh=VM5OiJN9Z257mj4pGFbU/IOKgo2qTzJwDQ+V5BjrtOY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OputCtB9gOruZ/4/OFZiRiFYBKVCQPfQ1mX6tSMqPt9zCaObNYM8k3GehqXtxMDk+WVaGsLgyabnalIqIX5EnV9rzhRGbXKx0DP2c0q1F3VStPd4tdguz69SQ8I/JP7BiWCQoik0/GsOCmdwen9qmidfM2hI541TMg8m9GgYl5o= 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=ihUjKg9I; 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="ihUjKg9I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747212242; 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=pxZyRZLrSNioQyNp9VBnZGfaP6hgfH1QQWD0nXaN4JQ=; b=ihUjKg9IXYLfUwQVQYkS5JCl2sv6eRKPRHDaKisst5O0XqWbioKfDovCSGIgIEOjM5WuFv aHaZmHxwfNfMMmCGdjTmMsIK4Z0tYE76gf/WEok5DL00wUN9OIxHhd5SFGbrLshicKAL8y noTcFq4tPkkGh3nIeXOVUWokfZOjuiA= 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-331-TN7pw6I4NNeXJW1yfMlhFg-1; Wed, 14 May 2025 04:43:59 -0400 X-MC-Unique: TN7pw6I4NNeXJW1yfMlhFg-1 X-Mimecast-MFC-AGG-ID: TN7pw6I4NNeXJW1yfMlhFg_1747212238 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 862D6180048E; Wed, 14 May 2025 08:43:58 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.com (unknown [10.44.32.189]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8B03C1953B82; Wed, 14 May 2025 08:43:54 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Steven Rostedt , Masami Hiramatsu , linux-trace-kernel@vger.kernel.org Cc: Gabriele Monaco , Nam Cao , Tomas Glozar , Juri Lelli Subject: [RFC PATCH v2 06/12] sched: Adapt sched tracepoints for RV task model Date: Wed, 14 May 2025 10:43:08 +0200 Message-ID: <20250514084314.57976-7-gmonaco@redhat.com> In-Reply-To: <20250514084314.57976-1-gmonaco@redhat.com> References: <20250514084314.57976-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.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" Add the following tracepoints: * sched_set_need_resched(tsk, cpu, tif) Called when a task is set the need resched [lazy] flag * sched_switch_vain(preempt, tsk, tsk_state) Called when a task is selected again during __schedule i.e. prev =3D=3D next =3D=3D tsk : no real context switch Add new parameter to sched_set_state to identify whether the state change was due to an explicit call or a signal pending while scheduling. We now also trace from try_to_block_task in case a signal was pending and the task is set to runnable. These tracepoints are useful to describe the Linux task model and are adapted from the patches by Daniel Bristot de Oliveira (https://bristot.me/linux-task-model/). Signed-off-by: Gabriele Monaco --- include/linux/sched.h | 7 ++++++- include/trace/events/sched.h | 17 +++++++++++++++-- kernel/sched/core.c | 10 +++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 04f808ab8888..4d9da32330bc 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -340,9 +340,11 @@ extern void io_schedule_finish(int token); extern long io_schedule_timeout(long timeout); extern void io_schedule(void); =20 -/* wrapper function to trace from this header file */ +/* wrapper functions to trace from this header file */ DECLARE_TRACEPOINT(sched_set_state_tp); extern void __trace_set_current_state(int state_value); +DECLARE_TRACEPOINT(sched_set_need_resched_tp); +extern void __trace_set_need_resched(struct task_struct *curr, int tif); =20 /** * struct prev_cputime - snapshot of system and user cputime @@ -2065,6 +2067,9 @@ static inline int test_tsk_thread_flag(struct task_st= ruct *tsk, int flag) =20 static inline void set_tsk_need_resched(struct task_struct *tsk) { + if (tracepoint_enabled(sched_set_need_resched_tp) && + !test_tsk_thread_flag(tsk, TIF_NEED_RESCHED)) + __trace_set_need_resched(tsk, TIF_NEED_RESCHED); set_tsk_thread_flag(tsk,TIF_NEED_RESCHED); } =20 diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index 2390818b139b..158b9c504fab 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -889,11 +889,24 @@ DECLARE_TRACE(sched_exit_tp, TP_PROTO(bool is_switch, unsigned long ip), TP_ARGS(is_switch, ip)); =20 +/* + * Tracepoint called when setting the state of a task; + * this tracepoint is guaranteed to be called from the waking context of t= he + * task setting the state. + */ DECLARE_TRACE_CONDITION(sched_set_state_tp, - TP_PROTO(struct task_struct *tsk, int state), - TP_ARGS(tsk, state), + TP_PROTO(struct task_struct *tsk, int state, bool from_signal), + TP_ARGS(tsk, state, from_signal), TP_CONDITION(!!(tsk->__state) !=3D !!state)); =20 +DECLARE_TRACE(sched_set_need_resched_tp, + TP_PROTO(struct task_struct *tsk, int cpu, int tif), + TP_ARGS(tsk, cpu, tif)); + +DECLARE_TRACE(sched_switch_vain_tp, + TP_PROTO(bool preempt, struct task_struct *tsk, unsigned int prev_state), + TP_ARGS(preempt, tsk, prev_state)); + #endif /* _TRACE_SCHED_H */ =20 /* This part must be outside protection */ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 5f844bae1a14..89e81fc7f393 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -494,7 +494,7 @@ EXPORT_TRACEPOINT_SYMBOL(sched_set_state_tp); /* Call via the helper macro trace_set_current_state. */ void __trace_set_current_state(int state_value) { - trace_sched_set_state_tp(current, state_value); + trace_sched_set_state_tp(current, state_value, false); } EXPORT_SYMBOL(__trace_set_current_state); =20 @@ -1109,6 +1109,7 @@ static void __resched_curr(struct rq *rq, int tif) =20 cpu =3D cpu_of(rq); =20 + trace_sched_set_need_resched_tp(curr, cpu, tif); if (cpu =3D=3D smp_processor_id()) { set_ti_thread_flag(cti, tif); if (tif =3D=3D TIF_NEED_RESCHED) @@ -1124,6 +1125,11 @@ static void __resched_curr(struct rq *rq, int tif) } } =20 +void __trace_set_need_resched(struct task_struct *curr, int tif) +{ + trace_sched_set_need_resched_tp(curr, smp_processor_id(), tif); +} + void resched_curr(struct rq *rq) { __resched_curr(rq, TIF_NEED_RESCHED); @@ -6587,6 +6593,7 @@ static bool try_to_block_task(struct rq *rq, struct t= ask_struct *p, int flags =3D DEQUEUE_NOCLOCK; =20 if (signal_pending_state(task_state, p)) { + trace_sched_set_state_tp(p, TASK_RUNNING, true); WRITE_ONCE(p->__state, TASK_RUNNING); *task_state_p =3D TASK_RUNNING; return false; @@ -6779,6 +6786,7 @@ static void __sched notrace __schedule(int sched_mode) rq =3D context_switch(rq, prev, next, &rf); } else { rq_unpin_lock(rq, &rf); + trace_sched_switch_vain_tp(preempt, prev, prev_state); __balance_callbacks(rq); raw_spin_rq_unlock_irq(rq); } --=20 2.49.0 From nobody Sat Feb 7 19:04:22 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 2D16122129B for ; Wed, 14 May 2025 08:44: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=1747212255; cv=none; b=lobzPXguqRafCJK3xI2xG8ajGGjU/SkLwr44YkCkIF/Uzd6SvY3jmDjSl6A+8R5ssCSJjyWMIZr8YDOLTppg4JLQ1+ht0qc0LNhyb8Z7qq5kidcEylD+GlhDL5tnyk6FXeqkScKFMnCF0lG1GUSCXtE1J9KvlKsvKhj47baUzVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747212255; c=relaxed/simple; bh=rMiJWGXqHnsezz2jyGTm+qtPAB7e+eI542LlREgSQtU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vj07ntkPV/NT+avw7pugLL0NQvo0cSgNYuhOB0/tp93+BS5W1QYIM9P+47bI0GKi8Obrfc4xD+Ek8N5oCNSH8IYIsICvCWGAHdaGlLku2mYZPH4OygWUjea11ftrNjFyzUDo5QDObAjenA1k82g9JLW9T96Yy26R6RG6rr6KkiI= 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=YJUarMN7; 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="YJUarMN7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747212252; 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=EV3dsS91MpBaNr38Ap9wP8gXKQqOlLCmuruk3UUAUPk=; b=YJUarMN7nLeFfdecw76kRAV7+QG1bav3gn6jilBbvMIEytMMQz7wh/+c0x5engK6EDJFz9 KDl3EK1uww0rWbZxlsuyFRr6aPgkX1t9T6WBv7R7pznnIKKiGkFFWPqkX4DlYAvUs8uFbL z6a4G3SeJdlbmo8a8H4rvBGWZus5mYc= 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-9-ngRI4SVOP_iw3zxZVv_8xA-1; Wed, 14 May 2025 04:44:06 -0400 X-MC-Unique: ngRI4SVOP_iw3zxZVv_8xA-1 X-Mimecast-MFC-AGG-ID: ngRI4SVOP_iw3zxZVv_8xA_1747212245 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 ED1FB180036F; Wed, 14 May 2025 08:44:04 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.com (unknown [10.44.32.189]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E4D7D1953B80; Wed, 14 May 2025 08:43:59 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Jonathan Corbet , Masami Hiramatsu , linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Gabriele Monaco , Ingo Molnar , Peter Zijlstra , Nam Cao , Tomas Glozar , Juri Lelli Subject: [RFC PATCH v2 07/12] rv: Adapt the sco monitor to the new set_state Date: Wed, 14 May 2025 10:43:09 +0200 Message-ID: <20250514084314.57976-8-gmonaco@redhat.com> In-Reply-To: <20250514084314.57976-1-gmonaco@redhat.com> References: <20250514084314.57976-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.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" The sched_set_state tracepoint changed prototype adding a new argument, this argument can differentiate between an explicit set_state called by a task and a set state to runnable by the scheduler due to a pending signal. Adapt the handlers prototypes for the sco monitor. Expand the model to handle the new set_state flavour, the monitor was making sure set state happens only outside of the scheduler, if the event occurs with the new argument (from_signal) set to true, we instead expect it to be inside the scheduler. Signed-off-by: Gabriele Monaco --- Documentation/trace/rv/monitor_sched.rst | 35 +++++++++++++----------- kernel/trace/rv/monitors/sco/sco.c | 8 ++++-- kernel/trace/rv/monitors/sco/sco.h | 6 ++-- tools/verification/models/sched/sco.dot | 1 + 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/Documentation/trace/rv/monitor_sched.rst b/Documentation/trace= /rv/monitor_sched.rst index 24b2c62a3bc2..6f76bba94d9f 100644 --- a/Documentation/trace/rv/monitor_sched.rst +++ b/Documentation/trace/rv/monitor_sched.rst @@ -64,22 +64,25 @@ Monitor sco ~~~~~~~~~~~ =20 The scheduling context operations (sco) monitor ensures changes in a task = state -happen only in thread context:: - - - | - | - v - sched_set_state +------------------+ - +------------------ | | - | | thread_context | - +-----------------> | | <+ - +------------------+ | - | | - | schedule_entry | schedule_exit - v | - | - scheduling_context -+ +happen only in thread context, the only exception is a special kind of set +state that occurs if a task about to sleep has a pending signal. This set = state +is not called by the thread but by the scheduler itself:: + + | + | + v + sched_set_state +------------------+ + +---------------------------------- | | + | | thread_context | + +---------------------------------> | | <+ + +------------------+ | + | | + | schedule_entry | schedule_exit + v | + sched_set_state_runnable_signal | + +---------------------------------- | + | scheduling_context | + +---------------------------------> -+ =20 Monitor snroc ~~~~~~~~~~~~~ diff --git a/kernel/trace/rv/monitors/sco/sco.c b/kernel/trace/rv/monitors/= sco/sco.c index 66f4639d46ac..6457ff2469d0 100644 --- a/kernel/trace/rv/monitors/sco/sco.c +++ b/kernel/trace/rv/monitors/sco/sco.c @@ -19,9 +19,13 @@ static struct rv_monitor rv_sco; DECLARE_DA_MON_PER_CPU(sco, unsigned char); =20 -static void handle_sched_set_state(void *data, struct task_struct *tsk, in= t state) +static void handle_sched_set_state(void *data, struct task_struct *tsk, + int state, bool from_signal) { - da_handle_start_event_sco(sched_set_state_sco); + if (from_signal) + da_handle_event_sco(sched_set_state_runnable_signal_sco); + else + da_handle_start_event_sco(sched_set_state_sco); } =20 static void handle_schedule_entry(void *data, bool preempt, unsigned long = ip) diff --git a/kernel/trace/rv/monitors/sco/sco.h b/kernel/trace/rv/monitors/= sco/sco.h index 7a4c1f2d5ca1..302750687f9c 100644 --- a/kernel/trace/rv/monitors/sco/sco.h +++ b/kernel/trace/rv/monitors/sco/sco.h @@ -15,6 +15,7 @@ enum states_sco { =20 enum events_sco { sched_set_state_sco =3D 0, + sched_set_state_runnable_signal_sco, schedule_entry_sco, schedule_exit_sco, event_max_sco @@ -35,12 +36,13 @@ static const struct automaton_sco automaton_sco =3D { }, .event_names =3D { "sched_set_state", + "sched_set_state_runnable_signal", "schedule_entry", "schedule_exit" }, .function =3D { - { thread_context_sco, scheduling_context_sco, INVALID_STATE= }, - { INVALID_STATE, INVALID_STATE, thread_context_sco= }, + { thread_context_sco, INVALID_STATE, scheduling_context_sco= , INVALID_STATE }, + { INVALID_STATE, scheduling_context_sco, INVALID_STATE= , thread_context_sco }, }, .initial_state =3D thread_context_sco, .final_states =3D { 1, 0 }, diff --git a/tools/verification/models/sched/sco.dot b/tools/verification/m= odels/sched/sco.dot index 20b0e3b449a6..4e44ed58c62a 100644 --- a/tools/verification/models/sched/sco.dot +++ b/tools/verification/models/sched/sco.dot @@ -7,6 +7,7 @@ digraph state_automaton { {node [shape =3D plaintext] "thread_context"}; "__init_thread_context" -> "thread_context"; "scheduling_context" [label =3D "scheduling_context"]; + "scheduling_context" -> "scheduling_context" [ label =3D "sched_set_state= _runnable_signal" ]; "scheduling_context" -> "thread_context" [ label =3D "schedule_exit" ]; "thread_context" [label =3D "thread_context", color =3D green3]; "thread_context" -> "scheduling_context" [ label =3D "schedule_entry" ]; --=20 2.49.0 From nobody Sat Feb 7 19:04:22 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 D599B2222D3 for ; Wed, 14 May 2025 08:44:18 +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=1747212260; cv=none; b=ec+hLv0REyepszoXdxOtyz8aubYrqpJ+dXC7HWvVkwklxEQTbFXYZnIxznTxtJFjXDL3vv4HHBro9kraConuSPBluylb4p88Ed6FIhqxj5lduQTEZyh0dLzUFwSuPSqL7EMQW/tINdycXEtY7w5vI0RsiKzrwdP1BQQK/DNVC48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747212260; c=relaxed/simple; bh=KqaMQEPSNBso+XyHfCeSq3fyp64JTOCX+YZLT1f3lhU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dO575kRMQo2WA+pdpxVtdTUlS8xCT10nlbCVAfsq+DtSsY1dahoeNq+Spx71Iu+SXzkkVmfU58XxKHTap5FNdhxhTSltY94UoNMHZxwLKDpsBHDnGMDqzhe5dcKoxWcR8Px1ZWSuUNq7XpRqQ6DxtRYzVamjuDNB8MzqowKaxAM= 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=HmMYgHZI; 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="HmMYgHZI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747212258; 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=1Z+XXf3nfcsL32lUalEpYO8BXUHAI1HsKF79TuLYRZo=; b=HmMYgHZIvvRvqC5GDISvHO3L9wRX2ZKfhUgWEbqeNwo4mkQoDRIjL2dQMjYp7IaJu2CzCj frXgFyzc+hMdwcQzGtershI1M8zpD7v0bH7FzjShwzrZcDbSi9VDQgVR4W7mBnZ5GjcUn2 EZkot0eB7UVzXp/CMpEA3UJBlhWaPX4= 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-62-OSYUDRpWPSK0scfz1JbKCQ-1; Wed, 14 May 2025 04:44:14 -0400 X-MC-Unique: OSYUDRpWPSK0scfz1JbKCQ-1 X-Mimecast-MFC-AGG-ID: OSYUDRpWPSK0scfz1JbKCQ_1747212253 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 593EC19541B4; Wed, 14 May 2025 08:44:12 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.com (unknown [10.44.32.189]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5F0AB1953B80; Wed, 14 May 2025 08:44:05 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Jonathan Corbet , Masami Hiramatsu , linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Gabriele Monaco , Ingo Molnar , Peter Zijlstra , Nam Cao , Tomas Glozar , Juri Lelli Subject: [RFC PATCH v2 08/12] rv: Extend and adapt snroc model Date: Wed, 14 May 2025 10:43:10 +0200 Message-ID: <20250514084314.57976-9-gmonaco@redhat.com> In-Reply-To: <20250514084314.57976-1-gmonaco@redhat.com> References: <20250514084314.57976-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.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" The snroc monitor ensures changes in a task state happens only in the respective task's context. This is the only monitor enforcing a task is to be switched in after being switched out, and vice-versa. Although this is a trivial claim, it is useful to complete other claims on when scheduling is possible while keeping models simple. Add the sched_switch_vain event to the model, enforcing that a vain switch doesn't change the context but can only occur while a task is running (e.g. a call to schedule that re-selects the current task). Also adapt the set_state handler prototypes to the tracepoint change. Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Gabriele Monaco --- Documentation/trace/rv/monitor_sched.rst | 32 ++++++++++++----------- kernel/trace/rv/monitors/snroc/snroc.c | 12 ++++++++- kernel/trace/rv/monitors/snroc/snroc.h | 8 +++--- tools/verification/models/sched/snroc.dot | 2 +- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/Documentation/trace/rv/monitor_sched.rst b/Documentation/trace= /rv/monitor_sched.rst index 6f76bba94d9f..5cb58ac441d8 100644 --- a/Documentation/trace/rv/monitor_sched.rst +++ b/Documentation/trace/rv/monitor_sched.rst @@ -89,21 +89,23 @@ Monitor snroc =20 The set non runnable on its own context (snroc) monitor ensures changes in= a task state happens only in the respective task's context. This is a per-ta= sk -monitor:: - - | - | - v - +------------------+ - | other_context | <+ - +------------------+ | - | | - | sched_switch_in | sched_switch_out - v | - sched_set_state | - +------------------ | - | own_context | - +-----------------> -+ +monitor. A task is in its own context after switching in and leaves the co= ntext +when switched out, a vain switch maintains the context:: + + | + | + v + +------------------+ + | other_context | <+ + +------------------+ | + | | + | sched_switch_in | sched_switch_out + v | + sched_set_state | + sched_switch_vain | + +-------------------- own_context | + | | + +-------------------> -+ =20 Monitor scpd ~~~~~~~~~~~~ diff --git a/kernel/trace/rv/monitors/snroc/snroc.c b/kernel/trace/rv/monit= ors/snroc/snroc.c index 540e686e699f..11a56b58665e 100644 --- a/kernel/trace/rv/monitors/snroc/snroc.c +++ b/kernel/trace/rv/monitors/snroc/snroc.c @@ -19,7 +19,8 @@ static struct rv_monitor rv_snroc; DECLARE_DA_MON_PER_TASK(snroc, unsigned char); =20 -static void handle_sched_set_state(void *data, struct task_struct *tsk, in= t state) +static void handle_sched_set_state(void *data, struct task_struct *tsk, + int state, bool from_signal) { da_handle_event_snroc(tsk, sched_set_state_snroc); } @@ -33,6 +34,13 @@ static void handle_sched_switch(void *data, bool preempt, da_handle_event_snroc(next, sched_switch_in_snroc); } =20 +static void handle_sched_switch_vain(void *data, bool preempt, + struct task_struct *tsk, + unsigned int tsk_state) +{ + da_handle_event_snroc(tsk, sched_switch_vain_snroc); +} + static int enable_snroc(void) { int retval; @@ -43,6 +51,7 @@ static int enable_snroc(void) =20 rv_attach_trace_probe("snroc", sched_set_state_tp, handle_sched_set_state= ); rv_attach_trace_probe("snroc", sched_switch, handle_sched_switch); + rv_attach_trace_probe("snroc", sched_switch_vain_tp, handle_sched_switch_= vain); =20 return 0; } @@ -53,6 +62,7 @@ static void disable_snroc(void) =20 rv_detach_trace_probe("snroc", sched_set_state_tp, handle_sched_set_state= ); rv_detach_trace_probe("snroc", sched_switch, handle_sched_switch); + rv_detach_trace_probe("snroc", sched_switch_vain_tp, handle_sched_switch_= vain); =20 da_monitor_destroy_snroc(); } diff --git a/kernel/trace/rv/monitors/snroc/snroc.h b/kernel/trace/rv/monit= ors/snroc/snroc.h index c3650a2b1b10..d6de40e15ae1 100644 --- a/kernel/trace/rv/monitors/snroc/snroc.h +++ b/kernel/trace/rv/monitors/snroc/snroc.h @@ -17,6 +17,7 @@ enum events_snroc { sched_set_state_snroc =3D 0, sched_switch_in_snroc, sched_switch_out_snroc, + sched_switch_vain_snroc, event_max_snroc }; =20 @@ -36,11 +37,12 @@ static const struct automaton_snroc automaton_snroc =3D= { .event_names =3D { "sched_set_state", "sched_switch_in", - "sched_switch_out" + "sched_switch_out", + "sched_switch_vain" }, .function =3D { - { INVALID_STATE, own_context_snroc, INVALID_STATE }, - { own_context_snroc, INVALID_STATE, other_context_snroc }, + { INVALID_STATE, own_context_snroc, INVALID_STATE, I= NVALID_STATE }, + { own_context_snroc, INVALID_STATE, other_context_snroc, own_c= ontext_snroc }, }, .initial_state =3D other_context_snroc, .final_states =3D { 1, 0 }, diff --git a/tools/verification/models/sched/snroc.dot b/tools/verification= /models/sched/snroc.dot index 8b71c32d4dca..5b1a787d0350 100644 --- a/tools/verification/models/sched/snroc.dot +++ b/tools/verification/models/sched/snroc.dot @@ -10,7 +10,7 @@ digraph state_automaton { "other_context" -> "own_context" [ label =3D "sched_switch_in" ]; "own_context" [label =3D "own_context"]; "own_context" -> "other_context" [ label =3D "sched_switch_out" ]; - "own_context" -> "own_context" [ label =3D "sched_set_state" ]; + "own_context" -> "own_context" [ label =3D "sched_set_state\nsched_switch= _vain" ]; { rank =3D min ; "__init_other_context"; "other_context"; --=20 2.49.0 From nobody Sat Feb 7 19:04:22 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 194D32222B0 for ; Wed, 14 May 2025 08:44:26 +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=1747212268; cv=none; b=lgbcgr5zVRJmt/9pDJ3BCexpH9GstVX2KGvblvSNcxTsCR0QCTAWDmsdecj1s9U/n8A0hWl1rhXUByJhNAXoiyCz5iCttuOxktUqqUDAyGtlVI0KLAfEuR5ppbAEkbkfL58OBme20qtbp5lmmT6CAnQ0s62ZGi3srPSQKbVRe4Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747212268; c=relaxed/simple; bh=UQCNcjNvetgdDVbITKUG4yv67Y1fIqHooim628HqLxs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J0BSOE7Tur3J3Roz7/85VMOjaS/Ca9Qu8ZUWxUHUwidrPNwaQTIx+FCzXL3VKX6YgEm1Qt6t/KaRw8JwSDO5V0ZjUwNZpUTXP2fTOXO5z6aCL8hMsEESSWLEDVnTjpmosGrLBNVtAqnv0wAt9JFOo3k2xNIXESEGbs0wabp6M8w= 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=fBJgxGST; 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="fBJgxGST" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747212265; 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=Z39mb9jvS5TIobPDMnxy6Ap3lBRoJ8wcwADq1WWaDDg=; b=fBJgxGSTQ3xvwCuhqPEVbnEfk6TRBqwJ3fe3w0JXZFxTxnQZcxA17JlBAy4g0igNwj2UZk J1PHAsg53YAYwrWWbzZZdpXCMHyrqa1Q9hCZZRfY7I5bVgd7WhVib2yZQDIslrHEShgGFR x+b1pbMjxH6nrS5I6aIBu+oteg+w4pE= 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-217-riB_37lwOfeo23yjOmNhjg-1; Wed, 14 May 2025 04:44:21 -0400 X-MC-Unique: riB_37lwOfeo23yjOmNhjg-1 X-Mimecast-MFC-AGG-ID: riB_37lwOfeo23yjOmNhjg_1747212260 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 76F411956051; Wed, 14 May 2025 08:44:20 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.com (unknown [10.44.32.189]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DEA961953B80; Wed, 14 May 2025 08:44:14 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Jonathan Corbet , Masami Hiramatsu , linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Gabriele Monaco , Ingo Molnar , Peter Zijlstra , Nam Cao , Tomas Glozar , Juri Lelli Subject: [RFC PATCH v2 09/12] rv: Replace tss monitor with more complete sts Date: Wed, 14 May 2025 10:43:11 +0200 Message-ID: <20250514084314.57976-10-gmonaco@redhat.com> In-Reply-To: <20250514084314.57976-1-gmonaco@redhat.com> References: <20250514084314.57976-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.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" The tss monitor currently guarantees context switches can happen only while scheduling, but it doesn't enforce that each scheduling call implies a task switch. This can be implied only if we rely on the newly introduced sched_switch_vain tracepoint, which represents a scheduler call where the previously running task is the same that is picked to run next, in fact no context is switched. Replace the monitor with a more comprehensive specification which implies tss but also ensures that: * each scheduler call switches context (or has a vain switch) * each context switch happens with interrupts disabled Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Gabriele Monaco --- Documentation/trace/rv/monitor_sched.rst | 68 +++++++--- kernel/trace/rv/Kconfig | 2 +- kernel/trace/rv/Makefile | 2 +- kernel/trace/rv/monitors/sts/Kconfig | 18 +++ kernel/trace/rv/monitors/sts/sts.c | 117 ++++++++++++++++++ kernel/trace/rv/monitors/sts/sts.h | 62 ++++++++++ .../{tss/tss_trace.h =3D> sts/sts_trace.h} | 8 +- kernel/trace/rv/monitors/tss/Kconfig | 14 --- kernel/trace/rv/monitors/tss/tss.c | 90 -------------- kernel/trace/rv/monitors/tss/tss.h | 47 ------- kernel/trace/rv/rv_trace.h | 2 +- tools/verification/models/sched/sts.dot | 29 +++++ tools/verification/models/sched/tss.dot | 18 --- 13 files changed, 281 insertions(+), 196 deletions(-) create mode 100644 kernel/trace/rv/monitors/sts/Kconfig create mode 100644 kernel/trace/rv/monitors/sts/sts.c create mode 100644 kernel/trace/rv/monitors/sts/sts.h rename kernel/trace/rv/monitors/{tss/tss_trace.h =3D> sts/sts_trace.h} (67= %) delete mode 100644 kernel/trace/rv/monitors/tss/Kconfig delete mode 100644 kernel/trace/rv/monitors/tss/tss.c delete mode 100644 kernel/trace/rv/monitors/tss/tss.h create mode 100644 tools/verification/models/sched/sts.dot delete mode 100644 tools/verification/models/sched/tss.dot diff --git a/Documentation/trace/rv/monitor_sched.rst b/Documentation/trace= /rv/monitor_sched.rst index 5cb58ac441d8..e4171aadef1c 100644 --- a/Documentation/trace/rv/monitor_sched.rst +++ b/Documentation/trace/rv/monitor_sched.rst @@ -40,26 +40,6 @@ defined in by Daniel Bristot in [1]. =20 Currently we included the following: =20 -Monitor tss -~~~~~~~~~~~ - -The task switch while scheduling (tss) monitor ensures a task switch happe= ns -only in scheduling context, that is inside a call to `__schedule`:: - - | - | - v - +-----------------+ - | thread | <+ - +-----------------+ | - | | - | schedule_entry | schedule_exit - v | - sched_switch | - +--------------- | - | sched | - +--------------> -+ - Monitor sco ~~~~~~~~~~~ =20 @@ -170,6 +150,54 @@ schedule is not called with interrupt disabled:: | cant_sched -+ =20 +Monitor sts +~~~~~~~~~~~ + +The schedule implies task switch (sts) monitor ensures a task switch happe= ns in +every scheduling context, that is inside a call to ``__schedule``, as well= as no +task switch can happen without scheduling and before interrupts are disabl= ed. +This require the special type of switch called vain, which occurs when the= next +task picked for execution is the same as the previously running one, in fa= ct no +real task switch occurs:: + + | + | + v + #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D# irq_disable + H H irq_enable + H thread H --------------+ + H H | + +-------------> H H <-------------+ + | #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D# + | | + | | schedule_entry + | v + | +--------------------+ + | | scheduling | <+ + | +--------------------+ | + | | | + | | irq_disable | irq_enable + | v | + | +--------------------+ | + | | disable_to_switch | -+ + | schedule_exit +--------------------+ + | | + | | sched_switch + | | sched_switch_vain + | v + | +--------------------+ + | | switching | + | +--------------------+ + | | + | | irq_enable + | v + | +--------------------+ irq_disable + | | | irq_enable + | | enable_to_exit | --------------+ + | | | | + +-------------- | | <-------------+ + +--------------------+ + References ---------- =20 diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig index b39f36013ef2..a53a3eca9616 100644 --- a/kernel/trace/rv/Kconfig +++ b/kernel/trace/rv/Kconfig @@ -28,12 +28,12 @@ menuconfig RV source "kernel/trace/rv/monitors/wip/Kconfig" source "kernel/trace/rv/monitors/wwnr/Kconfig" source "kernel/trace/rv/monitors/sched/Kconfig" -source "kernel/trace/rv/monitors/tss/Kconfig" source "kernel/trace/rv/monitors/sco/Kconfig" source "kernel/trace/rv/monitors/snroc/Kconfig" source "kernel/trace/rv/monitors/scpd/Kconfig" source "kernel/trace/rv/monitors/snep/Kconfig" source "kernel/trace/rv/monitors/sncid/Kconfig" +source "kernel/trace/rv/monitors/sts/Kconfig" # Add new monitors here =20 config RV_REACTORS diff --git a/kernel/trace/rv/Makefile b/kernel/trace/rv/Makefile index f9b2cd0483c3..c609b72275cb 100644 --- a/kernel/trace/rv/Makefile +++ b/kernel/trace/rv/Makefile @@ -6,12 +6,12 @@ obj-$(CONFIG_RV) +=3D rv.o obj-$(CONFIG_RV_MON_WIP) +=3D monitors/wip/wip.o obj-$(CONFIG_RV_MON_WWNR) +=3D monitors/wwnr/wwnr.o obj-$(CONFIG_RV_MON_SCHED) +=3D monitors/sched/sched.o -obj-$(CONFIG_RV_MON_TSS) +=3D monitors/tss/tss.o obj-$(CONFIG_RV_MON_SCO) +=3D monitors/sco/sco.o obj-$(CONFIG_RV_MON_SNROC) +=3D monitors/snroc/snroc.o obj-$(CONFIG_RV_MON_SCPD) +=3D monitors/scpd/scpd.o obj-$(CONFIG_RV_MON_SNEP) +=3D monitors/snep/snep.o obj-$(CONFIG_RV_MON_SNCID) +=3D monitors/sncid/sncid.o +obj-$(CONFIG_RV_MON_STS) +=3D monitors/sts/sts.o # Add new monitors here obj-$(CONFIG_RV_REACTORS) +=3D rv_reactors.o obj-$(CONFIG_RV_REACT_PRINTK) +=3D reactor_printk.o diff --git a/kernel/trace/rv/monitors/sts/Kconfig b/kernel/trace/rv/monitor= s/sts/Kconfig new file mode 100644 index 000000000000..5b486dac3f10 --- /dev/null +++ b/kernel/trace/rv/monitors/sts/Kconfig @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_STS + depends on RV + depends on IRQSOFF_TRACER + depends on RV_MON_SCHED + default y + select DA_MON_EVENTS_IMPLICIT + bool "sts monitor" + help + Monitor to ensure relationships between scheduler and switches + * each call to the scheduler implies a switch + * switches only happen inside the scheduler + * switches happen with interrupt disabled + This monitor is part of the sched monitors collection. + + For further information, see: + Documentation/trace/rv/monitor_sched.rst diff --git a/kernel/trace/rv/monitors/sts/sts.c b/kernel/trace/rv/monitors/= sts/sts.c new file mode 100644 index 000000000000..deb18a9d48f3 --- /dev/null +++ b/kernel/trace/rv/monitors/sts/sts.c @@ -0,0 +1,117 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include +#include +#include + +#define MODULE_NAME "sts" + +#include +#include +#include +#include + +#include "sts.h" + +static struct rv_monitor rv_sts; +DECLARE_DA_MON_PER_CPU(sts, unsigned char); + +static void handle_irq_disable(void *data, unsigned long ip, unsigned long= parent_ip) +{ + da_handle_event_sts(irq_disable_sts); +} + +static void handle_irq_enable(void *data, unsigned long ip, unsigned long = parent_ip) +{ + da_handle_event_sts(irq_enable_sts); +} + +static void handle_sched_switch(void *data, bool preempt, + struct task_struct *prev, + struct task_struct *next, + unsigned int prev_state) +{ + da_handle_event_sts(sched_switch_sts); +} + +static void handle_sched_switch_vain(void *data, bool preempt, + struct task_struct *tsk, + unsigned int tsk_state) +{ + da_handle_event_sts(sched_switch_vain_sts); +} + +static void handle_schedule_entry(void *data, bool preempt, unsigned long = ip) +{ + da_handle_event_sts(schedule_entry_sts); +} + +static void handle_schedule_exit(void *data, bool is_switch, unsigned long= ip) +{ + da_handle_start_event_sts(schedule_exit_sts); +} + +static int enable_sts(void) +{ + int retval; + + retval =3D da_monitor_init_sts(); + if (retval) + return retval; + + rv_attach_trace_probe("sts", irq_disable, handle_irq_disable); + rv_attach_trace_probe("sts", irq_enable, handle_irq_enable); + rv_attach_trace_probe("sts", sched_switch, handle_sched_switch); + rv_attach_trace_probe("sts", sched_switch_vain_tp, handle_sched_switch_va= in); + rv_attach_trace_probe("sts", sched_entry_tp, handle_schedule_entry); + rv_attach_trace_probe("sts", sched_exit_tp, handle_schedule_exit); + + return 0; +} + +static void disable_sts(void) +{ + rv_sts.enabled =3D 0; + + rv_detach_trace_probe("sts", irq_disable, handle_irq_disable); + rv_detach_trace_probe("sts", irq_enable, handle_irq_enable); + rv_detach_trace_probe("sts", sched_switch, handle_sched_switch); + rv_detach_trace_probe("sts", sched_switch_vain_tp, handle_sched_switch_va= in); + rv_detach_trace_probe("sts", sched_entry_tp, handle_schedule_entry); + rv_detach_trace_probe("sts", sched_exit_tp, handle_schedule_exit); + + da_monitor_destroy_sts(); +} + +/* + * This is the monitor register section. + */ +static struct rv_monitor rv_sts =3D { + .name =3D "sts", + .description =3D "schedule implies task switch.", + .enable =3D enable_sts, + .disable =3D disable_sts, + .reset =3D da_monitor_reset_all_sts, + .enabled =3D 0, +}; + +static int __init register_sts(void) +{ + return rv_register_monitor(&rv_sts, &rv_sched); +} + +static void __exit unregister_sts(void) +{ + rv_unregister_monitor(&rv_sts); +} + +module_init(register_sts); +module_exit(unregister_sts); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Gabriele Monaco "); +MODULE_DESCRIPTION("sts: schedule implies task switch."); diff --git a/kernel/trace/rv/monitors/sts/sts.h b/kernel/trace/rv/monitors/= sts/sts.h new file mode 100644 index 000000000000..6921c0042293 --- /dev/null +++ b/kernel/trace/rv/monitors/sts/sts.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Automatically generated C representation of sts automaton + * For further information about this format, see kernel documentation: + * Documentation/trace/rv/deterministic_automata.rst + */ + +enum states_sts { + thread_sts =3D 0, + disable_to_switch_sts, + enable_to_exit_sts, + scheduling_sts, + switching_sts, + state_max_sts +}; + +#define INVALID_STATE state_max_sts + +enum events_sts { + irq_disable_sts =3D 0, + irq_enable_sts, + sched_switch_sts, + sched_switch_vain_sts, + schedule_entry_sts, + schedule_exit_sts, + event_max_sts +}; + +struct automaton_sts { + char *state_names[state_max_sts]; + char *event_names[event_max_sts]; + unsigned char function[state_max_sts][event_max_sts]; + unsigned char initial_state; + bool final_states[state_max_sts]; +}; + +static const struct automaton_sts automaton_sts =3D { + .state_names =3D { + "thread", + "disable_to_switch", + "enable_to_exit", + "scheduling", + "switching" + }, + .event_names =3D { + "irq_disable", + "irq_enable", + "sched_switch", + "sched_switch_vain", + "schedule_entry", + "schedule_exit" + }, + .function =3D { + { thread_sts, thread_sts, INVALID_STATE, = INVALID_STATE, scheduling_sts, INVALID_STATE }, + { INVALID_STATE, scheduling_sts, switching_sts, = switching_sts, INVALID_STATE, INVALID_STATE }, + { enable_to_exit_sts, enable_to_exit_sts, INVALID_STATE, = INVALID_STATE, INVALID_STATE, thread_sts }, + { disable_to_switch_sts, INVALID_STATE, INVALID_STATE, = INVALID_STATE, INVALID_STATE, INVALID_STATE }, + { INVALID_STATE, enable_to_exit_sts, INVALID_STATE, = INVALID_STATE, INVALID_STATE, INVALID_STATE }, + }, + .initial_state =3D thread_sts, + .final_states =3D { 1, 0, 0, 0, 0 }, +}; diff --git a/kernel/trace/rv/monitors/tss/tss_trace.h b/kernel/trace/rv/mon= itors/sts/sts_trace.h similarity index 67% rename from kernel/trace/rv/monitors/tss/tss_trace.h rename to kernel/trace/rv/monitors/sts/sts_trace.h index 4619dbb50cc0..d78beb58d5b3 100644 --- a/kernel/trace/rv/monitors/tss/tss_trace.h +++ b/kernel/trace/rv/monitors/sts/sts_trace.h @@ -4,12 +4,12 @@ * Snippet to be included in rv_trace.h */ =20 -#ifdef CONFIG_RV_MON_TSS -DEFINE_EVENT(event_da_monitor, event_tss, +#ifdef CONFIG_RV_MON_STS +DEFINE_EVENT(event_da_monitor, event_sts, TP_PROTO(char *state, char *event, char *next_state, bool final_stat= e), TP_ARGS(state, event, next_state, final_state)); =20 -DEFINE_EVENT(error_da_monitor, error_tss, +DEFINE_EVENT(error_da_monitor, error_sts, TP_PROTO(char *state, char *event), TP_ARGS(state, event)); -#endif /* CONFIG_RV_MON_TSS */ +#endif /* CONFIG_RV_MON_STS */ diff --git a/kernel/trace/rv/monitors/tss/Kconfig b/kernel/trace/rv/monitor= s/tss/Kconfig deleted file mode 100644 index 479f86f52e60..000000000000 --- a/kernel/trace/rv/monitors/tss/Kconfig +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# -config RV_MON_TSS - depends on RV - depends on RV_MON_SCHED - default y - select DA_MON_EVENTS_IMPLICIT - bool "tss monitor" - help - Monitor to ensure sched_switch happens only in scheduling context. - This monitor is part of the sched monitors collection. - - For further information, see: - Documentation/trace/rv/monitor_sched.rst diff --git a/kernel/trace/rv/monitors/tss/tss.c b/kernel/trace/rv/monitors/= tss/tss.c deleted file mode 100644 index 0452fcd9edcf..000000000000 --- a/kernel/trace/rv/monitors/tss/tss.c +++ /dev/null @@ -1,90 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include -#include -#include -#include -#include -#include -#include - -#define MODULE_NAME "tss" - -#include -#include -#include - -#include "tss.h" - -static struct rv_monitor rv_tss; -DECLARE_DA_MON_PER_CPU(tss, unsigned char); - -static void handle_sched_switch(void *data, bool preempt, - struct task_struct *prev, - struct task_struct *next, - unsigned int prev_state) -{ - da_handle_event_tss(sched_switch_tss); -} - -static void handle_schedule_entry(void *data, bool preempt, unsigned long = ip) -{ - da_handle_event_tss(schedule_entry_tss); -} - -static void handle_schedule_exit(void *data, bool is_switch, unsigned long= ip) -{ - da_handle_start_event_tss(schedule_exit_tss); -} - -static int enable_tss(void) -{ - int retval; - - retval =3D da_monitor_init_tss(); - if (retval) - return retval; - - rv_attach_trace_probe("tss", sched_switch, handle_sched_switch); - rv_attach_trace_probe("tss", sched_entry_tp, handle_schedule_entry); - rv_attach_trace_probe("tss", sched_exit_tp, handle_schedule_exit); - - return 0; -} - -static void disable_tss(void) -{ - rv_tss.enabled =3D 0; - - rv_detach_trace_probe("tss", sched_switch, handle_sched_switch); - rv_detach_trace_probe("tss", sched_entry_tp, handle_schedule_entry); - rv_detach_trace_probe("tss", sched_exit_tp, handle_schedule_exit); - - da_monitor_destroy_tss(); -} - -static struct rv_monitor rv_tss =3D { - .name =3D "tss", - .description =3D "task switch while scheduling.", - .enable =3D enable_tss, - .disable =3D disable_tss, - .reset =3D da_monitor_reset_all_tss, - .enabled =3D 0, -}; - -static int __init register_tss(void) -{ - return rv_register_monitor(&rv_tss, &rv_sched); -} - -static void __exit unregister_tss(void) -{ - rv_unregister_monitor(&rv_tss); -} - -module_init(register_tss); -module_exit(unregister_tss); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Gabriele Monaco "); -MODULE_DESCRIPTION("tss: task switch while scheduling."); diff --git a/kernel/trace/rv/monitors/tss/tss.h b/kernel/trace/rv/monitors/= tss/tss.h deleted file mode 100644 index f0a36fda1b87..000000000000 --- a/kernel/trace/rv/monitors/tss/tss.h +++ /dev/null @@ -1,47 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Automatically generated C representation of tss automaton - * For further information about this format, see kernel documentation: - * Documentation/trace/rv/deterministic_automata.rst - */ - -enum states_tss { - thread_tss =3D 0, - sched_tss, - state_max_tss -}; - -#define INVALID_STATE state_max_tss - -enum events_tss { - sched_switch_tss =3D 0, - schedule_entry_tss, - schedule_exit_tss, - event_max_tss -}; - -struct automaton_tss { - char *state_names[state_max_tss]; - char *event_names[event_max_tss]; - unsigned char function[state_max_tss][event_max_tss]; - unsigned char initial_state; - bool final_states[state_max_tss]; -}; - -static const struct automaton_tss automaton_tss =3D { - .state_names =3D { - "thread", - "sched" - }, - .event_names =3D { - "sched_switch", - "schedule_entry", - "schedule_exit" - }, - .function =3D { - { INVALID_STATE, sched_tss, INVALID_STATE }, - { sched_tss, INVALID_STATE, thread_tss }, - }, - .initial_state =3D thread_tss, - .final_states =3D { 1, 0 }, -}; diff --git a/kernel/trace/rv/rv_trace.h b/kernel/trace/rv/rv_trace.h index 18fa0e358a30..a5e1c52e2992 100644 --- a/kernel/trace/rv/rv_trace.h +++ b/kernel/trace/rv/rv_trace.h @@ -58,11 +58,11 @@ DECLARE_EVENT_CLASS(error_da_monitor, ); =20 #include -#include #include #include #include #include +#include // Add new monitors based on CONFIG_DA_MON_EVENTS_IMPLICIT here =20 #endif /* CONFIG_DA_MON_EVENTS_IMPLICIT */ diff --git a/tools/verification/models/sched/sts.dot b/tools/verification/m= odels/sched/sts.dot new file mode 100644 index 000000000000..8152675b4f52 --- /dev/null +++ b/tools/verification/models/sched/sts.dot @@ -0,0 +1,29 @@ +digraph state_automaton { + center =3D true; + size =3D "7,11"; + {node [shape =3D circle] "disable_to_switch"}; + {node [shape =3D circle] "enable_to_exit"}; + {node [shape =3D circle] "scheduling"}; + {node [shape =3D circle] "switching"}; + {node [shape =3D plaintext, style=3Dinvis, label=3D""] "__init_thread"}; + {node [shape =3D doublecircle] "thread"}; + {node [shape =3D circle] "thread"}; + "__init_thread" -> "thread"; + "disable_to_switch" [label =3D "disable_to_switch"]; + "disable_to_switch" -> "scheduling" [ label =3D "irq_enable" ]; + "disable_to_switch" -> "switching" [ label =3D "sched_switch\nsched_switc= h_vain" ]; + "enable_to_exit" [label =3D "enable_to_exit"]; + "enable_to_exit" -> "enable_to_exit" [ label =3D "irq_disable\nirq_enable= " ]; + "enable_to_exit" -> "thread" [ label =3D "schedule_exit" ]; + "scheduling" [label =3D "scheduling"]; + "scheduling" -> "disable_to_switch" [ label =3D "irq_disable" ]; + "switching" [label =3D "switching"]; + "switching" -> "enable_to_exit" [ label =3D "irq_enable" ]; + "thread" [label =3D "thread", color =3D green3]; + "thread" -> "scheduling" [ label =3D "schedule_entry" ]; + "thread" -> "thread" [ label =3D "irq_disable\nirq_enable" ]; + { rank =3D min ; + "__init_thread"; + "thread"; + } +} diff --git a/tools/verification/models/sched/tss.dot b/tools/verification/m= odels/sched/tss.dot deleted file mode 100644 index 7dfa1d9121bb..000000000000 --- a/tools/verification/models/sched/tss.dot +++ /dev/null @@ -1,18 +0,0 @@ -digraph state_automaton { - center =3D true; - size =3D "7,11"; - {node [shape =3D plaintext] "sched"}; - {node [shape =3D plaintext, style=3Dinvis, label=3D""] "__init_thread"}; - {node [shape =3D ellipse] "thread"}; - {node [shape =3D plaintext] "thread"}; - "__init_thread" -> "thread"; - "sched" [label =3D "sched"]; - "sched" -> "sched" [ label =3D "sched_switch" ]; - "sched" -> "thread" [ label =3D "schedule_exit" ]; - "thread" [label =3D "thread", color =3D green3]; - "thread" -> "sched" [ label =3D "schedule_entry" ]; - { rank =3D min ; - "__init_thread"; - "thread"; - } -} --=20 2.49.0 From nobody Sat Feb 7 19:04:22 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 2FB92223709 for ; Wed, 14 May 2025 08:44:31 +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=1747212273; cv=none; b=qUmf1Ske6bSCRhupGqNOJ7e/lZodJM1A8MliJ+lz4A1HeL4QEJE7nXMqfqu/t64c97aPnp+fXKaX34YEdlNkz6XKtih5MjdfGBXuVLLU3kGV+UjV6Rv6uPWcHfMmSn2+nUdhf18cQEP/q6Ti+PXs1kutqwQLke0vjBEVG2DQSZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747212273; c=relaxed/simple; bh=WCCivkh+F3BfBeMHvOTrvD+/zKrI0ugclHHfXIfbsAY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mCpNH3f0dzQOxaCMJsZZPPhNwAYz3Knt54ETr1riFkiZGkY1ip37UBSOfCBSXqQBwWY4qK2mWZz/gxbb3LFLvtkMaQD0nkz+OKygzqHifUlix9igkOu35ZBUaCk44W4AY3vjY+BDKYapD32LcKr57zswfl/wSrgqQeo5f1kDcCA= 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=VnzzTqQ/; 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="VnzzTqQ/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747212270; 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=EKRhk+lgSAKiOsPo3FIiWva9od5/EemvjnyRISItWAs=; b=VnzzTqQ/InsUx0cdiKot1XsaYBwHeCHhg53FAB6AGjwz6lGYzPWEckYCLPLZfRfqcqJBoq eDw40cnd3yE9CICNboEp8yr9pxoHzyr679xSDu+1VDMMHCYP7wyYHI4RqJtSqIgj241ymD vNiwX72M15StfvtM3TupHjUKtLmsA10= 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-668-MlErnUgxOXys0FyakfiC-w-1; Wed, 14 May 2025 04:44:27 -0400 X-MC-Unique: MlErnUgxOXys0FyakfiC-w-1 X-Mimecast-MFC-AGG-ID: MlErnUgxOXys0FyakfiC-w_1747212265 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 D4AC0180048E; Wed, 14 May 2025 08:44:25 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.com (unknown [10.44.32.189]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9D5AF1953B82; Wed, 14 May 2025 08:44:21 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , linux-trace-kernel@vger.kernel.org Cc: Gabriele Monaco , Ingo Molnar , Peter Zijlstra , Nam Cao , Tomas Glozar , Juri Lelli Subject: [RFC PATCH v2 10/12] rv: Retry when da monitor detects race conditions Date: Wed, 14 May 2025 10:43:12 +0200 Message-ID: <20250514084314.57976-11-gmonaco@redhat.com> In-Reply-To: <20250514084314.57976-1-gmonaco@redhat.com> References: <20250514084314.57976-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.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" DA monitor can be accessed from multiple cores simultaneously, this is likely, for instance when dealing with per-task monitors reacting on events that do not always occur on the CPU where the task is running. This can cause race conditions where two events change the next state and we see inconsistent values. E.g.: [62] event_srs: 27: sleepable x sched_wakeup -> running (final) [63] event_srs: 27: sleepable x sched_set_state_sleepable -> sleepable [63] error_srs: 27: event sched_switch_suspend not expected in the state = running In this case the monitor fails because the event on CPU 62 wins against the one on CPU 63, although the correct state should have been sleepable, since the task get suspended. Detect if the current state was modified by using try_cmpxchg while storing the next value. If it was, try again reading the current state. After a maximum number of failed retries, react as if it was an error with invalid current state (we cannot determine it). Monitors where this type of condition can occur must be able to account for racing events in any possible order, as we cannot know the winner. Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Gabriele Monaco --- include/linux/rv.h | 3 ++- include/rv/da_monitor.h | 53 +++++++++++++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/include/linux/rv.h b/include/linux/rv.h index 3452b5e4b29e..a83a81ac6e46 100644 --- a/include/linux/rv.h +++ b/include/linux/rv.h @@ -7,7 +7,8 @@ #ifndef _LINUX_RV_H #define _LINUX_RV_H =20 -#define MAX_DA_NAME_LEN 32 +#define MAX_DA_NAME_LEN 32 +#define MAX_DA_RETRY_RACING_EVENTS 3 =20 #ifdef CONFIG_RV /* diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index 215c3eb770cc..8b714e3085a5 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -82,16 +82,19 @@ static inline void da_monitor_reset_##name(struct da_mo= nitor *da_mon) \ */ \ static inline type da_monitor_curr_state_##name(struct da_monitor *da_mon)= \ { \ - return da_mon->curr_state; \ + return READ_ONCE(da_mon->curr_state); \ } \ \ /* \ * da_monitor_set_state_##name - set the new current state \ + * \ + * return false without the change in case the state was modified elsewher= e \ */ \ -static inline void \ -da_monitor_set_state_##name(struct da_monitor *da_mon, enum states_##name = state) \ +static inline bool \ +da_monitor_set_state_##name(struct da_monitor *da_mon, enum states_##name = prev_state, \ + enum states_##name state) \ { \ - da_mon->curr_state =3D state; \ + return try_cmpxchg(&da_mon->curr_state, &prev_state, state); \ } \ \ /* \ @@ -150,17 +153,29 @@ static inline bool da_monitor_handling_event_##name(s= truct da_monitor *da_mon) * Event handler for implicit monitors. Implicit monitor is the one which = the * handler does not need to specify which da_monitor to manipulate. Exampl= es * of implicit monitor are the per_cpu or the global ones. + * + * Retry, in case there is a race while getting and setting the next state + * return an invalid current state if we run out of retries. The monitor s= hould + * be able to handle various orders. */ #define DECLARE_DA_MON_MODEL_HANDLER_IMPLICIT(name, type) \ \ static inline bool \ da_event_##name(struct da_monitor *da_mon, enum events_##name event) \ { \ - type curr_state =3D da_monitor_curr_state_##name(da_mon); \ - type next_state =3D model_get_next_state_##name(curr_state, event); \ + bool changed; \ + type curr_state, next_state; \ \ - if (next_state !=3D INVALID_STATE) { \ - da_monitor_set_state_##name(da_mon, next_state); \ + for (int i =3D 0; i < MAX_DA_RETRY_RACING_EVENTS; i++) { \ + curr_state =3D da_monitor_curr_state_##name(da_mon); \ + next_state =3D model_get_next_state_##name(curr_state, event); \ + if (next_state =3D=3D INVALID_STATE) \ + break; \ + changed =3D da_monitor_set_state_##name(da_mon, curr_state, next_state);= \ + if (unlikely(!changed)) { \ + curr_state =3D -1; \ + continue; \ + } \ \ trace_event_##name(model_get_state_name_##name(curr_state), \ model_get_event_name_##name(event), \ @@ -181,17 +196,29 @@ da_event_##name(struct da_monitor *da_mon, enum event= s_##name event) \ =20 /* * Event handler for per_task monitors. + * + * Retry, in case there is a race while getting and setting the next state + * return an invalid current state if we run out of retries. The monitor s= hould + * be able to handle various orders. */ #define DECLARE_DA_MON_MODEL_HANDLER_PER_TASK(name, type) \ \ static inline bool da_event_##name(struct da_monitor *da_mon, struct task_= struct *tsk, \ enum events_##name event) \ { \ - type curr_state =3D da_monitor_curr_state_##name(da_mon); \ - type next_state =3D model_get_next_state_##name(curr_state, event); \ - \ - if (next_state !=3D INVALID_STATE) { \ - da_monitor_set_state_##name(da_mon, next_state); \ + bool changed; \ + type curr_state, next_state; \ + \ + for (int i =3D 0; i < MAX_DA_RETRY_RACING_EVENTS; i++) { \ + curr_state =3D da_monitor_curr_state_##name(da_mon); \ + next_state =3D model_get_next_state_##name(curr_state, event); \ + if (next_state =3D=3D INVALID_STATE) \ + break; \ + changed =3D da_monitor_set_state_##name(da_mon, curr_state, next_state);= \ + if (unlikely(!changed)) { \ + curr_state =3D -1; \ + continue; \ + } \ \ trace_event_##name(tsk->pid, \ model_get_state_name_##name(curr_state), \ --=20 2.49.0 From nobody Sat Feb 7 19:04:22 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 27D2E223709 for ; Wed, 14 May 2025 08:44:40 +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=1747212282; cv=none; b=jrrjWM8Uwj49TZs9uj22B3fC4JDprEucgk4IhMJP4oilB/yhX5/wq5fiu8bN8RN9VuD5y4xo0QD9uRm3Yqz1pceUNsJTGgTjEDJFP8phu48v9DpKWI9hjQNWs2NX8ZRbjTZQWPHTEk8PPWA0LUJG0IZHC2umGhrXVeShyyeyrII= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747212282; c=relaxed/simple; bh=/I9lczaKO4wv3xodZYdmVjIa5Oc9Hg0q0UbjqFMTLDk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gbSqESY7aC3xQvvvTBxPKOx5YgXvWHe6WGb7wfKUqWBCJ9EcOI4X9MqOivLcRhEGULO/+FhvMWwr8vSKbure5Q4KgKIBAh9kLruzzutlElMsQXWUe6vcXa4NDJBgg2qTFYRECw0hqRwKVyQ5Wf8AHEIetSBMpD2yMy/YETqfe70= 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=Hh3yXY8W; 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="Hh3yXY8W" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747212279; 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=XyCw39UVwF5+lsFb+1n3E4Hf/IaIoDMA5GDvhJHHGC0=; b=Hh3yXY8WbJMSUhlO9x46z9XwiCaCW+4Mmn94A/V/pqDBxpXFPd9rY6XXXBG2vHN2BN+Jzs iW22mRzcgs0zlc5ON9jEs3FXQtCALQRBBpZoNvV0KJC32UyB2171SjbwP/rubV5wtqL6dm hlZpWYcuf+N7NWYBlV4gcWTY+y1QZiQ= 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-613-8jx3a1y5PO-qFa8gKZNOSw-1; Wed, 14 May 2025 04:44:35 -0400 X-MC-Unique: 8jx3a1y5PO-qFa8gKZNOSw-1 X-Mimecast-MFC-AGG-ID: 8jx3a1y5PO-qFa8gKZNOSw_1747212274 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 766DD1956046; Wed, 14 May 2025 08:44:34 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.com (unknown [10.44.32.189]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 039DD1953B80; Wed, 14 May 2025 08:44:28 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Jonathan Corbet , Masami Hiramatsu , linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Gabriele Monaco , Ingo Molnar , Peter Zijlstra , Nam Cao , Tomas Glozar , Juri Lelli Subject: [RFC PATCH v2 11/12] rv: Add nrp and sssw per-task monitors Date: Wed, 14 May 2025 10:43:13 +0200 Message-ID: <20250514084314.57976-12-gmonaco@redhat.com> In-Reply-To: <20250514084314.57976-1-gmonaco@redhat.com> References: <20250514084314.57976-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.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" Add 2 per-task monitors as part of the sched model: * nrp: need-resched preempts Monitor to ensure preemption requires need resched. * sssw: set state sleep and wakeup Monitor to ensure sched_set_state to sleepable leads to sleeping and sleeping tasks require wakeup. Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Gabriele Monaco --- Documentation/trace/rv/monitor_sched.rst | 117 ++++++++++++++++++ include/linux/rv.h | 2 +- kernel/trace/rv/Kconfig | 2 + kernel/trace/rv/Makefile | 2 + kernel/trace/rv/monitors/nrp/Kconfig | 14 +++ kernel/trace/rv/monitors/nrp/nrp.c | 135 +++++++++++++++++++++ kernel/trace/rv/monitors/nrp/nrp.h | 51 ++++++++ kernel/trace/rv/monitors/nrp/nrp_trace.h | 15 +++ kernel/trace/rv/monitors/sssw/Kconfig | 15 +++ kernel/trace/rv/monitors/sssw/sssw.c | 115 ++++++++++++++++++ kernel/trace/rv/monitors/sssw/sssw.h | 64 ++++++++++ kernel/trace/rv/monitors/sssw/sssw_trace.h | 15 +++ kernel/trace/rv/rv_trace.h | 2 + tools/verification/models/sched/nrp.dot | 19 +++ tools/verification/models/sched/sssw.dot | 24 ++++ 15 files changed, 591 insertions(+), 1 deletion(-) create mode 100644 kernel/trace/rv/monitors/nrp/Kconfig create mode 100644 kernel/trace/rv/monitors/nrp/nrp.c create mode 100644 kernel/trace/rv/monitors/nrp/nrp.h create mode 100644 kernel/trace/rv/monitors/nrp/nrp_trace.h create mode 100644 kernel/trace/rv/monitors/sssw/Kconfig create mode 100644 kernel/trace/rv/monitors/sssw/sssw.c create mode 100644 kernel/trace/rv/monitors/sssw/sssw.h create mode 100644 kernel/trace/rv/monitors/sssw/sssw_trace.h create mode 100644 tools/verification/models/sched/nrp.dot create mode 100644 tools/verification/models/sched/sssw.dot diff --git a/Documentation/trace/rv/monitor_sched.rst b/Documentation/trace= /rv/monitor_sched.rst index e4171aadef1c..97f0f1a10f43 100644 --- a/Documentation/trace/rv/monitor_sched.rst +++ b/Documentation/trace/rv/monitor_sched.rst @@ -198,6 +198,123 @@ real task switch occurs:: +-------------- | | <-------------+ +--------------------+ =20 +Monitor nrp +----------- + +The need resched preempts (nrp) monitor ensures preemption requires need +resched. A preemption is any of the following types of ``sched_switch``: + +* ``sched_switch_preempt``: + a task is ``preempted``, this can happen after the need for ``rescheduli= ng`` + has been set, also in its ``lazy`` flavour (which doesn't make a differe= nt in + this monitor). ``need_resched`` can be set as a flag to the task or in t= he + per-core preemption count, either of them can trigger a preemption. +* ``sched_switch_vain_preempt``: + a task goes through the scheduler from a preemption context but it is pi= cked + as the next task to run, hence no real task switch occurs. Since we run = the + scheduler, this clears the need to reschedule. + +This monitor ignores when the task is switched in, as this complicates thi= ngs +when different types of ``sched_switch`` occur (e.g. sleeping or yielding,= here +marked as ``sched_switch_other`` or ``sched_switch_vain``). The snroc moni= tor +ensures a task is switched in before it can be switched out again. +For this reason, the ``any_thread_running`` state does not imply that the +monitored task is not running, simply it is not set for rescheduling:: + + | + | + v + sched_switch_other #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D# + sched_switch_vain H H + +--------------------- H any_thread_running H + | H H + +--------------------> H H <+ + #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D# | + | | + | | sched_switch_preempt + | | sched_switch_vain_pree= mpt + | sched_need_resched | sched_switch_other + | | sched_switch_vain + v | + sched_need_resched +---------------------+ | + +--------------------- | | | + | | rescheduling | | + +--------------------> | | -+ + +---------------------+ + +Monitor sssw +------------ + +The set state sleep and wakeup (sssw) monitor ensures ``sched_set_state`` = to +sleepable leads to sleeping and sleeping tasks require wakeup. +It includes the following types of ``sched_switch``: + +* ``switch_suspend``: + a task puts itself to sleep, this can happen only after explicitly setti= ng + the task to ``sleepable``. After a task is suspended, it needs to be wok= en up + (``waking`` state) before being switched in again. + Setting the task's state to ``sleepable`` can be reverted before switchi= ng if it + is woken up or set to ``runnable``. +* ``switch_blocked``: + a special case of a ``switch_suspend`` where the task is waiting on a + sleeping RT lock (``PREEMPT_RT`` only), it is common to see wakeup and s= et + state events racing with each other and this leads the model to perceive= this + type of switch when the task is not set to sleepable. This is a limitati= on of + the model in SMP system and workarounds may slow down the system. +* ``switch_yield``: + a task explicitly calls the scheduler, this looks like a preemption as t= he + task is still runnable but the ``need_resched`` flag is not set. It can + happen after a ``yield`` system call or from the idle task. By definitio= n, + a task cannot yield while ``sleepable`` as that would be a suspension. +* ``switch_vain``: + a task explicitly calls the scheduler but it is picked as the next task = to run, + hence no real task switch occurs. This can occur as a yield, which is not + valid when the task is sleepable. A special case of a yield is when a ta= sk in + ``TASK_INTERRUPTIBLE`` calls the scheduler while a signal is pending. The + task doesn't go through the usual blocking/waking and is set back to + runnable, the resulting switch looks like a yield. + +As for the nrp monitor, this monitor doesn't include a running state, +``sleepable`` and ``runnable`` are only referring to the task's desired +state, which could be scheduled out (e.g. due to preemption). However, it = does +include the event ``sched_switch_in`` to represent when a task is allowed = to +become running. This can be triggered also by preemption, but cannot occur +after the task got to ``sleeping`` until a ``wakeup``:: + + sched_set_state_runnable + sched_wakeup + sched_switch_vain_preempt | + sched_switch_preempt | + sched_switch_yield v + sched_switch_vain #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D# + +-----------------> H H + | H H + +------------------ H runnable H + H H + +-----------------> H H + | #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D# + sched_set_state_runnable | | ^ + sched_wakeup | sched_switch_blocking | + | sched_set_state_sleepable | | + | v | | + | +------------------------+ | sched_wake= up + +------------------ | | | | + | | | | + +-----------------> | sleepable | | | + | | | | | + +------------------ | | | | + sched_switch_in +------------------------+ | | + sched_switch_preempt | | | + sched_switch_vain_preempt sched_switch_suspend | | + sched_set_state_sleepable sched_switch_blocking | | + | | | + v | | + +------------------------+ | | + | sleeping | <-+ | + +------------------------+ | + | | + +----------------------------+ + References ---------- =20 diff --git a/include/linux/rv.h b/include/linux/rv.h index a83a81ac6e46..20c89f5b9a5b 100644 --- a/include/linux/rv.h +++ b/include/linux/rv.h @@ -25,7 +25,7 @@ struct da_monitor { * adding more or developing a dynamic method. So far, none of * these are justified. */ -#define RV_PER_TASK_MONITORS 1 +#define RV_PER_TASK_MONITORS 3 #define RV_PER_TASK_MONITOR_INIT (RV_PER_TASK_MONITORS) =20 /* diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig index a53a3eca9616..f106cf7b2fd3 100644 --- a/kernel/trace/rv/Kconfig +++ b/kernel/trace/rv/Kconfig @@ -34,6 +34,8 @@ source "kernel/trace/rv/monitors/scpd/Kconfig" source "kernel/trace/rv/monitors/snep/Kconfig" source "kernel/trace/rv/monitors/sncid/Kconfig" source "kernel/trace/rv/monitors/sts/Kconfig" +source "kernel/trace/rv/monitors/nrp/Kconfig" +source "kernel/trace/rv/monitors/sssw/Kconfig" # Add new monitors here =20 config RV_REACTORS diff --git a/kernel/trace/rv/Makefile b/kernel/trace/rv/Makefile index c609b72275cb..c076cf48af18 100644 --- a/kernel/trace/rv/Makefile +++ b/kernel/trace/rv/Makefile @@ -12,6 +12,8 @@ obj-$(CONFIG_RV_MON_SCPD) +=3D monitors/scpd/scpd.o obj-$(CONFIG_RV_MON_SNEP) +=3D monitors/snep/snep.o obj-$(CONFIG_RV_MON_SNCID) +=3D monitors/sncid/sncid.o obj-$(CONFIG_RV_MON_STS) +=3D monitors/sts/sts.o +obj-$(CONFIG_RV_MON_NRP) +=3D monitors/nrp/nrp.o +obj-$(CONFIG_RV_MON_SSSW) +=3D monitors/sssw/sssw.o # Add new monitors here obj-$(CONFIG_RV_REACTORS) +=3D rv_reactors.o obj-$(CONFIG_RV_REACT_PRINTK) +=3D reactor_printk.o diff --git a/kernel/trace/rv/monitors/nrp/Kconfig b/kernel/trace/rv/monitor= s/nrp/Kconfig new file mode 100644 index 000000000000..726f34259a6d --- /dev/null +++ b/kernel/trace/rv/monitors/nrp/Kconfig @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_NRP + depends on RV + depends on RV_MON_SCHED + default y + select DA_MON_EVENTS_ID + bool "nrp monitor" + help + Monitor to ensure preemption requires need resched. + This monitor is part of the sched monitors collection. + + For further information, see: + Documentation/trace/rv/monitor_sched.rst diff --git a/kernel/trace/rv/monitors/nrp/nrp.c b/kernel/trace/rv/monitors/= nrp/nrp.c new file mode 100644 index 000000000000..9349026bb60b --- /dev/null +++ b/kernel/trace/rv/monitors/nrp/nrp.c @@ -0,0 +1,135 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include +#include +#include + +#define MODULE_NAME "nrp" + +#include +#include +#include + +#include "nrp.h" + +static struct rv_monitor rv_nrp; +DECLARE_DA_MON_PER_TASK(nrp, unsigned char); + +static void handle_sched_need_resched(void *data, struct task_struct *tsk, + int cpu, int tif) +{ + da_handle_event_nrp(tsk, sched_need_resched_nrp); +} + +static void handle_schedule_entry(void *data, bool preempt, unsigned long = ip) +{ + /* + * In theory, a preemption can only occur after the need_resched flag + * is set. In practice, however, we may see a preemption where the flag + * is not set. This can happen in one specific condition: + * + * need_resched + * preempt_schedule() + * preempt_schedule_irq() + * __schedule() + * !need_resched + * __schedule() + * + * In the situation above, we start a standard preemption (e.g. from + * preempt_enable when the flag is set), an interrupts occurs before we + * schedule and, on its exit path, it schedules, which clears the + * need_resched flag. + * When the preempted task runs again, we continue the standard + * preemption started earlier, although the flag is no longer set. + * + * The following workaround allows the model not to fail in this + * condition, but makes it weaker. In fact, we are not proving that: + * 1. we don't miss any event setting need_resched + * 2. we don't preempt when not required + * + * Ideally, we should find a way to narrow down the condition, however + * that's rather tricky without adding several tracepoints in + * undesired locations. + */ + if (preempt && unlikely(!tif_need_resched())) + da_handle_event_nrp(current, sched_need_resched_nrp); +} + +static void handle_sched_switch(void *data, bool preempt, + struct task_struct *prev, + struct task_struct *next, + unsigned int prev_state) +{ + if (preempt) + da_handle_start_event_nrp(prev, sched_switch_preempt_nrp); + else + da_handle_start_event_nrp(prev, sched_switch_other_nrp); +} + +static void handle_sched_switch_vain(void *data, bool preempt, + struct task_struct *tsk, + unsigned int tsk_state) +{ + if (preempt) + da_handle_start_event_nrp(tsk, sched_switch_vain_preempt_nrp); + else + da_handle_start_event_nrp(tsk, sched_switch_vain_nrp); +} + +static int enable_nrp(void) +{ + int retval; + + retval =3D da_monitor_init_nrp(); + if (retval) + return retval; + + rv_attach_trace_probe("snep", sched_entry_tp, handle_schedule_entry); + rv_attach_trace_probe("nrp", sched_set_need_resched_tp, handle_sched_need= _resched); + rv_attach_trace_probe("nrp", sched_switch, handle_sched_switch); + rv_attach_trace_probe("nrp", sched_switch_vain_tp, handle_sched_switch_va= in); + + return 0; +} + +static void disable_nrp(void) +{ + rv_nrp.enabled =3D 0; + + rv_detach_trace_probe("snep", sched_entry_tp, handle_schedule_entry); + rv_detach_trace_probe("nrp", sched_set_need_resched_tp, handle_sched_need= _resched); + rv_detach_trace_probe("nrp", sched_switch, handle_sched_switch); + rv_detach_trace_probe("nrp", sched_switch_vain_tp, handle_sched_switch_va= in); + + da_monitor_destroy_nrp(); +} + +static struct rv_monitor rv_nrp =3D { + .name =3D "nrp", + .description =3D "need resched preempts.", + .enable =3D enable_nrp, + .disable =3D disable_nrp, + .reset =3D da_monitor_reset_all_nrp, + .enabled =3D 0, +}; + +static int __init register_nrp(void) +{ + return rv_register_monitor(&rv_nrp, &rv_sched); +} + +static void __exit unregister_nrp(void) +{ + rv_unregister_monitor(&rv_nrp); +} + +module_init(register_nrp); +module_exit(unregister_nrp); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Gabriele Monaco "); +MODULE_DESCRIPTION("nrp: need resched preempts."); diff --git a/kernel/trace/rv/monitors/nrp/nrp.h b/kernel/trace/rv/monitors/= nrp/nrp.h new file mode 100644 index 000000000000..51c0e23da72a --- /dev/null +++ b/kernel/trace/rv/monitors/nrp/nrp.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Automatically generated C representation of nrp automaton + * For further information about this format, see kernel documentation: + * Documentation/trace/rv/deterministic_automata.rst + */ + +enum states_nrp { + any_thread_running_nrp =3D 0, + rescheduling_nrp, + state_max_nrp +}; + +#define INVALID_STATE state_max_nrp + +enum events_nrp { + sched_need_resched_nrp =3D 0, + sched_switch_other_nrp, + sched_switch_preempt_nrp, + sched_switch_vain_nrp, + sched_switch_vain_preempt_nrp, + event_max_nrp +}; + +struct automaton_nrp { + char *state_names[state_max_nrp]; + char *event_names[event_max_nrp]; + unsigned char function[state_max_nrp][event_max_nrp]; + unsigned char initial_state; + bool final_states[state_max_nrp]; +}; + +static const struct automaton_nrp automaton_nrp =3D { + .state_names =3D { + "any_thread_running", + "rescheduling" + }, + .event_names =3D { + "sched_need_resched", + "sched_switch_other", + "sched_switch_preempt", + "sched_switch_vain", + "sched_switch_vain_preempt" + }, + .function =3D { + { rescheduling_nrp, any_thread_running_nrp, INVALID_STAT= E, any_thread_running_nrp, INVALID_STATE }, + { rescheduling_nrp, any_thread_running_nrp, any_thread_running_nrp= , any_thread_running_nrp, any_thread_running_nrp }, + }, + .initial_state =3D any_thread_running_nrp, + .final_states =3D { 1, 0 }, +}; diff --git a/kernel/trace/rv/monitors/nrp/nrp_trace.h b/kernel/trace/rv/mon= itors/nrp/nrp_trace.h new file mode 100644 index 000000000000..2e13497de3b6 --- /dev/null +++ b/kernel/trace/rv/monitors/nrp/nrp_trace.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * Snippet to be included in rv_trace.h + */ + +#ifdef CONFIG_RV_MON_NRP +DEFINE_EVENT(event_da_monitor_id, event_nrp, + TP_PROTO(int id, char *state, char *event, char *next_state, bool fi= nal_state), + TP_ARGS(id, state, event, next_state, final_state)); + +DEFINE_EVENT(error_da_monitor_id, error_nrp, + TP_PROTO(int id, char *state, char *event), + TP_ARGS(id, state, event)); +#endif /* CONFIG_RV_MON_NRP */ diff --git a/kernel/trace/rv/monitors/sssw/Kconfig b/kernel/trace/rv/monito= rs/sssw/Kconfig new file mode 100644 index 000000000000..23b7eeb38bbf --- /dev/null +++ b/kernel/trace/rv/monitors/sssw/Kconfig @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_SSSW + depends on RV + depends on RV_MON_SCHED + default y + select DA_MON_EVENTS_ID + bool "sssw monitor" + help + Monitor to ensure sched_set_state to sleepable leads to sleeping and + sleeping tasks require wakeup. + This monitor is part of the sched monitors collection. + + For further information, see: + Documentation/trace/rv/monitor_sched.rst diff --git a/kernel/trace/rv/monitors/sssw/sssw.c b/kernel/trace/rv/monitor= s/sssw/sssw.c new file mode 100644 index 000000000000..efa695dead36 --- /dev/null +++ b/kernel/trace/rv/monitors/sssw/sssw.c @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include +#include +#include + +#define MODULE_NAME "sssw" + +#include +#include +#include + +#include "sssw.h" + +static struct rv_monitor rv_sssw; +DECLARE_DA_MON_PER_TASK(sssw, unsigned char); + +static void handle_sched_set_state(void *data, struct task_struct *tsk, + int state, bool from_signal) +{ + if (state =3D=3D TASK_RUNNING) + da_handle_start_event_sssw(tsk, sched_set_state_runnable_sssw); + else + da_handle_event_sssw(tsk, sched_set_state_sleepable_sssw); +} + +static void handle_sched_switch(void *data, bool preempt, + struct task_struct *prev, + struct task_struct *next, + unsigned int prev_state) +{ + if (preempt) + da_handle_event_sssw(prev, sched_switch_preempt_sssw); + else if (prev_state =3D=3D TASK_RUNNING) + da_handle_start_event_sssw(prev, sched_switch_yield_sssw); + else if (prev_state =3D=3D TASK_RTLOCK_WAIT) + /* special case of sleeping task with racy conditions */ + da_handle_event_sssw(prev, sched_switch_blocking_sssw); + else + da_handle_event_sssw(prev, sched_switch_suspend_sssw); + da_handle_event_sssw(next, sched_switch_in_sssw); +} + +static void handle_sched_switch_vain(void *data, bool preempt, + struct task_struct *tsk, + unsigned int tsk_state) +{ + if (preempt) + da_handle_event_sssw(tsk, sched_switch_vain_preempt_sssw); + else + da_handle_start_event_sssw(tsk, sched_switch_vain_sssw); +} + +static void handle_sched_wakeup(void *data, struct task_struct *p) +{ + da_handle_start_event_sssw(p, sched_wakeup_sssw); +} + +static int enable_sssw(void) +{ + int retval; + + retval =3D da_monitor_init_sssw(); + if (retval) + return retval; + + rv_attach_trace_probe("sssw", sched_set_state_tp, handle_sched_set_state); + rv_attach_trace_probe("sssw", sched_switch, handle_sched_switch); + rv_attach_trace_probe("sssw", sched_switch_vain_tp, handle_sched_switch_v= ain); + rv_attach_trace_probe("sssw", sched_wakeup, handle_sched_wakeup); + + return 0; +} + +static void disable_sssw(void) +{ + rv_sssw.enabled =3D 0; + + rv_detach_trace_probe("sssw", sched_set_state_tp, handle_sched_set_state); + rv_detach_trace_probe("sssw", sched_switch, handle_sched_switch); + rv_detach_trace_probe("sssw", sched_switch_vain_tp, handle_sched_switch_v= ain); + rv_detach_trace_probe("sssw", sched_wakeup, handle_sched_wakeup); + + da_monitor_destroy_sssw(); +} + +static struct rv_monitor rv_sssw =3D { + .name =3D "sssw", + .description =3D "set state sleep and wakeup.", + .enable =3D enable_sssw, + .disable =3D disable_sssw, + .reset =3D da_monitor_reset_all_sssw, + .enabled =3D 0, +}; + +static int __init register_sssw(void) +{ + return rv_register_monitor(&rv_sssw, &rv_sched); +} + +static void __exit unregister_sssw(void) +{ + rv_unregister_monitor(&rv_sssw); +} + +module_init(register_sssw); +module_exit(unregister_sssw); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Gabriele Monaco "); +MODULE_DESCRIPTION("sssw: set state sleep and wakeup."); diff --git a/kernel/trace/rv/monitors/sssw/sssw.h b/kernel/trace/rv/monitor= s/sssw/sssw.h new file mode 100644 index 000000000000..ae95a03bf2f3 --- /dev/null +++ b/kernel/trace/rv/monitors/sssw/sssw.h @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Automatically generated C representation of sssw automaton + * For further information about this format, see kernel documentation: + * Documentation/trace/rv/deterministic_automata.rst + */ + +enum states_sssw { + runnanble_sssw =3D 0, + sleepable_sssw, + sleeping_sssw, + state_max_sssw +}; + +#define INVALID_STATE state_max_sssw + +enum events_sssw { + sched_set_state_runnable_sssw =3D 0, + sched_set_state_sleepable_sssw, + sched_switch_blocking_sssw, + sched_switch_in_sssw, + sched_switch_preempt_sssw, + sched_switch_suspend_sssw, + sched_switch_vain_sssw, + sched_switch_vain_preempt_sssw, + sched_switch_yield_sssw, + sched_wakeup_sssw, + event_max_sssw +}; + +struct automaton_sssw { + char *state_names[state_max_sssw]; + char *event_names[event_max_sssw]; + unsigned char function[state_max_sssw][event_max_sssw]; + unsigned char initial_state; + bool final_states[state_max_sssw]; +}; + +static const struct automaton_sssw automaton_sssw =3D { + .state_names =3D { + "runnanble", + "sleepable", + "sleeping" + }, + .event_names =3D { + "sched_set_state_runnable", + "sched_set_state_sleepable", + "sched_switch_blocking", + "sched_switch_in", + "sched_switch_preempt", + "sched_switch_suspend", + "sched_switch_vain", + "sched_switch_vain_preempt", + "sched_switch_yield", + "sched_wakeup" + }, + .function =3D { + { runnanble_sssw, sleepable_sssw, sleeping_sssw, runnan= ble_sssw, runnanble_sssw, INVALID_STATE, runnanble_sssw, r= unnanble_sssw, runnanble_sssw, runnanble_sssw }, + { runnanble_sssw, sleepable_sssw, sleeping_sssw, sleepa= ble_sssw, sleepable_sssw, sleeping_sssw, INVALID_STATE, s= leepable_sssw, INVALID_STATE, runnanble_sssw }, + { INVALID_STATE, INVALID_STATE, INVALID_STATE, INVAL= ID_STATE, INVALID_STATE, INVALID_STATE, INVALID_STATE, = INVALID_STATE, INVALID_STATE, runnanble_sssw }, + }, + .initial_state =3D runnanble_sssw, + .final_states =3D { 1, 0, 0 }, +}; diff --git a/kernel/trace/rv/monitors/sssw/sssw_trace.h b/kernel/trace/rv/m= onitors/sssw/sssw_trace.h new file mode 100644 index 000000000000..6c03cfc6960b --- /dev/null +++ b/kernel/trace/rv/monitors/sssw/sssw_trace.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * Snippet to be included in rv_trace.h + */ + +#ifdef CONFIG_RV_MON_SSSW +DEFINE_EVENT(event_da_monitor_id, event_sssw, + TP_PROTO(int id, char *state, char *event, char *next_state, bool fi= nal_state), + TP_ARGS(id, state, event, next_state, final_state)); + +DEFINE_EVENT(error_da_monitor_id, error_sssw, + TP_PROTO(int id, char *state, char *event), + TP_ARGS(id, state, event)); +#endif /* CONFIG_RV_MON_SSSW */ diff --git a/kernel/trace/rv/rv_trace.h b/kernel/trace/rv/rv_trace.h index a5e1c52e2992..d12ab74dcabc 100644 --- a/kernel/trace/rv/rv_trace.h +++ b/kernel/trace/rv/rv_trace.h @@ -124,6 +124,8 @@ DECLARE_EVENT_CLASS(error_da_monitor_id, =20 #include #include +#include +#include // Add new monitors based on CONFIG_DA_MON_EVENTS_ID here =20 #endif /* CONFIG_DA_MON_EVENTS_ID */ diff --git a/tools/verification/models/sched/nrp.dot b/tools/verification/m= odels/sched/nrp.dot new file mode 100644 index 000000000000..6aa7604e98fc --- /dev/null +++ b/tools/verification/models/sched/nrp.dot @@ -0,0 +1,19 @@ +digraph state_automaton { + center =3D true; + size =3D "7,11"; + {node [shape =3D plaintext, style=3Dinvis, label=3D""] "__init_any_thread= _running"}; + {node [shape =3D doublecircle] "any_thread_running"}; + {node [shape =3D circle] "any_thread_running"}; + {node [shape =3D circle] "rescheduling"}; + "__init_any_thread_running" -> "any_thread_running"; + "any_thread_running" [label =3D "any_thread_running", color =3D green3]; + "any_thread_running" -> "any_thread_running" [ label =3D "sched_switch_ot= her\nsched_switch_vain" ]; + "any_thread_running" -> "rescheduling" [ label =3D "sched_need_resched" ]; + "rescheduling" [label =3D "rescheduling"]; + "rescheduling" -> "any_thread_running" [ label =3D "sched_switch_preempt\= nsched_switch_vain_preempt\nsched_switch_other\nsched_switch_vain" ]; + "rescheduling" -> "rescheduling" [ label =3D "sched_need_resched" ]; + { rank =3D min ; + "__init_any_thread_running"; + "any_thread_running"; + } +} diff --git a/tools/verification/models/sched/sssw.dot b/tools/verification/= models/sched/sssw.dot new file mode 100644 index 000000000000..362e783f2bd5 --- /dev/null +++ b/tools/verification/models/sched/sssw.dot @@ -0,0 +1,24 @@ +digraph state_automaton { + center =3D true; + size =3D "7,11"; + {node [shape =3D plaintext, style=3Dinvis, label=3D""] "__init_runnanble"= }; + {node [shape =3D doublecircle] "runnanble"}; + {node [shape =3D circle] "runnanble"}; + {node [shape =3D circle] "sleepable"}; + {node [shape =3D circle] "sleeping"}; + "__init_runnanble" -> "runnanble"; + "runnanble" [label =3D "runnanble", color =3D green3]; + "runnanble" -> "runnanble" [ label =3D "sched_set_state_runnable\nsched_w= akeup\nsched_switch_in\nsched_switch_vain\nsched_switch_yield\nsched_switch= _preempt\nsched_switch_vain_preempt" ]; + "runnanble" -> "sleepable" [ label =3D "sched_set_state_sleepable" ]; + "runnanble" -> "sleeping" [ label =3D "sched_switch_blocking" ]; + "sleepable" [label =3D "sleepable"]; + "sleepable" -> "runnanble" [ label =3D "sched_set_state_runnable\nsched_w= akeup" ]; + "sleepable" -> "sleepable" [ label =3D "sched_set_state_sleepable\nsched_= switch_in\nsched_switch_preempt\nsched_switch_vain_preempt" ]; + "sleepable" -> "sleeping" [ label =3D "sched_switch_suspend\nsched_switch= _blocking" ]; + "sleeping" [label =3D "sleeping"]; + "sleeping" -> "runnanble" [ label =3D "sched_wakeup" ]; + { rank =3D min ; + "__init_runnanble"; + "runnanble"; + } +} --=20 2.49.0 From nobody Sat Feb 7 19:04:22 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 96923223DED for ; Wed, 14 May 2025 08:44:47 +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=1747212289; cv=none; b=Y6Y8HLtYU60DL43ZgGHMeKdgrYASb+Pqu7caiuAKUt6wQUQCPP2sfLg6xmXU2v2yGcoNdFfd35gH2ybVg1BuCAF94Xbcqjkvr5E/evlson4XdzaWNej5to8/etyLmiu0QtgnkX+xPdsCpPqbJpJNQ/vxb9oRoLrA5Yq1eM1r38k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747212289; c=relaxed/simple; bh=JQllrsynzjm68Qj/f/HNSQitBzIq2FfcbBmseRxy/mA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SKkFOiFjKQC1phNjRBwXcIzxqQiKMDb4G67LTEBKPXe0R5GR5vMWyFJm9BFtO52ELiG6jGobqem2MxBBC8bD8CcZtFtEv0mx46Z+SzSPnxChFGd1ra8NUravqCaFMupezcWHUK+VOTbvBZ1i6uC6xTm5yBAk0MT/d8uy7E3OS0A= 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=eDfT7ykd; 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="eDfT7ykd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747212286; 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=tDUti7k9M7nDIV6nH94mmZUc7PAtTA41xzVPHy++Yzo=; b=eDfT7ykd7U7VfL9oZF69b7dYsQJA1m/dbbRvGIrdb1AuDhLjZNpb0y5SYrbrmT4FuY1ZVC V+3cO6rWp8e2JMVElbyPX+QMNtxDufY6lJJsf3DPfwG6AeICGZ98UjbR8X8p5M4f9Hbnkj UmeS1mMGWhnH/xIzK30+mNrV4+yHnZE= 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-17-MlX00-HuN-GuKdOmZA5pVw-1; Wed, 14 May 2025 04:44:43 -0400 X-MC-Unique: MlX00-HuN-GuKdOmZA5pVw-1 X-Mimecast-MFC-AGG-ID: MlX00-HuN-GuKdOmZA5pVw_1747212281 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 D138A180035E; Wed, 14 May 2025 08:44:41 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.com (unknown [10.44.32.189]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 48A761953B80; Wed, 14 May 2025 08:44:35 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Jonathan Corbet , Masami Hiramatsu , linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Gabriele Monaco , Ingo Molnar , Peter Zijlstra , Nam Cao , Tomas Glozar , Juri Lelli Subject: [RFC PATCH v2 12/12] rv: Add opid per-cpu monitor Date: Wed, 14 May 2025 10:43:14 +0200 Message-ID: <20250514084314.57976-13-gmonaco@redhat.com> In-Reply-To: <20250514084314.57976-1-gmonaco@redhat.com> References: <20250514084314.57976-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.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" Add a per-cpu monitor as part of the sched model: * opid: operations with preemption and irq disabled Monitor to ensure wakeup and need_resched occur with irq and preemption disabled or in irq handlers. Signed-off-by: Gabriele Monaco --- Documentation/trace/rv/monitor_sched.rst | 48 +++++++ kernel/trace/rv/Kconfig | 1 + kernel/trace/rv/Makefile | 1 + kernel/trace/rv/monitors/opid/Kconfig | 17 +++ kernel/trace/rv/monitors/opid/opid.c | 151 +++++++++++++++++++++ kernel/trace/rv/monitors/opid/opid.h | 64 +++++++++ kernel/trace/rv/monitors/opid/opid_trace.h | 15 ++ kernel/trace/rv/rv_trace.h | 1 + tools/verification/models/sched/opid.dot | 35 +++++ 9 files changed, 333 insertions(+) create mode 100644 kernel/trace/rv/monitors/opid/Kconfig create mode 100644 kernel/trace/rv/monitors/opid/opid.c create mode 100644 kernel/trace/rv/monitors/opid/opid.h create mode 100644 kernel/trace/rv/monitors/opid/opid_trace.h create mode 100644 tools/verification/models/sched/opid.dot diff --git a/Documentation/trace/rv/monitor_sched.rst b/Documentation/trace= /rv/monitor_sched.rst index 97f0f1a10f43..f044bca7ac31 100644 --- a/Documentation/trace/rv/monitor_sched.rst +++ b/Documentation/trace/rv/monitor_sched.rst @@ -315,6 +315,54 @@ after the task got to ``sleeping`` until a ``wakeup``:: | | +----------------------------+ =20 +Monitor opid +------------ + +The operations with preemption and irq disabled (opid) monitor ensures +operations like ``wakeup`` and ``need_resched`` occur with interrupts and +preemption disabled or during IRQs, in such case preemption may not be dis= abled +explicitly. +``need_resched`` can be set by some RCU internals functions, in which case= it +doesn't match a task wakeup and might occur with only interrupts disabled:: + + | sched_need_resched + | sched_waking + | irq_entry + | +--------------------+ + v v | + +------------------------------------------------------+ + +----------- | disabled | <+ + | +------------------------------------------------------+ | + | | ^ | + | | preempt_disable sched_need_resched | + | preempt_enable | +--------------------+ | + | v | v | | + | +------------------------------------------------------+ | + | | irq_disabled | | + | +------------------------------------------------------+ | + | | | ^ | + | irq_entry | | | + | sched_need_resched v | irq_disable | + | sched_waking +--------------+ | | | + | +----- | | irq_enable | | + | | | in_irq | | | | + | +----> | | | | | + | +--------------+ | | irq_dis= able + | | | | | + | irq_enable | irq_enable | | | + | v v | | + | #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D# | + | H enabled H | + | #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D# | + | | ^ ^ preempt_enable | | + | preempt_disable preempt_enable +--------------------+ | + | v | | + | +------------------+ | | + +----------> | preempt_disabled | -+ | + +------------------+ | + | | + +-------------------------------------------------------+ + References ---------- =20 diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig index f106cf7b2fd3..9ebb80931a9f 100644 --- a/kernel/trace/rv/Kconfig +++ b/kernel/trace/rv/Kconfig @@ -36,6 +36,7 @@ source "kernel/trace/rv/monitors/sncid/Kconfig" source "kernel/trace/rv/monitors/sts/Kconfig" source "kernel/trace/rv/monitors/nrp/Kconfig" source "kernel/trace/rv/monitors/sssw/Kconfig" +source "kernel/trace/rv/monitors/opid/Kconfig" # Add new monitors here =20 config RV_REACTORS diff --git a/kernel/trace/rv/Makefile b/kernel/trace/rv/Makefile index c076cf48af18..0eca5e77d0d2 100644 --- a/kernel/trace/rv/Makefile +++ b/kernel/trace/rv/Makefile @@ -14,6 +14,7 @@ obj-$(CONFIG_RV_MON_SNCID) +=3D monitors/sncid/sncid.o obj-$(CONFIG_RV_MON_STS) +=3D monitors/sts/sts.o obj-$(CONFIG_RV_MON_NRP) +=3D monitors/nrp/nrp.o obj-$(CONFIG_RV_MON_SSSW) +=3D monitors/sssw/sssw.o +obj-$(CONFIG_RV_MON_OPID) +=3D monitors/opid/opid.o # Add new monitors here obj-$(CONFIG_RV_REACTORS) +=3D rv_reactors.o obj-$(CONFIG_RV_REACT_PRINTK) +=3D reactor_printk.o diff --git a/kernel/trace/rv/monitors/opid/Kconfig b/kernel/trace/rv/monito= rs/opid/Kconfig new file mode 100644 index 000000000000..c59d51654cd1 --- /dev/null +++ b/kernel/trace/rv/monitors/opid/Kconfig @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_OPID + depends on RV + depends on IRQSOFF_TRACER + depends on PREEMPT_TRACER + depends on RV_MON_SCHED + default y + select DA_MON_EVENTS_IMPLICIT + bool "opid monitor" + help + Monitor to ensure operations like wakeup and need resched occur with + interrupts and preemption disabled or during IRQs, where preemption + may not be disabled explicitly. + + For further information, see: + Documentation/trace/rv/monitor_sched.rst diff --git a/kernel/trace/rv/monitors/opid/opid.c b/kernel/trace/rv/monitor= s/opid/opid.c new file mode 100644 index 000000000000..d8732d681753 --- /dev/null +++ b/kernel/trace/rv/monitors/opid/opid.c @@ -0,0 +1,151 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include +#include +#include + +#define MODULE_NAME "opid" + +#include +#include +#include +#include +#include + +#include "opid.h" + +static struct rv_monitor rv_opid; +DECLARE_DA_MON_PER_CPU(opid, unsigned char); + +#ifdef CONFIG_X86_LOCAL_APIC +#include + +static void handle_vector_irq_entry(void *data, int vector) +{ + da_handle_event_opid(irq_entry_opid); +} + +static void attach_vector_irq(void) { + rv_attach_trace_probe("opid", local_timer_entry, handle_vector_irq_entry); +} + +static void detach_vector_irq(void) { + rv_detach_trace_probe("opid", local_timer_entry, handle_vector_irq_entry); +} + +#else +/* We assume irq_entry tracepoints are sufficient on other architectures */ +static void attach_vector_irq() { } +static void detach_vector_irq() { } +#endif + +static void handle_irq_disable(void *data, unsigned long ip, unsigned long= parent_ip) +{ + da_handle_event_opid(irq_disable_opid); +} + +static void handle_irq_enable(void *data, unsigned long ip, unsigned long = parent_ip) +{ + da_handle_event_opid(irq_enable_opid); +} + +static void handle_irq_entry(void *data, int irq, struct irqaction *action) +{ + da_handle_event_opid(irq_entry_opid); +} + +static void handle_preempt_disable(void *data, unsigned long ip, unsigned = long parent_ip) +{ + da_handle_event_opid(preempt_disable_opid); +} + +static void handle_preempt_enable(void *data, unsigned long ip, unsigned l= ong parent_ip) +{ + da_handle_event_opid(preempt_enable_opid); +} + +static void handle_sched_need_resched(void *data, struct task_struct *tsk,= int cpu, int tif) +{ + if(in_irq()) + da_handle_event_opid(sched_need_resched_opid); + else + da_handle_start_event_opid(sched_need_resched_opid); +} + +static void handle_sched_waking(void *data, struct task_struct *p) +{ + if(in_irq()) + da_handle_event_opid(sched_waking_opid); + else + da_handle_start_event_opid(sched_waking_opid); +} + +static int enable_opid(void) +{ + int retval; + + retval =3D da_monitor_init_opid(); + if (retval) + return retval; + + rv_attach_trace_probe("opid", irq_disable, handle_irq_disable); + rv_attach_trace_probe("opid", irq_enable, handle_irq_enable); + rv_attach_trace_probe("opid", irq_handler_entry, handle_irq_entry); + rv_attach_trace_probe("opid", preempt_disable, handle_preempt_disable); + rv_attach_trace_probe("opid", preempt_enable, handle_preempt_enable); + rv_attach_trace_probe("opid", sched_set_need_resched_tp, handle_sched_nee= d_resched); + rv_attach_trace_probe("opid", sched_waking, handle_sched_waking); + attach_vector_irq(); + + return 0; +} + +static void disable_opid(void) +{ + rv_opid.enabled =3D 0; + + rv_detach_trace_probe("opid", irq_disable, handle_irq_disable); + rv_detach_trace_probe("opid", irq_enable, handle_irq_enable); + rv_detach_trace_probe("opid", irq_handler_entry, handle_irq_entry); + rv_detach_trace_probe("opid", preempt_disable, handle_preempt_disable); + rv_detach_trace_probe("opid", preempt_enable, handle_preempt_enable); + 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); + detach_vector_irq(); + + da_monitor_destroy_opid(); +} + +/* + * This is the monitor register section. + */ +static struct rv_monitor rv_opid =3D { + .name =3D "opid", + .description =3D "operations with preemption and irq disabled.", + .enable =3D enable_opid, + .disable =3D disable_opid, + .reset =3D da_monitor_reset_all_opid, + .enabled =3D 0, +}; + +static int __init register_opid(void) +{ + rv_register_monitor(&rv_opid, &rv_sched); + return 0; +} + +static void __exit unregister_opid(void) +{ + rv_unregister_monitor(&rv_opid); +} + +module_init(register_opid); +module_exit(unregister_opid); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Gabriele Monaco "); +MODULE_DESCRIPTION("opid: operations with preemption and irq disabled."); diff --git a/kernel/trace/rv/monitors/opid/opid.h b/kernel/trace/rv/monitor= s/opid/opid.h new file mode 100644 index 000000000000..4c6d4a3964c5 --- /dev/null +++ b/kernel/trace/rv/monitors/opid/opid.h @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Automatically generated C representation of opid automaton + * For further information about this format, see kernel documentation: + * Documentation/trace/rv/deterministic_automata.rst + */ + +enum states_opid { + disabled_opid =3D 0, + enabled_opid, + in_irq_opid, + irq_disabled_opid, + preempt_disabled_opid, + state_max_opid +}; + +#define INVALID_STATE state_max_opid + +enum events_opid { + irq_disable_opid =3D 0, + irq_enable_opid, + irq_entry_opid, + preempt_disable_opid, + preempt_enable_opid, + sched_need_resched_opid, + sched_waking_opid, + event_max_opid +}; + +struct automaton_opid { + char *state_names[state_max_opid]; + char *event_names[event_max_opid]; + unsigned char function[state_max_opid][event_max_opid]; + unsigned char initial_state; + bool final_states[state_max_opid]; +}; + +static const struct automaton_opid automaton_opid =3D { + .state_names =3D { + "disabled", + "enabled", + "in_irq", + "irq_disabled", + "preempt_disabled" + }, + .event_names =3D { + "irq_disable", + "irq_enable", + "irq_entry", + "preempt_disable", + "preempt_enable", + "sched_need_resched", + "sched_waking" + }, + .function =3D { + { INVALID_STATE, preempt_disabled_opid, disabled_opid, = INVALID_STATE, irq_disabled_opid, disabled_opid, = disabled_opid }, + { irq_disabled_opid, INVALID_STATE, INVALID_STATE, p= reempt_disabled_opid, enabled_opid, INVALID_STATE, = INVALID_STATE }, + { INVALID_STATE, enabled_opid, INVALID_STATE, = INVALID_STATE, INVALID_STATE, in_irq_opid, = in_irq_opid }, + { INVALID_STATE, enabled_opid, in_irq_opid, = disabled_opid, INVALID_STATE, irq_disabled_opid, = INVALID_STATE }, + { disabled_opid, INVALID_STATE, INVALID_STATE, = INVALID_STATE, enabled_opid, INVALID_STATE, = INVALID_STATE }, + }, + .initial_state =3D disabled_opid, + .final_states =3D { 0, 1, 0, 0, 0 }, +}; diff --git a/kernel/trace/rv/monitors/opid/opid_trace.h b/kernel/trace/rv/m= onitors/opid/opid_trace.h new file mode 100644 index 000000000000..3df6ff955c30 --- /dev/null +++ b/kernel/trace/rv/monitors/opid/opid_trace.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * Snippet to be included in rv_trace.h + */ + +#ifdef CONFIG_RV_MON_OPID +DEFINE_EVENT(event_da_monitor, event_opid, + TP_PROTO(char *state, char *event, char *next_state, bool final_stat= e), + TP_ARGS(state, event, next_state, final_state)); + +DEFINE_EVENT(error_da_monitor, error_opid, + TP_PROTO(char *state, char *event), + TP_ARGS(state, event)); +#endif /* CONFIG_RV_MON_OPID */ diff --git a/kernel/trace/rv/rv_trace.h b/kernel/trace/rv/rv_trace.h index d12ab74dcabc..5d3c5c3f7545 100644 --- a/kernel/trace/rv/rv_trace.h +++ b/kernel/trace/rv/rv_trace.h @@ -63,6 +63,7 @@ DECLARE_EVENT_CLASS(error_da_monitor, #include #include #include +#include // Add new monitors based on CONFIG_DA_MON_EVENTS_IMPLICIT here =20 #endif /* CONFIG_DA_MON_EVENTS_IMPLICIT */ diff --git a/tools/verification/models/sched/opid.dot b/tools/verification/= models/sched/opid.dot new file mode 100644 index 000000000000..2d5e1df3405f --- /dev/null +++ b/tools/verification/models/sched/opid.dot @@ -0,0 +1,35 @@ +digraph state_automaton { + center =3D true; + size =3D "7,11"; + {node [shape =3D plaintext, style=3Dinvis, label=3D""] "__init_disabled"}; + {node [shape =3D circle] "disabled"}; + {node [shape =3D doublecircle] "enabled"}; + {node [shape =3D circle] "enabled"}; + {node [shape =3D circle] "in_irq"}; + {node [shape =3D circle] "irq_disabled"}; + {node [shape =3D circle] "preempt_disabled"}; + "__init_disabled" -> "disabled"; + "disabled" [label =3D "disabled"]; + "disabled" -> "disabled" [ label =3D "sched_need_resched\nsched_waking\ni= rq_entry" ]; + "disabled" -> "irq_disabled" [ label =3D "preempt_enable" ]; + "disabled" -> "preempt_disabled" [ label =3D "irq_enable" ]; + "enabled" [label =3D "enabled", color =3D green3]; + "enabled" -> "enabled" [ label =3D "preempt_enable" ]; + "enabled" -> "irq_disabled" [ label =3D "irq_disable" ]; + "enabled" -> "preempt_disabled" [ label =3D "preempt_disable" ]; + "in_irq" [label =3D "in_irq"]; + "in_irq" -> "enabled" [ label =3D "irq_enable" ]; + "in_irq" -> "in_irq" [ label =3D "sched_need_resched\nsched_waking" ]; + "irq_disabled" [label =3D "irq_disabled"]; + "irq_disabled" -> "disabled" [ label =3D "preempt_disable" ]; + "irq_disabled" -> "enabled" [ label =3D "irq_enable" ]; + "irq_disabled" -> "in_irq" [ label =3D "irq_entry" ]; + "irq_disabled" -> "irq_disabled" [ label =3D "sched_need_resched" ]; + "preempt_disabled" [label =3D "preempt_disabled"]; + "preempt_disabled" -> "disabled" [ label =3D "irq_disable" ]; + "preempt_disabled" -> "enabled" [ label =3D "preempt_enable" ]; + { rank =3D min ; + "__init_disabled"; + "disabled"; + } +} --=20 2.49.0