From patchwork Tue Jun 2 10:09:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 1302311 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=c5JPMvUc; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bnq33zwpz9sSd for ; Tue, 2 Jun 2020 20:10:23 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 4969C80EAF; Tue, 2 Jun 2020 10:10:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rfGp0qrGX4ra; Tue, 2 Jun 2020 10:10:20 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id BE92084483; Tue, 2 Jun 2020 10:10:20 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A5004C0865; Tue, 2 Jun 2020 10:10:20 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2561AC0865 for ; Tue, 2 Jun 2020 10:10:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 0556A86366 for ; Tue, 2 Jun 2020 10:10:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BnM9flJm9IuQ for ; Tue, 2 Jun 2020 10:10:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 20431862FC for ; Tue, 2 Jun 2020 10:10:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591092609; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2F7p9mDHdkR4QMZhAKxrofmae/RMslKMMtHY9pL1jQk=; b=c5JPMvUcDf2BHlzTK6Yl9mrOgeR8WnVhkUzMoVuDCjzOOf1/h9LcrTri3xJoFCw0SKQveL wZ6iOSGc7EH4HD33zAecHZ1WC6x/xJ4kK4hUn992Ii79u9QiqIszX6nUvEmC4JNUEEqArn Fa9vIHONgQG/SzBzIWKwzJugddwan2c= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-109-AA7rd1VhM6-OxeY88cj1Og-1; Tue, 02 Jun 2020 06:10:07 -0400 X-MC-Unique: AA7rd1VhM6-OxeY88cj1Og-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27DA3100A8E8; Tue, 2 Jun 2020 10:10:06 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-111.sin2.redhat.com [10.67.117.111]) by smtp.corp.redhat.com (Postfix) with ESMTP id C746A5D9DD; Tue, 2 Jun 2020 10:10:00 +0000 (UTC) From: Gowrishankar Muthukrishnan To: dev@openvswitch.org Date: Tue, 2 Jun 2020 15:39:44 +0530 Message-Id: <4649bf8c47b75d7821567a2470dcd9dc20870922.1591091223.git.gmuthukr@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: anju.thomas@ericsson.com, Keshav Gupta , i.maximets@ovn.org Subject: [ovs-dev] [PATCH 2/7] stopwatch: expose required api for event library X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Timer notifications in event library require handling stopwatch across one or more events, so share few required functions. Signed-off-by: Gowrishankar Muthukrishnan --- lib/stopwatch.c | 20 +++++++++++++++++++- lib/stopwatch.h | 9 +++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/stopwatch.c b/lib/stopwatch.c index f560216..0858d72 100644 --- a/lib/stopwatch.c +++ b/lib/stopwatch.c @@ -463,7 +463,7 @@ stopwatch_thread(void *ign OVS_UNUSED) return NULL; } -static void +void stopwatch_exit(void) { struct shash_node *node, *node_next; @@ -526,6 +526,24 @@ stopwatch_create(const char *name, enum stopwatch_units units) } void +stopwatch_delete(const char *name) +{ + ovs_mutex_lock(&stopwatches_lock); + shash_find_and_delete(&stopwatches, name); + ovs_mutex_unlock(&stopwatches_lock); +} + +unsigned int +stopwatch_count(void) +{ + unsigned int n; + ovs_mutex_lock(&stopwatches_lock); + n = shash_count(&stopwatches); + ovs_mutex_unlock(&stopwatches_lock); + return n; +} + +void stopwatch_start(const char *name, unsigned long long ts) { struct stopwatch_packet *pkt = stopwatch_packet_create(OP_START_SAMPLE); diff --git a/lib/stopwatch.h b/lib/stopwatch.h index 91abd64..2f8e56c 100644 --- a/lib/stopwatch.h +++ b/lib/stopwatch.h @@ -56,4 +56,13 @@ bool stopwatch_get_stats(const char *name, struct stopwatch_stats *stats); /* Block until all enqueued samples have been processed. */ void stopwatch_sync(void); +/* Delete stopwatch */ +void stopwatch_delete(const char *name); + +/* Count stopwatches */ +unsigned int stopwatch_count(void); + +/* Exit stopwatch */ +void stopwatch_exit(void); + #endif /* stopwatch.h */