From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.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 52E5B472F64 for ; Wed, 22 Jul 2026 11:37:55 +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=1784720277; cv=none; b=m0rK0oW//nf2vQMub0nSNytCBl0nIhVWUJYy1e/zlHJcqG+mb3hUc3VvC3QCIgIdRwdU3k23YlNdl0NCO63zjExFr1uoYEss0cxtGNFugnNyNti6XWGNydO2hI/I5jL5TDiSi1B+dFUfKVOragBl7/z9a6QbIcRX6xM+Ic7mBDw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784720277; c=relaxed/simple; bh=ljGt4LvhCKfFQTgx3PNYB8uvJjwOIj2Gsg2thpZt+pY=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=gkjJexKPAzYuUv1dsSVjAgEmh+c1nN43dafJ7XYaA953E/pa+pG9VgU5+cQN4CEkYj1ggCNKV1UO0pUj8QSryDaCi+aKU7UIiq1P4lyo2dQdFVRrc2V+g+qHQopTX2athn11soYPuSdKVlp2Jkwq4C+WulopSEBBMuJKcxIsbl0= 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=in81WnYK; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=GbuPOx3N; 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="in81WnYK"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="GbuPOx3N" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784720274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=kv4Fh6cCMLCK92Fu8BkvDkrCHd5Rl2hZHVs+Zxq4OOE=; b=in81WnYKXVzel7TO2mUUYRriqJJ7GM9LqB+bPRUIMMnV90/+niA3qDZ4X+Fk5U8esdO4TI NTHYcwAzyMx8q88I21ROB6umZVeMbE35OXBgxzJunEsCG2gYQ3cRoSZWjteP11Bws7SP68 Np9oWdkLhPUS0FdRsDDKYdZxupLiP9g= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-158-cI8vhmvVOKmit0xJ7yDa0A-1; Wed, 22 Jul 2026 07:37:52 -0400 X-MC-Unique: cI8vhmvVOKmit0xJ7yDa0A-1 X-Mimecast-MFC-AGG-ID: cI8vhmvVOKmit0xJ7yDa0A_1784720272 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-c15eb4015e7so96383766b.3 for ; Wed, 22 Jul 2026 04:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1784720272; x=1785325072; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:content-type :autocrypt:references:in-reply-to:date:cc:to:from:subject:message-id :from:to:cc:subject:date:message-id:reply-to:content-type; bh=kv4Fh6cCMLCK92Fu8BkvDkrCHd5Rl2hZHVs+Zxq4OOE=; b=GbuPOx3Nrp0Gqs4sstzsQSu2CL6yWV8t59AePGGaijazYlAhF1clu1BUpBtcVUltAp iRUa3zkdMc7gUsnshEWICYyPX1d667Ccj23EJvhF50zoY3ZLdRBdJKQEQ2lmi3CiwAGs p0/ym7PrwDQbv5yB+wfLit9W5itVW0gMEAcklYC7lv+Fz5faoNke+6VNrEKR45q1D0xc qtONgKnPfUYFnzeIPN9nLtjBNf1LOJHu5lIS747ZG8QYWcxsXO0zvirGTnfWPYmjqrsq KIDWjhowBLX4XwW0oTMxpg2WHn8HWrFgWLPVUhfzkPMF7oybzggB1ybGozziiQY1EbK0 adwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784720272; x=1785325072; h=mime-version:user-agent:content-transfer-encoding:content-type :autocrypt:references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=kv4Fh6cCMLCK92Fu8BkvDkrCHd5Rl2hZHVs+Zxq4OOE=; b=IPyc8TpN/94FUR43DsEmniNP12SHN6JWihrgecqeoE8CLxjfSUNFsxvIHOJfKdGaUg E26MouhfiAP36FNu5OTqmlBNdSlPQKjlUgPZrHhMlGSPsdTReFJeqIfJp9D27IPB5O6w v07aK2OJo5r43W58GfqbT9mzEOdEFy5jLuPRbBoMDgj3HxHXbw9M7wK+hjc9P2aTgz6D N1YSNk+q23gWDKBssJnxrXzGQjl+rf35nfR9QZP11YUOkbuQ8dRsIvn/Ztv9m6PZxQpH A1B+R3vmEYIX4XxuS03MFV4VVgr+bdUlaglWWUWtZTTdg4NENSiEpIg5yptISuy4eRqS N3nQ== X-Gm-Message-State: AOJu0Yy5SA1FJ1JBz3j2tEyjgID8kRNKmDFvsWpd+jIRkLTxVZ2DYanG AMyO7OxCFkv8NTLpscPu2hY+l/zjpQ4fCVlsBGXK+sw7fNCcUTFBqr5vBdMdE1PbPnauL9wJ506 h8oWf1M1ZpgTYFtp5T6uOCZxXLCVxjwkx8gg0zaAneIm7GkdI5oIObR5AfwbTRlRO9OtDFaU8cW 6XQ6638n9h0oRLGHeK43oVPBvAcy0dC5lenKRPuAtHNrbRLiqx8zo= X-Gm-Gg: AR+sD10fLZRMj/Zx+m8g4wAf8XmYqyf3BJ3N//16cqFpBf0iHi0OCydHudZTzCLZuEU akedFtapTvguY6K+faWfdExhZWVcbVJ2pakm02lhbDD0Uap3Mcsznsp8ukvlny24E3EXrKTEIxR 0YMoEKnMY7NtPibmpsEjNAek8cbiTRzHI9j7WfuE7iv8UhWX47VqOyOloQ5XytEoIoPvZl7mfvw UBMLvKRCWVeZlpO8EmvkR4XmvRgUtHywBK/zwdyG1kYP48JQbYUcwwCy2ucD0eNJ3SnDn9KeytE VNCUuRzp6TyG8a0s/FOyJVem2nWUV8c6JrNUUrIXD6qgBkVNc84EE5LpcxfOlnZ6d8GCy3GCarA btM8ZJ07KBa5LlxSbKK7Gg3OI9UYKRUvf4yx/Lo1RnLU5joX5X9mtWGA1S3JREK2K3qu9rg== X-Received: by 2002:a17:907:cd07:b0:c15:ce72:934a with SMTP id a640c23a62f3a-c16b48331e9mr887108166b.48.1784720271644; Wed, 22 Jul 2026 04:37:51 -0700 (PDT) X-Received: by 2002:a17:907:cd07:b0:c15:ce72:934a with SMTP id a640c23a62f3a-c16b48331e9mr887106566b.48.1784720271034; Wed, 22 Jul 2026 04:37:51 -0700 (PDT) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (212-8-243-115.hosted-by-worldstream.net. [212.8.243.115]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1c32ac7041sm90086266b.14.2026.07.22.04.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2026 04:37:50 -0700 (PDT) Message-ID: <2280c5a84ce419bf9f96b79552ad47775dc8997e.camel@redhat.com> Subject: Re: [PATCH v4 13/17] rv: Add KUnit stub for current From: Gabriele Monaco To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Nam Cao Cc: Steven Rostedt , Masami Hiramatsu , Thomas Weissschuh , Tomas Glozar , John Kacur , Wen Yang Date: Wed, 22 Jul 2026 13:37:48 +0200 In-Reply-To: <20260717154638.220789-14-gmonaco@redhat.com> References: <20260717154638.220789-1-gmonaco@redhat.com> <20260717154638.220789-14-gmonaco@redhat.com> Autocrypt: addr=gmonaco@redhat.com; prefer-encrypt=mutual; keydata=mDMEZuK5YxYJKwYBBAHaRw8BAQdAmJ3dM9Sz6/Hodu33Qrf8QH2bNeNbOikqYtxWFLVm0 1a0JEdhYnJpZWxlIE1vbmFjbyA8Z21vbmFjb0BrZXJuZWwub3JnPoiZBBMWCgBBFiEEysoR+AuB3R Zwp6j270psSVh4TfIFAmjKX2MCGwMFCQWjmoAFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgk Q70psSVh4TfIQuAD+JulczTN6l7oJjyroySU55Fbjdvo52xiYYlMjPG7dCTsBAMFI7dSL5zg98I+8 cXY1J7kyNsY6/dcipqBM4RMaxXsOtCRHYWJyaWVsZSBNb25hY28gPGdtb25hY29AcmVkaGF0LmNvb T6InAQTFgoARAIbAwUJBaOagAULCQgHAgIiAgYVCgkICwIEFgIDAQIeBwIXgBYhBMrKEfgLgd0WcK eo9u9KbElYeE3yBQJoymCyAhkBAAoJEO9KbElYeE3yjX4BAJ/ETNnlHn8OjZPT77xGmal9kbT1bC1 7DfrYVISWV2Y1AP9HdAMhWNAvtCtN2S1beYjNybuK6IzWYcFfeOV+OBWRDQ== Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-1.fc44) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2026-07-17 at 17:46 +0200, Gabriele Monaco wrote: > Some monitors do not only rely on tracepoint arguments but also on the > currently executing task. > This makes it more challenging to mock events in KUnit. >=20 > Define wrapper functions around current, the functionality is stubbed > only during KUnit, however the additional function call is necessary > whenever the KUnit tests are built in. >=20 > Reviewed-by: Nam Cao > Signed-off-by: Gabriele Monaco As reported by sashiko, using KUnit's standard stubbing can be dangerous. I= n the rare case of an NMI causing an RV event (e.g. a pagefault) when an unrelate= d KUnit test is running, the stub would end up using locks and causing issues= . Additionally, it isn't ideal to downgrade to a function call directly if th= e tests are built, which is for instance the default on the stock Fedora kern= el (CONFIG_KUNIT_ALL_TESTS=3Dm). I'm soon going to send a V5 addressing both: no stub and function call only= if KUnit is really running. I'll reset the review since the patch essentially changes. > --- > =C2=A0include/rv/da_monitor.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 |=C2=A0 1 + > =C2=A0include/rv/kunit.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 13 +++++++++- > =C2=A0include/rv/ltl_monitor.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 |=C2=A0 1 + > =C2=A0kernel/trace/rv/Kconfig=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 |=C2=A0 3 +++ > =C2=A0.../trace/rv/monitors/pagefault/pagefault.c=C2=A0=C2=A0 |=C2=A0 2 += - > =C2=A0kernel/trace/rv/monitors/sleep/sleep.c=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 | 24 +++++++++---------- > =C2=A0kernel/trace/rv/rv.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 8 +++++++ > =C2=A0kernel/trace/rv/rv_monitors_test.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 9 +++++++ > =C2=A08 files changed, 47 insertions(+), 14 deletions(-) >=20 > diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h > index 773564720ba1..9f7ba443d777 100644 > --- a/include/rv/da_monitor.h > +++ b/include/rv/da_monitor.h > @@ -16,6 +16,7 @@ > =C2=A0 > =C2=A0#include > =C2=A0#include > +#include > =C2=A0#include > =C2=A0#include > =C2=A0#include > diff --git a/include/rv/kunit.h b/include/rv/kunit.h > index ff98b5137285..6d16a422a80c 100644 > --- a/include/rv/kunit.h > +++ b/include/rv/kunit.h > @@ -2,7 +2,10 @@ > =C2=A0/* > =C2=A0 * Copyright (C) 2026-2029 Red Hat, Inc. Gabriele Monaco > =C2=A0 * > - * Declaration of utilities to run KUnit tests. > + * Declaration of wrappers to allow stubbing core functionality, like > current, > + * and other testing utilities. > + * Necessary only when mocking may be needed. If the RV KUnit test is > + * enabled, the wrappers incur an additional function call overhead. > =C2=A0 */ > =C2=A0 > =C2=A0#ifndef _RV_KUNIT_H > @@ -16,6 +19,7 @@ > =C2=A0 > =C2=A0int rv_set_testing(struct kunit_suite *suite); > =C2=A0void rv_clear_testing(struct kunit_suite *suite); > +struct task_struct *rv_get_current(void); > =C2=A0 > =C2=A0#define RV_KUNIT_MAX_MOCK_TASKS 8 > =C2=A0 > @@ -23,6 +27,7 @@ struct rv_kunit_ctx { > =C2=A0 int reactions, expected; > =C2=A0 int mock_task_count; > =C2=A0 struct task_struct *mock_tasks[RV_KUNIT_MAX_MOCK_TASKS]; > + struct task_struct *curr; > =C2=A0}; > =C2=A0 > =C2=A0#define RV_KUNIT_EXPECT_REACTION(test, ctx)=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \ > @@ -57,5 +62,11 @@ void prepare_test(struct kunit *test, const struct > rv_kunit_mon *mon); > =C2=A0void teardown_test(void *arg); > =C2=A0struct task_struct *rv_kunit_alloc_mock_task(struct kunit *test); > =C2=A0 > +#define rv_mock_current(ctx, task) (ctx->curr =3D task) > + > +#else /* !CONFIG_RV_MONITORS_KUNIT_TEST */ > + > +#define rv_get_current() current > + > =C2=A0#endif /* CONFIG_RV_MONITORS_KUNIT_TEST */ > =C2=A0#endif /* _RV_KUNIT_H */ > diff --git a/include/rv/ltl_monitor.h b/include/rv/ltl_monitor.h > index 56e83edcf0c4..d7dc01db4dd9 100644 > --- a/include/rv/ltl_monitor.h > +++ b/include/rv/ltl_monitor.h > @@ -9,6 +9,7 @@ > =C2=A0#include > =C2=A0#include > =C2=A0#include > +#include > =C2=A0#include > =C2=A0#include > =C2=A0 > diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig > index 34c1feb35a9b..7bae9723cdbf 100644 > --- a/kernel/trace/rv/Kconfig > +++ b/kernel/trace/rv/Kconfig > @@ -121,4 +121,7 @@ config RV_MONITORS_KUNIT_TEST > =C2=A0 =C2=A0 These tests verify that monitors correctly detect violation= s by > =C2=A0 =C2=A0 triggering fake events and validating the expected reaction= s. > =C2=A0 > + =C2=A0 Enabling this may slightly increase overhead of some monitors ev= en > + =C2=A0 when the KUnit test is not running. > + > =C2=A0 =C2=A0 If unsure, say N. > diff --git a/kernel/trace/rv/monitors/pagefault/pagefault.c > b/kernel/trace/rv/monitors/pagefault/pagefault.c > index 5e1a2a606783..e52500fd2de0 100644 > --- a/kernel/trace/rv/monitors/pagefault/pagefault.c > +++ b/kernel/trace/rv/monitors/pagefault/pagefault.c > @@ -38,7 +38,7 @@ static void ltl_atoms_init(struct task_struct *task, st= ruct > ltl_monitor *mon, bo > =C2=A0static void handle_page_fault(void *data, unsigned long address, st= ruct > pt_regs *regs, > =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned long error_code) > =C2=A0{ > - ltl_atom_pulse(current, LTL_PAGEFAULT, true); > + ltl_atom_pulse(rv_get_current(), LTL_PAGEFAULT, true); > =C2=A0} > =C2=A0 > =C2=A0static int enable_pagefault(void) > diff --git a/kernel/trace/rv/monitors/sleep/sleep.c > b/kernel/trace/rv/monitors/sleep/sleep.c > index 12328ce663f5..71d2005ce520 100644 > --- a/kernel/trace/rv/monitors/sleep/sleep.c > +++ b/kernel/trace/rv/monitors/sleep/sleep.c > @@ -102,7 +102,7 @@ static void handle_sched_waking(void *data, struct > task_struct *task) > =C2=A0 if (this_cpu_read(hardirq_context)) { > =C2=A0 ltl_atom_pulse(task, LTL_WOKEN_BY_HARDIRQ, true); > =C2=A0 } else if (in_task()) { > - if (current->prio <=3D task->prio) > + if (rv_get_current()->prio <=3D task->prio) > =C2=A0 ltl_atom_pulse(task, > LTL_WOKEN_BY_EQUAL_OR_HIGHER_PRIO, true); > =C2=A0 } else if (in_nmi()) { > =C2=A0 ltl_atom_pulse(task, LTL_WOKEN_BY_NMI, true); > @@ -112,12 +112,12 @@ static void handle_sched_waking(void *data, struct > task_struct *task) > =C2=A0static void handle_contention_begin(void *data, void *lock, unsigne= d int > flags) > =C2=A0{ > =C2=A0 if (flags & LCB_F_RT) > - ltl_atom_update(current, LTL_BLOCK_ON_RT_MUTEX, true); > + ltl_atom_update(rv_get_current(), LTL_BLOCK_ON_RT_MUTEX, > true); > =C2=A0} > =C2=A0 > =C2=A0static void handle_contention_end(void *data, void *lock, int ret) > =C2=A0{ > - ltl_atom_update(current, LTL_BLOCK_ON_RT_MUTEX, false); > + ltl_atom_update(rv_get_current(), LTL_BLOCK_ON_RT_MUTEX, false); > =C2=A0} > =C2=A0 > =C2=A0static void handle_sys_enter(void *data, struct pt_regs *regs, long= id) > @@ -126,7 +126,7 @@ static void handle_sys_enter(void *data, struct pt_re= gs > *regs, long id) > =C2=A0 unsigned long args[6]; > =C2=A0 int op, cmd; > =C2=A0 > - mon =3D ltl_get_monitor(current); > + mon =3D ltl_get_monitor(rv_get_current()); > =C2=A0 > =C2=A0 switch (id) { > =C2=A0#ifdef __NR_clock_nanosleep > @@ -135,11 +135,11 @@ static void handle_sys_enter(void *data, struct pt_= regs > *regs, long id) > =C2=A0#ifdef __NR_clock_nanosleep_time64 > =C2=A0 case __NR_clock_nanosleep_time64: > =C2=A0#endif > - syscall_get_arguments(current, regs, args); > + syscall_get_arguments(rv_get_current(), regs, args); > =C2=A0 ltl_atom_set(mon, LTL_NANOSLEEP_CLOCK_MONOTONIC, args[0] =3D=3D > CLOCK_MONOTONIC); > =C2=A0 ltl_atom_set(mon, LTL_NANOSLEEP_CLOCK_TAI, args[0] =3D=3D > CLOCK_TAI); > =C2=A0 ltl_atom_set(mon, LTL_NANOSLEEP_TIMER_ABSTIME, args[1] =3D=3D > TIMER_ABSTIME); > - ltl_atom_update(current, LTL_CLOCK_NANOSLEEP, true); > + ltl_atom_update(rv_get_current(), LTL_CLOCK_NANOSLEEP, true); > =C2=A0 break; > =C2=A0 > =C2=A0#ifdef __NR_futex > @@ -148,25 +148,25 @@ static void handle_sys_enter(void *data, struct pt_= regs > *regs, long id) > =C2=A0#ifdef __NR_futex_time64 > =C2=A0 case __NR_futex_time64: > =C2=A0#endif > - syscall_get_arguments(current, regs, args); > + syscall_get_arguments(rv_get_current(), regs, args); > =C2=A0 op =3D args[1]; > =C2=A0 cmd =3D op & FUTEX_CMD_MASK; > =C2=A0 > =C2=A0 switch (cmd) { > =C2=A0 case FUTEX_LOCK_PI: > =C2=A0 case FUTEX_LOCK_PI2: > - ltl_atom_update(current, LTL_FUTEX_LOCK_PI, true); > + ltl_atom_update(rv_get_current(), LTL_FUTEX_LOCK_PI, > true); > =C2=A0 break; > =C2=A0 case FUTEX_WAIT: > =C2=A0 case FUTEX_WAIT_BITSET: > =C2=A0 case FUTEX_WAIT_REQUEUE_PI: > - ltl_atom_update(current, LTL_FUTEX_WAIT, true); > + ltl_atom_update(rv_get_current(), LTL_FUTEX_WAIT, > true); > =C2=A0 break; > =C2=A0 } > =C2=A0 break; > =C2=A0#ifdef __NR_epoll_wait > =C2=A0 case __NR_epoll_wait: > - ltl_atom_update(current, LTL_EPOLL_WAIT, true); > + ltl_atom_update(rv_get_current(), LTL_EPOLL_WAIT, true); > =C2=A0 break; > =C2=A0#endif > =C2=A0 } > @@ -174,7 +174,7 @@ static void handle_sys_enter(void *data, struct pt_re= gs > *regs, long id) > =C2=A0 > =C2=A0static void handle_sys_exit(void *data, struct pt_regs *regs, long = ret) > =C2=A0{ > - struct ltl_monitor *mon =3D ltl_get_monitor(current); > + struct ltl_monitor *mon =3D ltl_get_monitor(rv_get_current()); > =C2=A0 > =C2=A0 ltl_atom_set(mon, LTL_FUTEX_LOCK_PI, false); > =C2=A0 ltl_atom_set(mon, LTL_FUTEX_WAIT, false); > @@ -182,7 +182,7 @@ static void handle_sys_exit(void *data, struct pt_reg= s > *regs, long ret) > =C2=A0 ltl_atom_set(mon, LTL_NANOSLEEP_CLOCK_TAI, false); > =C2=A0 ltl_atom_set(mon, LTL_NANOSLEEP_TIMER_ABSTIME, false); > =C2=A0 ltl_atom_set(mon, LTL_EPOLL_WAIT, false); > - ltl_atom_update(current, LTL_CLOCK_NANOSLEEP, false); > + ltl_atom_update(rv_get_current(), LTL_CLOCK_NANOSLEEP, false); > =C2=A0} > =C2=A0 > =C2=A0static void handle_kthread_stop(void *data, struct task_struct *tas= k) > diff --git a/kernel/trace/rv/rv.c b/kernel/trace/rv/rv.c > index cfe950fef3b4..edb10812f296 100644 > --- a/kernel/trace/rv/rv.c > +++ b/kernel/trace/rv/rv.c > @@ -142,6 +142,7 @@ > =C2=A0#include > =C2=A0#include > =C2=A0#include > +#include > =C2=A0 > =C2=A0#ifdef CONFIG_RV_MON_EVENTS > =C2=A0#define CREATE_TRACE_POINTS > @@ -893,4 +894,11 @@ void rv_clear_testing(struct kunit_suite *suite) > =C2=A0 mutex_unlock(&rv_interface_lock); > =C2=A0} > =C2=A0EXPORT_SYMBOL_IF_KUNIT(rv_clear_testing); > + > +struct task_struct *rv_get_current(void) > +{ > + KUNIT_STATIC_STUB_REDIRECT(rv_get_current); > + return current; > +} > +EXPORT_SYMBOL_GPL(rv_get_current); > =C2=A0#endif > diff --git a/kernel/trace/rv/rv_monitors_test.c > b/kernel/trace/rv/rv_monitors_test.c > index 2145c85d4c9a..2108973383b2 100644 > --- a/kernel/trace/rv/rv_monitors_test.c > +++ b/kernel/trace/rv/rv_monitors_test.c > @@ -106,6 +106,13 @@ struct task_struct *rv_kunit_alloc_mock_task(struct = kunit > *test) > =C2=A0 return tsk; > =C2=A0} > =C2=A0 > +static struct task_struct *stub_rv_get_current(void) > +{ > + if (active_ctx && active_ctx->curr) > + return active_ctx->curr; > + return current; > +} > + > =C2=A0static int rv_mon_test_init(struct kunit *test) > =C2=A0{ > =C2=A0 struct rv_kunit_ctx *ctx; > @@ -115,6 +122,8 @@ static int rv_mon_test_init(struct kunit *test) > =C2=A0 > =C2=A0 test->priv =3D ctx; > =C2=A0 > + kunit_activate_static_stub(test, rv_get_current, > stub_rv_get_current); > + > =C2=A0 return 0; > =C2=A0} > =C2=A0