From patchwork Wed Mar 22 10:10:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 741950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vp56M5r3Mz9s7M for ; Wed, 22 Mar 2017 21:10:35 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 311D794F; Wed, 22 Mar 2017 10:10:32 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id C34C78EE for ; Wed, 22 Mar 2017 10:10:31 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 96113177 for ; Wed, 22 Mar 2017 10:10:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF3534DD58 for ; Wed, 22 Mar 2017 10:10:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EF3534DD58 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=echaudro@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EF3534DD58 Received: from rhvm.com (ovpn-116-164.ams2.redhat.com [10.36.116.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 798E2BFE89 for ; Wed, 22 Mar 2017 10:10:30 +0000 (UTC) From: Eelco Chaudron To: dev@openvswitch.org Date: Wed, 22 Mar 2017 11:10:23 +0100 Message-Id: <13f2083d47e80ac11470b5164765e2ce0b711543.1490177338.git.echaudro@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 22 Mar 2017 10:10:31 +0000 (UTC) X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 1/1] dpif-netdev: The pmd-*-show commands will show info in core order X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org The "ovs-appctl dpif-netdev/pmd-rxq-show" and "ovs-appctl dpif-netdev/pmd-stats-show" commands show their output per core_id, sorted on the hash location. My OCD was kicking in when using these commands, hence this change to display them in natural core_id order. In addition I had to change a test case that would fail if the cores where not in order in the hash list. This is due to OVS assigning queues to cores based on the order in the hash list. The test case now checks if any core has the set of queues in the given order. Manually tested this on my setup, and ran clang-analyze. Signed-off-by: Eelco Chaudron --- lib/dpif-netdev.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- tests/pmd.at | 7 ++++--- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index a14a2eb..b44c03b 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -923,13 +923,57 @@ pmd_info_show_rxq(struct ds *reply, struct dp_netdev_pmd_thread *pmd) } } +static int +compare_poll_thread_list(const void *a_, const void *b_) +{ + const struct dp_netdev_pmd_thread *a, *b; + + a = *(struct dp_netdev_pmd_thread **)a_; + b = *(struct dp_netdev_pmd_thread **)b_; + + if (a->core_id < b->core_id) { + return -1; + } + if (a->core_id > b->core_id) { + return 1; + } + return 0; +} + +/* Create a sorted list of pmd's from the dp->poll_threads cmap. We can use + * this list, as long as we do not got to quiescent state. */ +static void +sorted_poll_thread_list(struct dp_netdev *dp, + struct dp_netdev_pmd_thread ***list, + size_t *n) +{ + struct dp_netdev_pmd_thread *pmd; + struct dp_netdev_pmd_thread **pmd_list; + size_t k = 0, n_pmds; + + n_pmds = cmap_count(&dp->poll_threads); + pmd_list = xcalloc(n_pmds, sizeof *pmd_list); + + CMAP_FOR_EACH (pmd, node, &dp->poll_threads) { + ovs_assert(k < n_pmds); + pmd_list[k++] = pmd; + } + + qsort(pmd_list, k, sizeof *pmd_list, compare_poll_thread_list); + + *list = pmd_list; + *n = k; +} + static void dpif_netdev_pmd_info(struct unixctl_conn *conn, int argc, const char *argv[], void *aux) { struct ds reply = DS_EMPTY_INITIALIZER; struct dp_netdev_pmd_thread *pmd; + struct dp_netdev_pmd_thread **pmd_list; struct dp_netdev *dp = NULL; + size_t i, n; enum pmd_info_type type = *(enum pmd_info_type *) aux; ovs_mutex_lock(&dp_netdev_mutex); @@ -948,7 +992,10 @@ dpif_netdev_pmd_info(struct unixctl_conn *conn, int argc, const char *argv[], return; } - CMAP_FOR_EACH (pmd, node, &dp->poll_threads) { + sorted_poll_thread_list(dp, &pmd_list, &n); + for (i = 0; i < n; i++) { + pmd = pmd_list[i]; + if (type == PMD_INFO_SHOW_RXQ) { pmd_info_show_rxq(&reply, pmd); } else { @@ -971,6 +1018,7 @@ dpif_netdev_pmd_info(struct unixctl_conn *conn, int argc, const char *argv[], } } } + free(pmd_list); ovs_mutex_unlock(&dp_netdev_mutex); diff --git a/tests/pmd.at b/tests/pmd.at index 5686bed..7263d4b 100644 --- a/tests/pmd.at +++ b/tests/pmd.at @@ -53,6 +53,7 @@ m4_define([CHECK_PMD_THREADS_CREATED], [ ]) m4_define([SED_NUMA_CORE_PATTERN], ["s/\(numa_id \)[[0-9]]*\( core_id \)[[0-9]]*:/\1\2:/"]) +m4_define([SED_NUMA_CORE_QUEUE_PATTERN], ["s/\(numa_id \)[[0-9]]*\( core_id \)[[0-9]]*:/\1\2:/;s/\(queue-id: \)\(0 2 4 6\|1 3 5 7\)/\1/"]) m4_define([DUMMY_NUMA], [--dummy-numa="0,0,0,0"]) AT_SETUP([PMD - creating a thread/add-port]) @@ -126,13 +127,13 @@ TMP=$(cat ovs-vswitchd.log | wc -l | tr -d [[:blank:]]) AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0x3]) CHECK_PMD_THREADS_CREATED([2], [], [+$TMP]) -AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], [0], [dnl +AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_QUEUE_PATTERN], [0], [dnl pmd thread numa_id core_id : isolated : false - port: p0 queue-id: 0 2 4 6 + port: p0 queue-id: pmd thread numa_id core_id : isolated : false - port: p0 queue-id: 1 3 5 7 + port: p0 queue-id: ]) TMP=$(cat ovs-vswitchd.log | wc -l | tr -d [[:blank:]])