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=-4.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 8DCFBC10F13 for ; Mon, 8 Apr 2019 22:27:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4CE8F2084F for ; Mon, 8 Apr 2019 22:27:02 +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="vvaYwjf7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726951AbfDHW1B (ORCPT ); Mon, 8 Apr 2019 18:27:01 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:34135 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726188AbfDHW1B (ORCPT ); Mon, 8 Apr 2019 18:27:01 -0400 Received: by mail-qt1-f194.google.com with SMTP id k2so17548107qtm.1 for ; Mon, 08 Apr 2019 15:27:00 -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=3QuGzInh74kVbFXqLkVVrJO9KzyHNim9E2Em8DnEkOQ=; b=vvaYwjf7XOltTGAH3/tVcwp8sp+rNkj5/9CwIVnVFuapEhqcJWn7VAvxeyuEGaQAV0 8+zqOL99k0jXJdehh22xGvX/MqxxD4nqQIre7ZZ+z8YwTtE08mzxNM+R3yuKhZTIAR4s QHnfVQQuSMZPyL4i9XlqpDDqCvV09aW9rTO4BSoyuDZ0HciDTeZTLD70WphCbXRQx3PM 5cnaoobSDEEHz5fktiw5JSqDMxOVhabwGoMITpxbJiIvUa5LPFz78OqxYiPJvr/o8uRm 5MBv9WGWyHeuwwnQ01YENOwxzXWA2ocxh+YMjAArMOUaAzCkiHMGjwPaygPeXEbxEBEj VWzQ== 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=3QuGzInh74kVbFXqLkVVrJO9KzyHNim9E2Em8DnEkOQ=; b=pvCNPLtK8DcTsOPwvZB8PDNwGdU2MRt+gjzhrSyDO7SGs9X9lUzbYz7Z+4ZB0chB6f nS86FRncvcr995ESgXVGw8JH2RutxbilTHiP0cmhlkPasdMJR/SC0RcZBqNZLh4ibYnq nYrMAQ2gWNPAxygGRx4sMPIKjwvVNI3YkpQVIGw1HHTKNyJ+peQnsn/GhY5qhOZAE6iv gLv5dfDyysQoZTDIzjfa8PblYjE6dC3A++g2VEn0w7wMLswrcFO+yeGectirbHgocO4H 7ZorAJt4bQKnoRYTJ7wdhepSD5mIexKX0FY50muc6MGwBRC0FxuaLeC2Cv9o4hv93FWi ag1Q== X-Gm-Message-State: APjAAAUWT/JNWpPktqcaPucpDC5s+/6YX77WpuDVqMscZ5LXOskhh+Eg MHjAzpcaK3NDyzeSo1+B/p7+6Q== X-Google-Smtp-Source: APXvYqxxzKpbrSvD90D4oNB5m5/kwSf7EciRnoZVGAMpP4LzQ3xUKveM9rEgiY9qZBarRDO9kygmsg== X-Received: by 2002:a0c:aed4:: with SMTP id n20mr25659870qvd.136.1554762420148; Mon, 08 Apr 2019 15:27:00 -0700 (PDT) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id x28sm20711207qtx.71.2019.04.08.15.26.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Apr 2019 15:26:59 -0700 (PDT) Date: Mon, 8 Apr 2019 15:26:55 -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: <20190408152655.1891ee77@cakuba.netronome.com> In-Reply-To: <20190405175626.4123-1-vladbu@mellanox.com> References: <20190405175626.4123-1-vladbu@mellanox.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 Fri, 5 Apr 2019 20:56:26 +0300, Vlad Buslov wrote: > John reports: > > Recent refactoring of fl_change aims to use the classifier spinlock to > avoid the need for rtnl lock. In doing so, the fl_hw_replace_filer() > function was moved to before the lock is taken. This can create problems > for drivers if duplicate filters are created (commmon in ovs tc offload > due to filters being triggered by user-space matches). > > Drivers registered for such filters will now receive multiple copies of > the same rule, each with a different cookie value. This means that the > drivers would need to do a full match field lookup to determine > duplicates, repeating work that will happen in flower __fl_lookup(). > Currently, drivers do not expect to receive duplicate filters. > > To fix this, verify that filter with same key is not present in flower > classifier hash table and insert the new filter to the flower hash table > before offloading it to hardware. Implement helper function > fl_ht_insert_unique() to atomically verify/insert a filter. > > This change makes filter visible to fast path at the beginning of > fl_change() function, which means it can no longer be freed directly in > case of error. Refactor fl_change() error handling code to deallocate the > filter with rcu timeout. > > Fixes: 620da4860827 ("net: sched: flower: refactor fl_change") > Reported-by: John Hurley > Signed-off-by: Vlad Buslov How is re-offload consistency guaranteed? IIUC the code is: insert into HT offload insert into IDR What guarantees re-offload consistency if new callback is added just after offload is requested but before rules ends up in IDR?