Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp313714imm; Tue, 15 May 2018 02:00:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoNymvviQHX5PZXxbSalvvIL76rh9kh0n/9eAlAoJg6xeFcdv+LtxvAOKsov1mvxY5eL1Nl X-Received: by 2002:a63:2ace:: with SMTP id q197-v6mr11592964pgq.60.1526374847743; Tue, 15 May 2018 02:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526374847; cv=none; d=google.com; s=arc-20160816; b=Vb9jsSrcE595ahx/xez9ZUasJKR10zc9bDZPGUXPqx8FYVAp8wEZKCXjv9Ol+YKnTO UKa8KJJlGy7RJzDvDFTU+x/JKgJ9X+jZU6plPS09RYle80utrqMatmxVJTJUJ5o7/Wh7 VJbiUAzm+BJ+mN7ubXj1oDr9C9VxHSvYZ4uYPJVfXAym+DXDlqHPW4+9FqUhTXUy3BCQ 3BtKutU4j5V8Bi1o1tNRmYKJ85CwLOF9R5vTJUgAFxNaus230Es0mB6DJTPZVTcCLuOA TPrA6P2jhjPTG5L9kthLQxlZdIyz4dI3xwtd2YGIaGPcGoqRjsWl+eRubntLy9uPi8/f duzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=TGvEMqQN/XwaWQhNFHdugYADG7rp1IGoQMZk+u/GYnM=; b=hVTkSca0xcVCUj/ZK5FOkTKHZ+0cnDWZS4fzcO540tYNw/mnT2fm26VqyjPVbWNrVe 31h1PMy4URD89aUb3EpJOif64L/M60ROxplPR9jYRUXJUT7W8ouAm6bggeqnyHjZgy/5 U5f15pxupwDS0oQu5qmgbXYjYguU+acNAZAa9V5WdfQbn20adEFTtr9rRTyF/PN3iIbc qpVWBEYIQZxiUHRXJRl+LrfKoNmdniAnUH54zOQvtflNONt98Xu7h7LKVfNcvdiTWr50 m2Ti+XgFD73mXD9oqnpznjUQhtRmvnqCnVyEt8IdGtwTJfSMUX3H5B82wkSfpgqLLP11 JtsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=GrLWbb9P; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17-v6si6253146pgf.15.2018.05.15.02.00.33; Tue, 15 May 2018 02:00:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=GrLWbb9P; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752761AbeEOI7F (ORCPT + 99 others); Tue, 15 May 2018 04:59:05 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:42214 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752674AbeEOI63 (ORCPT ); Tue, 15 May 2018 04:58:29 -0400 Received: by mail-wr0-f194.google.com with SMTP id v5-v6so15109366wrf.9 for ; Tue, 15 May 2018 01:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=TGvEMqQN/XwaWQhNFHdugYADG7rp1IGoQMZk+u/GYnM=; b=GrLWbb9Pem+FSKcUe6skFwn08owl7fkF4B+WXmL0CwfWasakNClvwIhOsE6ZPxhGyW vSovlzJjYhExlbD/DZx8ZP16CRZnChcWPAapV06uaYxvafwL0Ib3gU271aMc7eDk/pNT 6EzLoc1Ot9qINFw2Jw7q08BpAvE5ZN+2hZgu95mWVo5EIGqSvvEGEiYAcTwQesFvwZbl cD3hM39MVr8pkKLTBK00mLD1tjhyhQ+5NTKcfVHuePlne+CHA3JVXFZ+Xqy+QE0bsJoj /FYp5zyuX79Hi/edlQUngozBNcfHUrL9jmZWUjsBKD2PhPbMsFezq0MHMdvsqcO/zG8T 9Whg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=TGvEMqQN/XwaWQhNFHdugYADG7rp1IGoQMZk+u/GYnM=; b=qoFiVCHU84CloiOIgl6FxFeT9LuHE8IKKo58UBE4yPUPuA45PKLIlNxCct+WL2SK1G haLlzVld8HLteoQCF/fQSHv/l6v7c58u5TGHoM7m3Kp/PVqvpkTc+sDWCKH+CfYyefx0 snl5+R5wNfktAHJLvfwguiGvtA4d0eqqO/+8eHoFmtGexqYrGqI9mivV3f558D8uZ0Pf zxeOjuPxiOzKKg+eQAItYwNmRGsDrgDxxkP1/pmAkNv4AQf+RkOhPaCygoJ2rwAPhXH0 MGWDM0j1osbAWpGnmIqOUo7u/3nGYjBon8/rnhoHOTM9ZBCbLFkyc4iSZG0HMZxQRsVK 3EsA== X-Gm-Message-State: ALKqPwd4GLWEDlgxxD0oap8TKVfvJD8ozn0UuTyX2BTfRODysdvPLptb 5GXiit8kr2YnUXfssQ1QPIn3dw== X-Received: by 2002:adf:ba4a:: with SMTP id t10-v6mr9131256wrg.219.1526374708256; Tue, 15 May 2018 01:58:28 -0700 (PDT) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id a14-v6sm20029101wra.84.2018.05.15.01.58.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 01:58:27 -0700 (PDT) Date: Tue, 15 May 2018 10:58:27 +0200 From: Jiri Pirko To: Vlad Buslov Cc: netdev@vger.kernel.org, davem@davemloft.net, jhs@mojatatu.com, xiyou.wangcong@gmail.com, pablo@netfilter.org, kadlec@blackhole.kfki.hu, fw@strlen.de, ast@kernel.org, daniel@iogearbox.net, edumazet@google.com, keescook@chromium.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, kliteyn@mellanox.com Subject: Re: [PATCH 05/14] net: sched: always take reference to action Message-ID: <20180515085827.GJ2134@nanopsycho.orion> References: <1526308035-12484-1-git-send-email-vladbu@mellanox.com> <1526308035-12484-6-git-send-email-vladbu@mellanox.com> <20180514162301.GC2134@nanopsycho.orion> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mon, May 14, 2018 at 08:49:07PM CEST, vladbu@mellanox.com wrote: > >On Mon 14 May 2018 at 16:23, Jiri Pirko wrote: >> Mon, May 14, 2018 at 04:27:06PM CEST, vladbu@mellanox.com wrote: >>>Without rtnl lock protection it is no longer safe to use pointer to tc >>>action without holding reference to it. (it can be destroyed concurrently) >>> >>>Remove unsafe action idr lookup function. Instead of it, implement safe tcf >>>idr check function that atomically looks up action in idr and increments >>>its reference and bind counters. >>> >>>Implement both action search and check using new safe function. >>> >>>Signed-off-by: Vlad Buslov >>>--- >>> net/sched/act_api.c | 38 ++++++++++++++++---------------------- >>> 1 file changed, 16 insertions(+), 22 deletions(-) >>> >>>diff --git a/net/sched/act_api.c b/net/sched/act_api.c >>>index 1331beb..9459cce 100644 >>>--- a/net/sched/act_api.c >>>+++ b/net/sched/act_api.c >>>@@ -284,44 +284,38 @@ int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb, >>> } >>> EXPORT_SYMBOL(tcf_generic_walker); >>> >>>-static struct tc_action *tcf_idr_lookup(u32 index, struct tcf_idrinfo *idrinfo) >>>+bool __tcf_idr_check(struct tc_action_net *tn, u32 index, struct tc_action **a, >>>+ int bind) >>> { >>>- struct tc_action *p = NULL; >>>+ struct tcf_idrinfo *idrinfo = tn->idrinfo; >>>+ struct tc_action *p; >>> >>> spin_lock_bh(&idrinfo->lock); >> >> Why "_bh" variant is necessary here? > >It is not my code. Yeah, yet still I wonder :)