Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1755527rwb; Mon, 7 Nov 2022 05:32:03 -0800 (PST) X-Google-Smtp-Source: AMsMyM46hRy+tko/E0A4QXUabouc13H+W85oLsASrPhJKEeDUiapL8veIsntmnPhJdQAi3DClm+R X-Received: by 2002:a05:6a00:22d6:b0:56d:39a2:14ae with SMTP id f22-20020a056a0022d600b0056d39a214aemr45607145pfj.80.1667827923488; Mon, 07 Nov 2022 05:32:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667827923; cv=none; d=google.com; s=arc-20160816; b=xev3tMevcsKVxuGrRDSUKgPFbHHMibhOyivKKEjvVuUQeM672a6dki7MD8OcN3V/vr t4qAggzaekwSAFcqPnhXUZQEBMlFt1aayI+MKdiWCxeY6KBdc0vAmkgSeIOFFWq82C5o XDujwoPaTI1rTMhzM+MedRUYxm7PT8PU+F48I0tYEdyws3+Au7R8zqKk6pdVJZHKlvCl psrNEwqxe3k/45HOJjq8NgPy8oEfqG80d4gbMmOwX+aGLqXIxFmMrvbilcRvX0mu5zgm 1r/HVl+g8T0WxJLAyj1Cnpnzdo6466c7fHxPSevl7/CS+43dQXvf7zVHlCo7COkpW+Wm rThg== 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=eJNmkTVGuEN8Z4KDgftkyeqz6lbn5zaHdj9DAo/2scU=; b=BGp4555ZHTHakVx+uzrYDmEYqlcNg7+IQpBQIjVjNu1362bmb0JdKFo1U4G3FFaTPW rabNSHf7ySpTQuPd3MomwpAvEdglm/9VmV6ZghVO8bKHjDRJJIyFOkBpsH0gYB2nf/IO b3KCbPtmjSuqGRfmt5nld0jHEzf9ZC+z/psfUsU6L8CyxVxd2+R8Zq3eg9SgznQFKTWz YRc8BMIjbTjbSD/HT9OT950IZBoEHA7U4hAMV7TSr6s1uIVxBFETlViqlRXa3JIUvI8r d7Fe+LoPJ6rkE6IfHDejl2HQvuBes0mQ2S8OHNdfnU8wUVeTZZEVWR4zNLctB/50WICi owHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RzSePtA+; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s78-20020a632c51000000b00460c07c5542si10418366pgs.407.2022.11.07.05.31.51; Mon, 07 Nov 2022 05:32:03 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=RzSePtA+; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231946AbiKGN0B (ORCPT + 94 others); Mon, 7 Nov 2022 08:26:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231803AbiKGNZ6 (ORCPT ); Mon, 7 Nov 2022 08:25:58 -0500 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F65C1C927 for ; Mon, 7 Nov 2022 05:25:57 -0800 (PST) Received: by mail-qv1-xf29.google.com with SMTP id x15so8068309qvp.1 for ; Mon, 07 Nov 2022 05:25:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=eJNmkTVGuEN8Z4KDgftkyeqz6lbn5zaHdj9DAo/2scU=; b=RzSePtA+1KqdSsq8crudtZQKzWstuJdxe83ms3LYIQt9XN/VF3LQpTAkRdJF14NLzp BPe/k3ON+F7JWOjXAwSWDuWkXXj0EiLlpbuwdYoScLgCXyYc7NRJ8yfK88v14uXHwoSQ SzT7HsLWiYZkGxAEA2Fy+32tgHcmEN2xkOeipBMnCyWjRx8cwv/VWQCywgGhHlFiBe6s kb+HgBTwEJHA0i3OxZfK5oFTXzce72qkt+siIBcYx8zX8bk0Qj2fse7bmVgdb9nF/MvR Yh/VNqKXepeOIx7IoTK8N5C406lartwm161g3j1SXzkl1LKpTEWXYDkiVNCN9XE0A2wo RJHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eJNmkTVGuEN8Z4KDgftkyeqz6lbn5zaHdj9DAo/2scU=; b=H3nERCExZ0c3HdaqNS3Pw4TkVNhso8bzKmBAC5tg14vbZxSytKh+La5SxUlU8UiCgy NkQL+24hrtj7NznMu8YkczpKP1eFZKs4kNg+Yo1hjGX/rQJPLqWCPCm0OecAaxOUXeTE UROsPofRMzv4IWI8aRERKJsebgInq5Yc/wbWmL07fTZ/SvmEMCpwhVYtcaPksJIyCYkB PSnFC3aeWXrV8lnmq3Wdt5aC2FEpNB8IloELwd9nuSaENalwTNa6+bVN1322ZSHsT/pK /o1GSp70BL2KEcMr6AXwYOjGXfzFE4D7ALiMPDljrQH54y5wR53fnjEEg/xniJMH3+6Q nTbQ== X-Gm-Message-State: ACrzQf3JVFQGGOQ4HKW6o4vc96to9gkxzT9PTSeQTHDlBsi4++OFVCu1 mPZmar1/ADJSl/JqZxXzTqMct3CtKyU= X-Received: by 2002:ad4:5c4e:0:b0:4bb:9fea:f52e with SMTP id a14-20020ad45c4e000000b004bb9feaf52emr44942138qva.51.1667827556286; Mon, 07 Nov 2022 05:25:56 -0800 (PST) Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com. [209.85.219.180]) by smtp.gmail.com with ESMTPSA id cj25-20020a05622a259900b003a4c3c4d2d4sm6044866qtb.49.2022.11.07.05.25.55 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Nov 2022 05:25:55 -0800 (PST) Received: by mail-yb1-f180.google.com with SMTP id z192so13627749yba.0 for ; Mon, 07 Nov 2022 05:25:55 -0800 (PST) X-Received: by 2002:a05:6902:1001:b0:6be:820d:a0de with SMTP id w1-20020a056902100100b006be820da0demr49694453ybt.240.1667827555181; Mon, 07 Nov 2022 05:25:55 -0800 (PST) MIME-Version: 1.0 References: <20221030220203.31210-1-axboe@kernel.dk> <02e5bf45-f877-719b-6bf8-c4ac577187a8@kernel.dk> <88353f13-d1d8-ef69-bcdc-eb2aa17c7731@kernel.dk> <46cb04ca-467c-2e33-f221-3e2a2eaabbda@kernel.dk> In-Reply-To: From: Willem de Bruijn Date: Mon, 7 Nov 2022 08:25:18 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHSET v3 0/5] Add support for epoll min_wait To: Jens Axboe Cc: Willem de Bruijn , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Sat, Nov 5, 2022 at 2:46 PM Jens Axboe wrote: > > On 11/5/22 12:05 PM, Willem de Bruijn wrote: > > On Sat, Nov 5, 2022 at 1:39 PM Jens Axboe wrote: > >> > >>>> FWIW, when adding nsec resolution I initially opted for an init-based > >>>> approach, passing a new flag to epoll_create1. Feedback then was that > >>>> it was odd to have one syscall affect the behavior of another. The > >>>> final version just added a new epoll_pwait2 with timespec. > >>> > >>> I'm fine with just doing a pure syscall variant too, it was my original > >>> plan. Only changed it to allow for easier experimentation and adoption, > >>> and based on the fact that most use cases would likely use a fixed value > >>> per context anyway. > >>> > >>> I think it'd be a shame to drop the ctl, unless there's strong arguments > >>> against it. I'm quite happy to add a syscall variant too, that's not a > >>> big deal and would be a minor addition. Patch 6 should probably cut out > >>> the ctl addition and leave that for a patch 7, and then a patch 8 for > >>> adding a syscall. > >> I split the ctl patch out from the core change, and then took a look at > >> doing a syscall variant too. But there are a few complications there... > >> It would seem to make the most sense to build this on top of the newest > >> epoll wait syscall, epoll_pwait2(). But we're already at the max number > >> of arguments there... > >> > >> Arguably pwait2 should've been converted to use some kind of versioned > >> struct instead. I'm going to take a stab at pwait3 with that kind of > >> interface. > > > > Don't convert to a syscall approach based solely on my feedback. It > > would be good to hear from others. > > It's not just based on your feedback, if you read the original cover > letter, then that is the question that is posed in terms of API - ctl to > modify it, new syscall, or both? So figured I should at least try and > see what the syscall would look like. > > > At a high level, I'm somewhat uncomfortable merging two syscalls for > > behavior that already works, just to save half the syscall overhead. > > There is no shortage of calls that may make some sense for a workload > > to merge. Is the quoted 6-7% cpu cycle reduction due to saving one > > SYSENTER/SYSEXIT (as the high resolution timer wake-up will be the > > same), or am I missing something more fundamental? > > No, it's not really related to saving a single syscall, and you'd > potentially save more than just one as well. If we look at the two > extremes of applications, one will be low load and you're handling > probably just 1 event per loop. Not really interesting. At the other > end, you're fully loaded, and by the time you check for events, you have > 'maxevents' (or close to) available. That obviously reduces system > calls, but more importantly, it also allows the application to get some > batching effects from processing these events. > > In the medium range, there's enough processing to react pretty quickly > to events coming in, and you then end up doing just 1 event (or close to > that). To overcome that, we have some applications that detect this > medium range and do an artificial sleep before calling epoll_wait(). > That was a nice effiency win for them. But we can do this a lot more > efficiently in the kernel. That was the idea behind this, and the > initial results from TAO (which does that sleep hack) proved it to be > more than worthwhile. Syscall reduction is one thing, improved batching > another, and just as importanly is sleep+wakeup reductions. Thanks for the context. So this is akin to interrupt moderation in network interfaces. Would it make sense to wait for timeout or nr of events, whichever comes first, similar to rx_usecs/rx_frames. Instead of an unconditional sleep at the start.