From: Petr Machata <petrm@nvidia.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: <davem@davemloft.net>, <netdev@vger.kernel.org>,
<edumazet@google.com>, <pabeni@redhat.com>,
<przemyslaw.kitszel@intel.com>, <petrm@nvidia.com>,
<willemdebruijn.kernel@gmail.com>
Subject: Re: [PATCH net-next v2 2/3] selftests: drv-net: add ability to schedule cleanup with defer()
Date: Fri, 28 Jun 2024 16:31:25 +0200 [thread overview]
Message-ID: <87msn587g7.fsf@nvidia.com> (raw)
In-Reply-To: <20240627185502.3069139-3-kuba@kernel.org>
Jakub Kicinski <kuba@kernel.org> writes:
> This implements what I was describing in [1]. When writing a test
> author can schedule cleanup / undo actions right after the creation
> completes, eg:
>
> cmd("touch /tmp/file")
> defer(cmd, "rm /tmp/file")
>
> defer() takes the function name as first argument, and the rest are
> arguments for that function. defer()red functions are called in
> inverse order after test exits. It's also possible to capture them
> and execute earlier (in which case they get automatically de-queued).
>
> undo = defer(cmd, "rm /tmp/file")
> # ... some unsafe code ...
> undo.exec()
>
> As a nice safety all exceptions from defer()ed calls are captured,
> printed, and ignored (they do make the test fail, however).
> This addresses the common problem of exceptions in cleanup paths
> often being unhandled, leading to potential leaks.
>
> There is a global action queue, flushed by ksft_run(). We could support
> function level defers too, I guess, but there's no immediate need..
>
> Link: https://lore.kernel.org/all/877cedb2ki.fsf@nvidia.com/ # [1]
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Petr Machata <petrm@nvidia.com>
next prev parent reply other threads:[~2024-06-28 14:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-27 18:54 [PATCH net-next v2 0/3] selftests: drv-net: add ability to schedule cleanup with defer() Jakub Kicinski
2024-06-27 18:55 ` [PATCH net-next v2 1/3] selftests: net: ksft: avoid continue when handling results Jakub Kicinski
2024-06-28 14:30 ` Petr Machata
2024-06-27 18:55 ` [PATCH net-next v2 2/3] selftests: drv-net: add ability to schedule cleanup with defer() Jakub Kicinski
2024-06-28 12:35 ` Przemek Kitszel
2024-06-28 14:31 ` Petr Machata [this message]
2024-06-27 18:55 ` [PATCH net-next v2 3/3] selftests: drv-net: rss_ctx: convert to defer() Jakub Kicinski
2024-06-28 14:31 ` Petr Machata
2024-06-29 1:50 ` [PATCH net-next v2 0/3] selftests: drv-net: add ability to schedule cleanup with defer() patchwork-bot+netdevbpf
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=87msn587g7.fsf@nvidia.com \
--to=petrm@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=willemdebruijn.kernel@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.