[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20111121135955.571254b1@nehalam.linuxnetplumber.net>
Date: Mon, 21 Nov 2011 13:59:55 -0800
From: Stephen Hemminger <shemminger@...tta.com>
To: Jesse Gross <jesse@...ira.com>
Cc: "David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
dev@...nvswitch.org
Subject: Re: [PATCH v2 5/5] net: Add Open vSwitch kernel components.
On Mon, 21 Nov 2011 13:30:29 -0800
Jesse Gross <jesse@...ira.com> 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;
};
/**
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists