Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2704664pxb; Sat, 30 Jan 2021 11:18:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyLPmRp3ufL4LPgLy5TjBvNYUJQuFSvtvZLFccE9o4bLCkcOWfeZzNtnGXCHUfJ9DOhAQH X-Received: by 2002:a05:6402:c9:: with SMTP id i9mr11301334edu.123.1612034337474; Sat, 30 Jan 2021 11:18:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612034337; cv=none; d=google.com; s=arc-20160816; b=jwF9osMHTKiavwIqm6eSUkK+MGyMwl1u9jmb3a5eCQ4vDGGKjiTldufuUIVTnxw6RX 71cIbxsh1EYFt3NUuDW36yC1kKPV9l4DDZfw43tPOyLzcwCOLi2fT1V6Ugh9RqdoNk7k BjU38j4kzhw9HjZs1H/bcH6m5gk8NIQUVj+nwizBwqNk9j2fE0w4hl90Yru5R3tZxgMC cKWKoFP5pHpS4b5DYcx6DvgLlFq0cm4EYjyNIa3+SIqZutlt2QXPKxuv1s/AOahMSYAB bmQfQjsNg4fuklIQUC4wheN+cvzhyMvD8KvWNp8fsdh+n3TLgbcD9R/1xlbcgDOsaZVE FPiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=gFIE+cS6t5X4heRAnIjhgZu4S6VCvwUFS23CE1wkqbo=; b=FeUxZpVqrCt3FwdMeBB7uxSqLS8PNTbg9hxYvBTLHziMWExtFoJqMSua03iMyOC4eJ L9vmSsjbcqQ7iO2wsIEFKETPN02egW3VqF18ISEoHAMp9SlUXjiXKicwXOhMbb0a69l1 1nZ0mlY3VViKJNRUCg3XX76zg1BjFcQ9vpcMVBq0YOTyGi26h5o8jXvml1VGc0Ru1FNI 8wm6BKZ/DnzntDKEMTZgqNAso2VVS3Wxn2XJd3dsn+PJIdmNVm2DX0NBQuepdyWksQ4E Np9QY3DRKpTis4axnwp0Gw5Qt2OgZoxX26y2YzsOD4rJGIBga5Btch2Glb3Enij3lu1R vufA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iqFwsa34; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si8268307edo.40.2021.01.30.11.18.32; Sat, 30 Jan 2021 11:18:57 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=iqFwsa34; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232259AbhA3TRB (ORCPT + 99 others); Sat, 30 Jan 2021 14:17:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:37566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232204AbhA3TRA (ORCPT ); Sat, 30 Jan 2021 14:17:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7B41F64E15; Sat, 30 Jan 2021 19:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612034179; bh=yNI/zbRVAZi7i5zFsn4fJE94geSUHpso7ntTBnGczLY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=iqFwsa34f4ivyrjHaQKp5Ux+uq79sDlfi5DnKKMtE4Dez3lFsjVobMXk1s1IXHqtf ys72eYfgOTm0XIH251AMP8yEETFP2ueRgeLH/NScZllsrFIneGgwAY/+hT7hmRgwe0 +IZWjBHYoatfk4woFA3r6ZUaLmjMhVUpK2/YB1S6Wv75vgoK1+RN/FPfd88lCCjI9t Ffre2qv1RAbe3AERs+qADlP7yCFeA1EA2i/iPBrYipJ/22PnxAInWPppqhb4Z9+3Nd X7C/ndsIvD0SnbLb8ZvplSl7rlD/bqql5mxlz4UG49hrpJKSEoef4NtGCnaF6mGMGT PADC2t17CweAQ== Date: Sat, 30 Jan 2021 11:16:18 -0800 From: Jakub Kicinski To: Xie He Cc: Martin Schiller , "David S. Miller" , Linux X25 , Linux Kernel Network Developers , LKML , Krzysztof Halasa Subject: Re: [PATCH net] net: hdlc_x25: Use qdisc to queue outgoing LAPB frames Message-ID: <20210130111618.335b6945@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: References: <20210127090747.364951-1-xie.he.0141@gmail.com> <20210128114659.2d81a85f@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <3f67b285671aaa4b7903733455a730e1@dev.tdt.de> <20210129173650.7c0b7cda@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 30 Jan 2021 06:29:20 -0800 Xie He wrote: > On Fri, Jan 29, 2021 at 5:36 PM Jakub Kicinski wrote: > > I'm still struggling to wrap my head around this. > > > > Did you test your code with lockdep enabled? Which Qdisc are you using? > > You're queuing the frames back to the interface they came from - won't > > that cause locking issues? > > Hmm... Thanks for bringing this to my attention. I indeed find issues > when the "noqueue" qdisc is used. > > When using a qdisc other than "noqueue", when sending an skb: > "__dev_queue_xmit" will call "__dev_xmit_skb"; > "__dev_xmit_skb" will call "qdisc_run_begin" to mark the beginning of > a qdisc run, and if the qdisc is already running, "qdisc_run_begin" > will fail, then "__dev_xmit_skb" will just enqueue this skb without > starting qdisc. There is no problem. > > When using "noqueue" as the qdisc, when sending an skb: > "__dev_queue_xmit" will try to send this skb directly. Before it does > that, it will first check "txq->xmit_lock_owner" and will find that > the current cpu already owns the xmit lock, it will then print a > warning message "Dead loop on virtual device ..." and drop the skb. > > A solution can be queuing the outgoing L2 frames in this driver first, > and then using a tasklet to send them to the qdisc TX queue. > > Thanks! I'll make changes to fix this. Sounds like too much afford for a sub-optimal workaround. The qdisc semantics are borken in the proposed scheme (double counting packets) - both in term of statistics and if user decides to add a policer, filter etc. Another worry is that something may just inject a packet with skb->protocol == ETH_P_HDLC but unexpected structure (IDK if that's a real concern). It may be better to teach LAPB to stop / start the internal queue. The lower level drivers just needs to call LAPB instead of making the start/wake calls directly to the stack, and LAPB can call the stack. Would that not work?