Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1228703ybz; Sat, 25 Apr 2020 14:01:56 -0700 (PDT) X-Google-Smtp-Source: APiQypKOyfStRIEAmcMN7pktqEph2tDYcrbCJgYuFAwDLwE6yoLiCY5pPtaj7le7eOQaz1ObBoTw X-Received: by 2002:a17:906:16d0:: with SMTP id t16mr12788254ejd.303.1587848516132; Sat, 25 Apr 2020 14:01:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587848516; cv=none; d=google.com; s=arc-20160816; b=uSx8IU5+3YebliCPtwO4vRB0gd1f2QU7M3lRSbRpRc0PjKFFslqwbFpMDLur9oE1oq SWg8aB2A9lsExcbBoq+bDy2QHvEhw/Rl5yUdtOM/XXM2lRk2UUVgWyxFQRUmroNhiPI3 tXNgXrKzllE1dLqM5gSlAam6Lf9g+J/UTtPipS7KrDS8O6IZJY15OMOD5cQrrRWkiuvD drLtpnyLUiH3d0f3VlIVlXf+6goGz988nhf8G7Y9TbS5IEZyn6YvdtPrGePNg1QURrDh TVyUatHVewz8gfO1wU46F4HoNxgmTWizeFI9sQWgiMUP6DwLa6HCDyx+83eWm7K9SxKn PRUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=V9HpfRS435lskObag0L5vmppJY/Hcu6mU2OIeCkAO2s=; b=igu8AHY1vzLbfCSVW3neH8Eoss8HL6BeemD/NLFB6c2n0+N9BDsuK1/Trsg+EIxJXy IijI7QeK+iP2XctERyJ43hM1JXQdfNPTBpR2y2fh6L1s6VM04UTfKgyydOv99vd0MK1G lTxXW5c3oiAFaKBXAjrrhDCEhlOtc7hZfza8ls5lRCzIX9WzIeBzU7WLspXT4GAqpyJw BREa7a0G8CQboBeq7F5EgmnLiPhVWGNi9Hlp/aAF9pLEX2eDa6UbXTj1gAYCiQhvgVn/ mpBwTKtoCHum98X9QcoQ0mQMKN1jYVEGNAG93r9E8R7BZ3Kg/gDIJmXrYn3w8/ehgr3D /DIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uGJnNK2Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs23si5606167edb.203.2020.04.25.14.01.32; Sat, 25 Apr 2020 14:01:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uGJnNK2Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726364AbgDYVAJ (ORCPT + 99 others); Sat, 25 Apr 2020 17:00:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726278AbgDYVAI (ORCPT ); Sat, 25 Apr 2020 17:00:08 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D17FC09B04D for ; Sat, 25 Apr 2020 14:00:08 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id s63so14100175qke.4 for ; Sat, 25 Apr 2020 14:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=V9HpfRS435lskObag0L5vmppJY/Hcu6mU2OIeCkAO2s=; b=uGJnNK2Q3UI/ALmhO3z/sKERhVcr2JjP/pvYj93M7Oatcw16z72Cs4hZrN8yIEnn0g ZQw0mg3yEenSzW8teRHySlW1M6GWAgQVgkp3jcit/PfQginacbw4jtpLfrxug40IAaCf O4fbaCJycmIsN2PGAJqnNFOPLHD4T0ZtXVzQ79w65jEoj+EGlcs5EaLUqUsy2QqIy6l3 FwlqL0xq19ok78cMCKeaJayFoeVTVq5mqDFd6pTtL2+tAtDwXCa+1AxShU3ufQCSgguF 2XzHkCRiD8w9ih4NB0PqYAuXxFeXvDAseM1vO+PJ1n1uoNRyB8mqU7QF2Edr6Q6PrU+L M3qw== 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=V9HpfRS435lskObag0L5vmppJY/Hcu6mU2OIeCkAO2s=; b=Axt/hjSAjBT/T1Zc9NP3fMB8Nu24wHbnrzdyfwEffEXcbsCjfqm5DQLP21eN7wW1ty bKY7lOwGztFgKwPxYFlERptEpAOuhcXz50TnHdNeUlMittGuQTIN2nCh0Fc/jvve8zS3 5x9uPqYLp2Dnp76VRAazhNqjvVp8gr5qn6EEVikNBhiwJIMAMVkDBNktDMnGZGN+gICr B6Dbqt3sd3YXcf3t8TY11JSySJvhgeAWmravKYn3R4rl83fDg1sorSXYAAzqBICIYEPw GT4b+WFUDwW+NLIbdy5e5aCUbgEtyij6dYoJ3t1KSBh/rFnD/YpMJdP6ic1LX2gl6IRS ILqA== X-Gm-Message-State: AGi0Pub3eKVaKkheikGbQUvlCs/MOGOv/LRfYwHEKgAu7ht+eBYdQ7OU InbbbNYf5d+SwNlnDk74Wrb9Ax5aDsMOIooK9aoYcw== X-Received: by 2002:a37:6691:: with SMTP id a139mr15665894qkc.501.1587848407222; Sat, 25 Apr 2020 14:00:07 -0700 (PDT) MIME-Version: 1.0 References: <20200424025057.118641-1-khazhy@google.com> <20200424190039.192373-1-khazhy@google.com> <66f26e74-6c7b-28c2-8b3f-faf8ea5229d4@akamai.com> In-Reply-To: <66f26e74-6c7b-28c2-8b3f-faf8ea5229d4@akamai.com> From: Khazhismel Kumykov Date: Sat, 25 Apr 2020 13:59:56 -0700 Message-ID: Subject: Re: [PATCH v2] eventpoll: fix missing wakeup for ovflist in ep_poll_callback To: Jason Baron Cc: Andrew Morton , linux-fsdevel , Linux Kernel Mailing List , Roman Penyaev , Alexander Viro , Heiher , stable@vger.kernel.org Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="0000000000004fb90705a423c480" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0000000000004fb90705a423c480 Content-Type: text/plain; charset="UTF-8" On Sat, Apr 25, 2020 at 9:17 AM Jason Baron wrote: > > > > On 4/24/20 3:00 PM, Khazhismel Kumykov wrote: > > In the event that we add to ovflist, before 339ddb53d373 we would be > > woken up by ep_scan_ready_list, and did no wakeup in ep_poll_callback. > > With that wakeup removed, if we add to ovflist here, we may never wake > > up. Rather than adding back the ep_scan_ready_list wakeup - which was > > resulting in unnecessary wakeups, trigger a wake-up in ep_poll_callback. > > I'm just curious which 'wakeup' we are talking about here? There is: > wake_up(&ep->wq) for the 'ep' and then there is the nested one via: > ep_poll_safewake(ep, epi). It seems to me that its only about the later > one being missing not both? Is your workload using nested epoll? > > If so, it might make sense to just do the later, since the point of > the original patch was to minimize unnecessary wakeups. The missing wake-ups were when we added to ovflist instead of rdllist. Both are "the ready list" together - so I'd think we'd want the same wakeups regardless of which specific list we added to. ep_poll_callback isn't nested specific? > > Thanks, > > -Jason > > > > > We noticed that one of our workloads was missing wakeups starting with > > 339ddb53d373 and upon manual inspection, this wakeup seemed missing to > > me. With this patch added, we no longer see missing wakeups. I haven't > > yet tried to make a small reproducer, but the existing kselftests in > > filesystem/epoll passed for me with this patch. > > > > Fixes: 339ddb53d373 ("fs/epoll: remove unnecessary wakeups of nested epoll") > > > > Signed-off-by: Khazhismel Kumykov > > Reviewed-by: Roman Penyaev > > Cc: Alexander Viro > > Cc: Heiher > > Cc: Jason Baron > > Cc: > > --- > > v2: use if/elif instead of goto + cleanup suggested by Roman > > fs/eventpoll.c | 18 +++++++++--------- > > 1 file changed, 9 insertions(+), 9 deletions(-) > > > > diff --git a/fs/eventpoll.c b/fs/eventpoll.c > > index 8c596641a72b..d6ba0e52439b 100644 > > --- a/fs/eventpoll.c > > +++ b/fs/eventpoll.c > > @@ -1171,6 +1171,10 @@ static inline bool chain_epi_lockless(struct epitem *epi) > > { > > struct eventpoll *ep = epi->ep; > > > > + /* Fast preliminary check */ > > + if (epi->next != EP_UNACTIVE_PTR) > > + return false; > > + > > /* Check that the same epi has not been just chained from another CPU */ > > if (cmpxchg(&epi->next, EP_UNACTIVE_PTR, NULL) != EP_UNACTIVE_PTR) > > return false; > > @@ -1237,16 +1241,12 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v > > * chained in ep->ovflist and requeued later on. > > */ > > if (READ_ONCE(ep->ovflist) != EP_UNACTIVE_PTR) { > > - if (epi->next == EP_UNACTIVE_PTR && > > - chain_epi_lockless(epi)) > > + if (chain_epi_lockless(epi)) > > + ep_pm_stay_awake_rcu(epi); > > + } else if (!ep_is_linked(epi)) { > > + /* In the usual case, add event to ready list. */ > > + if (list_add_tail_lockless(&epi->rdllink, &ep->rdllist)) > > ep_pm_stay_awake_rcu(epi); > > - goto out_unlock; > > - } > > - > > - /* If this file is already in the ready list we exit soon */ > > - if (!ep_is_linked(epi) && > > - list_add_tail_lockless(&epi->rdllink, &ep->rdllist)) { > > - ep_pm_stay_awake_rcu(epi); > > } > > > > /* > > --0000000000004fb90705a423c480 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime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