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 22A0BA034C; Mon, 28 Mar 2022 12:07:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B5B82427EA; Mon, 28 Mar 2022 12:07:02 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id E3BB041104 for ; Mon, 28 Mar 2022 12:07:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648462021; x=1679998021; h=message-id:date:subject:to:references:from:in-reply-to: content-transfer-encoding:mime-version; bh=ztY71Bdg/18iMX+v309KooNOyMuz09p9/pJvYzHssuI=; b=isTh2oq6SxmJpxZjwD+BORxhdkCGAmQl3EpvhV+EHbLw4n0Y7P+XJZxG 0ym+jvYrQZqS2hbJ/Og4VbUsaDuv+q/vIAdbNrglBMg4w0Y1XKUhDL25H gxVWoElcAPdDzpW6jcVksfpa+QaVO3/NouDTzs5Brvfi3wZB3rti+weqY NIyZXDj115QBBmCqTJ8EOl82JQw51exdfpt06F/u9R9nAEWRgiramj3i6 swC/GJ/FtYZj3k+Kh0Jy2UEbHlB8Rnn7ZCqqTEwalSaTnxsksQnZ2St5V eI2cAMc9XgfUAzZmA6Dv/2sBNg53jSqJwNnY/c0HO/WUyrMb8SQgjk+Cn g==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="322147732" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="322147732" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 03:06:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="651894046" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by orsmga004.jf.intel.com with ESMTP; 28 Mar 2022 03:06:59 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Mon, 28 Mar 2022 03:06:59 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Mon, 28 Mar 2022 03:06:58 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Mon, 28 Mar 2022 03:06:59 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.42) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.21; Mon, 28 Mar 2022 03:06:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DjiB4tySZFicplqFfHvVGuoZrBCl5gzxMTrV6p6szrKoWCM7ZBmX04/pIEibVWedQMpj8Z6A7sIpaTG0oacyflZ40ixzJ7mW01JzNLkrT9VWESv4W6P30aX17R5RoTL3RjnDrjpBHFjha3P6oXJfmrt9O7TCHlji13kUIMSRKUXwskTW0PXpATE+6j7fxaOhrznQHu79b5LurayFd5qCQCT8GXOyun8baTrT09h8U8ohEJ2LyaFh0uOuLFNgaq5EDnPc9BvSETtjZriqvIBeAFE2TRmoVPPMveLZITE3nXSLccfubHliBAeLAF/ci9eHD2SVlw2/cINm9a1Z01Lwog== 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=IzZe7Is6gN58l7f/0mmHIZAwPgCGnqnqPfRevtvz4Z0=; b=Dyo8knZr9RxtvmumGsHnoHts+HGf9ZOXdCYRzpv1Z1lLvR4+osc/NAa+2zS03FqYE6SgyxIEVFiXCyJ9nGuT+51qZiWNuszMnspB5O5hJ4No8eFv7BheY5F/w4Ln8Mjjsf/0I43BLz1ITLrkRuH4FDfehLUGSUSDO9Y+ZSaYNdxTSmTS24b2f4zkRgVc+CHRKtOofyQ0gtwgYJOFlgrettDVqemDAp/X4501+XD2rSsXdb7R5zLpeDlz0P3CBY4+E7U2WRaQAM9d4PQ/HSCFXhQgI3p9QNUoEUMpMuWwblIno464m6/dvqpKLBgaVriI6IY0IjkjAJ9oaOAnBvza4w== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MWHPR11MB0062.namprd11.prod.outlook.com (2603:10b6:301:67::34) by BN6PR11MB0001.namprd11.prod.outlook.com (2603:10b6:405:69::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.16; Mon, 28 Mar 2022 10:06:35 +0000 Received: from MWHPR11MB0062.namprd11.prod.outlook.com ([fe80::bcb3:2b8:38c7:1567]) by MWHPR11MB0062.namprd11.prod.outlook.com ([fe80::bcb3:2b8:38c7:1567%3]) with mapi id 15.20.5102.023; Mon, 28 Mar 2022 10:06:35 +0000 Message-ID: Date: Mon, 28 Mar 2022 15:36:25 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] app/testpmd: fix quit testpmd with vfs and pf Content-Language: en-US To: Ke Zhang , , , References: <20220322071833.199619-1-ke1x.zhang@intel.com> From: "Singh, Aman Deep" In-Reply-To: <20220322071833.199619-1-ke1x.zhang@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PN2PR01CA0147.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:6::32) To MWHPR11MB0062.namprd11.prod.outlook.com (2603:10b6:301:67::34) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9a09abff-2412-4f84-9de5-08da10a2a42e X-MS-TrafficTypeDiagnostic: BN6PR11MB0001: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: fzEokU2U03Gfchw28gCs3YsFysH+m6UKxfASqnaI4S4aWgN/IN2gpUcP3Ive5Ptieum5IvKXZw2hV6nKxpFsCo0LbG6oPbOzYL9fT5a5NtNivpLBUqdKL/o9+B/9BeXJZ6k2vV0pmJl+2fTYzi3Sfgbj/vX7RCWpCz6IRm1Si0WOliy1g32myKwiWn/x5SHCLsf3HSrY+NDGmpgZzC4WJSpquprciPa97ZV8T5MWXuHGcid3le61I+Sfz2JIpzO/LcT+9TI6nK1ygjpz2fOcaS0prEsV3euntQkwSeSe3Ui645Bk4HBWYp0+fZeyILTqS5i1Ot8XBFocrkw7+MC/CfFIfjVSyJxvY+SZ3DvBKr6xbE+YX8Ebxse0ab88F9YSE64yv6j8hthv3HNsWdsACP8v+f+0mLSRH169OeTFZUuxATx393mpU73BFc4ucFFG0gYDBJrg+LjeKxqSiU64Elb61R9ANW9cXjNroyo9lUNRSaqxb2qoIJ7cypBB90F06W3u3+c//RT1Njv53k6OHFfZQzITx3fLqy2aT6g6uZXPMc3IB9hDiQjQkjDUGslRUPtEGGFDVusz3N5HHxgTmht7JyQN9s7uVNDS14U2KNsJ3o6bBzGO79GjezmQMHC1xWff/QAup/0GpTk/6c6GO8WjHSc2EHKOWR/qqBbtTwLcrBW/vGMiY3EUZ15nbWThGCuNkNiA2pojineD5jkB/ubZYdcLOjvyEgwo4uPJF6Q= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB0062.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6512007)(6506007)(6666004)(31696002)(66556008)(66476007)(53546011)(8936002)(66946007)(5660300002)(316002)(86362001)(6486002)(36756003)(8676002)(508600001)(82960400001)(31686004)(83380400001)(2906002)(38100700002)(26005)(186003)(2616005)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MUxoOUJ3VUZWQllua2xBYS9SdlJRZzJkS3JvTHlnUXpYTlRRL1QzODBjMEV0?= =?utf-8?B?SjVLeDJyRlFYc3NabloyZzZManZHWjE2L1dKditwREZlS1ovRWZ4UTFBa1RG?= =?utf-8?B?ZHpONE1zVGFWYnUwREt5NkF5N1ZnQTJMUVJ0SEF6OEI0REVjR1J3azIvczNS?= =?utf-8?B?OVFMeFVNbHpqNVhTMW1QN1Y5MmhRRlRYQ2hyN0ZvWnN5RW50VFBxNUxLSDFS?= =?utf-8?B?QUJFcjVYdnpUaG8rUXVCWTlzSmpZSmVGSFdpODlOenQ2d3JmZ2dFK2tyT0Nh?= =?utf-8?B?N2t4aTRuTUJGVlh2ZmtPMjRqd3lmUUdrem04ZWh3STNpbWRoVmtVcGxKY05H?= =?utf-8?B?SERZWXpZd2M1N2hsZHJWZ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=?utf-8?B?a1ZHbHByaHhzWWg0K3p1MHNHOXZ0d2tvTEdqYzF6ZU9xc0pjVENGekxxMjBW?= =?utf-8?B?azU3dmVBQmIzZTBtalpSb0l3WG9MZ0JwQUV3Z2F4bWJxbTBSQ3hTQUREV1ND?= =?utf-8?B?bFRBVkZQaUx4RjgxVFdNNHlXWmxKcmIzNlM0dWZZRHNzSDZaTVhJQ3M3UkFq?= =?utf-8?Q?Y4zszw735xU+4SKw=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 9a09abff-2412-4f84-9de5-08da10a2a42e X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB0062.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2022 10:06:35.5673 (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: EiASjY0Cnwt7XXSQrAT3Na8+OdGXJJkN9U1d1UqphFT8xyCAPz7ner+eEKnNo9DkCL8OefSU14uuDrpN2FToubAW42qE0vRt4MYcAlsd3A4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB0001 X-OriginatorOrg: intel.com 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 On 3/22/2022 12:48 PM, Ke Zhang wrote: > When testpmd startups with pf and vfs,this error occurs when quitting, > results in pf is released before vfs ,so the vf would access an > freed heap memory. > > The solution is two steps: > 1. Fetch the valid port value from RTE_ETH_FOREACH_DEV. > 2. free the port in reverse order. > > Signed-off-by: Ke Zhang > --- This fix looks similar to series: 21823. Please check Ferruh's comments on it. There is a scenario, where this fix may not work. "if there is an earlier port id which is released, after that new vf is created taking that port id. In such case port id of vf < pf port id" This patch covers most of the cases and that way its an improvement. So I am ok with it. Acked-by: Aman Singh > app/test-pmd/testpmd.c | 28 +++++++++++++++++++++++----- > 1 file changed, 23 insertions(+), 5 deletions(-) > > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c > index f7e18aee25..ca6c77b14b 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -3378,8 +3378,11 @@ detach_devargs(char *identifier) > void > pmd_test_exit(void) > { > + unsigned int ports[RTE_MAX_ETHPORTS]; > + unsigned int count = 0; > portid_t pt_id; > unsigned int i; > + int index; > int ret; > > if (test_done == 0) > @@ -3396,15 +3399,30 @@ pmd_test_exit(void) > #endif > if (ports != NULL) { > no_link_check = 1; > + i = 0; > + > + /* Fetch the valid port id from port list*/ > RTE_ETH_FOREACH_DEV(pt_id) { > - printf("\nStopping port %d...\n", pt_id); > + ports[i] = pt_id; > + i++; > + } > + > + count = i; > + /* > + * Free the port from Reverse order, as general, > + * PF port < VF port, VF should be free before PF > + * be free. > + */ > + for (index = count - 1 ; index >= 0 ; index--) { > + printf("\nStopping port %d...\n", ports[index]); > fflush(stdout); > - stop_port(pt_id); > + stop_port(ports[index]); > } > - RTE_ETH_FOREACH_DEV(pt_id) { > - printf("\nShutting down port %d...\n", pt_id); > + > + for (index = count - 1 ; index >= 0 ; index--) { > + printf("\nShutting down port %d...\n", ports[index]); > fflush(stdout); > - close_port(pt_id); > + close_port(ports[index]); > } > } >