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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham 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 C6E97C43381 for ; Mon, 4 Mar 2019 23:57:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9C6FA2070B for ; Mon, 4 Mar 2019 23:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726782AbfCDX5A (ORCPT ); Mon, 4 Mar 2019 18:57:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38872 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbfCDX47 (ORCPT ); Mon, 4 Mar 2019 18:56:59 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 91D1E3084294; Mon, 4 Mar 2019 23:56:59 +0000 (UTC) Received: from localhost (ovpn-200-19.brq.redhat.com [10.40.200.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 138BF17119; Mon, 4 Mar 2019 23:56:56 +0000 (UTC) Date: Tue, 5 Mar 2019 00:56:52 +0100 From: Stefano Brivio To: Vlad Buslov Cc: "netdev@vger.kernel.org" , "jhs@mojatatu.com" , "xiyou.wangcong@gmail.com" , "jiri@resnulli.us" , "davem@davemloft.net" Subject: Re: [PATCH net-next v2 04/12] net: sched: flower: track filter deletion with flag Message-ID: <20190305005652.6b39e464@redhat.com> In-Reply-To: References: <20190227101226.26196-1-vladbu@mellanox.com> <20190227101226.26196-5-vladbu@mellanox.com> <20190302005129.4d4508c9@redhat.com> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 04 Mar 2019 23:56:59 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, 4 Mar 2019 14:24:05 +0000 Vlad Buslov wrote: > On Fri 01 Mar 2019 at 23:51, Stefano Brivio wrote: > > Hi Vlad, > > > > On Wed, 27 Feb 2019 12:12:18 +0200 > > Vlad Buslov wrote: > > > >> -static bool __fl_delete(struct tcf_proto *tp, struct cls_fl_filter *f, > >> - struct netlink_ext_ack *extack) > >> +static int __fl_delete(struct tcf_proto *tp, struct cls_fl_filter *f, > >> + bool *last, struct netlink_ext_ack *extack) > >> { > >> struct cls_fl_head *head = fl_head_dereference(tp); > >> bool async = tcf_exts_get_net(&f->exts); > >> - bool last; > >> > >> + *last = false; > >> + > >> + if (f->deleted) > >> + return -ENOENT; > >> + > >> + f->deleted = true; > > > > Now that I can read this more easily :) I have a doubt: you say this > > flag "prevent[s] double deletion of filter by concurrent tasks". > > > > However, if this has no further protections (which I can't readily > > see), I think this is racy: > > > > task 1 task 2 > > if (f->deleted) [false] > > if (f->deleted) [false] > > f->deleted = true; f->deleted = true; > > > > what am I missing here? > > Of course! Lock is added in "[PATCH net-next v2 10/12] net: sched: > flower: protect flower classifier state with spinlock". This is safe to > do because everything is still protected by rtnl mutex until last patch > in this series sets the TCF_PROTO_OPS_DOIT_UNLOCKED flag for flower. Indeed! My bad, I forgot about 10/12 here. -- Stefano