From patchwork Thu Nov 23 19:41:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Traynor X-Patchwork-Id: 840885 X-Patchwork-Delegate: ian.stokes@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) 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 3yjV8M54dlz9ryv for ; Fri, 24 Nov 2017 06:42:11 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 11AB2ABC; Thu, 23 Nov 2017 19:42:08 +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 71C8EAB9 for ; Thu, 23 Nov 2017 19:42:06 +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 773181E1 for ; Thu, 23 Nov 2017 19:42:05 +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 CB9EBC0587DD; Thu, 23 Nov 2017 19:42:04 +0000 (UTC) Received: from ktraynor.remote.csb (unknown [10.36.118.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E5945D6A5; Thu, 23 Nov 2017 19:42:02 +0000 (UTC) From: Kevin Traynor To: dev@openvswitch.org, aserdean@ovn.org, i.maximets@samsung.com, billy.o.mahony@intel.com, ian.stokes@intel.com Date: Thu, 23 Nov 2017 19:41:55 +0000 Message-Id: <1511466117-27191-1-git-send-email-ktraynor@redhat.com> In-Reply-To: <1511375946-28054-1-git-send-email-ktraynor@redhat.com> References: <1511375946-28054-1-git-send-email-ktraynor@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.32]); Thu, 23 Nov 2017 19:42:05 +0000 (UTC) X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 v4 1/3] dpif-netdev: Add port/queue tiebreaker to rxq_cycle_sort. 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 rxq_cycle_sort is used to compare rx queues by their measured number of cycles. In the event that they are equal, 0 could be returned. However, it is observed that returning 0 results in a different sort order on Windows/Linux. This is ok in practice but it causes a unit test failure for "1007: PMD - pmd-cpu-mask/distribution of rx queues" when running on different OS's. In order to have a consistent sort result across multiple OS's, introduce a tiebreaker of port/queue. Fixes: 655856ef39b9 ("dpif-netdev: Change rxq_scheduling to use rxq processing cycles.") Reported-by: Alin Gabriel Serdean Tested-by: Alin Gabriel Serdean Co-authored-by: Ilya Maximets Signed-off-by: Ilya Maximets Signed-off-by: Kevin Traynor --- V4: Added patch into series after Alin tested it as RFC lib/dpif-netdev.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 0a62630..f5cdd92 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -3464,8 +3464,17 @@ rxq_cycle_sort(const void *a, const void *b) dp_netdev_rxq_set_cycles(qb, RXQ_CYCLES_PROC_HIST, total_qb); - if (total_qa >= total_qb) { - return -1; + if (total_qa != total_qb) { + return (total_qa < total_qb) ? 1 : -1; + } else { + /* Cycles are the same so tiebreak on port/queue id. + * Tiebreaking (as opposed to return 0) ensures consistent + * sort results across multiple OS's. */ + if (qa->port->port_no != qb->port->port_no) { + return (qa->port->port_no > qb->port->port_no) ? 1 : -1; + } else { + return netdev_rxq_get_queue_id(qa->rx) + - netdev_rxq_get_queue_id(qb->rx); + } } - return 1; }