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=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED 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 67D64C10F11 for ; Wed, 10 Apr 2019 16:09:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E7C420693 for ; Wed, 10 Apr 2019 16:09:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="u1q4R+Xg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387671AbfDJQJM (ORCPT ); Wed, 10 Apr 2019 12:09:12 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:34162 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387666AbfDJQJL (ORCPT ); Wed, 10 Apr 2019 12:09:11 -0400 Received: by mail-qt1-f196.google.com with SMTP id k2so3547743qtm.1 for ; Wed, 10 Apr 2019 09:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=k13dQjs66bs7UT7NxLNQGvkFyLJa9afoKNoVuiuHO3E=; b=u1q4R+Xgyo+WCguwT7Yjz5aEhSwBgadtG/Ed2pIzQlb/e6g0Qo3JQMVdp8m9GImO5Y yXGPU/JajEVmewonE9xJfLDM28x2VlOvNsZEF2gYSTv2/s5RuGN2NKi2BwvSNMZo5LJH 0igGHBSlC9O0xuNh3QjTC8yGUkbd0MWK+CFJ5R2Z5eM7mHtQIc45CUsmqDV4J5S/HMRx ct7H1wTbxdRO9567rybY+nlosF+NdXKV7dYn/wNVMLnpGyX/ISqIZGnRS5uo5ltlNJQv 5IPeq8+HtWYzYJqlG+yn7IcBSSS0VQjkLzbtN4zE9FTV9ljZ2wqfz6ll7fKwc0gItzDm 1WHQ== 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:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=k13dQjs66bs7UT7NxLNQGvkFyLJa9afoKNoVuiuHO3E=; b=IEexNr/KdoD+iOr3hU9Hj8IfvbvXL7+xY3L5HUYYM1wpwqe9tpvYdrUAwavQuDloQm xgdZ6po3/pUOmRo3RU55GcH4iwjuOpBOjhhi53xHkq1gG+DyTqMAsQphJ5AEAB0DOsoB iWnJCDqiPwTG8NstJNzP9sR+f1NfagHLOftR55AMa9iZOcnKkHyXYPEqItDEAUD+kHcb ifimkRoWx2or5ICIVrscWKyboLiCcv3xCqbRZuWDBiuPJoIOztWT6zj5/eTPUhAafk2d CBoIUBo8wHj6HpPEQk3OYH5BE53msZjo9JCHePMipi7Kg2vuq9SkJoRT+LZJWseMa6yk 1xng== X-Gm-Message-State: APjAAAUxsL+K2GVQZ8tYP8hOFAwJHPa/l2kxEDDa424Tw2jrXkFUh2xB vb6VhbezD8FjtRUZwHLxzQb4Qc9CqyM= X-Google-Smtp-Source: APXvYqz0+NsvxTsN73Tdy7f7qHgqFPxBoNKmxt4KUbwPZRVVCKwI9cuD5Nz62fYj5aU+Z+FUAe63PQ== X-Received: by 2002:a0c:e014:: with SMTP id j20mr35003486qvk.172.1554912550919; Wed, 10 Apr 2019 09:09:10 -0700 (PDT) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id c18sm21654993qkk.1.2019.04.10.09.09.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2019 09:09:10 -0700 (PDT) Date: Wed, 10 Apr 2019 09:09:05 -0700 From: Jakub Kicinski To: Vlad Buslov Cc: "netdev@vger.kernel.org" , "jhs@mojatatu.com" , "xiyou.wangcong@gmail.com" , "jiri@resnulli.us" , "davem@davemloft.net" , "john.hurley@netronome.com" Subject: Re: [PATCH net-next] net: sched: flower: insert filter to ht before offloading it to hw Message-ID: <20190410090905.248bf773@cakuba.netronome.com> In-Reply-To: References: <20190405175626.4123-1-vladbu@mellanox.com> <20190408152655.1891ee77@cakuba.netronome.com> <20190409101023.4fe0ad04@cakuba.netronome.com> <20190410084830.378b37fa@cakuba.netronome.com> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, 10 Apr 2019 16:02:17 +0000, Vlad Buslov wrote: > On Wed 10 Apr 2019 at 18:48, Jakub Kicinski wrote: > > On Wed, 10 Apr 2019 14:53:53 +0000, Vlad Buslov wrote: > >> >> For my next patch set that unlocks the offloads API I implemented the > >> >> algorithm to track reoffload count for each tp that works like this: > >> >> > >> >> 1. struct tcf_proto is extended with reoffload_count counter that > >> >> incremented each time reoffload is called on particular tp instance. > >> >> Counter is protected by tp->lock. > >> >> > >> >> 2. struct cls_fl_filter is also extended with reoffload_count counter. > >> >> Its value is set to current tp->reoffload_count when offloading the > >> >> filter. > >> >> > >> >> 3. After offloading the filter, but before inserting it to idr, > >> >> f->reoffload_count is compared with tp->reoffload_count. If values > >> >> don't match, filter is deleted and -EAGAIN is returned. Cls API > >> >> retries filter insertion on -EAGAIN. > >> > > >> > Sounds good for add. Does this solve delete case as well? > >> > > >> > CPU 0 CPU 1 > >> > > >> > __fl_delete > >> > IDR remove > >> > cb unregister > >> > hw delete all flows <- doesn't see the > >> > remove in progress > >> > > >> > hw delete <- doesn't see > >> > the removed cb > >> > >> Thanks for pointing that out! Looks like I need to move call to hw > >> delete in __fl_delete() function to be executed before idr removal. > > > > Ack, plus you need to do the same retry mechanism. Save CB "count"/seq, > > hw delete, remove from IDR, if CB "count"/seq changed hw delete again. > > Right? > > Actually, I intended to modify fl_reoffload() to ignore filters with > 'deleted' flag set when adding, but I guess reusing 'reoffload_count' to > retry fl_hw_destroy_filter() would also work. Yeah, I don't see how you can ignore deleted safely. Perhaps lack of coffee :)