[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3e0baf8d-941c-4bce-bf21-41940c3227ac@intel.com>
Date: Wed, 26 Jun 2024 11:38:42 +0200
From: Przemek Kitszel <przemyslaw.kitszel@...el.com>
To: Petr Machata <petrm@...dia.com>
CC: Jakub Kicinski <kuba@...nel.org>, <netdev@...r.kernel.org>,
<edumazet@...gle.com>, <pabeni@...hat.com>,
<willemdebruijn.kernel@...il.com>, <leitao@...ian.org>, <davem@...emloft.net>
Subject: Re: [RFC net-next 1/2] selftests: drv-net: add ability to schedule
cleanup with defer()
On 6/26/24 11:19, Petr Machata wrote:
>
> Przemek Kitszel <przemyslaw.kitszel@...el.com> writes:
>
>> On 6/26/24 03:36, Jakub Kicinski wrote:
>>
>>> 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..
>>
>> That would be a must have for general solution, would it require some
>> boilerplate code at function level?
>
> Presumably you'd need a per-function defer pool.
>
> Which would be naturally modeled as a context manager, but I promised
> myself I'd shut up about that.
>
>>> + def __enter__(self):
>>> + return self
>>> +
>>> + def __exit__(self, ex_type, ex_value, ex_tb):
>>> + return self.exec()
>>
>> why do you need __enter__ and __exit__ if this is not a context
>> manager / to-be-used-via-with?
>
> But you could use it as a context manager.
>
> with defer(blah blah):
> do stuff
> # blah blah runs here
>
> IMHO makes sense.
oh, nice! agree!
Then this little part is "the general solution", with the rest
(global queue) added as a sugar layer for kselftests, to only
avoid inflating indentation levels, great
Powered by blists - more mailing lists