Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1623031pxf; Fri, 19 Mar 2021 11:17:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrTdR+Z3VjUlhhsmVeRrDWHzKBA5y7v3FOlT8zo6tIgr6Oi8CxzIvFXVdwCSCmI7MmA8YE X-Received: by 2002:aa7:df86:: with SMTP id b6mr11249421edy.294.1616177836947; Fri, 19 Mar 2021 11:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616177836; cv=none; d=google.com; s=arc-20160816; b=LkEQmppwg/4EIzMSX4Rnyx1yDxiTd7VdSnWCFE80H2VO/S3mcUHzRtTUpJV2PW/9oV mhwMjvCufQc711ye/fhRrBNM7sJ7gLVLAbtz3X2Vyb716lxsqajb6WnNrsLN5xFYwYFe vQ0C6556DhSI90E+ytp6EGckrbfXrSqXDVpJAXJ1BcFbGuTvmHCoCh3WnQPh01KtOedB Zjp5KYq0LngfhIRHLp65HDVr9FDw5rMUjAve7VXB9/rxro68uTKVNs8xd6Z2DCWZ1YlF Gx3QkR3lrJcdKLcG05NX+OhZbvbqVPHCcxEs3cjczxsc0CGe/WqdbVoZeYayBtRw9E6u xADQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=yApSLu496m7gvqSRhwz6HeRoNaU50Bo27wlXzUIZtfg=; b=BzhKbnw4MVtpGBeZCEb/Z5+f33iFhk4Hz6uXX8892FBaq9f4m9Zlv0W8F9+dzJRYJB M7UZTWIJtMitLBM4PmvosBBlDpvd83+1PrmGOeAIHBvn+7kEXjXA/nJelqD2hrnATkl7 18fTwVBR2ScBaMKD9i1sS1zQ6PMhDwBDSYI0GLGt2N07yvWI7TETfVrf1U/1vXDN1CV3 h+EOtVVjWhf1EcI4UN3zOqSX+SFihtS79v4ENbzWAoXFSjE6M8wskfrjMLJf4GwuZKYZ 6bfTzstDVpsdNp2f9BPQWPCrds7tNfJB5W0PhdQBTYHbkUAorELKuvWnlzLinb141MOH Qx3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eehFhYe7; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp15si4597341ejc.548.2021.03.19.11.16.54; Fri, 19 Mar 2021 11:17:16 -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=@gmail.com header.s=20161025 header.b=eehFhYe7; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230477AbhCSSQB (ORCPT + 99 others); Fri, 19 Mar 2021 14:16:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229956AbhCSSP0 (ORCPT ); Fri, 19 Mar 2021 14:15:26 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6800C06175F; Fri, 19 Mar 2021 11:15:25 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id k24so4231329pgl.6; Fri, 19 Mar 2021 11:15:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=yApSLu496m7gvqSRhwz6HeRoNaU50Bo27wlXzUIZtfg=; b=eehFhYe7ZsCKZWptxyH0GSZhy5Czr+VIm5/5FElKHxrK/4P3sYqetHdmkKeorMqAYi SOqlnw7HVehgKaV9C3Kyg2dqeOXMpmUGRwPDbPWy8Wj60BO5RYzhJuDbY6apBrJIoKkJ vsDoSq9U5qjx7mrQtiO7xxMr3a7sPCgcEsRBofgPCNCKu4+fl90GquyGAIelLzNL2/tu o2D3UCZjwpL9gZwPwvnYNWadT/m0WXeJH7wAl/giSchVh6Zuk0qB0t++wjck5fDXCmjq K8hCc5k+e9VqSZKvXaaK7CfRxCJFfhTb3Djc0TjK13IhEknLZhDgVaBAnXLUV0lC2o3n W7bw== 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:content-transfer-encoding; bh=yApSLu496m7gvqSRhwz6HeRoNaU50Bo27wlXzUIZtfg=; b=reOf36TGQ7b21vv9PZWNE+e3qJwoNYfeH3iVPfHV7zTncH1cXadKdWUjjV7A0pNwn6 eEiml+4gfqsN10wQgiWEqpOtpsgjbak+jIwadP3Lwv5k46lNF84Uh8GkHT1lzvrhuv5W Y35uPmu3PaslpvMxmsc9Vc8tG+dKaPCG2JLFlAcoJrm8Xzp87pZP8IPs/lk1Sk7ei/29 J7qT0G9EMp7kB0Nx2ohWKMGz2WuvL0vaBbV9FOFtgyynhC5wAvQrJJ/A3rbM0RM2inP2 tDJKEgg7mPvC+rKzbnXZE20hwrYvlT5AEQ9NUdNbJUm7WEr38CYzfVwEirM7UfKyVGDh xUww== X-Gm-Message-State: AOAM533iZQoOv9U7UXmJsGwYGv5sCSSEZecGnfVNQmxX/lIfzXK6XXTB qMT3IGHUJ1c4AyIi15G0n6Fuj8Jzp6bgr8HIAMs= X-Received: by 2002:aa7:85c1:0:b029:1f4:4fcc:384d with SMTP id z1-20020aa785c10000b02901f44fcc384dmr10609791pfn.10.1616177725389; Fri, 19 Mar 2021 11:15:25 -0700 (PDT) MIME-Version: 1.0 References: <1615603667-22568-1-git-send-email-linyunsheng@huawei.com> <1615777818-13969-1-git-send-email-linyunsheng@huawei.com> <20210315115332.1647e92b@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <87eegddhsj.fsf@toke.dk> <3bae7b26-9d7f-15b8-d466-ff5c26d08b35@huawei.com> In-Reply-To: <3bae7b26-9d7f-15b8-d466-ff5c26d08b35@huawei.com> From: Cong Wang Date: Fri, 19 Mar 2021 11:15:14 -0700 Message-ID: Subject: Re: [Linuxarm] Re: [RFC v2] net: sched: implement TCQ_F_CAN_BYPASS for lockless qdisc To: Yunsheng Lin Cc: "Jason A. Donenfeld" , =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= , Jakub Kicinski , David Miller , Vladimir Oltean , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eric Dumazet , Wei Wang , "Cong Wang ." , Taehee Yoo , Linux Kernel Network Developers , LKML , linuxarm@openeuler.org, Marc Kleine-Budde , linux-can@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 18, 2021 at 12:33 AM Yunsheng Lin wrot= e: > > On 2021/3/17 21:45, Jason A. Donenfeld wrote: > > On 3/17/21, Toke H=C3=B8iland-J=C3=B8rgensen wrote: > >> Cong Wang writes: > >> > >>> On Mon, Mar 15, 2021 at 2:07 PM Jakub Kicinski wrot= e: > >>>> > >>>> I thought pfifo was supposed to be "lockless" and this change > >>>> re-introduces a lock between producer and consumer, no? > >>> > >>> It has never been truly lockless, it uses two spinlocks in the ring > >>> buffer > >>> implementation, and it introduced a q->seqlock recently, with this pa= tch > >>> now we have priv->lock, 4 locks in total. So our "lockless" qdisc end= s > >>> up having more locks than others. ;) I don't think we are going to a > >>> right direction... > >> > >> Just a thought, have you guys considered adopting the lockless MSPC ri= ng > >> buffer recently introduced into Wireguard in commit: > >> > >> 8b5553ace83c ("wireguard: queueing: get rid of per-peer ring buffers") > >> > >> Jason indicated he was willing to work on generalising it into a > >> reusable library if there was a use case for it. I haven't quite thoug= h > >> through the details of whether this would be such a use case, but > >> figured I'd at least mention it :) > > > > That offer definitely still stands. Generalization sounds like a lot of= fun. > > > > Keep in mind though that it's an eventually consistent queue, not an > > immediately consistent one, so that might not match all use cases. It > > works with wg because we always trigger the reader thread anew when it > > finishes, but that doesn't apply to everyone's queueing setup. > > Thanks for mentioning this. > > "multi-producer, single-consumer" seems to match the lockless qdisc's > paradigm too, for now concurrent enqueuing/dequeuing to the pfifo_fast's > queues() is not allowed, it is protected by producer_lock or consumer_loc= k. > > So it would be good to has lockless concurrent enqueuing, while dequeuing > can be protected by qdisc_lock() or q->seqlock, which meets the "multi-pr= oducer, > single-consumer" paradigm. I don't think so. Usually we have one queue for each CPU so we can expect each CPU has a lockless qdisc assigned, but we can not assume this in the code, so we still have to deal with multiple CPU's sharing a lockless q= disc, and we usually enqueue and dequeue in process context, so it means we could have multiple producers and multiple consumers. On the other hand, I don't think the problems we have been fixing are the r= ing buffer implementation itself, they are about the high-level qdisc state transitions. Thanks.