From patchwork Fri Jun 8 19:12:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 10455055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 14A2060318 for ; Fri, 8 Jun 2018 19:14:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4AA8260CD for ; Fri, 8 Jun 2018 19:14:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5BBD294EA; Fri, 8 Jun 2018 19:14:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2912260CD for ; Fri, 8 Jun 2018 19:14:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752693AbeFHTMi (ORCPT ); Fri, 8 Jun 2018 15:12:38 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:38435 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752621AbeFHTMh (ORCPT ); Fri, 8 Jun 2018 15:12:37 -0400 Received: by mail-wr0-f195.google.com with SMTP id e18-v6so6134001wrs.5 for ; Fri, 08 Jun 2018 12:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scylladb-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=3VOUFDRzVTPPkHKgia+ybV0nS68P2ApEyakeGkhWYfk=; b=DyH8beMd3s8qQ6mvX8lQQ9yTjTuHwxrUih2H/601ljuPYk1lInoAVyzdlpnUpzSMIr ysMKADvI003spMgGuAPrADxSKZhgXMz3D/caeSC5P8nztRsTHNHfuTGO2EAUapwIakDo 4OJ69vH6Z5GYdjRwbRdRkiCR8kGtB44oPzLPRjtDgT89fJ8OBWb1K9oTMEmE10YicUPJ fe2u6FXlDclmJfSs6UYGYhDooMeEUShudncESnrZVt2t8sZDmmINzYVemyeA7JxuLSc9 Y/VlTPIZ0Xh56ut5eDAfdbyNXNo99GIub5PXbHMfMRYuw8uYf0gRu5HCDbopSvItp18B jRLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3VOUFDRzVTPPkHKgia+ybV0nS68P2ApEyakeGkhWYfk=; b=GvxhpPhoLwr1q047/GZBgmypwkx43oTBS4QRPhOTjn3nMNbpqSJU1G2ua2EbYa/TMM M6WPZIULvFuaQgK9i1NcC+jJw/aVVk0aao9YV7IhDMk6ZlEtoE3I99Oxl2Zi8+g9aDYT ot1ZxQe7q+c3E999RA0TxmW4TdAxwFTbbLuWt2omkIGpWBiWqvibZ4mMGdCoRyNC/EeV nsEKs7d7Kp0LOZtc8mQvajWHFcqWkPWatgjjy08yu9EE2ifxYmVFKkewR+xCAMuvN4v8 ip6jcK66mPy7C/znJNesuIrKCEQl0WBeOt6avCVUjKFGnQRCaOmszkY92tKse1/LmUE9 4sBA== X-Gm-Message-State: APt69E1AWoS4qJARY0fdRpblFM9w0zM+MYaGhg2Q/k70JQFE+c8xaeiX 4wHyevzNkMzUtW0gTKC/4tHztA== X-Google-Smtp-Source: ADUXVKL/ZYPY0ezstnxRnXQk08ZkAc/+Q81zXEGT95Rb57cz/HudqMGxnDB2sj9V44aTe1B/NGvoGQ== X-Received: by 2002:adf:9aa5:: with SMTP id a34-v6mr6366777wrc.50.1528485156481; Fri, 08 Jun 2018 12:12:36 -0700 (PDT) Received: from avi.cloudius-systems.com (system.cloudius-systems.com. [199.203.229.89]) by smtp.gmail.com with ESMTPSA id u7-v6sm40715117wrp.44.2018.06.08.12.12.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jun 2018 12:12:35 -0700 (PDT) From: Avi Kivity To: Alexander Viro Cc: hch@lst.de, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v1] eventfd: only return events requested in poll_mask() Date: Fri, 8 Jun 2018 22:12:32 +0300 Message-Id: <20180608191232.4758-1-avi@scylladb.com> X-Mailer: git-send-email 2.14.4 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ->poll_mask() operation has a mask of events that the caller is interested in, but we're returning all events regardless. Change to return only the events the caller is interested in. This fixes aio IO_CMD_POLL returning immediately when called with POLLIN on an eventfd, since an eventfd is almost always ready for a write. Signed-off-by: Avi Kivity --- fs/eventfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/eventfd.c b/fs/eventfd.c index 61c9514da5e9..ceb1031f1cac 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -154,15 +154,15 @@ static __poll_t eventfd_poll_mask(struct file *file, __poll_t eventmask) * eventfd_poll returns 0 */ count = READ_ONCE(ctx->count); if (count > 0) - events |= EPOLLIN; + events |= (EPOLLIN & eventmask); if (count == ULLONG_MAX) events |= EPOLLERR; if (ULLONG_MAX - 1 > count) - events |= EPOLLOUT; + events |= (EPOLLOUT & eventmask); return events; } static void eventfd_ctx_do_read(struct eventfd_ctx *ctx, __u64 *cnt)