linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/3] kunit: Deferred action helpers
@ 2023-03-31  8:04 David Gow
  2023-03-31  8:04 ` [RFC PATCH v2 1/3] kunit: Add kunit_add_action() to defer a call until test exit David Gow
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: David Gow @ 2023-03-31  8:04 UTC (permalink / raw)
  To: Matti Vaittinen, Maxime Ripard, Brendan Higgins, Stephen Boyd,
	Shuah Khan, Daniel Latypov, Rae Moar, Benjamin Berg
  Cc: David Gow, Greg Kroah-Hartman, Rafael J . Wysocki,
	Heikki Krogerus, Jonathan Cameron, linux-kernel, linux-kselftest,
	kunit-dev

This is a follow-up to the kunit_defer() parts of 'KUnit device API
proposal'[1], with a number of changes suggested by Matti Vaittinen,
Maxime Ripard and Benjamin Berg.

Most notably, kunit_defer() has been renamed to kunit_add_action(), in
order to match the equivalent devres API[2]. Likewise:
kunit_defer_cancel() has become kunit_remove_action(), and
kunit_defer_trigger() has become kunit_release_action().

The _token() versions of these APIs remain, for the moment, even though
they're a bit more awkward and less useful, as they have two advantages:
1. They're faster, as the action doesn't need to be looked up.
2. They provide more flexibility in the ordering of actions in cases
where several identical actions are interleaved with other, different
actions.

Similarly, the internal_gfp argument remains for now, as this is useful
in implementing kunit_kalloc() and similar.

The implementation now uses a single allocation for both the
kunit_resource and the kunit_action_ctx (previously kunit_defer_ctx).

The 'cancellation token' is now of type 'struct kunit_action_ctx',
instead of void*.

Tests have been added to the kunit-resource-test suite which exercise
this functionality. Similarly, the kunit executor tests and
kunit allocation functions have been updated to make use of this API.

I'd love to hear any further thoughts!

Cheers,
-- David


[1]: https://lore.kernel.org/linux-kselftest/20230325043104.3761770-1-davidgow@google.com/
[2]: https://docs.kernel.org/driver-api/basics.html#c.devm_add_action

David Gow (3):
  kunit: Add kunit_add_action() to defer a call until test exit
  kunit: executor_test: Use kunit_add_action()
  kunit: kmalloc_array: Use kunit_add_action()

 include/kunit/resource.h  |  89 +++++++++++++++++++++++++++
 lib/kunit/executor_test.c |  12 ++--
 lib/kunit/kunit-test.c    | 123 +++++++++++++++++++++++++++++++++++++-
 lib/kunit/resource.c      |  99 ++++++++++++++++++++++++++++++
 lib/kunit/test.c          |  48 +++------------
 5 files changed, 323 insertions(+), 48 deletions(-)

-- 
2.40.0.348.gf938b09366-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2023-04-17 11:10 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-31  8:04 [RFC PATCH v2 0/3] kunit: Deferred action helpers David Gow
2023-03-31  8:04 ` [RFC PATCH v2 1/3] kunit: Add kunit_add_action() to defer a call until test exit David Gow
2023-04-04 13:32   ` Maxime Ripard
2023-04-04 17:55     ` Benjamin Berg
2023-04-05  8:09       ` David Gow
2023-04-05  7:47     ` David Gow
2023-04-14  9:53       ` Maxime Ripard
2023-04-14 10:01   ` maxime
2023-04-14 11:00     ` Benjamin Berg
2023-04-14 11:33       ` Maxime Ripard
2023-04-15  8:48       ` David Gow
2023-04-15  8:42     ` David Gow
2023-04-17 11:07       ` Maxime Ripard
2023-03-31  8:04 ` [RFC PATCH v2 2/3] kunit: executor_test: Use kunit_add_action() David Gow
2023-03-31  8:04 ` [RFC PATCH v2 3/3] kunit: kmalloc_array: " David Gow
2023-04-04 17:58   ` Benjamin Berg
2023-04-05  7:48     ` David Gow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).