From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3F78FA0093; Thu, 10 Mar 2022 00:42:39 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BBEB140687; Thu, 10 Mar 2022 00:42:38 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2047.outbound.protection.outlook.com [40.107.237.47]) by mails.dpdk.org (Postfix) with ESMTP id 4BCFB4067C; Thu, 10 Mar 2022 00:42:37 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CRg24k2DYhFSlMIAF6pXs9Xp1AJWN3d6SILy5BUzpRz4BeGJL15O6vQL3PatkiSddGOFeRuHjmXWi2Sdgwn2bT8IX/RotFLOZNux2hUfT81z40WfG608+jhBMdWqLWD3F7j5A3nxov6NIQxvNBRZF7QAv4hNwMOOqy2ZsZ/HO1JAb/EVwA3Pxcjet+5/yY3afXqzDODiH+IrIjlFIP27B1Yr6yERuV2h26CWALDsF0DfF/HEmpH+hMVXo0+HzaVpy6m0A9BPDGbfWHwWiCcaTbhmi4NMy68v81SwLhmTFQEbZhaFnisnY+KZhLndoJJCsftYOMflT2D2xUP646+n3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=12X4SqvIfj2OczXkH0lzS74POOVzf00u1MvhCm/vuc0=; b=dxCsFuDkJkZ8/0Bnmm0ezDKrFxEpqjCH2jevONeFbeoFzwuBi9/lRH2zmC8OIjo9tnBx6C+Np6O5Q5nSVry7iL/FXIacf/TruR1mLuwacbzsYAYK92ykyy6d3oKuYZsjlgHYrJ9QTxEHG/3ngJNgOvPvS84grpA3/9PS7r0B13Eh4HzEehOA+QeB9C9PH5TGN5qIANJG0LX9DrZbyVaG3zwDh7QBKtvEweKqv+BgAxAdOaWkAKw/1S1nTMrkc7NjfKG8hmKwovNdGkk3LjX5kcumkUQn4dt3LlqWegXDLF2h2ILyscuiIojmAtcwdguvsWXev0Ujy4VdFUYSbevjZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=12X4SqvIfj2OczXkH0lzS74POOVzf00u1MvhCm/vuc0=; b=lDVmV/sRprvPcqipnxvbJa3iQN3c0IYX5o06S4hKdGNWHKgyoJ1B7B8V4rzLsq6WGkfYw/5ven+JLnVAXF30rTY36dfXP/wsSWo0v2tW+k6i6Y8S74Y6ZFckvnthwZ4y0cNVJ1iPPBg9V31qhL+95ddvSAxs8/gUbMT4ssHZUlsL9+e1iR2xjDGoc86TsCkWHkSNaHmfmzmp7oIrpJWVO5aPPPIxZq0ZEjVKD9KouDydp7wBLAU2MCd5gbU2wyPdQEkioUxqsRkCJJa+x8g4XxfzOWegf6sLgJ8eh7ywt+jCtz2Ta8tEORCs4pscwrdVZDn9T40xAicS4LgZjWNZ7g== Received: from MWHPR14CA0072.namprd14.prod.outlook.com (2603:10b6:300:81::34) by DM6PR12MB4402.namprd12.prod.outlook.com (2603:10b6:5:2a5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.29; Wed, 9 Mar 2022 23:42:34 +0000 Received: from CO1NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:300:81:cafe::61) by MWHPR14CA0072.outlook.office365.com (2603:10b6:300:81::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.20 via Frontend Transport; Wed, 9 Mar 2022 23:42:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by CO1NAM11FT056.mail.protection.outlook.com (10.13.175.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5038.14 via Frontend Transport; Wed, 9 Mar 2022 23:42:34 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 9 Mar 2022 23:42:33 +0000 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Wed, 9 Mar 2022 15:42:31 -0800 From: Gerry Gribbon To: CC: , , Subject: [PATCH] app/test-regex: fix incorrect number of matches Date: Wed, 9 Mar 2022 23:41:52 +0000 Message-ID: <20220309234152.1063100-1-ggribbon@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e3c240e8-780d-4a3c-d430-08da02267c3b X-MS-TrafficTypeDiagnostic: DM6PR12MB4402:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PvWyq51KHlyEcx/dxwD7g2G8+CHtBM5APPruLj5YoBovGov3roD5bCtsQP/wXrjnTUCGIPTjiQZ+d2hc7Ims7xzbEgICcee19AQ6ivqvA12mHRdlrMIA902zzDONcRfoljq8Py9Y/saZqE9UlUbKqiZm021R+LRdoD2Fj3hVq8l0ub8tKzq1fkcZ5D8SYEFE8ko1O+C9Fqkf9NX3P9sKVEK47eRqxwU5BpboYTQvZP1W4KnwZZOU/EshI5LKJxhEsj7mkaUu4+SVjHOPg8Bu6hb8Z3jyYOeSefWfs4/RXgeIKp/obyO3z1LyYO0PWu05Rzex9tMu4XAsF3WLcfryIN9UZnNImHWzZnS87cP7zXagcc4eq9l6UVnvmIZeUfJXyFGZHhmhP297okj9/rppcGS75UmZlMZkgnMzd4E6MnsuU2W8y3IX9Ockp5/NAufp3bApjGIp1giRYqmps4qrhLAEGfEEsLSV7T1iAzMt7f1q/BHUr3mXe9fecu/bZcTTrTMhcNPx2A3dWLimCJrA1oN7i43AGTE5hmqwQBgkNesKMeek4bZli6dxVjGZnM6O/1Lee6VbPDaPDCmENXAdGgbB+z6GEkY80eQ8w7woBggylKzFxKB7YAmZUZ2XXE16MKmqtHVHpZuFO2n1uMGLDr0S7ia84FPkIejOIT7ahgLJV8vlVNEpCE8MxfBQiE6meGpMuJjZJGai5dbPZY+Ynw== X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(4326008)(55016003)(6286002)(36860700001)(40460700003)(6862004)(426003)(186003)(336012)(2906002)(37006003)(86362001)(7696005)(54906003)(26005)(508600001)(36756003)(16526019)(316002)(47076005)(1076003)(356005)(81166007)(8936002)(2616005)(5660300002)(70586007)(450100002)(8676002)(70206006)(6636002)(83380400001)(82310400004)(6666004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2022 23:42:34.1561 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3c240e8-780d-4a3c-d430-08da02267c3b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4402 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Depending on number of jobs specified on command line, part of the data buffer may not get searched, resulting in incorrect number of matches being reported. Additional change to ensure the "All Matches" summary outputs the correct match start locations in the supplied data buffer. Fixes: de06137cb295 ("app/regex: add RegEx test application") Cc: yuvalav@mellanox.com Cc: stable@dpdk.org Signed-off-by: Gerry Gribbon Acked-by: Ori Kam --- app/test-regex/main.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/app/test-regex/main.c b/app/test-regex/main.c index ab8a3e56e7..7c014b2210 100644 --- a/app/test-regex/main.c +++ b/app/test-regex/main.c @@ -382,10 +382,13 @@ run_regex(void *args) char *data_buf = rgxc->data_buf; long data_len = rgxc->data_len; long job_len = rgxc->job_len; - + long remainder; + long act_job_len = 0; + bool last_job = false; char *buf = NULL; uint32_t actual_jobs = 0; uint32_t i; + uint32_t job_id; uint16_t qp_id; uint16_t dev_id = 0; uint8_t nb_matches; @@ -456,9 +459,16 @@ run_regex(void *args) /* Assign each mbuf with the data to handle. */ actual_jobs = 0; pos = 0; + remainder = data_len % nb_jobs; + /* Allocate the jobs and assign each job with an mbuf. */ for (i = 0; (pos < data_len) && (i < nb_jobs) ; i++) { - long act_job_len = RTE_MIN(job_len, data_len - pos); + act_job_len = RTE_MIN(job_len, data_len - pos); + + if (i == (nb_jobs - 1)) { + last_job = true; + act_job_len += remainder; + } ops[i] = rte_malloc(NULL, sizeof(*ops[0]) + nb_max_matches * @@ -478,7 +488,12 @@ run_regex(void *args) if (ops[i]->mbuf) { rte_pktmbuf_attach_extbuf(ops[i]->mbuf, &buf[pos], 0, act_job_len, &shinfo); - ops[i]->mbuf->data_len = job_len; + + if (!last_job) + ops[i]->mbuf->data_len = job_len; + else + ops[i]->mbuf->data_len = act_job_len; + ops[i]->mbuf->pkt_len = act_job_len; } } @@ -506,6 +521,9 @@ run_regex(void *args) qp = &qps[qp_id]; qp->total_enqueue = 0; qp->total_dequeue = 0; + /* Re-set user id after dequeue to match data in mbuf. */ + for (job_id = 0 ; job_id < nb_jobs; job_id++) + qp->ops[job_id]->user_id = job_id; } do { update = false; @@ -551,10 +569,10 @@ run_regex(void *args) for (qp_id = 0; qp_id < nb_qps; qp_id++) { qp = &qps[qp_id]; time = (long double)qp->cycles / rte_get_timer_hz(); - printf("Core=%u QP=%u Job=%ld Bytes Time=%Lf sec Perf=%Lf " + printf("Core=%u QP=%u Job=%ld Bytes Last Job=%ld Bytes Time=%Lf sec Perf=%Lf " "Gbps\n", rte_lcore_id(), qp_id + qp_id_base, - job_len, time, - (((double)actual_jobs * job_len * nb_iterations * 8) + job_len, act_job_len, time, + (((double)data_len * nb_iterations * 8) / time) / 1000000000.0); } @@ -587,10 +605,10 @@ run_regex(void *args) qp->total_matches += nb_matches; match = qp->ops[d_ind % actual_jobs]->matches; for (i = 0; i < nb_matches; i++) { - printf("start = %ld, len = %d, rule = %d\n", - match->start_offset + - d_ind * job_len, - match->len, match->rule_id); + printf("start = %d, len = %d, rule = %d\n", + match->start_offset + + (int)(qp->ops[d_ind % actual_jobs]->user_id * job_len), + match->len, match->rule_id); match++; } } -- 2.25.1