From patchwork Mon Dec 18 15:26:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Ledford X-Patchwork-Id: 10120159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2AD3B6057F for ; Mon, 18 Dec 2017 15:27:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D82828508 for ; Mon, 18 Dec 2017 15:27:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 124EC28DC1; Mon, 18 Dec 2017 15:27:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85D052853A for ; Mon, 18 Dec 2017 15:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933079AbdLRP06 (ORCPT ); Mon, 18 Dec 2017 10:26:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48168 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933068AbdLRP06 (ORCPT ); Mon, 18 Dec 2017 10:26:58 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0718F128A for ; Mon, 18 Dec 2017 15:26:58 +0000 (UTC) Received: from haswell-e.nc.xsintricity.com (ovpn-124-254.rdu2.redhat.com [10.10.124.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E7B77F780; Mon, 18 Dec 2017 15:26:57 +0000 (UTC) From: Doug Ledford To: linux-rdma@vger.kernel.org Cc: Doug Ledford Subject: [PATCH 2/4] Move num-threads and cpu-affinity to common opts Date: Mon, 18 Dec 2017 10:26:44 -0500 Message-Id: <7013670ca1d67055599a3c61fcc0e545cc0a4f5c.1513609601.git.dledford@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 18 Dec 2017 15:26:58 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The option settings are split into common, server, client (which is really client common), and client mode specific settings. Move the two listed options to the common settings. This does not make the options *work* for clients yet, just makes them accepted for clients. With the exception of changing the help comment for num-threads, this made no other change except to move the code location. Signed-off-by: Doug Ledford --- src/SockPerf.cpp | 90 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/src/SockPerf.cpp b/src/SockPerf.cpp index a7bc55e6bbc8..7f8d6969e645 100644 --- a/src/SockPerf.cpp +++ b/src/SockPerf.cpp @@ -169,6 +169,14 @@ static const AOPT_DESC common_opt_desc[] = 'f', AOPT_ARG, aopt_set_literal( 'f' ), aopt_set_string( "file" ), "Read multiple ip+port combinations from file (will use IO muxer '-F' such as epoll, poll or select)" }, + { + OPT_THREADS_NUM, AOPT_ARG, aopt_set_literal( 0 ), aopt_set_string( "threads-num" ), + "Run threads to process sockets (requires '-f' option)." + }, + { + OPT_THREADS_AFFINITY, AOPT_ARG, aopt_set_literal( 0 ), aopt_set_string( "cpu-affinity" ), + "Set threads affinity to the given core ids in list format (see: cat /proc/cpuinfo)." + }, { 'F', AOPT_ARG, aopt_set_literal( 'F' ), aopt_set_string( "iomux-type" ), #ifdef WIN32 @@ -1421,14 +1429,6 @@ static int proc_mode_server( int id, int argc, const char **argv ) "Run in Bridge mode." }, */ - { - OPT_THREADS_NUM, AOPT_ARG, aopt_set_literal( 0 ), aopt_set_string( "threads-num" ), - "Run threads on server side (requires '-f' option)." - }, - { - OPT_THREADS_AFFINITY, AOPT_ARG, aopt_set_literal( 0 ), aopt_set_string( "cpu-affinity" ), - "Set threads affinity to the given core ids in list format (see: cat /proc/cpuinfo)." - }, #ifndef WIN32 { OPT_VMARXFILTERCB, AOPT_NOARG, aopt_set_literal( 0 ), aopt_set_string( "vmarxfiltercb" ), @@ -1493,43 +1493,6 @@ static int proc_mode_server( int id, int argc, const char **argv ) s_user_params.mode = MODE_BRIDGE; p_addr->sin_port = htons(5001); /*iperf's default port*/ } - - if ( !rc && aopt_check(server_obj, OPT_THREADS_NUM) ) { - if (aopt_check(common_obj, 'f')) { - const char* optarg = aopt_value(server_obj, OPT_THREADS_NUM); - if (optarg) { - s_user_params.mthread = 1; - errno = 0; - int threads_num = strtol(optarg, NULL, 0); - if (errno != 0 || threads_num <= 0) { - log_msg("'-%d' Invalid threads number: %s", OPT_THREADS_NUM, optarg); - rc = SOCKPERF_ERR_BAD_ARGUMENT; - } - else { - s_user_params.threads_num = threads_num; - } - } - else { - log_msg("'-%d' Invalid value", OPT_THREADS_NUM); - rc = SOCKPERF_ERR_BAD_ARGUMENT; - } - } - else { - log_msg("--threads-num must be used with feed file (option '-f')"); - rc = SOCKPERF_ERR_BAD_ARGUMENT; - } - } - - if ( !rc && aopt_check(server_obj, OPT_THREADS_AFFINITY) ) { - const char* optarg = aopt_value(server_obj, OPT_THREADS_AFFINITY); - if (optarg) { - strcpy(s_user_params.threads_affinity, optarg); - } - else { - log_msg("'-%d' Invalid threads affinity", OPT_THREADS_AFFINITY); - rc = SOCKPERF_ERR_BAD_ARGUMENT; - } - } #ifndef WIN32 if ( !rc && aopt_check(server_obj, OPT_VMARXFILTERCB) ) { s_user_params.is_vmarxfiltercb = true; @@ -1691,6 +1654,43 @@ static int parse_common_opt( const AOPT_OBJECT *common_obj ) } } + if ( !rc && aopt_check(common_obj, OPT_THREADS_NUM) ) { + if (aopt_check(common_obj, 'f')) { + const char* optarg = aopt_value(common_obj, OPT_THREADS_NUM); + if (optarg) { + s_user_params.mthread = 1; + errno = 0; + int threads_num = strtol(optarg, NULL, 0); + if (errno != 0 || threads_num <= 0) { + log_msg("'-%d' Invalid threads number: %s", OPT_THREADS_NUM, optarg); + rc = SOCKPERF_ERR_BAD_ARGUMENT; + } + else { + s_user_params.threads_num = threads_num; + } + } + else { + log_msg("'-%d' Invalid value", OPT_THREADS_NUM); + rc = SOCKPERF_ERR_BAD_ARGUMENT; + } + } + else { + log_msg("--threads-num must be used with feed file (option '-f')"); + rc = SOCKPERF_ERR_BAD_ARGUMENT; + } + } + + if ( !rc && aopt_check(common_obj, OPT_THREADS_AFFINITY) ) { + const char* optarg = aopt_value(common_obj, OPT_THREADS_AFFINITY); + if (optarg) { + strcpy(s_user_params.threads_affinity, optarg); + } + else { + log_msg("'-%d' Invalid threads affinity", OPT_THREADS_AFFINITY); + rc = SOCKPERF_ERR_BAD_ARGUMENT; + } + } + if ( !rc && aopt_check(common_obj, 'F') ) { if (aopt_check(common_obj, 'f')) { const char* optarg = aopt_value(common_obj, 'F');