[PATCH] block: Avoid polling configuration errors

From: hexue
Date: Fri May 31 2024 - 05:10:54 EST


Here's a misconfigured if application is doing polled IO
for devices that don't have a poll queue, the process will
continue to do syscall between user space and kernel space,
as in normal poll IO, CPU utilization will be 100%. IO actually
arrives through interruption.

This patch returns a signal that does not support the operation
when the underlying device does not have a poll queue, avoiding
performance and CPU simultaneous loss.

Signed-off-by: hexue <xue01.he@xxxxxxxxxxx>
---
block/blk-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 01186333c88e..0afcd74ae939 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -913,7 +913,7 @@ int bio_poll(struct bio *bio, struct io_comp_batch *iob, unsigned int flags)
q = bdev_get_queue(bdev);
if (cookie == BLK_QC_T_NONE ||
!test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
- return 0;
+ return -EOPNOTSUPP;

blk_flush_plug(current->plug, false);

--
2.40.1