[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.21.1906230934080.4961@hadrien>
Date: Sun, 23 Jun 2019 09:35:17 +0200 (CEST)
From: Julia Lawall <julia.lawall@...6.fr>
To: Kirill Smelkov <kirr@...edi.com>
cc: cocci@...teme.lip6.fr, linux-kernel@...r.kernel.org,
Julia Lawall <Julia.Lawall@...6.fr>,
Logan Gunthorpe <logang@...tatee.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Bjorn Helgaas <helgaas@...nel.org>
Subject: Re: [PATCH 1/2] coccinelle: api/stream_open: treat all wait_.*()
calls as blocking
On Sun, 23 Jun 2019, Kirill Smelkov wrote:
> Previously steam_open.cocci was treating only wait_event_.* - e.g.
> wait_event_interruptible - as a blocking operation. However e.g.
> wait_for_completion_interruptible is also blocking, and so from this
> point of view it would be more logical to treat all wait_.* as a
> blocking point.
>
> The logic of this change actually came up for real when
> drivers/pci/switch/switchtec.c changed from using
> wait_event_interruptible to wait_for_completion_interruptible:
>
> https://lore.kernel.org/linux-pci/20190413170056.GA11293@deco.navytux.spb.ru/
> https://lore.kernel.org/linux-pci/20190415145456.GA15280@deco.navytux.spb.ru/
> https://lore.kernel.org/linux-pci/20190415154102.GB17661@deco.navytux.spb.ru/
>
> For a driver that uses nonseekable_open with read/write having stream
> semantic and read also calling e.g. wait_for_completion_interruptible,
> running stream_open.cocci before this patch would produce:
>
> WARNING: <driver>_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
>
> while after this patch it will report:
>
> ERROR: <driver>_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
Are you really sure that every word that starts with wait_ in the Linux
kernel has the property you want? How many of them are there? Would it
be reasonable to put the names in the semantic patch explicitly?
julia
>
> Cc: Julia Lawall <Julia.Lawall@...6.fr>
> Cc: Logan Gunthorpe <logang@...tatee.com>
> Cc: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
> Cc: Bjorn Helgaas <helgaas@...nel.org>
> Signed-off-by: Kirill Smelkov <kirr@...edi.com>
> ---
> scripts/coccinelle/api/stream_open.cocci | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/coccinelle/api/stream_open.cocci b/scripts/coccinelle/api/stream_open.cocci
> index 350145da7669..12ce18fa6b74 100644
> --- a/scripts/coccinelle/api/stream_open.cocci
> +++ b/scripts/coccinelle/api/stream_open.cocci
> @@ -35,11 +35,11 @@ type loff_t;
> // a function that blocks
> @ blocks @
> identifier block_f;
> -identifier wait_event =~ "^wait_event_.*";
> +identifier wait =~ "^wait_.*";
> @@
> block_f(...) {
> ... when exists
> - wait_event(...)
> + wait(...)
> ... when exists
> }
>
> @@ -49,12 +49,12 @@ identifier wait_event =~ "^wait_event_.*";
> // XXX currently reader_blocks supports only direct and 1-level indirect cases.
> @ reader_blocks_direct @
> identifier stream_reader.readstream;
> -identifier wait_event =~ "^wait_event_.*";
> +identifier wait =~ "^wait_.*";
> @@
> readstream(...)
> {
> ... when exists
> - wait_event(...)
> + wait(...)
> ... when exists
> }
>
> --
> 2.20.1
>
Powered by blists - more mailing lists