Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2192609iof; Tue, 7 Jun 2022 22:45:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeThuaZaYJSg3Pq7wbfbF5DhXaTDnaPRGIpet2s5pDwwzXEsGSiJlOQtMjbZdu8mAmXJj7 X-Received: by 2002:a17:90b:1d08:b0:1e4:dad9:64e5 with SMTP id on8-20020a17090b1d0800b001e4dad964e5mr40369148pjb.200.1654667126056; Tue, 07 Jun 2022 22:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667126; cv=none; d=google.com; s=arc-20160816; b=OoX1Biw/FAGU5CQRXNnfpWnzuG80V7ztUEDdl2Wg8qC6GeuoeizSYCr3j7JanXWpep b3eMBl1MEdtuRP0kG+F6057ZfZIlsO8SfO53mxOBFMj3f+nAd+9ePPJDTBGJqy++7zQQ i1JY4segQGpYIqk78FzC16OUHB6cwPLISdQYl7t460TvYAYuZb6ub1tcWf5vUvAjKqkp XaPBR2Y7M5pHY2vVyBJ1FWLCIslS+ofBlw2+BPq1qPM154mFZQUASMyIdsnqUIGfiJ80 VOG0v0mSXvTudEPbJOVl8IFmxohfir+tUMgQInS/li/XCfey2t7JyJl83+w0YEJGtZT7 pX8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=h9ToOevOgJiY9LGfUcJ/hknNvaxvHav/gyw+H6A2XdU=; b=MFlzcx3lOUCQrb6XUAAWHtTbIi3T+hqqjDRT2R1uKkNLZh3TNMEVO3mwIsnBINmMwB nc8k7TegY3Moq8vTCAb+Y6p/qtAVjW7rJhJ00bAh+U1B1Lv4IDYK0OS3XCVmzsnaG0HM YQ3GFdKvFIYkwalIn2HyKYVyEqFksrw5u/ruMjm+f859o/u4bRQYOC2FvGFCJgw1BIVW r9V/r1dOuL3VQ9Y8toZGk40BEQkOBkIY2zPZxXjUHMAeE8P0FG3JsssWTuUnveFXP0uU jKuCSJd01j4GybdweIcdiJhNAV74NKRIwiK7gG1EGwsKSOc9pXB9lj/Vln6U6gnPVypZ Df/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GPsHLHzH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bm18-20020a656e92000000b003fcd3d1b031si29974725pgb.562.2022.06.07.22.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:45:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GPsHLHzH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1A35A1E301A; Tue, 7 Jun 2022 22:10:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385747AbiFHAVx (ORCPT + 99 others); Tue, 7 Jun 2022 20:21:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382141AbiFGVtY (ORCPT ); Tue, 7 Jun 2022 17:49:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2405118FF11; Tue, 7 Jun 2022 12:08:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8B06461768; Tue, 7 Jun 2022 19:08:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97DC7C385A5; Tue, 7 Jun 2022 19:08:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628913; bh=1xphEaU64A+Q8NDY8DCsk7LVDIw4vXTtIDDTXjOER0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GPsHLHzHS/FeLP6xIzS39z0qqe/vnJfgREmPexgRTUOw8pjdoGX5GT+LqW+xAFZ5e /Rjtu81428sVvoH0fTbzP5i1Esro63exTEi8tLxzI8eBLNxUd+VGze++Y20i10zcBg Qsmljk7MN03rUtCsGTwf/hMu0U2iyt4kHxRT9iBA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dylan Yudaken , Jens Axboe , Sasha Levin Subject: [PATCH 5.18 461/879] io_uring: only wake when the correct events are set Date: Tue, 7 Jun 2022 18:59:39 +0200 Message-Id: <20220607165016.254910676@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dylan Yudaken [ Upstream commit 1b1d7b4bf1d9948c8dba5ee550459ce7c65ac019 ] The check for waking up a request compares the poll_t bits, however this will always contain some common flags so this always wakes up. For files with single wait queues such as sockets this can cause the request to be sent to the async worker unnecesarily. Further if it is non-blocking will complete the request with EAGAIN which is not desired. Here exclude these common events, making sure to not exclude POLLERR which might be important. Fixes: d7718a9d25a6 ("io_uring: use poll driven retry for files that support it") Signed-off-by: Dylan Yudaken Link: https://lore.kernel.org/r/20220512091834.728610-3-dylany@fb.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- fs/io_uring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 7272e410d24a..9e247335e70d 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5981,6 +5981,7 @@ static void io_poll_cancel_req(struct io_kiocb *req) #define wqe_to_req(wait) ((void *)((unsigned long) (wait)->private & ~1)) #define wqe_is_double(wait) ((unsigned long) (wait)->private & 1) +#define IO_ASYNC_POLL_COMMON (EPOLLONESHOT | POLLPRI) static int io_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync, void *key) @@ -6015,7 +6016,7 @@ static int io_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync, } /* for instances that support it check for an event match first */ - if (mask && !(mask & poll->events)) + if (mask && !(mask & (poll->events & ~IO_ASYNC_POLL_COMMON))) return 0; if (io_poll_get_ownership(req)) { @@ -6171,7 +6172,7 @@ static int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags) struct io_ring_ctx *ctx = req->ctx; struct async_poll *apoll; struct io_poll_table ipt; - __poll_t mask = EPOLLONESHOT | POLLERR | POLLPRI; + __poll_t mask = IO_ASYNC_POLL_COMMON | POLLERR; int ret; if (!def->pollin && !def->pollout) -- 2.35.1