From: Jakub Kicinski <kuba@kernel.org>
To: Petr Machata <petrm@nvidia.com>
Cc: <davem@davemloft.net>, <netdev@vger.kernel.org>,
<edumazet@google.com>, <pabeni@redhat.com>,
<willemdebruijn.kernel@gmail.com>, <przemyslaw.kitszel@intel.com>,
<leitao@debian.org>
Subject: Re: [RFC net-next 1/2] selftests: drv-net: add ability to schedule cleanup with defer()
Date: Wed, 26 Jun 2024 09:09:20 -0700 [thread overview]
Message-ID: <20240626090920.64b0a5c0@kernel.org> (raw)
In-Reply-To: <878qys9cqt.fsf@nvidia.com>
On Wed, 26 Jun 2024 12:18:58 +0200 Petr Machata wrote:
> Jakub Kicinski <kuba@kernel.org> writes:
> > +def ksft_flush_defer():
> > + global KSFT_RESULT
> > +
> > + while global_defer_queue:
> > + entry = global_defer_queue[-1]
> > + try:
> > + entry.exec()
>
> I wonder if you added _exec() to invoke it here. Because then you could
> just do entry = global_defer_queue.pop() and entry._exec(), and in the
> except branch you would just have the test-related business, without the
> queue management.
Initially I had both _exec, and _dequeue as separate helpers, but then
_dequeue was identical to cancel, so I removed that one, but _exec
stayed.
As you point out _exec() would do nicely during "flush".. but linter was
angry at me for calling private functions. I couldn't quickly think of
a clean scheme of naming things. Or rather, I should say, I like that
the only non-private functions in class defer right now are
test-author-facing. At some point I considered renaming _exec() to
__call__() or run() but I was worried people will incorrectly
call it, instead of calling exec().
So I decided to stick to a bit of awkward handling in the internals for
the benefit of more obvious test-facing API. But no strong preference,
LMK if calling _exec() here is fine or I should rename it..
> > + except Exception:
>
> I think this should be either an unqualified except: or except
> BaseException:.
SG
> > print(
> > f"# Totals: pass:{totals['pass']} fail:{totals['fail']} xfail:{totals['xfail']} xpass:0 skip:{totals['skip']} error:0"
>
> Majority of this hunk is just preparatory and should be in a patch of
> its own. Then in this patch it should just introduce the flush.
True, will split.
> > + def cancel(self):
>
> This shouldn't dequeue if not self.queued.
I was wondering if we're better off throwing the exception from
remove() or silently ignoring (what is probably an error in the
test code). I went with the former intentionally, but happy to
change.
> > + self._queue.remove(self)
> > + self.queued = False
> > +
> > + def exec(self):
>
> This shouldn't exec if self.executed.
>
> But I actually wonder if we need two flags at all. Whether the defer
> entry is resolved through exec(), cancel() or __exit__(), it's "done".
> It could be left in the queue, in which case the "done" flag is going to
> disable future exec requests. Or it can just be dropped from the queue
> when done, in which case we don't even need the "done" flag as such.
If you recall there's a rss_ctx test case which removes contexts out of
order. The flags are basically for that test. We run the .exec() to
remove a context, and then we can check
if thing.queued:
.. code for context that's alive ..
else:
.. code for dead context ..
next prev parent reply other threads:[~2024-06-26 16:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 1:36 [RFC net-next 0/2] selftests: drv-net: add ability to schedule cleanup with defer() Jakub Kicinski
2024-06-26 1:36 ` [RFC net-next 1/2] " Jakub Kicinski
2024-06-26 7:43 ` Przemek Kitszel
2024-06-26 9:19 ` Petr Machata
2024-06-26 9:38 ` Przemek Kitszel
2024-06-26 16:44 ` Jakub Kicinski
2024-06-26 16:49 ` Jakub Kicinski
2024-06-27 8:40 ` Przemek Kitszel
2024-06-27 15:35 ` Jakub Kicinski
2024-06-26 10:18 ` Petr Machata
2024-06-26 16:09 ` Jakub Kicinski [this message]
2024-06-27 7:37 ` Petr Machata
2024-06-27 15:41 ` Jakub Kicinski
2024-06-26 1:36 ` [RFC net-next 2/2] selftests: drv-net: rss_ctx: convert to defer() Jakub Kicinski
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=20240626090920.64b0a5c0@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=leitao@debian.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.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.