public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Petr Machata <petrm@nvidia.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Petr Machata <petrm@nvidia.com>, <davem@davemloft.net>,
	<netdev@vger.kernel.org>, <edumazet@google.com>,
	<pabeni@redhat.com>, <andrew+netdev@lunn.ch>, <horms@kernel.org>,
	<leitao@debian.org>, <jdamato@fastly.com>
Subject: Re: [PATCH net-next 2/2] selftests: net: py: ensure defer() is only used within a test case
Date: Fri, 9 Jan 2026 16:43:16 +0100	[thread overview]
Message-ID: <87344e6b7z.fsf@nvidia.com> (raw)
In-Reply-To: <20260109063938.3445c940@kernel.org>


Jakub Kicinski <kuba@kernel.org> writes:

> On Fri, 9 Jan 2026 09:23:54 +0100 Petr Machata wrote:
>> > I wasted a couple of hours recently after accidentally adding
>> > a defer() from within a function which itself was called as
>> > part of defer(). This leads to an infinite loop of defer().
>> > Make sure this cannot happen and raise a helpful exception.
>> >
>> > I understand that the pair of _ksft_defer_arm() calls may
>> > not be the most Pythonic way to implement this, but it's
>> > easy enough to understand.
>> >
>> > Signed-off-by: Jakub Kicinski <kuba@kernel.org>  
>> 
>> I think we achieve the same without the extra globals though? Just drain
>> the queue and walk through a copy of it?
>> 
>>     defer_queue = utils.GLOBAL_DEFER_QUEUE
>>     utils.GLOBAL_DEFER_QUEUE = []
>>     for i, entry in enumerate(defer_queue):
>>         ...
>>     if utils.GLOBAL_DEFER_QUEUE:
>>         warning / exception
>
> That's what I had initially (IIUC), I was assigning None to the queue,
> and then [] only while inside a test case. It gets slightly hairy
> because either we need to pass in the queue into the flush function;
> or we have to restore the queue if something raises and exception during
> flush (in which case ksft_run() prints a warning and calls
> ksft_flush_defer() one more time).

Hmm, yeah, the exception robustness will complicate it. OK, let's have
it your way then :)

Reviewed-by: Petr Machata <petrm@nvidia.com>

  reply	other threads:[~2026-01-09 15:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-08 22:52 [PATCH net-next 1/2] selftests: net: py: capitalize defer queue and improve import Jakub Kicinski
2026-01-08 22:52 ` [PATCH net-next 2/2] selftests: net: py: ensure defer() is only used within a test case Jakub Kicinski
2026-01-09  8:23   ` Petr Machata
2026-01-09 14:39     ` Jakub Kicinski
2026-01-09 15:43       ` Petr Machata [this message]
2026-01-09  8:38 ` [PATCH net-next 1/2] selftests: net: py: capitalize defer queue and improve import Petr Machata
2026-01-09  9:57 ` Breno Leitao
2026-01-12 20:57 ` 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=87344e6b7z.fsf@nvidia.com \
    --to=petrm@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jdamato@fastly.com \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox