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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE098C433EF for ; Thu, 2 Dec 2021 00:37:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354645AbhLBAk2 (ORCPT ); Wed, 1 Dec 2021 19:40:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233847AbhLBAkX (ORCPT ); Wed, 1 Dec 2021 19:40:23 -0500 Received: from mail-ua1-x935.google.com (mail-ua1-x935.google.com [IPv6:2607:f8b0:4864:20::935]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C141C061574 for ; Wed, 1 Dec 2021 16:37:01 -0800 (PST) Received: by mail-ua1-x935.google.com with SMTP id az37so52682476uab.13 for ; Wed, 01 Dec 2021 16:37:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=o514D1uhYEuhVflwqtCZuE/ZpMReL0NhA7xwmfYSlag=; b=g+P9kPgV2HDyvGog5C8JdvOkx1/LJz+d7iJwKg7PWMfXLR9Z7bHpmRzY7OJMrXBenc Vr2F24EkEgLGkEVm7aRxKWrJ8rPL1rIs/kFYEY5hYFJtUSMfVxXiqCUny+1WWQZI6ibt +WgPNeEmWWelHagVXeI9196nciM57pA38C96o/6nWdzLrSFN2YmROMtzlYexPtto9wb9 1Ru9opswNpzj1Kxpl5/+qAew5CBARJzqdZpYVXuImRXTSa4Ds7gKUK7vBjS+K0z4L7H9 6QDCOKruK47OiMPvpyJ+HW/tLvPVRv5RNLFpOf/gXkSGIC+izuC69LKv2bkmaUG/AqIo OgkA== 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=o514D1uhYEuhVflwqtCZuE/ZpMReL0NhA7xwmfYSlag=; b=XkBxJSzGj48Pnu2YYucDAnCZnemohyVigKVdxGqpY6RYYlQrikRcQPc6ZM9gacDHiY Vjr20FNvPTEflsZdLQ48MEM/6AccKxWtWYOE8sYY+LRPmV4fD2YMuHBl8zh9NUyACeCQ SLoMsTw7D/J6RitZhvOXi2O8nnEN+XlrMPHVRtAoWGE0AygPUodKg8DvRp7azFxcinBo dZopKfh8Xa2bJF/YQFIIOGBMYS/o57+kmQoSkKlr6Dsh9/PFSgwrI5mjoekSS1LC+ztF 9/Zu7/E9/lzrnYXTDTco8UhgtFcAbcDGYdp88L/PCR5as9vOwHI9UEsH3SVFn1ilPCW6 JMqA== X-Gm-Message-State: AOAM533+Uw0eR+Pjyek+NbBpTutXuBakueFVkoy/S6N+FGAHnW1oWOG/ y2mqqTy1oi3rpJPb8jS294ltdpPuAsXDmw== X-Google-Smtp-Source: ABdhPJxXNp2Rqr1zt0JzORqEO5eWQ8UUhSugn9nVoN+xjCaX3sJPWFVR0dxzga2DU21y1WzTmgVIFw== X-Received: by 2002:a05:6102:237a:: with SMTP id o26mr11417155vsa.79.1638405420778; Wed, 01 Dec 2021 16:37:00 -0800 (PST) Received: from mail-ua1-f47.google.com (mail-ua1-f47.google.com. [209.85.222.47]) by smtp.gmail.com with ESMTPSA id w17sm466661uar.18.2021.12.01.16.37.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Dec 2021 16:37:00 -0800 (PST) Received: by mail-ua1-f47.google.com with SMTP id i6so52608342uae.6 for ; Wed, 01 Dec 2021 16:37:00 -0800 (PST) X-Received: by 2002:ab0:15a1:: with SMTP id i30mr12304408uae.122.1638405419938; Wed, 01 Dec 2021 16:36:59 -0800 (PST) MIME-Version: 1.0 References: <0d82f4e2-730f-4888-ec82-2354ffa9c2d8@gmail.com> In-Reply-To: From: Willem de Bruijn Date: Wed, 1 Dec 2021 19:36:22 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 00/12] io_uring zerocopy send To: Pavel Begunkov Cc: io-uring@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski , Jonathan Lemon , "David S . Miller" , Eric Dumazet , Hideaki YOSHIFUJI , David Ahern , Jens Axboe Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > >>> 1) we pass a bvec, so no page table walks. > >>> 2) zerocopy_sg_from_iter() is just slow, adding a bvec optimised version > >>> still doing page get/put (see 4/12) slashed 4-5%. > >>> 3) avoiding get_page/put_page in 5/12 > >>> 4) completion events are posted into io_uring's CQ, so no > >>> extra recvmsg for getting events > >>> 5) no poll(2) in the code because of io_uring > >>> 6) lot of time is spent in sock_omalloc()/free allocating ubuf_info. > >>> io_uring caches the structures reducing it to nearly zero-overhead. > >> > >> Nice set of complementary optimizations. > >> > >> We have looked at adding some of those as independent additions to > >> msg_zerocopy before, such as long-term pinned regions. One issue with > >> that is that the pages must remain until the request completes, > >> regardless of whether the calling process is alive. So it cannot rely > >> on a pinned range held by a process only. > >> > >> If feasible, it would be preferable if the optimizations can be added > >> to msg_zerocopy directly, rather than adding a dependency on io_uring > >> to make use of them. But not sure how feasible that is. For some, like > >> 4 and 5, the answer is clearly it isn't. 6, it probably is? > > Forgot about 6), io_uring uses the fact that submissions are > done under an per ring mutex, and completions are under a per > ring spinlock, so there are two lists for them and no extra > locking. Lists are spliced in a batched manner, so it's > 1 spinlock per N (e.g. 32) cached ubuf_info's allocations. > > Any similar guarantees for sockets? For datagrams it might matter, not sure if it would show up in a profile. The current notification mechanism is quite a bit more heavyweight than any form of fixed ubuf pool. For TCP this matters less, as multiple sends are not needed and completions are coalesced, because in order.