From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1801333FE2F for ; Thu, 7 May 2026 11:31:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778153492; cv=none; b=Rgz+K9oyPSvyBMvxNtujWD7WVRyAN/JZ4dbWNZaGJejBEmlB8tL58Srsq6USR1b2ccyGDqq/NNgwGAVMOh9ypCUvPTaRP6iaVZ1tayh0hr/8yDgStBBkI752Mw48tMYoYRZlc5Ygpo02uhD51JPN3IXPGR4RLDT7wMtlFHW/RAY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778153492; c=relaxed/simple; bh=cyiYGy1gEv+iXflgXx44xNGEmkBTXcFw6mlOVf+LM8c=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZWpkPBziLgksq7DuBFgXB7ec53PYo6Z2OYWGOLzP89L/RoH8osmf475CD077YlI8iRI05Aj239pzaNriTJbwf7wZ0hlmPNWNfsKHtnQ5NDltuRMRHAho2HjzyztwUS56Z/GuSs1BlGOx6ssL3/pTIhjxQfm0ZXgrV3pg8A02dtY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=A9W2MlY6; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=ogJ63FRd; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A9W2MlY6"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="ogJ63FRd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778153490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BomrRhKMx3+Q9j/dmB0a3mhqfb+BMVARxbi6baHw+i4=; b=A9W2MlY67A/66xZDLUnw9ulTsbc1tNGb8W6u9sJnPzougxGo4IjMAf9e0FypYeHSM5ylP9 ufSX2flS/Fy24QRgsEe2ZBYjKTOXNbvbtRfM8nsTQDbA6FyGSyKkmTxwWqclVGfawFtPsV zVpt2vqDAppYsKTSAQwe9Dryj5sPK6c= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-237-uiV08yqEPPaHn1RBM-sG6w-1; Thu, 07 May 2026 07:31:28 -0400 X-MC-Unique: uiV08yqEPPaHn1RBM-sG6w-1 X-Mimecast-MFC-AGG-ID: uiV08yqEPPaHn1RBM-sG6w_1778153488 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-48d1bc85bb3so3165165e9.0 for ; Thu, 07 May 2026 04:31:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778153488; x=1778758288; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=BomrRhKMx3+Q9j/dmB0a3mhqfb+BMVARxbi6baHw+i4=; b=ogJ63FRdHExcP0QnggXEc4JtQuAaM3FrEQax8VRq4wItnJh7jt89ASleR9JqEd5E1d 6fKBEtdBZ7Mwd8K2TJ8JbjZ5KiMZguk7dnDaPziv/BE2tXuTKT6FHFiE+Ejq+wWF+o0R P89Ve+wq1ks6vsU0u1pmiqW0wL/TXPrb5RGbn+6IpxSVra0aoHRWZqcXL4WftmGC2SG8 6dLMje0IY0upT8bzatjdnNBTqs9k5ck+fOF6+P6E1C8vV/ePskvrM9bJnWPSdUVPAS7Q TRobEb74JtYW7opSVe+HxVCTu77aKvxLhfKslgJ35I826DojSXgnCjaAACmTC+ql4Muh 6I9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778153488; x=1778758288; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BomrRhKMx3+Q9j/dmB0a3mhqfb+BMVARxbi6baHw+i4=; b=GKgnhRNPPY0r+gDuGHPRpYtNekARJjzbzU7pI5kJjNXnQ3ge00HOohNqpmtEW1Jmn1 YQS2fmIob0I1PxBg6ZerlFZVXpywj9lgeaI/6Y//1RY7H/IkgXwN8By//hJIanTADs+F l8rO73ZYTmLbKW/fYkglm2mWcCBkY64zsrUUY9+eMb10Vs1tdIpbg2IFjzTv6eu1SI6s L7ZePHfQEuL6WBPrLlErhcWTba5Eikb8bzOL2WB7lZcnB9vB439AgBjRWqlIVyNNdoAQ 4gbi++XIrSExdy4uDbt8ChnteB9+rU/l8p/Xvqt3vj04oCwx1ViPM11n6Ls6/Afaj5ES aFqg== X-Forwarded-Encrypted: i=1; AFNElJ9FEriYeIcclDRzmfqIXv6nMRcLVfULJ/j5W5jMxzLXQq4wsUuM86w6QKsYh1oxnR2eUFLK53oI/fLUVGk=@vger.kernel.org X-Gm-Message-State: AOJu0YxQqYVLMvyXLDLQg1Z7qTd8fVenoXrGezG/al5sAhRSEoySMUXv QhGAY75Kna7ajmgIsLZG8hhKIz6zxNLPr7O+Oc9x9xbCL/KnhWIDK2SGh+MlxXD0zQoAKb9Do4Z Fo32UsLSIyT+buyrmvt33Ya6osx3BNwM7L84LiX1y9weQ6/e5hmgdCCX/I3q8zdbpwQ== X-Gm-Gg: AeBDietwB5MpHY5UYkuEmseBdarZAvQ1HkeNwJqaVirPFu0QYw3IkprV+O7AMNO+W7E ATPJ7yPKqsO7G0coeU3PPeLVLwomjnblx3QBvjhTA5ww4UzfXxTUwHZkwF7gqTETVXlVNlP3Ozv uDrpu42CypVxlNWsxYArTUf8DGHjelHSXS2O/dV6hjzPx6C3W6Z7vTBGDzXX1Xqy9HPERMpObBp 04C5NhV5oC3LifgpAI/YAdqtZgubww0ce0ZEDytbg5bbAt75cbk+8basSM7G9akY74s3qZ/GtKJ gQz5xH80Mv7FMtxKLhuAmqJmnMQHYx9TOEGnKFnPlSLsHrAXjihgstYOVU0ygBNq7nIk/XUWOwA 5pYMY8Lx5+V+tg1UEfwvKLENAPLAeFTyJ1QampcR6OEaDx1xvvFOGcvWaeWUoYg== X-Received: by 2002:a05:600c:4749:b0:488:aa33:dc8f with SMTP id 5b1f17b1804b1-48e5df8d7a7mr35210255e9.0.1778153487377; Thu, 07 May 2026 04:31:27 -0700 (PDT) X-Received: by 2002:a05:600c:4749:b0:488:aa33:dc8f with SMTP id 5b1f17b1804b1-48e5df8d7a7mr35209555e9.0.1778153486685; Thu, 07 May 2026 04:31:26 -0700 (PDT) Received: from [192.168.88.32] ([150.228.93.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e53895effsm114434365e9.3.2026.05.07.04.31.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 May 2026 04:31:26 -0700 (PDT) Message-ID: Date: Thu, 7 May 2026 13:31:24 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v3 2/2] net: openvswitch: decouple flow_table from ovs_mutex To: Adrian Moreno , netdev@vger.kernel.org Cc: aconole@redhat.com, Eelco Chaudron , Ilya Maximets , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Simon Horman , "open list:OPENVSWITCH" , open list References: <20260505084253.998548-1-amorenoz@redhat.com> <20260505084253.998548-3-amorenoz@redhat.com> Content-Language: en-US From: Paolo Abeni In-Reply-To: <20260505084253.998548-3-amorenoz@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/5/26 10:42 AM, Adrian Moreno wrote: > In order to protect flow operations from RTNL contention, this patch > decouples flow_table modifications from ovs_mutex by means of the > following: > > 1 - Create a new mutex inside the flow_table that protects it from > concurrent modifications. > Putting the mutex inside flow_table makes it easier to consume for > functions inside flow_table.c that do not currently take pointers to the > datapath. > Some function signatures need to be changed to accept flow_table so that > lockdep checks can be performed. > > 2 - Create a reference count to temporarily extend rcu protection from > the datapath to the flow_table. > One reference is held by the datapath, the other is temporarily > increased during flow modifications. > > Signed-off-by: Adrian Moreno > --- > net/openvswitch/datapath.c | 230 ++++++++++++++++++++++------------- > net/openvswitch/flow.c | 13 +- > net/openvswitch/flow.h | 9 +- > net/openvswitch/flow_table.c | 173 ++++++++++++++++---------- > net/openvswitch/flow_table.h | 53 +++++++- > 5 files changed, 318 insertions(+), 160 deletions(-) This is still considerably big. I'm wondering if introducing the lockdep_ovs_tbl_is_held/rcu_dereference_ovs_tbl annotations with a separate earlier patch would make it more palatable? Just a very wild guess; if the result is ugly (or you have string feeling that would be) please ignore. > @@ -1112,7 +1132,8 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info) > ufid_flags); > BUG_ON(error < 0); > } > - ovs_unlock(); > + mutex_unlock(&table->lock); > + ovs_flow_tbl_put(table); Minot nit: you can consolidate 2 ovs_flow_tbl_put() calls after the if/than/else statement. @@ -524,9 +540,22 @@ void ovs_flow_tbl_destroy_rcu(struct rcu_head *rcu) > call_rcu(&mc->rcu, mask_cache_rcu_cb); > call_rcu(&ma->rcu, mask_array_rcu_cb); > table_instance_destroy(ti, ufid_ti); > + mutex_destroy(&table->lock); > kfree(table); > } > > +void ovs_flow_tbl_put(struct flow_table *table) > +{ > + if (refcount_dec_and_test(&table->refcnt)) { > + mutex_lock(&table->lock); > + table_instance_flow_flush(table, > + ovs_tbl_dereference(table->ti, table), > + ovs_tbl_dereference(table->ufid_ti, table)); > + mutex_unlock(&table->lock); As mentioned in the previous patch you can follow-up moving here the call_rcu(&mc->rcu, mask_cache_rcu_cb); call_rcu(&ma->rcu, mask_array_rcu_cb); currently in ovs_flow_tbl_destroy_rcu. > +/* Must be called with flow_table->lock held. */ > int ovs_flow_tbl_flush(struct flow_table *flow_table) > { > struct table_instance *old_ti, *new_ti; > struct table_instance *old_ufid_ti, *new_ufid_ti; > > + ASSERT_OVS_TBL(flow_table); Minor nit: adding the assert and the comment is redundant. I think the assert alone would be better. There are other similar later occurrences. /P