mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Stanner <phasta@mailbox.org>
To: "Maíra Canal" <mcanal@igalia.com>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>
Cc: "Philipp Stanner" <phasta@kernel.org>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"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>,
	"Pierre-Eric Pelloux-Prayer" <pierre-eric.pelloux-prayer@amd.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/sched/tests: Make timedout_job callback a better role model
Date: Mon, 16 Jun 2025 14:56:13 +0200	[thread overview]
Message-ID: <e7c3a8a33d00409935f4d43b40aa19c2c146e996.camel@mailbox.org> (raw)
In-Reply-To: <723c98e2-cf75-4565-b78b-711b3022d44d@igalia.com>

On Mon, 2025-06-16 at 09:49 -0300, Maíra Canal wrote:
> Hi Danilo,
> 
> On 16/06/25 08:14, Danilo Krummrich wrote:
> > On Mon, Jun 16, 2025 at 11:57:47AM +0100, Tvrtko Ursulin wrote:
> > > Code looks fine, but currently nothing is broken and I disagree
> > > with the
> > > goal that the _mock_^1 components should be role models. The idea
> > > is to
> > > implement as little in the mock components as it is required to
> > > exercise the
> > > tested functionality.
> > 
> > No, please consider the following.
> > 
> >    1) When we write tests for common infrastructure we should be
> > testing things
> >       as close as possible to how we intend real code to use this
> > infrastructure.
> >       Relying on internals in creative ways is likely to underrun
> > this testing.
> 
> Regarding unit testing (and KUnit is a unit testing framework), the
> core
> principle is that individual components of the code should be tested
> in
> isolation to validate that they perform as expected.
> 
> The "units" should be tested independently and we use those mocks to
> simulate dependencies, ensuring that the test focuses solely on the
> unit
> under scrutiny.
> 
> If we introduce more things into the mock, we end up losing the
> isolation.

That depends on what those "things" are.

In the presented case, the unit tests are just as isolated as before.
The particular test case itself is not even modified and it will still
do exactly one thing: See if the job actually timed out as expected.

The added overhead in the mock component is merely the guarantee that
the fence gets signaled and that the job is removed from the mock
component's list at the appropriate place.

0 downside, documentation upside.

Each unit test still tests exactly 1 functionality.


> The mock scheduler, from what I understand, is not suppose to
> be a reference design or even something close to a driver. 

We here in DRM define what it is supposed to be.

And since the scheduler has been infinitely abused and misused, at
least having one official, simple example "this is how you're supposed
to do it" is desirable, wouldn't you say so?


P.

>  It should
> remain just a mock, a minimal interface to test the scheduler's
> internals.
> 
> Best Regards,
> - Maíra
> 
> > 
> >    2) Being close to a reference design is a good thing, why
> > wouldn't we want
> >       that? The reality is that people *will* look at this code for
> > reference.
> > 
> > > Also, there are various ways drivers use the scheduler API.
> > > Trying to make
> > > the mock scheduler a reference driver implementation would only
> > > be able to
> > > make it a reference for one possible use.
> > 
> > Why? Nothing prevents us from covering all of them eventually.
> > 
> > If for now, we just implement one of them, that's better than none,
> > so why not?
> 


  reply	other threads:[~2025-06-16 13:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-05 13:41 Philipp Stanner
2025-06-16 10:57 ` Tvrtko Ursulin
2025-06-16 11:14   ` Danilo Krummrich
2025-06-16 12:49     ` Maíra Canal
2025-06-16 12:56       ` Philipp Stanner [this message]
2025-06-16 13:04       ` Danilo Krummrich
2025-06-23  9:00 ` Philipp Stanner
2025-06-30 12:49 ` Danilo Krummrich
2025-07-01 13:37 ` Philipp Stanner

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=e7c3a8a33d00409935f4d43b40aa19c2c146e996.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=mcanal@igalia.com \
    --cc=mripard@kernel.org \
    --cc=phasta@kernel.org \
    --cc=pierre-eric.pelloux-prayer@amd.com \
    --cc=simona@ffwll.ch \
    --cc=tvrtko.ursulin@igalia.com \
    --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®