From: Ding Tianhong <dthxman@gmail.com>
To: Nikolay Aleksandrov <nikolay@redhat.com>
Cc: Ding Tianhong <dingtianhong@huawei.com>,
Jay Vosburgh <fubar@us.ibm.com>,
Andy Gospodarek <andy@greyhouse.net>,
"David S. Miller" <davem@davemloft.net>,
Veaceslav Falico <vfalico@redhat.com>,
Netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next v2 6/10] bonding: rebuild the lock use for bond_activebackup_arp_mon()
Date: Sun, 10 Nov 2013 12:08:02 +0800 [thread overview]
Message-ID: <527F06A2.2070407@gmail.com> (raw)
In-Reply-To: <527D0AEF.1060802@redhat.com>
>> + rcu_read_unlock();
>>
>> re_arm:
>> if (bond->params.arp_interval)
>> queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks);
>>
>> - read_unlock(&bond->lock);
>> -
>> if (should_notify_peers) {
>> if (!rtnl_trylock())
>> return;
>> diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
>> index deb9738..90b745c 100644
>> --- a/drivers/net/bonding/bonding.h
>> +++ b/drivers/net/bonding/bonding.h
>> @@ -97,6 +97,13 @@
>> netdev_adjacent_get_private(bond_slave_list(bond)->prev) : \
>> NULL)
>>
>> +#define bond_first_slave_rcu(bond) \
>> + ({struct list_head *__ptr = (bond_slave_list(bond)); \
>> + struct list_head *__next = ACCESS_ONCE(__ptr->next); \
>> + likely(__ptr != __next) ? \
>> + netdev_adjacent_get_private_rcu(__next) : NULL; \
>> + })
>> +
> Honestly, I don't like this, it sure can be re-written in a more
> straight-forward manner.
I have re-write the function by 2 ways, the first one just like
list_first_or_null_rcu,
the second one just used the exist function
netdev_lower_get_next_private_rcu,
I think the first one is better, it is more exactly.
1:
+#define bond_first_slave_rcu(bond) \
+ ({struct list_head *__ptr = (bond_slave_list(bond)); \
+ struct list_head *__next = ACCESS_ONCE(__ptr->next); \
+ likely(__ptr != __next) ? \
+ (list_entry_rcu(__next, struct netdev_adjacent, list))->private : NULL; \
+ })
+
2:
+#define bond_first_slave_rcu(bond) \
+ ({struct list_head *iter = (bond_slave_list(bond)); \
+ netdev_lower_get_next_private_rcu(bond->dev, &iter) ? : NULL; \
+ })
what do you think about is, maybe you have more wonderful idea, pls
remind me,
thanks
Regards
Ding
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
prev parent reply other threads:[~2013-11-10 4:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-08 2:08 [PATCH net-next v2 6/10] bonding: rebuild the lock use for bond_activebackup_arp_mon() Ding Tianhong
2013-11-08 16:01 ` Nikolay Aleksandrov
2013-11-09 14:08 ` Ding Tianhong
2013-11-10 4:08 ` Ding Tianhong [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=527F06A2.2070407@gmail.com \
--to=dthxman@gmail.com \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=dingtianhong@huawei.com \
--cc=fubar@us.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@redhat.com \
--cc=vfalico@redhat.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 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.