From: Stephen Hemminger <shemminger-ZtmgI6mnKB3QT0dZR+AlfA@public.gmane.org>
To: Jesse Gross <jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
Cc: dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Subject: Re: [PATCH v2 5/5] net: Add Open vSwitch kernel components.
Date: Mon, 21 Nov 2011 13:59:55 -0800 [thread overview]
Message-ID: <20111121135955.571254b1@nehalam.linuxnetplumber.net> (raw)
In-Reply-To: <1321911029-20707-6-git-send-email-jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
On Mon, 21 Nov 2011 13:30:29 -0800
Jesse Gross <jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org> wrote:
> +/**
> + * vport_record_error - indicate device error to generic stats layer
> + *
> + * @vport: vport that encountered the error
> + * @err_type: one of enum vport_err_type types to indicate the error type
> + *
> + * If using the vport generic stats layer indicate that an error of the given
> + * type has occured.
> + */
> +void vport_record_error(struct vport *vport, enum vport_err_type err_type)
> +{
> + spin_lock(&vport->stats_lock);
Sorry for over analyzing this... but I don't think the stats_lock
is necessary either. The only thing it is protecting is against 64 bit
wrap. If you used another u64_stat_sync for that one, it could be eliminated.
Maybe?
--- a/net/openvswitch/vport.c 2011-11-21 13:56:54.991757053 -0800
+++ b/net/openvswitch/vport.c 2011-11-21 13:57:49.352333329 -0800
@@ -130,8 +130,6 @@ struct vport *vport_alloc(int priv_size,
if (!vport->percpu_stats)
return ERR_PTR(-ENOMEM);
- spin_lock_init(&vport->stats_lock);
-
return vport;
}
@@ -235,6 +233,7 @@ void vport_del(struct vport *vport)
void vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats)
{
int i;
+ unsigned int start;
memset(stats, 0, sizeof(*stats));
@@ -247,19 +246,17 @@ void vport_get_stats(struct vport *vport
* netdev-stats can be directly read over netlink-ioctl.
*/
- spin_lock_bh(&vport->stats_lock);
-
- stats->rx_errors = vport->err_stats.rx_errors;
- stats->tx_errors = vport->err_stats.tx_errors;
- stats->tx_dropped = vport->err_stats.tx_dropped;
- stats->rx_dropped = vport->err_stats.rx_dropped;
-
- spin_unlock_bh(&vport->stats_lock);
+ do {
+ start = u64_stats_fetch_begin_bh(&vport->err_stats.sync);
+ stats->rx_errors = vport->err_stats.rx_errors;
+ stats->tx_errors = vport->err_stats.tx_errors;
+ stats->tx_dropped = vport->err_stats.tx_dropped;
+ stats->rx_dropped = vport->err_stats.rx_dropped;
+ } while (u64_stats_fetch_retry_bh(&vport->err_stats.sync, start));
for_each_possible_cpu(i) {
const struct vport_percpu_stats *percpu_stats;
struct vport_percpu_stats local_stats;
- unsigned int start;
percpu_stats = per_cpu_ptr(vport->percpu_stats, i);
@@ -372,7 +369,7 @@ int vport_send(struct vport *vport, stru
*/
void vport_record_error(struct vport *vport, enum vport_err_type err_type)
{
- spin_lock(&vport->stats_lock);
+ u64_stats_update_begin(&vport->err_stats.sync);
switch (err_type) {
case VPORT_E_RX_DROPPED:
@@ -392,5 +389,5 @@ void vport_record_error(struct vport *vp
break;
};
- spin_unlock(&vport->stats_lock);
+ u64_stats_update_end(&vport->err_stats.sync);
}
--- a/net/openvswitch/vport.h 2011-11-21 13:56:54.991757053 -0800
+++ b/net/openvswitch/vport.h 2011-11-21 13:58:01.448461585 -0800
@@ -62,6 +62,7 @@ struct vport_err_stats {
u64 rx_errors;
u64 tx_dropped;
u64 tx_errors;
+ struct u64_stats_sync sync;
};
/**
next prev parent reply other threads:[~2011-11-21 21:59 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-21 21:30 [GIT PULL v2] Open vSwitch Jesse Gross
[not found] ` <1321911029-20707-1-git-send-email-jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2011-11-21 21:30 ` [PATCH v2 1/5] genetlink: Add genl_notify() Jesse Gross
2011-11-21 21:30 ` [PATCH v2 2/5] genetlink: Add lockdep_genl_is_held() Jesse Gross
2011-11-21 21:30 ` [PATCH v2 3/5] genetlink: Add rcu_dereference_genl and genl_dereference Jesse Gross
2011-11-21 21:30 ` [PATCH v2 4/5] vlan: Move vlan_set_encap_proto() to vlan header file Jesse Gross
2011-11-21 21:30 ` [PATCH v2 5/5] net: Add Open vSwitch kernel components Jesse Gross
[not found] ` <1321911029-20707-6-git-send-email-jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2011-11-21 21:59 ` Stephen Hemminger [this message]
[not found] ` <20111121135955.571254b1-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2011-11-21 23:18 ` Jesse Gross
[not found] ` <CAEP_g=8uoq7tJjUTAC_Sp3kOYwZJuKjD3J7Ratu67Kq56ZiyYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-11-21 23:25 ` Stephen Hemminger
[not found] ` <20111121152518.79e82eb8-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2011-11-21 23:49 ` Michał Mirosław
2011-11-21 22:12 ` Stephen Hemminger
[not found] ` <20111121141235.71a5f8fd-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2011-11-21 23:23 ` Jesse Gross
2011-11-22 0:27 ` Stephen Hemminger
2011-11-22 17:03 ` Jesse Gross
2011-11-22 20:50 ` [GIT PULL v2] Open vSwitch David Miller
2011-11-22 23:18 ` Stephen Hemminger
[not found] ` <20111122151854.198da33d-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2011-11-23 5:34 ` Chris Wright
2011-11-23 7:54 ` Herbert Xu
[not found] ` <20111123075433.GA7928-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
2011-11-23 8:12 ` Eric Dumazet
2011-11-23 8:21 ` Herbert Xu
2011-11-23 12:47 ` jamal
2011-11-23 12:55 ` Eric Dumazet
2011-11-23 13:44 ` Jamal Hadi Salim
2011-11-23 16:05 ` John Fastabend
[not found] ` <4ECD19AC.8090505-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2011-11-24 13:19 ` Jamal Hadi Salim
2011-11-27 19:34 ` Lennert Buytenhek
[not found] ` <20111127193438.GV795-OLH4Qvv75CYX/NnBR394Jw@public.gmane.org>
2011-11-27 21:31 ` jamal
2011-11-23 13:13 ` David Täht
[not found] ` <4ECCF17D.5020509-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-11-23 13:36 ` jamal
2011-11-23 14:15 ` Eric Dumazet
2011-11-24 13:04 ` Jamal Hadi Salim
2011-11-27 14:14 ` WANG Cong
2011-11-23 12:22 ` jamal
2011-11-28 13:04 ` Herbert Xu
[not found] ` <20111128130409.GB16828-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
2011-11-28 13:54 ` Fischer, Anna
[not found] ` <0199E0D51A61344794750DC57738F58E7586A74137-1IhDuF6AwYvulpxXP3Mx0dVKv6DIAtwysh7EHKopUjU@public.gmane.org>
2011-11-28 14:07 ` Issues with openflow protocol WAS(RE: " Jamal Hadi Salim
2011-11-28 18:44 ` Justin Pettit
[not found] ` <20124540-D566-41B0-B86F-0BCA19B948AA-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2011-11-28 18:54 ` Fischer, Anna
2011-11-28 22:55 ` Jamal Hadi Salim
2011-11-28 16:04 ` Ben Pfaff
[not found] ` <20111128160400.GB6349-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2011-11-28 18:52 ` Fischer, Anna
2011-11-28 14:51 ` Herbert Xu
[not found] ` <20111128145157.GA17678-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
2011-11-30 6:21 ` Jesse Gross
2011-11-30 7:02 ` Herbert Xu
[not found] ` <20111130070219.GB32630-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
2011-12-01 7:24 ` Simon Horman
2011-12-01 7:52 ` Herbert Xu
[not found] ` <20111201075237.GA12799-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
2011-12-01 8:06 ` Simon Horman
2011-12-02 23:00 ` Jesse Gross
2011-11-28 14:02 ` Jamal Hadi Salim
2011-11-28 15:27 ` Martin Casado
2011-11-28 15:32 ` [ovs-dev] " Jamal Hadi Salim
2011-11-28 15:50 ` Martin Casado
2011-11-28 16:01 ` Ben Pfaff
[not found] ` <20111128160117.GA6349-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2011-11-28 22:21 ` Jamal Hadi Salim
2011-11-28 23:14 ` [ovs-dev] " Ben Pfaff
2011-11-30 6:18 ` Jesse Gross
2011-11-30 7:06 ` Herbert Xu
[not found] ` <CAEP_g=-+F8bpkb8Qe1bPk65PQVNxz+VO7NoUrBCw6=GDUFbOFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-11-30 13:23 ` jamal
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=20111121135955.571254b1@nehalam.linuxnetplumber.net \
--to=shemminger-ztmgi6mnkb3qt0dzr+alfa@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org \
--cc=jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 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).