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 X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2095CC49361 for ; Sat, 19 Jun 2021 00:38:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 049E161358 for ; Sat, 19 Jun 2021 00:38:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235308AbhFSAkx (ORCPT ); Fri, 18 Jun 2021 20:40:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:54878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234620AbhFSAkt (ORCPT ); Fri, 18 Jun 2021 20:40:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E33D36124C; Sat, 19 Jun 2021 00:38:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624063119; bh=mP7tDiOcpNjEq88FHza9d1X97mpYxtBkgmm1X01yAQA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Mx37JGeiBfvsxF9ov9oi3/SG5pBcaQ4hSc7Qsa3Jsqa42J1FEIJWIzUJlEf8neuer Yp+4Afyw+qdfTHisqLbTGkuTUPD7qkfb2eR42lbTejXKnuonTtj8DSnAxN7w5RnuOo JitY/lKdKVWJw6CfpImGbWKJkfBzcSWTEY2Di6/Hb27XB21dSiKGtalt2Fz3uduAlL iANAze31asnMnZTgNEab/ZX5RNVNSDm7yxn6TyIu4m3AsuxCLB/F0Rrki0Oz4Dq8dI 17XUVEGMdBWpAFBu7+wmRBim2tSHh27iDakSlR15d2IafObb6NN+NDpfyhNe+ztXBt 2RdBEdia7PQNQ== Date: Fri, 18 Jun 2021 17:38:37 -0700 From: Jakub Kicinski To: Yunsheng Lin Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH net v2] net: sched: add barrier to ensure correct ordering for lockless qdisc Message-ID: <20210618173837.0131edc3@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20210618173047.68db0b81@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> References: <1623891854-57416-1-git-send-email-linyunsheng@huawei.com> <20210618173047.68db0b81@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 Fri, 18 Jun 2021 17:30:47 -0700 Jakub Kicinski wrote: > On Thu, 17 Jun 2021 09:04:14 +0800 Yunsheng Lin wrote: > > The spin_trylock() was assumed to contain the implicit > > barrier needed to ensure the correct ordering between > > STATE_MISSED setting/clearing and STATE_MISSED checking > > in commit a90c57f2cedd ("net: sched: fix packet stuck > > problem for lockless qdisc"). > > > > But it turns out that spin_trylock() only has load-acquire > > semantic, for strongly-ordered system(like x86), the compiler > > barrier implicitly contained in spin_trylock() seems enough > > to ensure the correct ordering. But for weakly-orderly system > > (like arm64), the store-release semantic is needed to ensure > > the correct ordering as clear_bit() and test_bit() is store > > operation, see queued_spin_lock(). > > > > So add the explicit barrier to ensure the correct ordering > > for the above case. > > > > Fixes: a90c57f2cedd ("net: sched: fix packet stuck problem for lockless qdisc") > > Signed-off-by: Yunsheng Lin > > Acked-by: Jakub Kicinski Actually.. do we really need the _before_atomic() barrier? I'd think we only need to make sure we re-check the lock after we set the bit, ordering of the first check doesn't matter.