Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp669389iog; Thu, 30 Jun 2022 08:03:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1spW86OMUibfEC1H3Fqedl+urW8c5leQMONU8qWnAtUg/ZdWmWXAXF/p5cQrcU37XlP+U8T X-Received: by 2002:a65:5a87:0:b0:411:8061:87b9 with SMTP id c7-20020a655a87000000b00411806187b9mr7357031pgt.413.1656601395724; Thu, 30 Jun 2022 08:03:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656601395; cv=none; d=google.com; s=arc-20160816; b=rx7cAkhMZFApKXSkCmbQkzU1amBhCo0gtbVpPTOWHDzieLJQcq7qChNgvJfo14sazD 5gvMktBNSYKm3QZUYOOjElZwVkU4q60dNIca+ike/CZIEommW+FvjSGhHTRnwSTWOdi+ mErJ07ztY8z8sb4wbjClp/epMG6RaY8qjIPKk1eqMiAw/VwlpehucRU3tbVkBZEHjGUP HsCDyvuWq2orSJGgFjLEcoymzaFdtcu2thaDEd7k1W2w3fi2WmdLdobWYw99qz5WrqEx PRCNOz12ZC3v6gV37EB5A+Dv6Tt5climfiKgBSJDY43fUit+XElGphe5Ream6e0jZIZG RDOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qlh+zR4sLlUERmwK/XvlQfyn3K58u4Hbj9CmOVIz4kE=; b=XJL0gpy7EFjx1MEIvbkMZ5666Kbdx23dmfkreA+a+SWGeLT7ixPQERCW5kFG1+tbTS yogbIf0b64LDPKaTd1YXJm3to4bHGusSTifxbaHfJiogfU9guBPDaG4rZEzxJGw4yLZu jHL4YA7wL7OQJXt0C7EpITzSjvR8ZOA27wmmYuxi/5wBH/TxijeuuwPuzbvMnjwy/u1H p4YfvXWtSlkmP+UH1gk5zI0ubF/nrF7WnWlY2/vDCBjVnGTS84E8F6k/ammXlOyDS5xS TqPUTD1v7tPsb9ssMrvLAQWqNsea1D8mxFLQTywF6vfHsG8G1T94QqgYIoeHWkTdoZ0z 1TJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=cySIqHpy; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 5-20020a630205000000b0040c67af257dsi7075370pgc.121.2022.06.30.08.03.03; Thu, 30 Jun 2022 08:03:15 -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=@google.com header.s=20210112 header.b=cySIqHpy; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234003AbiF3O7U (ORCPT + 99 others); Thu, 30 Jun 2022 10:59:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232881AbiF3O7S (ORCPT ); Thu, 30 Jun 2022 10:59:18 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D8851EC42 for ; Thu, 30 Jun 2022 07:59:17 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id n12so18468964pfq.0 for ; Thu, 30 Jun 2022 07:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qlh+zR4sLlUERmwK/XvlQfyn3K58u4Hbj9CmOVIz4kE=; b=cySIqHpyfsq8wQfibZxaJwaBXBeRR3JRvYpqgG1nVFVyrgi4LGoeV1DCnz+GUpcJZi vT2GKVz1T5yQgwGNvIl6KYW0vxnhoYMmHep7DSLgEhlE4dH3JbX8xsH7u7Q0YDAaqWZB PXQeuKGS5/5qJdUNfMydr8TlO412HmIgUpCRDqcO6iCx42bmkoMoolK4422JO9qnvbKu sKB5LHRSVjQQL+eS4HB3OHwcVCB46n5hn22BgT5u4wWgh1yMKWK0hg2Fypw+Baqu285d Z1HOy9YW95intZv3yiOB/e2R2hwuAhPHQUe1HLSN9SxxalhlNtvcxT7m3s1B3qU6k40r XorA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qlh+zR4sLlUERmwK/XvlQfyn3K58u4Hbj9CmOVIz4kE=; b=i1niB8FLlRBVuOiKdg90vtW+5sWZW4tMcBVqzp0CaCoZRENkJ3JJdIBcKu+vINX/2p 6mkVSCllNMClWUclsDuTDFnJ4cgYE/wFmlV7MirrGUiPRv587yH5qISueTdpqIyDZJVW XA/FGyrboFXDvsMarfSUMXg3ZIn/dZQAO8w0/K/47Y2KOExwkHGKcUyPje2Nmgf7Hvfj SldSEovMtpThtlxpgLrW5KugdxBWM6iFPALHZPPn8nDDkrivQ96JljE7GYXH6B2bm5E5 SAqe3wDhkUebyKh3JC2nPeHbdXvvqYeZQsKenx8/8sDGfJ6hOA/47ufu8FmNoTkZNhFa 995g== X-Gm-Message-State: AJIora/6jjydmormcCYVAF8hMv1ClvPNdyfEBWGptbR+lu/lgtLfz4k5 u1MuQ6T22MNXGs27+apIXgy+jG7Q32Gtqe+n0O/WTg== X-Received: by 2002:a05:6a00:2395:b0:525:8980:5dc7 with SMTP id f21-20020a056a00239500b0052589805dc7mr16410526pfc.8.1656601156814; Thu, 30 Jun 2022 07:59:16 -0700 (PDT) MIME-Version: 1.0 References: <20220629165542.da7fc8a2a5dbd53cf99572aa@linux-foundation.org> <20220629192435.df27c0dbb07ef72165e1de5e@linux-foundation.org> In-Reply-To: <20220629192435.df27c0dbb07ef72165e1de5e@linux-foundation.org> From: Shakeel Butt Date: Thu, 30 Jun 2022 07:59:05 -0700 Message-ID: Subject: Re: [RESEND RFC PATCH] epoll: autoremove wakers even more aggressively To: Andrew Morton Cc: Benjamin Segall , Alexander Viro , linux-fsdevel , LKML , Linus Torvalds , Eric Dumazet , Roman Penyaev , Jason Baron , Khazhismel Kumykov , Heiher Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Wed, Jun 29, 2022 at 7:24 PM Andrew Morton wrote: > > On Wed, 29 Jun 2022 18:12:46 -0700 Shakeel Butt wrote: > > > On Wed, Jun 29, 2022 at 4:55 PM Andrew Morton wrote: > > > > > > On Wed, 15 Jun 2022 14:24:23 -0700 Benjamin Segall wrote: > > > > > > > If a process is killed or otherwise exits while having active network > > > > connections and many threads waiting on epoll_wait, the threads will all > > > > be woken immediately, but not removed from ep->wq. Then when network > > > > traffic scans ep->wq in wake_up, every wakeup attempt will fail, and > > > > will not remove the entries from the list. > > > > > > > > This means that the cost of the wakeup attempt is far higher than usual, > > > > does not decrease, and this also competes with the dying threads trying > > > > to actually make progress and remove themselves from the wq. > > > > > > > > Handle this by removing visited epoll wq entries unconditionally, rather > > > > than only when the wakeup succeeds - the structure of ep_poll means that > > > > the only potential loss is the timed_out->eavail heuristic, which now > > > > can race and result in a redundant ep_send_events attempt. (But only > > > > when incoming data and a timeout actually race, not on every timeout) > > > > > > > > > > Thanks. I added people from 412895f03cbf96 ("epoll: atomically remove > > > wait entry on wake up") to cc. Hopefully someone there can help review > > > and maybe test this. > > > > > > > > > > Thanks Andrew. Just wanted to add that we are seeing this issue in > > production with real workloads and it has caused hard lockups. > > Particularly network heavy workloads with a lot of threads in > > epoll_wait() can easily trigger this issue if they get killed > > (oom-killed in our case). > > Hard lockups are undesirable. Is a cc:stable justified here? Not for now as I don't know if we can blame a patch which might be the source of this behavior.