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 90815A0501; Thu, 31 Mar 2022 10:29:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 33422410FA; Thu, 31 Mar 2022 10:29:10 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 8945540DF6 for ; Thu, 31 Mar 2022 10:29:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648715347; x=1680251347; h=message-id:date:subject:from:to:references:in-reply-to: content-transfer-encoding:mime-version; bh=mO1tEXr0pWzgxK5yGL+5ThldMEdnEcHi4EJTSt7EprM=; b=nwKs7LXrhqbP46sI+5vimmJRIClEPNaK7ZhK//c18bFuuo5i8J270bWG ae6GkvkQCOfEZT5JObdVSWLWx9BtkB7aeQFt5n60TTFzuy5MYF2Y9kPWj uvFfRQ5qmhhM9XEmm2qPlnMjHYXg++TeygzBi1HonRHvTNsylXDc6dPIW GmRu/vabLbcMRzXnYTXjlEwLxRotNXzry3N2P1cUOS+gYlb4TZvK2ey8o j+M5tVviUSP+OSbm5MoaK82v/p7IC+ExJrkIjaif5T0gynZkEd4lkcpG/ zX4ydjqz9L1sBiyDckS9yLmzgcOcL+jWfUQP5Bxypz2GXWqjQMCoczhbq Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10302"; a="284671419" X-IronPort-AV: E=Sophos;i="5.90,224,1643702400"; d="scan'208";a="284671419" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 01:29:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,224,1643702400"; d="scan'208";a="720355215" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga005.jf.intel.com with ESMTP; 31 Mar 2022 01:29:05 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 31 Mar 2022 01:29:05 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 31 Mar 2022 01:29:05 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Thu, 31 Mar 2022 01:29:05 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.100) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Thu, 31 Mar 2022 01:29:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m2lfuO06/vsA4nlYFVTY1exjNWp6/breR+Nrh7vWwds8CFMGE9rbqpznTgFbrMf/tLDSAvQxlojqNKWFqk2NwvKEkf/0TF0eflcIZ4oD9cbHUGm76f5MuRBPeYunD3NKnxKBLGWuPJcNIn4n7UGCNhoFgTeherbY0DJk5ZSLpOE5Hx9FiqoiM/SvETgSCKwfVJf7gGwedfFFLmX8K07NR94w6/9VZK9ocu2XNFrLH0iGL1FFRQeb7byu9lJUjekMXO+FvY0xIiEFCws9R/Mfi5Zj9B+zV88jHK/R5RB3h6BEegwYhTRbM7KXjFAZpP20/7zHWlx4p96sQgnRNWu8XQ== 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=BPdmvtr9T2ZXy4BL84VfifGIyEr8bL6t4eqwcvE8nZ8=; b=gRIPulDAcW7sUXEFfA2knHCGHcLbNKhz0YQhQnorGbeItaFWft4co5ujSgEhSUiBqK8SdyTw93ZkQgf/5Kv0h+doeFydB6ZYu1yqdqTDIv89ZxtkDjGgLPtMtOcIr5gQ+Z3I5HQsnsfdkhtPFYiQF2Y8BPHXkvo7jZ1xKG3ZvOTKTX9iVQfb/5oGkNBWnMkTjcccczfoJC2aVaSQRS1mOq5c0reRKMjTVXwFH9JdIr0rR3B0iWRMDUS41uJ4cnBZCJVLiHmpwvigY3p445hACiTShlBQqaHNSfCM7QRHZWtnGjbPD0K29PVz8usEpAf9Isau6klqv6puH1405MpmKw== 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 CH2PR11MB4325.namprd11.prod.outlook.com (2603:10b6:610:3e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.20; Thu, 31 Mar 2022 08:29:02 +0000 Received: from MWHPR11MB0062.namprd11.prod.outlook.com ([fe80::c3c:359:d9c4:3a54]) by MWHPR11MB0062.namprd11.prod.outlook.com ([fe80::c3c:359:d9c4:3a54%4]) with mapi id 15.20.5123.021; Thu, 31 Mar 2022 08:29:02 +0000 Message-ID: <12ad7362-9fc1-ad7d-2f43-cea020e1f8bb@intel.com> Date: Thu, 31 Mar 2022 13:58:54 +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 From: "Singh, Aman Deep" To: References: <20220322071833.199619-1-ke1x.zhang@intel.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: BM1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1a::19) 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: 046dabe7-90eb-4446-b985-08da12f082fb X-MS-TrafficTypeDiagnostic: CH2PR11MB4325: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: /gap23b+9qgOZjGykw2ESbbvBdh/zKqlPzDtyZlLwU1uPPBZY9F88Zy3d5w/Y+iFnEMPHRfGZCxBTcfb/eWnZCQxB8mtN5QgDXwGoVqnK0vnkLaL7+CftstlmZKAR2ltaj0J8oIhjcniA5hfiFa7kPnZ5swbovP0gTWpvyAgB8aDawppDebspN+v1biScxKgVpoRmc+ytgjnFt0xRgz1fk0Q/rSwfep2E/zYT80vjrcCoolEHNQrq9TpXDV/UJTFwDhTYaSv7UKunv14mPv95LpTctS/uAB5Ba+bg4cSeJPJ5mp+9jU3niSPOIIwS9MGVdubCPFXwnO/OEQi3ZlBGcPAfYNij1qhtd7sfx9b3zGP1YssyMooQW2FQnVqccgPGKAN1ENIOVes9RK/xZj2mPpKq4ubSfo7XA0myU3zbpQPe5pwUtXL4vh359X1KRX7p5lUvtyFfHgV+/3cOYcCKY3gwI1kQG5GG3B2b0nj0CQC7TKrDEzfoaePdCSASR2MP6nGm/sZIYb8bRP4Rkq/H+KJfwWUWBaayaYlwGkhU3z2I8++F+VaN69em6uooaMcgieOpXzrtJ0eaWWueYa+xdrIImwSxO6D75GJjdBabfnIyo/JfOHW0xFlOD78H4hQaVel0ScaJ1AIZ4va2Ae0kY1jLESV0QRSGRpyHeRr429HZx9gHnQH34YX64JXhlmMTyvMpM96F0ioDjRGzAItVT1U22tJVmGWOfaKJstdT/I= 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)(508600001)(316002)(38100700002)(6486002)(6916009)(2906002)(6512007)(86362001)(82960400001)(83380400001)(66946007)(66556008)(66476007)(6506007)(31686004)(8936002)(31696002)(53546011)(26005)(5660300002)(6666004)(36756003)(2616005)(186003)(8676002)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bmZvaUZpZHpTd3NiTlhuTUJ6UUpyMXBPUi93bTBoSnhydzFNMktNbGlXcEcw?= =?utf-8?B?RWN6ZE9QRzh5RGZEamIrMHRmVlBaN1JkVzFIOU4xclZJWml4WTkzV0hMZHVK?= =?utf-8?B?dXM2NWpscVdTNnR2ZzAzWC9IeEhGaDRNVEg4WkIyVGZCSXIyYUhjT3VDTDVP?= =?utf-8?B?RUE1MjV0NUQxWWRsWDhUekxXSGs3ajREbURpS0pYY2ZOeC8rbkxha1hRUkYz?= =?utf-8?B?T0dzT0JvNTg3MEdPTi9CTXZMVFUzamNvbS9Cb0QzTmczdXZLNEZIbGV6VXR4?= =?utf-8?B?OW1tTEYwNkhhZ1RiMDRzYk52Y0dwdTNkSUpERXE5UVFtVWNjcmE3cml1VDQ1?= =?utf-8?B?S28rTEMyRzZCZ29V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MFIyOTdTSXVM?= =?utf-8?B?S2wxMnNTYnllZUJPdk5nWEQ3NUltZHhyOGswZFV6cDZuMitIV004OVVWdDAx?= =?utf-8?B?TkNsTjdGaXlVYlNlRlcyUTZ0R0xEaXlLcXdqcklTM3RzemVqVGRjU1AxTHRr?= =?utf-8?B?cGc2YkJraFZKRXViTWtQZEZpM0tPaVBQV1RRVCt6KzN3QmFONXNxdEhnRXZO?= =?utf-8?Q?sTfMhfKDThOOzq9c=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 046dabe7-90eb-4446-b985-08da12f082fb X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB0062.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2022 08:29:02.8769 (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: msvJSLz77rwf+D5M1/X55AstpON9biLxP3BL8TkHQBH5C7ctIncmaXNixXR/tY3Sa7s1pQx/E0C3ObsmJoPAe2euZ79Dw0GNABXxXZ3Fcpc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR11MB4325 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/28/2022 3:36 PM, Singh, Aman Deep wrote: > > > 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]); >>           } >>       } >