netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlad Buslov <vladbu@mellanox.com>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: Vlad Buslov <vladbu@mellanox.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"jhs@mojatatu.com" <jhs@mojatatu.com>,
	"xiyou.wangcong@gmail.com" <xiyou.wangcong@gmail.com>,
	"jiri@resnulli.us" <jiri@resnulli.us>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"pablo@netfilter.org" <pablo@netfilter.org>,
	Jiri Pirko <jiri@mellanox.com>
Subject: Re: [PATCH net-next 06/10] net: sched: conditionally obtain rtnl lock in cls hw offloads API
Date: Fri, 23 Aug 2019 10:42:39 +0000	[thread overview]
Message-ID: <vbfef1c17tv.fsf@mellanox.com> (raw)
In-Reply-To: <20190822160328.46f7fab7@cakuba.netronome.com>


On Fri 23 Aug 2019 at 02:03, Jakub Kicinski <jakub.kicinski@netronome.com> wrote:
> On Thu, 22 Aug 2019 15:43:49 +0300, Vlad Buslov wrote:
>> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
>> index 02a547aa77c0..bda42f1b5514 100644
>> --- a/net/sched/cls_api.c
>> +++ b/net/sched/cls_api.c
>> @@ -3076,11 +3076,28 @@ __tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type,
>>  int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type,
>>  		     void *type_data, bool err_stop, bool rtnl_held)
>>  {
>> +	bool take_rtnl = false;
>
> Should we perhaps speculatively:
>
> 	 bool take_rtnl = READ_ONCE(block->lockeddevcnt);
>
> here? It shouldn't hurt, really, and otherwise every offload that
> requires rtnl will have to re-lock cb_lock, every single time..

Great idea! This looks like a straightforward opportunity for
optimization.

>
>>  	int ok_count;
>>
>> +retry:
>> +	if (take_rtnl)
>> +		rtnl_lock();
>>  	down_read(&block->cb_lock);
>> +	/* Need to obtain rtnl lock if block is bound to devs that require it.
>> +	 * In block bind code cb_lock is obtained while holding rtnl, so we must
>> +	 * obtain the locks in same order here.
>> +	 */
>> +	if (!rtnl_held && !take_rtnl && block->lockeddevcnt) {
>> +		up_read(&block->cb_lock);
>> +		take_rtnl = true;
>> +		goto retry;
>> +	}
>> +
>>  	ok_count = __tc_setup_cb_call(block, type, type_data, err_stop);
>> +
>>  	up_read(&block->cb_lock);
>> +	if (take_rtnl)
>> +		rtnl_unlock();
>>  	return ok_count;
>>  }
>>  EXPORT_SYMBOL(tc_setup_cb_call);

  reply	other threads:[~2019-08-23 10:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-22 12:43 [PATCH net-next 00/10] Refactor cls hardware offload API to support rtnl-independent drivers Vlad Buslov
2019-08-22 12:43 ` [PATCH net-next 01/10] net: sched: protect block offload-related fields with rw_semaphore Vlad Buslov
2019-08-22 22:15   ` Jakub Kicinski
2019-08-23 10:25     ` Vlad Buslov
2019-08-22 12:43 ` [PATCH net-next 02/10] net: sched: change tcf block offload counter type to atomic_t Vlad Buslov
2019-08-22 12:43 ` [PATCH net-next 03/10] net: sched: refactor block offloads counter usage Vlad Buslov
2019-08-22 22:53   ` Jakub Kicinski
2019-08-23 10:39     ` Vlad Buslov
2019-08-23 18:26       ` Jakub Kicinski
2019-08-22 12:43 ` [PATCH net-next 04/10] net: sched: notify classifier on successful offload add/delete Vlad Buslov
2019-08-22 22:58   ` Jakub Kicinski
2019-08-22 12:43 ` [PATCH net-next 05/10] net: sched: add API for registering unlocked offload block callbacks Vlad Buslov
2019-08-22 12:43 ` [PATCH net-next 06/10] net: sched: conditionally obtain rtnl lock in cls hw offloads API Vlad Buslov
2019-08-22 23:03   ` Jakub Kicinski
2019-08-23 10:42     ` Vlad Buslov [this message]
2019-08-22 12:43 ` [PATCH net-next 07/10] net: sched: take rtnl lock in tc_setup_flow_action() Vlad Buslov
2019-08-22 12:43 ` [PATCH net-next 08/10] net: sched: take reference to action dev before calling offloads Vlad Buslov
2019-08-22 12:43 ` [PATCH net-next 09/10] net: sched: copy tunnel info when setting flow_action entry->tunnel Vlad Buslov
2019-08-22 12:43 ` [PATCH net-next 10/10] net: sched: flower: don't take rtnl lock for cls hw offloads API Vlad Buslov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vbfef1c17tv.fsf@mellanox.com \
    --to=vladbu@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@mellanox.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).