From patchwork Sun Oct 30 22:01:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13068 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1981798wru; Sun, 30 Oct 2022 15:03:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6+q31L5m9beDIO6WgR0U+EB9NpnjI+3hnve467rRnvjhFp7hIeJU4xVhi+UKljpw33AeNl X-Received: by 2002:a63:8949:0:b0:46f:57b1:35bd with SMTP id v70-20020a638949000000b0046f57b135bdmr9755030pgd.623.1667167433669; Sun, 30 Oct 2022 15:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667167433; cv=none; d=google.com; s=arc-20160816; b=YXfyHmrzNP/Xnr9TVylKjIx2a2+vF3WrDU/dBXVoLCaHXFU6Me5a6dc1NGO5lM8ocZ FIAJQVdsIhxndDifPsk0r/kCvB2aKVM5Yr1JAZB/yENzdvaWH062zniSwENjSvvmz0GN gv9AqvxuwOvvFJT8RIIo5B7Hxna22IabSwI19zPzPUpWA6nHogo1qYbLKSTL05QVwIDH FBTNJ7Z+OG+C0C3p06Pk6sdi69rcI7pS8rXH3VteH30wJ4qG9ht+jQkrDYuKJsdvYu3b yD5xsXmy5Xl9e/ZpYCmufTQHjCA2GX/e8zy8iuJuXlUpbEuRSGgm5uMLV1IDXHnLc+sQ RncQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8PHeEQvI03GO1u4arOs5eKGxrrWj+QcJXenB1+d+Ev4=; b=WX343VwYGP0WAosH8AjOt0dL7XFZ+G75mN7c8++xP67422HiEc5fXeNydP3Z+TKIsU cvsA1nfII//LSwM+ECfbaH/NuQDY3j4PmG/aAlnA+KS2+WrnOYXOdbKiXoUr57c84CzK mn5ooVweWBvsETDfNFNiYZdXvrjPDyxgnv6gWrQ/dfuVhelZbiN1xNf2lpRjhcFE/WWW NV4aW7o0SfhIiXn9Rv9t6zflq361363FBsnYbhSVHsGRIIW2P0aeIX7o0C8KJgv/6o3d 0KAexrH5vAZYvDuvSh0Vm1/Ti1Rq4nEa0YDAtE/Sd9YMmNrYXKOX8T/JiScxc1Q7x+Vi XHGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=6l9nZSzx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb19-20020a056a004c9300b00565c028c4edsi5805038pfb.355.2022.10.30.15.03.41; Sun, 30 Oct 2022 15:03:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=6l9nZSzx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229944AbiJ3WCS (ORCPT + 99 others); Sun, 30 Oct 2022 18:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbiJ3WCM (ORCPT ); Sun, 30 Oct 2022 18:02:12 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95E32A1BE for ; Sun, 30 Oct 2022 15:02:09 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id o7so5703363pjj.1 for ; Sun, 30 Oct 2022 15:02:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8PHeEQvI03GO1u4arOs5eKGxrrWj+QcJXenB1+d+Ev4=; b=6l9nZSzxsOlgev3XI2BPsdlCYcxkwe86MfpEVfJczMSX1+0I/rH8AlHqSqBvvyUFD+ FLOo+9r+o+aWu5kEugJOUFPwjCw4I54idiEjMpMSPIltB8jPPCqhqN8P1bXH5sssnvQA qkfQNjn4W48osJfV2juo6XvIlw9Z/Hure5Ix8EsJEn5JkL+e3nOK6wqxUNn8vX9vqmPp rG+PyTTCQLqQ6k6pwkXoxeA+qz4Tgabrzzbj+3ooWXmaRO+62+Qi0xNSgA3F6qi5GTnj gMK/ksFvl1WR/UPEciiD58drbBPYSQwTv7nUZ+wLrJehGnY27OoUj1IHxXCBypqKpjKr qU9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8PHeEQvI03GO1u4arOs5eKGxrrWj+QcJXenB1+d+Ev4=; b=kBXWnhdTONVxRWkrvozqzBWM15CSlYWET7nerFyxdW1toYQ/A9pWjIg4s4JFtBHY8s rjcOA95PwZBSRNzJAE5C54UruTvPkfyYmJ8VTlNyUDGCAo0r7DrQFzVGHi8bJuBVLV/4 z+pslT5N1pgvY+a6FG/VVQsiYG0qOo73/NbJtxAd5f3a81kLLXBndgGUXrUo7BHFW+Z8 he2j7p4Q20MH3NzZMRTxLs/tPTUrSizqA1aIVKa7WAGZ9wuI95YA5CNrfFVepycTvtVB OoWZ1HFWa50qZRddLiQHov153es6y+ZHrGe7UzTgkoI3nMCMJIB5eGrthbtrw+2LPhbb xGug== X-Gm-Message-State: ACrzQf09nVe6bOjVX7WY1hIKbu4pQIN/+mD17TaF1FVhYcPjniaX3Bax nbqMk/gf6Q/HU2/yLstJIqaBto8zpgoxs12F X-Received: by 2002:a17:903:2452:b0:186:99e0:672d with SMTP id l18-20020a170903245200b0018699e0672dmr11199251pls.95.1667167328768; Sun, 30 Oct 2022 15:02:08 -0700 (PDT) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id y3-20020aa79e03000000b0056d73ef41fdsm562852pfq.75.2022.10.30.15.02.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Oct 2022 15:02:08 -0700 (PDT) From: Jens Axboe To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 1/6] eventpoll: cleanup branches around sleeping for events Date: Sun, 30 Oct 2022 16:01:58 -0600 Message-Id: <20221030220203.31210-2-axboe@kernel.dk> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221030220203.31210-1-axboe@kernel.dk> References: <20221030220203.31210-1-axboe@kernel.dk> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748151758485333356?= X-GMAIL-MSGID: =?utf-8?q?1748151758485333356?= Rather than have two separate branches here, collapse them into a single one instead. No functional changes here, just a cleanup in preparation for changes in this area. Signed-off-by: Jens Axboe --- fs/eventpoll.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 52954d4637b5..3061bdde6cba 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1869,14 +1869,15 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, * important. */ eavail = ep_events_available(ep); - if (!eavail) + if (!eavail) { __add_wait_queue_exclusive(&ep->wq, &wait); - - write_unlock_irq(&ep->lock); - - if (!eavail) + write_unlock_irq(&ep->lock); timed_out = !schedule_hrtimeout_range(to, slack, HRTIMER_MODE_ABS); + } else { + write_unlock_irq(&ep->lock); + } + __set_current_state(TASK_RUNNING); /*