Skip to content

Commit

Permalink
coccinelle: api/stream_open: treat all wait_.*() calls as blocking
Browse files Browse the repository at this point in the history
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/[email protected]/
	https://lore.kernel.org/linux-pci/[email protected]/
	https://lore.kernel.org/linux-pci/[email protected]/

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.

Signed-off-by: Kirill Smelkov <[email protected]>
Acked-by: Julia Lawall <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
navytux authored and masahir0y committed Jul 7, 2019
1 parent f58c17c commit 0c4ab18
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/coccinelle/api/stream_open.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down

0 comments on commit 0c4ab18

Please sign in to comment.