From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CD14C00A89 for ; Mon, 2 Nov 2020 17:09:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38AF920756 for ; Mon, 2 Nov 2020 17:09:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604336940; bh=ooh8wTqfJlSRN6V5CxcXzPZy0UyRYio50u2paWm8R48=; h=References:In-Reply-To:From:Date:Subject:To:Cc:Reply-To:List-ID: From; b=vMwNawbj9AKEwgbWMMCtqOEFFeUF+l8OlOXx5bGNWmtme+oLEqrZkqOmPPftNxmcw F25I5cwNju6/ezCwf1wIjb351mKynGdAXgjNmSuxZpzIiCoUaxGkJYaS+S5u2kFBAE QE2y/67sy2BsHtkZ0aUa9rqPmysL/bza3XdCC1uw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727413AbgKBRI7 (ORCPT ); Mon, 2 Nov 2020 12:08:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727316AbgKBRI7 (ORCPT ); Mon, 2 Nov 2020 12:08:59 -0500 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58484C0617A6 for ; Mon, 2 Nov 2020 09:08:59 -0800 (PST) Received: by mail-lf1-x144.google.com with SMTP id a7so18352535lfk.9 for ; Mon, 02 Nov 2020 09:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/yKbwd8teEZfRwagaMtRcUpC2gb0x64xrCI3HX4kiMo=; b=GO1P0qRzMuEf9eqjFiCYJZL5DwDA374+wWDOxErTNzaxestNIqQQXioUHFyKKCoRpn kInBe+In8Vsyahjo7HvQKMf1i2i2X76nvHCqlxOFio2PpyaIvst+5/LdBNO5fvNAMNV8 RqVoVU2njXn+oAP5zbMN0mC5JHkXvl8ZQNNLc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/yKbwd8teEZfRwagaMtRcUpC2gb0x64xrCI3HX4kiMo=; b=o54MuVvR3c4jgOKOGyRQPOJ993wG+FtO8dwhw4GlbD6ngSKu3ds5fax9e3t6PYSLAG EFFITdF2np4ELMG7YSI3nUdJW9tVYVz46flewiqXq/lJCey3cdyY1ALYxwzXcoAcLOj4 YHSwPgr/ZwjHRtS/92TGG/68g3KAAYee9sPwm0+tHf2BsHjIX0kZyavE9fs0o3SFlOjd AyjDjAUp5pZUoZf0V8mRqCny+rnVTrp+nYddzTup2T32KpcpqfNmCeEN1IqdtV3Najlb Sr4SRbIW/xza+swoIkd+r64S+T3KZpX1BKMLh6IeaZUQc0wgfVBmlnl7+5C/uAS6Bwi6 YncQ== X-Gm-Message-State: AOAM5307VIPDr5hspzTMRJUbftI0Q8XRerpOs4rryau2DTyoUYhWb36E E6QZjWBCYpU8RJ2sVM6sDrGfCrwNKOrEZQ== X-Google-Smtp-Source: ABdhPJzcRDsx3NNfQ/ikl5fDzEKL5ZnXy4fAaIkkfQH0pGGDlkfDjlB2ulgIbsnTcgVHHNRbfmInEw== X-Received: by 2002:a19:cb12:: with SMTP id b18mr5628921lfg.262.1604336937292; Mon, 02 Nov 2020 09:08:57 -0800 (PST) Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com. [209.85.167.44]) by smtp.gmail.com with ESMTPSA id 21sm2596228lju.110.2020.11.02.09.08.52 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Nov 2020 09:08:53 -0800 (PST) Received: by mail-lf1-f44.google.com with SMTP id 126so18359104lfi.8 for ; Mon, 02 Nov 2020 09:08:52 -0800 (PST) X-Received: by 2002:a19:c703:: with SMTP id x3mr5683463lff.105.1604336932623; Mon, 02 Nov 2020 09:08:52 -0800 (PST) MIME-Version: 1.0 References: <20201101170656.48abbd5e88375219f868af5e@linux-foundation.org> <20201102010804.uENOQsZO9%akpm@linux-foundation.org> In-Reply-To: <20201102010804.uENOQsZO9%akpm@linux-foundation.org> From: Linus Torvalds Date: Mon, 2 Nov 2020 09:08:36 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [patch 13/15] epoll: check ep_events_available() upon timeout To: Andrew Morton Cc: Davidlohr Bueso , Eric Dumazet , guantaol@google.com, khazhy@google.com, Linux-MM , mm-commits@vger.kernel.org, Soheil Hassas Yeganeh , Al Viro , willemb@google.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org On Sun, Nov 1, 2020 at 5:08 PM Andrew Morton wrote: > > After abc610e01c66 ("fs/epoll: avoid barrier after an epoll_wait(2) > timeout"), we break out of the ep_poll loop upon timeout, without checking > whether there is any new events available. Prior to that patch-series we > always called ep_events_available() after exiting the loop. This patch looks overly complicated to me. It does the exact same thing as the "break" does, except: - it does it the non-optimized way without the "avoid spinlock" - it sets eavail if there was It would seem like the *much* simpler patch is to just do this oneliner instead: diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 4df61129566d..29fa770ce1e3 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1907,6 +1907,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, if (!schedule_hrtimeout_range(to, slack, HRTIMER_MODE_ABS)) { timed_out = 1; + eavail = 1; break; } and *boom* you're done. That will mean that after a timeout we'll try one more time to just do that ep_events_available() thing. I can see no downside to just setting eavail unconditionally and keeping the code much simpler. Hmm? Linus From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA3CBC4742C for ; Mon, 2 Nov 2020 17:09:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 38B522071A for ; Mon, 2 Nov 2020 17:09:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="GO1P0qRz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38B522071A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A6BC26B0036; Mon, 2 Nov 2020 12:09:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A1AD16B0068; Mon, 2 Nov 2020 12:09:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B9106B006C; Mon, 2 Nov 2020 12:09:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 5619E6B0036 for ; Mon, 2 Nov 2020 12:09:00 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id EACD4824999B for ; Mon, 2 Nov 2020 17:08:59 +0000 (UTC) X-FDA: 77440113198.11.books54_1f0afc9272b1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id BFF3D180F8B86 for ; Mon, 2 Nov 2020 17:08:59 +0000 (UTC) X-HE-Tag: books54_1f0afc9272b1 X-Filterd-Recvd-Size: 4774 Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Mon, 2 Nov 2020 17:08:59 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id 23so15804964ljv.7 for ; Mon, 02 Nov 2020 09:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/yKbwd8teEZfRwagaMtRcUpC2gb0x64xrCI3HX4kiMo=; b=GO1P0qRzMuEf9eqjFiCYJZL5DwDA374+wWDOxErTNzaxestNIqQQXioUHFyKKCoRpn kInBe+In8Vsyahjo7HvQKMf1i2i2X76nvHCqlxOFio2PpyaIvst+5/LdBNO5fvNAMNV8 RqVoVU2njXn+oAP5zbMN0mC5JHkXvl8ZQNNLc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/yKbwd8teEZfRwagaMtRcUpC2gb0x64xrCI3HX4kiMo=; b=P2NqeJMxHn45AD8L/JYgTIWDNfV4vWRXngQfpbNUmVGYg2qrR1y3QfPyRUCs4LZ0uT lKHS2MdalmzLxVqSO9s6mr3B7ZJHUnwah+AXStdsbbvjawW11DQVU/mEKXGtMlA14yCJ Ee+ktz+3kjsFB59/3IDe1+q/Z+XkuoExy3CDeHHXNjTQq2R6nlPfwTV4KSv+iqJJdYm/ gbAgFjyBzejiJUKk/PzJEOi6aosvFgeOP8cg572bjzYs/r5qp+6HU4MzriZcWinw/K4E zXFElVSD0Lm0hUx2feUYmMLvgSuqtGzLHr3mYAuJH0qEkTHDApc5g25ra5NijqeIs3w5 FMFw== X-Gm-Message-State: AOAM533XTOzrvW/16fkWI2yt8iSaTlZe/OGN1Z5/whN1fXPcnGmWKfsg NFvSTVWfYuasb/nfyAvU/xtqhinMr+HFxQ== X-Google-Smtp-Source: ABdhPJyryJPK08lvtmfqVBjxxE8rpz5QFua1JPsHWcjnzkU9/CULfeVdsozW01bj1leEGquOsKJE6Q== X-Received: by 2002:a2e:b888:: with SMTP id r8mr6701214ljp.138.1604336937063; Mon, 02 Nov 2020 09:08:57 -0800 (PST) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com. [209.85.167.48]) by smtp.gmail.com with ESMTPSA id p26sm2448629lfc.75.2020.11.02.09.08.53 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Nov 2020 09:08:53 -0800 (PST) Received: by mail-lf1-f48.google.com with SMTP id y184so16416537lfa.12 for ; Mon, 02 Nov 2020 09:08:53 -0800 (PST) X-Received: by 2002:a19:c703:: with SMTP id x3mr5683463lff.105.1604336932623; Mon, 02 Nov 2020 09:08:52 -0800 (PST) MIME-Version: 1.0 References: <20201101170656.48abbd5e88375219f868af5e@linux-foundation.org> <20201102010804.uENOQsZO9%akpm@linux-foundation.org> In-Reply-To: <20201102010804.uENOQsZO9%akpm@linux-foundation.org> From: Linus Torvalds Date: Mon, 2 Nov 2020 09:08:36 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [patch 13/15] epoll: check ep_events_available() upon timeout To: Andrew Morton Cc: Davidlohr Bueso , Eric Dumazet , guantaol@google.com, khazhy@google.com, Linux-MM , mm-commits@vger.kernel.org, Soheil Hassas Yeganeh , Al Viro , willemb@google.com Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, Nov 1, 2020 at 5:08 PM Andrew Morton wrote: > > After abc610e01c66 ("fs/epoll: avoid barrier after an epoll_wait(2) > timeout"), we break out of the ep_poll loop upon timeout, without checking > whether there is any new events available. Prior to that patch-series we > always called ep_events_available() after exiting the loop. This patch looks overly complicated to me. It does the exact same thing as the "break" does, except: - it does it the non-optimized way without the "avoid spinlock" - it sets eavail if there was It would seem like the *much* simpler patch is to just do this oneliner instead: diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 4df61129566d..29fa770ce1e3 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1907,6 +1907,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, if (!schedule_hrtimeout_range(to, slack, HRTIMER_MODE_ABS)) { timed_out = 1; + eavail = 1; break; } and *boom* you're done. That will mean that after a timeout we'll try one more time to just do that ep_events_available() thing. I can see no downside to just setting eavail unconditionally and keeping the code much simpler. Hmm? Linus