From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EFD11A04DD; Thu, 22 Oct 2020 10:08:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6527E6948; Thu, 22 Oct 2020 10:08:26 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by dpdk.org (Postfix) with ESMTP id D5F3766DA for ; Thu, 22 Oct 2020 10:08:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603354102; 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; bh=0dQT0YK5Im/lhJJWi7qjADkAfCp+1f7WNrkcEL7zHCU=; b=iljBHhzC6i4n3TRO2v+hdWQxNl5i8pMOKxWwIO77YY8DTKBTXEyKy8PD45osSwU+SobePI awauuPg9db6Aral8kKpgSdYiQ4hUA78LhKG9DNkp+kA72FApB5Wj4sHb7L4hMVTjKNzG9M v7M44oILPSt/KMX8NoYCwVAzUKfd+P0= 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-391-DjnVQEpEPb6hEvAjaJv7EA-1; Thu, 22 Oct 2020 04:08:19 -0400 X-MC-Unique: DjnVQEpEPb6hEvAjaJv7EA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 470A6846378; Thu, 22 Oct 2020 08:08:18 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.193.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 634526EF41; Thu, 22 Oct 2020 08:08:17 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Harry van Haaren Date: Thu, 22 Oct 2020 10:08:10 +0200 Message-Id: <20201022080810.22153-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH] service: separate dump and reset code X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" No functional change intended. service_dump_calls_per_lcore() was always called with a 0 reset flag. service_dump_one() was called with either a 0 reset flag or a NULL FILE pointer. We can split the code for readability sake. Note: there is no path to resetting calls_per_service[], this is left as is. Signed-off-by: David Marchand --- lib/librte_eal/common/rte_service.c | 54 +++++++++++------------------ 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c index 6c955d319a..bd8fb72e78 100644 --- a/lib/librte_eal/common/rte_service.c +++ b/lib/librte_eal/common/rte_service.c @@ -832,37 +832,14 @@ rte_service_lcore_attr_get(uint32_t lcore, uint32_t attr_id, } } -static void -service_dump_one(FILE *f, struct rte_service_spec_impl *s, uint32_t reset) -{ - /* avoid divide by zero */ - int calls = 1; - if (s->calls != 0) - calls = s->calls; - - if (reset) { - s->cycles_spent = 0; - s->calls = 0; - return; - } - - if (f == NULL) - return; - - fprintf(f, " %s: stats %d\tcalls %"PRIu64"\tcycles %" - PRIu64"\tavg: %"PRIu64"\n", - s->spec.name, service_stats_enabled(s), s->calls, - s->cycles_spent, s->cycles_spent / calls); -} - int32_t rte_service_attr_reset_all(uint32_t id) { struct rte_service_spec_impl *s; SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL); - int reset = 1; - service_dump_one(NULL, s, reset); + s->cycles_spent = 0; + s->calls = 0; return 0; } @@ -884,7 +861,21 @@ rte_service_lcore_attr_reset_all(uint32_t lcore) } static void -service_dump_calls_per_lcore(FILE *f, uint32_t lcore, uint32_t reset) +service_dump_one(FILE *f, struct rte_service_spec_impl *s) +{ + /* avoid divide by zero */ + int calls = 1; + + if (s->calls != 0) + calls = s->calls; + fprintf(f, " %s: stats %d\tcalls %"PRIu64"\tcycles %" + PRIu64"\tavg: %"PRIu64"\n", + s->spec.name, service_stats_enabled(s), s->calls, + s->cycles_spent, s->cycles_spent / calls); +} + +static void +service_dump_calls_per_lcore(FILE *f, uint32_t lcore) { uint32_t i; struct core_state *cs = &lcore_states[lcore]; @@ -894,8 +885,6 @@ service_dump_calls_per_lcore(FILE *f, uint32_t lcore, uint32_t reset) if (!service_valid(i)) continue; fprintf(f, "%"PRIu64"\t", cs->calls_per_service[i]); - if (reset) - cs->calls_per_service[i] = 0; } fprintf(f, "\n"); } @@ -911,8 +900,7 @@ rte_service_dump(FILE *f, uint32_t id) struct rte_service_spec_impl *s; SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL); fprintf(f, "Service %s Summary\n", s->spec.name); - uint32_t reset = 0; - service_dump_one(f, s, reset); + service_dump_one(f, s); return 0; } @@ -921,8 +909,7 @@ rte_service_dump(FILE *f, uint32_t id) for (i = 0; i < RTE_SERVICE_NUM_MAX; i++) { if (!service_valid(i)) continue; - uint32_t reset = 0; - service_dump_one(f, &rte_services[i], reset); + service_dump_one(f, &rte_services[i]); } fprintf(f, "Service Cores Summary\n"); @@ -930,8 +917,7 @@ rte_service_dump(FILE *f, uint32_t id) if (lcore_config[i].core_role != ROLE_SERVICE) continue; - uint32_t reset = 0; - service_dump_calls_per_lcore(f, i, reset); + service_dump_calls_per_lcore(f, i); } return 0; -- 2.23.0