From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 9CCD0A0C4E;
	Tue,  2 Nov 2021 17:47:52 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 30ECC4069F;
	Tue,  2 Nov 2021 17:47:52 +0100 (CET)
Received: from mga03.intel.com (mga03.intel.com [134.134.136.65])
 by mails.dpdk.org (Postfix) with ESMTP id 71F3F40689
 for <dev@dpdk.org>; Tue,  2 Nov 2021 17:47:50 +0100 (CET)
X-IronPort-AV: E=McAfee;i="6200,9189,10156"; a="231270768"
X-IronPort-AV: E=Sophos;i="5.87,203,1631602800"; d="scan'208";a="231270768"
Received: from fmsmga007.fm.intel.com ([10.253.24.52])
 by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 02 Nov 2021 09:47:49 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.87,203,1631602800"; d="scan'208";a="497260079"
Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14])
 by fmsmga007.fm.intel.com with ESMTP; 02 Nov 2021 09:47:48 -0700
Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by
 ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2242.12; Tue, 2 Nov 2021 09:47:48 -0700
Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by
 ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2242.12; Tue, 2 Nov 2021 09:47:48 -0700
Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by
 orsmsx608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2242.12 via Frontend Transport; Tue, 2 Nov 2021 09:47:48 -0700
Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.172)
 by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.1.2242.12; Tue, 2 Nov 2021 09:47:47 -0700
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=ZYh/7RtWg2x8BBtTOEXTL+MamDep60JcQ9KTL1YP4IZHmpZgtcs5u49laYmyjCnxTeeBlfDljzOc//PUIPQ7veS0NsKqUsJE4/dRkcEBvMTyEnJ9Eo5W+4UQvVp1zRFgVa78JxFbzRbz91muSCgg4mXAd+jpvPQGFnp0YrT2VQivbc56ZoIGA3Km8xLZ67C4LSRkdFvAH2H4Q1KiJDyyWv3J0y1HCj2IqggdiPlHFeeTaZ7r99X4LPfr4+nSsCuPdAPAbC/92cYhOzeb/2x96XBjv/98fgyuWiMcQmln6SeeGPVTcOsVw5VtgCJHPm7b0Xz63s4RgHflEFp9b9UD7Q==
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=2YzKYBJP1NwnqkhSR3mE/6Lot8mG+FR1TAc+aEX8GzQ=;
 b=Ur6McIhnsaKgPMHjgCvbFDR9KSO92Mvihs60YdzELJwcw/s4eVGtTyM6Kc+mXJ5D5Nj3SNEQluXv3LTJi96AMeEw3xYz4NefseX3Yg79Oxg+udkEx+XwECQlmFVh+f+tEK7cXoz8wZtI3i3HCt6V+yunxnygszjVaLdcXrEcGyjKql6Ds591m9nESUosrh3b3Tj1cfBebbmkTm/MD6EBqswTX908pJp56dmQmtltVx159vHkO0v/tPAiIYLTBsQtQrqTzWPHtLmEnUVlEVrB7yn7ZCNFb2Oe7dbQ5x926cykG2M3UR4/1qkMR45sNFFBq+PR8l07Y3agdj77/yERlg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com;
 dkim=pass header.d=intel.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; 
 s=selector2-intel-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=2YzKYBJP1NwnqkhSR3mE/6Lot8mG+FR1TAc+aEX8GzQ=;
 b=zhuRBGHSdZ8Rkvp9uVid7cOKyB6y7JTWxfxTXJZZGkvnvr0qiBr7hfcEk8b3430AdDCur3F/iQ2IgVDJYxIg5VdBebTCkStDm9SQcWHSc/Yp9DNrtcAaa4CGYI0DEFEWZWhGD9/rX6urROZJ6l6HXSU/LU5whmrXcdOIajawTaU=
Authentication-Results: gmail.com; dkim=none (message not signed)
 header.d=none;gmail.com; dmarc=none action=none header.from=intel.com;
Received: from PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19)
 by PH7PR11MB5861.namprd11.prod.outlook.com (2603:10b6:510:133::8)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Tue, 2 Nov
 2021 16:47:46 +0000
Received: from PH0PR11MB5000.namprd11.prod.outlook.com
 ([fe80::bd7d:29be:3342:632c]) by PH0PR11MB5000.namprd11.prod.outlook.com
 ([fe80::bd7d:29be:3342:632c%5]) with mapi id 15.20.4649.020; Tue, 2 Nov 2021
 16:47:46 +0000
Message-ID: <ddcd5b98-3515-321c-490b-572ddb408803@intel.com>
Date: Tue, 2 Nov 2021 16:47:40 +0000
Content-Language: en-US
To: Tudor Cornea <tudor.cornea@gmail.com>
CC: <linville@tuxdriver.com>, <thomas@monjalon.net>,
 <pogonarumihai@gmail.com>, <dev@dpdk.org>
References: <1631540746-38443-1-git-send-email-tudor.cornea@gmail.com>
 <1635868044-69456-1-git-send-email-tudor.cornea@gmail.com>
From: Ferruh Yigit <ferruh.yigit@intel.com>
X-User: ferruhy
In-Reply-To: <1635868044-69456-1-git-send-email-tudor.cornea@gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-ClientProxiedBy: DB6PR0501CA0003.eurprd05.prod.outlook.com
 (2603:10a6:4:8f::13) To PH0PR11MB5000.namprd11.prod.outlook.com
 (2603:10b6:510:41::19)
MIME-Version: 1.0
Received: from [192.168.0.206] (37.228.236.146) by
 DB6PR0501CA0003.eurprd05.prod.outlook.com (2603:10a6:4:8f::13) with Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.4649.15 via Frontend Transport; Tue, 2 Nov 2021 16:47:45 +0000
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: b3d26f5a-529c-459f-95a2-08d99e207f71
X-MS-TrafficTypeDiagnostic: PH7PR11MB5861:
X-Microsoft-Antispam-PRVS: <PH7PR11MB586110C68533DE8C5475A964958B9@PH7PR11MB5861.namprd11.prod.outlook.com>
X-MS-Oob-TLC-OOBClassifiers: OLM:9508;
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: 9ywJABjF1POmjpPQhz9GcGgPfhJe+zEz3jk41rKiskBCuIFccAx6bZC0bKqIQ8363+HG73E0CKJ6HeYbkIQwPA2is17P8p7mrzJDGKkqEfU46pwgyhDp1xMzI7VvCPFjUnOYedHUFfXH4wt+OLCvyj5eGVAg5baFQFBC/KkxlK2DVdqoQusrWDSN2RKk0b3tUEnjZvuwMaTuZV37KOAawFquaHLZGq3ZwcRgNRYAt97wIUATl5wIB81PNXbE/xKJIhsOVSWhwy+8kTI3TQs4gFQtifF4w2sRwdm6Q4X3NXPoeil7kugWes0AXK7GLABOlVCGo0ZEJlwBFihpY4xzhbxqm9GhIuImivl+Ftnq72/1UDYizouxuzEmQKHdPqquxQCbXBaXthWqPFPNEIPBBpTGShECUqP+gBT6FN2/kXyRH6i3IwTB8Ps035PQ8cPeJL0eoEQrTkEZ2IezNqLrgmYIdN32UVhI1yvrsvvGERSQO0wKWVuSLqe65LvbgvzPuZ0BQlKGujPIR0W6+sMmkINz2lX+hjo2ttVo0RbJqH3spOsH7v8hoybDbjfKIvjZ772M4ZMtDlNBugv6MLQlSDzApqhpSakTW7jZ7+8dycivDu79l0kUEczmByTEM+aqloO/A6F1b+hA/0ceyjfDlbRf3qOPMqgJsv51oRTOffb3YnU5JP6ePAhZIxmAJCo7j6RFQ4V/DvMaARvJt8Hrb/VujTm4PbRePxEAb8y5HkPgQd7cnMIDV3i5AJMvGQK0ncnkQU9o21xhK6N+QZuK8fUThWjnxgj1M/FJYUH2ZwE=
X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:PH0PR11MB5000.namprd11.prod.outlook.com; PTR:; CAT:NONE;
 SFS:(366004)(66556008)(66476007)(66946007)(53546011)(26005)(82960400001)(508600001)(31686004)(4326008)(6916009)(44832011)(8936002)(966005)(31696002)(8676002)(5660300002)(186003)(86362001)(38100700002)(2906002)(6666004)(6486002)(16576012)(83380400001)(36756003)(316002)(2616005)(956004)(45980500001);
 DIR:OUT; SFP:1102; 
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MGdIYllhcE1kL0VndXFtZEN4T1FRclhVTWQ3L3AvMitUNytHWDhCOStzTE1q?=
 =?utf-8?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8?B?aHhObnV6V3JrdVovOXFZSVQ3OWNKZW0wdUpVbU1LR2pWUFNtdU1kREJrdmdK?=
 =?utf-8?B?QlpUQnJML3pxcUFXOTdPZjFpK2VxRTNqaVZabE9NZUIycC9wYkp5MjRjRzUw?=
 =?utf-8?B?REI5U25tQVp5U0wvQVk1VjFzSEFadk54TmlwdU81NGo5OUgzSFBZdFBVMFVI?=
 =?utf-8?B?R3FvRExNaWdrVEd5YkVzSmJNdTM0VHBaVkdCTmlydlU4TS9JbnExQ2NHZGsv?=
 =?utf-8?B?ZERGeGpFR2p4U0o5NHVNS3pUandldkpmaGw1RzJsSjJNeis0NytEY2ZlYUY4?=
 =?utf-8?B?aGJ0dDlYZURSMWRkNlVENXU1NXl6QVdlZjJCazlGTE1Sc3c5bDdiV0tpd0Vq?=
 =?utf-8?Q?mgDuVyMsMNHclZkeygKZ85w=3D?=
X-MS-Exchange-CrossTenant-Network-Message-Id: b3d26f5a-529c-459f-95a2-08d99e207f71
X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5000.namprd11.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2021 16:47:46.6277 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: 5u/Bn1ikVQmGtweam4TXihpsBrvetiqU62Busxz12PhbTvTC/Tzc3vR62c+2OyCyM53VUe72bPTyBt9SZ85uWQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB5861
X-OriginatorOrg: intel.com
Subject: Re: [dpdk-dev] [PATCH v3] net/af_packet: fix ignoring full ring on
 tx
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

On 11/2/2021 3:47 PM, Tudor Cornea wrote:
> The poll call can return POLLERR which is ignored, or it can return
> POLLOUT, even if there are no free frames in the mmap-ed area.
> 
> We can account for both of these cases by re-checking if the next
> frame is empty before writing into it.
> 
> We have attempted to reproduce this issue with pktgen-dpdk, using the
> following configuration.
> 
> pktgen -l 1-4 -n 4 --proc-type=primary --no-pci --no-telemetry \
>      --no-huge -m 512 \
>      --vdev=net_af_packet0,iface=eth1,blocksz=16384,framesz=8192, \
>      framecnt=2048,qpairs=1,qdisc_bypass=0 \
>      -- \
>      -P \
>      -T \
>      -m "3.0" \
>      -f themes/black-yellow.theme
> 
> We configure a low tx rate (~ 335 packets / second) and a small
> packet size, of about 300 Bytes from the pktgen CLI.
> 
> set 0 size 300
> set 0 rate 0.008
> set 0 burst 1
> start 0
> 
> After bringing the interface down, and up again, we seem to arrive
> in a state in which the tx rate is inconsistent, and does not recover.
> 
> ifconfig eth1 down; sleep 7; ifconfig eth1 up
> 
> [1] http://code.dpdk.org/pktgen-dpdk/pktgen-20.11.2/source/INSTALL.md
> 
> Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
> Signed-off-by: Tudor Cornea <tudor.cornea@gmail.com>
> 
> ---
> v2:
> * Added check for POLLERR
> * Used tx_ring_status_available() for checking TP_STATUS_AVAILABLE
> ---
>   drivers/net/af_packet/rte_eth_af_packet.c | 26 ++++++++++++++++++++++++--
>   1 file changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
> index 559f5a0..d3d3104 100644
> --- a/drivers/net/af_packet/rte_eth_af_packet.c
> +++ b/drivers/net/af_packet/rte_eth_af_packet.c
> @@ -237,8 +237,30 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
>   		}
>   
>   		/* point at the next incoming frame */
> -		if (!tx_ring_status_available(ppd->tp_status) &&
> -		    poll(&pfd, 1, -1) < 0)
> +		if (!tx_ring_status_available(ppd->tp_status)) {
> +			if (poll(&pfd, 1, -1) < 0)
> +				break;
> +			if (pfd.revents & POLLERR)
> +				break;
> +		}
> +
> +		/*
> +		 * Poll can return POLLERR if the interface is down
> +		 *

Above comment fits better to above check, or can remove it completely.
Can you send a new version, or I can remove it while merging if you prefer?

Except from above comment,
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

> +		 * It will almost always return POLLOUT, even if there
> +		 * are no extra buffers available
> +		 *
> +		 * This happens, because packet_poll() calls datagram_poll()
> +		 * which checks the space left in the socket buffer and,
> +		 * in the case of packet_mmap, the default socket buffer length
> +		 * doesn't match the requested size for the tx_ring.
> +		 * As such, there is almost always space left in socket buffer,
> +		 * which doesn't seem to be correlated to the requested size
> +		 * for the tx_ring in packet_mmap.
> +		 *
> +		 * This results in poll() returning POLLOUT.
> +		 */
> +		if (!tx_ring_status_available(ppd->tp_status))
>   			break;
>   
>   		/* copy the tx frame data */
>