From: Philipp Stanner <phasta@mailbox.org>
To: oushixiong1025@163.com, Matthew Brost <matthew.brost@intel.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
"Philipp Stanner" <phasta@kernel.org>,
"Christian König" <ckoenig.leichtzumerken@gmail.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
"Shixiong Ou" <oushixiong@kylinos.cn>
Subject: Re: [PATCH RESEND] drm/sched: Create faux device for KUnit tests
Date: Thu, 03 Sep 2026 11:33:02 +0200 [thread overview]
Message-ID: <b9d46dbb2f84d0bb601d5e0586f2e63f618d416b.camel@mailbox.org> (raw)
In-Reply-To: <20260903090256.552317-1-oushixiong1025@163.com>
On Thu, 2026-09-03 at 17:02 +0800, oushixiong1025@163.com wrote:
> From: Shixiong Ou <oushixiong@kylinos.cn>
>
> The DRM scheduler KUnit tests currently pass NULL for the dev field in
> drm_sched_init_args, which causes a NULL pointer dereference in the
> drm_sched_job trace event when it calls dev_name() on sched->dev.
>
> Use faux_device_create() to create a fake device for the mock scheduler,
> so the scheduler always has a valid device pointer. This avoids the
> trace event crash without requiring the production code to accept a NULL
> device pointer, which conceptually makes no sense for a scheduler.
>
> An atomic counter is used to generate unique device names, since
> multiple mock schedulers can exist simultaneously across different
> test suites.
>
> Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
Didn't you address a fault / bug with that?
Cc: stable …
Fixes:
?
> ---
>
[…]
>
> +static atomic_t drm_mock_sched_instance = ATOMIC_INIT(0);
> +
> /**
> * drm_mock_sched_entity_new - Create a new mock scheduler entity
> *
> @@ -296,11 +300,20 @@ struct drm_mock_scheduler *drm_mock_sched_new(struct kunit *test, long timeout)
> .name = "drm-mock-scheduler",
> };
> struct drm_mock_scheduler *sched;
> + char name[64];
> int ret;
>
> sched = kunit_kzalloc(test, sizeof(*sched), GFP_KERNEL);
> KUNIT_ASSERT_NOT_NULL(test, sched);
>
> + snprintf(name, sizeof(name), "drm-mock-scheduler-%d",
You could use args.name here.
> + atomic_inc_return(&drm_mock_sched_instance));
Couldn't that atomic be a `static unsigned int` inside this function?
Is simpler and limits the scope. And I wouldn't expect that we'll ever
call drm_mock_sched_new() multi-threaded, or would we?
Besides looks cool, thx
P.
next prev parent reply other threads:[~2026-09-03 9:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 9:02 oushixiong1025
2026-09-03 9:33 ` Philipp Stanner [this message]
2026-09-03 9:36 ` Maxime Ripard
2026-09-03 9:53 ` Danilo Krummrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b9d46dbb2f84d0bb601d5e0586f2e63f618d416b.camel@mailbox.org \
--to=phasta@mailbox.org \
--cc=airlied@gmail.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=mripard@kernel.org \
--cc=oushixiong1025@163.com \
--cc=oushixiong@kylinos.cn \
--cc=phasta@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®