All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: David Miller <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <stephen@networkplumber.org>
Subject: Re: [PATCH net-next 4/4] sch_netem: replace spin_(un)lock_bh with sch_tree_(un)lock
Date: Fri, 14 Feb 2014 09:32:24 +0800	[thread overview]
Message-ID: <52FD7228.3010804@huawei.com> (raw)
In-Reply-To: <20140213.174606.334208738068503053.davem@davemloft.net>

On 2014/2/14 6:46, David Miller wrote:
> From: Yang Yingliang <yangyingliang@huawei.com>
> Date: Wed, 12 Feb 2014 10:58:15 +0800
> 
>> spin_(un)lock_bh(root_lock) is same as sch_tree_(un)lock.
>>
>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>  ...
>> @@ -684,11 +683,9 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr)
>>  	for (i = 0; i < n; i++)
>>  		d->table[i] = data[i];
>>  
>> -	root_lock = qdisc_root_sleeping_lock(sch);
>> -
>> -	spin_lock_bh(root_lock);
>> +	sch_tree_lock(sch);
>>  	swap(q->delay_dist, d);
>> -	spin_unlock_bh(root_lock);
>> +	sch_tree_unlock(sch);
>>  
>>  	dist_free(d);
>>  	return 0;
> 
> This is more expensive than the existing code.
> 
> We will now calculate qdisc_root_sleeping_lock() twice which is at
> least two pointer dereferences each.
> 
> Without explicitly open-coding this, the compiler cannot cache the
> result, because the spin lock operations have memory barriers (if
> implemented inline) or are considered to potentially modify all memory
> (if implemented as function calls).
> 
> 
OK, thanks!
I'll send v2 without this patch.

      reply	other threads:[~2014-02-14  1:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-12  2:58 [PATCH net-next 0/4] sch_netem: some improvements and cleanups Yang Yingliang
2014-02-12  2:58 ` [PATCH net-next 1/4] sch_netem: return errcode before setting params Yang Yingliang
2014-02-12  2:58 ` [PATCH net-next 2/4] sch_netem: change some func's param from "struct Qdisc *" to "struct netem_sched_data *" Yang Yingliang
2014-02-12  2:58 ` [PATCH net-next 3/4] sch_netem: replace magic numbers with enumerate in GE model Yang Yingliang
2014-02-12  2:58 ` [PATCH net-next 4/4] sch_netem: replace spin_(un)lock_bh with sch_tree_(un)lock Yang Yingliang
2014-02-13 22:46   ` David Miller
2014-02-14  1:32     ` Yang Yingliang [this message]

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=52FD7228.3010804@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.