From patchwork Mon Nov 21 21:59:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 126951 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A76A9B6F62 for ; Tue, 22 Nov 2011 09:00:21 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757253Ab1KUWAJ (ORCPT ); Mon, 21 Nov 2011 17:00:09 -0500 Received: from mail.vyatta.com ([76.74.103.46]:54127 "EHLO mail.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753692Ab1KUWAE (ORCPT ); Mon, 21 Nov 2011 17:00:04 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.vyatta.com (Postfix) with ESMTP id 28134141000C; Mon, 21 Nov 2011 14:00:04 -0800 (PST) X-Virus-Scanned: amavisd-new at tahiti.vyatta.com Received: from mail.vyatta.com ([127.0.0.1]) by localhost (mail.vyatta.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QQrEt5Pt09Zk; Mon, 21 Nov 2011 13:59:58 -0800 (PST) Received: from nehalam.linuxnetplumber.net (unknown [10.250.0.104]) by mail.vyatta.com (Postfix) with ESMTPSA id E2DAC1410003; Mon, 21 Nov 2011 13:59:57 -0800 (PST) Date: Mon, 21 Nov 2011 13:59:55 -0800 From: Stephen Hemminger To: Jesse Gross Cc: "David S. Miller" , netdev@vger.kernel.org, dev@openvswitch.org Subject: Re: [PATCH v2 5/5] net: Add Open vSwitch kernel components. Message-ID: <20111121135955.571254b1@nehalam.linuxnetplumber.net> In-Reply-To: <1321911029-20707-6-git-send-email-jesse@nicira.com> References: <1321911029-20707-1-git-send-email-jesse@nicira.com> <1321911029-20707-6-git-send-email-jesse@nicira.com> Organization: Vyatta X-Mailer: Claws Mail 3.7.10 (GTK+ 2.24.7; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, 21 Nov 2011 13:30:29 -0800 Jesse Gross 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? --- 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 --- 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; }; /**