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 4AE81A00C4 for ; Tue, 3 Jan 2023 13:47:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 43668410F9; Tue, 3 Jan 2023 13:47:12 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2076.outbound.protection.outlook.com [40.107.220.76]) by mails.dpdk.org (Postfix) with ESMTP id DC3BD40689; Tue, 3 Jan 2023 13:47:09 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OpbP3FRMgLjD4dIuNUTeo3rFtROxqlM8QgxVX8Vq9mcN2D65dJVi/172CVy5+C6pFAV0AXMZrhox8GGCH7fXk8tsRKTbhV1PiR/xthCt93mkgp/fUEkeCX3ctQggNUAekZYJ323BkKBcmAonmBnPXwn+lMGGKjVX9+w7XZ+stCayE/xBo+B9U8YqZZdakMkxEaH0fT3s/TayRhBwhEmxeLMj5Wxz1NsowzGUaj1Elhu2Q/Q9M5jGgcrz3xstuC1OXnkxjTKEcyoDkbqAPy1Mk3C/vTA/6rQMgRXRD/Auc5XF7lXJq403pt9K7Kz63PvDH6eMFYSDDXkCwap/qoojdw== 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=sylLKQ8HljspIiEEJvHb8q5oNwbEgELBgplYdnrDOZo=; b=DcrbeNWOr+yfHqPhAetpSbBFd8xP4mUTzYIjrhBgTuNKrizCz5d8AiXnUJqgN7OQDwcwEbvbzWplESnkXdv963FHpBBQJUVO/eYVU8FiDIPR2XMKaqBV4niTLj4cqsb+siZC4/KkrbNf5mLPxwSyUQB0kyvfbfniRoqVj3UQx0ZuqpQxzzqsN9QHIFWL5S4mElfZoJoBACX5hPaLj5KL/Vzec9se8KNwEd5cLMFijOrKmWJKN5fgOQKnKGmw1uol4SG4gkR+hnrIRHCv7cr6tCdP0diWcLbkJa25tkir+ohL0t0Y69XWTbmekpy27/vyjwLBD+hUuPmgPJqdYCj/XA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sylLKQ8HljspIiEEJvHb8q5oNwbEgELBgplYdnrDOZo=; b=l38cDBu1bBZSeWoXkqCpwK8O7TFqRO1EilG3QTyLtNbHzygghQhB77TcHLv2Q0CV0okqVN/Z56y2iGoVJz/HZ65ICzfzxW2iHrXwnQpjC8Y4GxUT7G5wSGkiKUTWjEEQphyD82JwNKLEIJlNne0fPcfYN6Nm2myeO0CvyeqgoGc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by BL1PR12MB5143.namprd12.prod.outlook.com (2603:10b6:208:31b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Tue, 3 Jan 2023 12:47:08 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::4807:1f44:5e04:e05a]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::4807:1f44:5e04:e05a%7]) with mapi id 15.20.5944.016; Tue, 3 Jan 2023 12:47:07 +0000 Message-ID: <042de5cd-c410-7925-efe9-bea547fec736@amd.com> Date: Tue, 3 Jan 2023 12:47:01 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH v3] kni: fix possible alloc_q starvation when mbufs are exhausted Content-Language: en-US To: Yangchao Zhou , dev@dpdk.org Cc: stephen@networkplumber.org, stable@dpdk.org References: <20221109060434.2012064-1-zhouyates@gmail.com> <20221230042338.1670768-1-zhouyates@gmail.com> From: Ferruh Yigit In-Reply-To: <20221230042338.1670768-1-zhouyates@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LNXP265CA0051.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5d::15) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|BL1PR12MB5143:EE_ X-MS-Office365-Filtering-Correlation-Id: 93c0bebc-e10d-4bf4-aabb-08daed889f1f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +YH80m2NZcE01zyqbmPhKXooZArBvyO6DOz3cRJYGcf/aEm3TAoPWwKkc2Jn6QQK3GqHyxyBTeuY7CKndG2DY1Gcdb4LAD0yW+YZEA5L7e++Xu88KIUIAS6atgpTMPaF+AnypEhYNEMlak5fB3Jm5IljMZryajwXOCV1gsOvFvA019Q6G0riQQeoMVzIiOq/1L05296JCT/8BwjdL1VZYbIWSCd1/dMO0vXm1d2ppgKXVZBQAAAT1naRJifuPUXrinvg00MLcLM+Op8qTK9K7AYztSP9lxBeU1C4LNw+wK99TrXGepyYnoMhKIcPSkX5pRQtdPQy44qgDPl5mAsIbmXVE2N6IHp29/G5YXiSnt1mJMrtFUfzSnFSHN2FMIyYf+aSbbR9BBFN1z5mdUXOB9cH26PgDIDb/VzAkDSUOQVsRR7AKet6QANwpIoxqpsIc4m4z75/2HKk+jyYfyCuo1qcN/DESqSrGEX+tY3266o5CV0KXzP1ywWTujbKhWxNY/Xwb/8cbJfliHrvCOEszKdXPNk28nMs9BqR5aQ8SbFngLo8dk/7QU/8WwPJWSQ0pblw7BJcwWAsZBa6bGSehFFftmpNuV06isCAKwXxVicId4p8oKaeeAZ03OWnHRd9N386QyrOCUnksCue7cKoOu49Atc1NL28EcvZg0OkNAGQWVRx2aeSTED940jAPaStzETLttorQgfl9ZtVB/pwIYdd5ir0HzaIyoKW71pr83dldvuLg/RW9SLSOd+odII4umFS/4NW1icL0W96nKDaNQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(366004)(39860400002)(136003)(376002)(346002)(396003)(451199015)(5660300002)(2906002)(8936002)(44832011)(31686004)(4326008)(8676002)(41300700001)(316002)(66946007)(66476007)(6486002)(478600001)(66556008)(2616005)(53546011)(6512007)(26005)(186003)(6506007)(6666004)(83380400001)(38100700002)(86362001)(31696002)(36756003)(22166006)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Mi8vbVYxV0tKblpFUFpKS3o1ZFFOc2tLNHFzMzJNUnA2S1hjZWg4Qk5kS0Fm?= =?utf-8?B?NGxWaDJ1MmwxNkxENXlvbjhvZHZqa3lxMDJLdHBKYTYvbnU1aENDNGxXZ2hq?= =?utf-8?B?bDZyZjNwUTVYWlk2WDJXTWdXMHlvTTY3U3ZZQzZodVpGeSsrVXB1bFVYUE1O?= =?utf-8?B?STJ5ZCtOQjRiT3MvVEdIdDZucVdBWCs5a3VJSkhoV05ZcHhqSWY1VmF3ZEhl?= =?utf-8?B?dFQ2S2N4R0JmS3JMWFRUMC9vT0pEUHYxU3lrQjV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UE5XbkcwYXRrYUhVblFyUStLZ25rY0taU3pSbWZVMElRWDdHdWtIN3FHK0Qy?= =?utf-8?Q?fPdmsX0nTN62vq1aH44kh84C/?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93c0bebc-e10d-4bf4-aabb-08daed889f1f X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2023 12:47:07.0146 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: k4TeXNbS3WOW+DHuQBh1ALm72bChzune3o8SEEsx4vszgo/gIU0kAhDoi6E8a8l4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5143 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On 12/30/2022 4:23 AM, Yangchao Zhou wrote: > In some scenarios, mbufs returned by rte_kni_rx_burst are not freed > immediately. So kni_allocate_mbufs may be failed, but we don't know. > > Even worse, when alloc_q is completely exhausted, kni_net_tx in > rte_kni.ko will drop all tx packets. kni_allocate_mbufs is never > called again, even if the mbufs are eventually freed. > > In this patch, we try to allocate mbufs for alloc_q when it is empty. > > According to historical experience, the performance bottleneck of KNI > is offen the usleep_range of kni thread in rte_kni.ko. > The check of kni_fifo_count is trivial and the cost should be acceptable. > Hi Yangchao, Are you observing any performance impact with this change in you use case? > Fixes: 3e12a98fe397 ("kni: optimize Rx burst") > Cc: stable@dpdk.org > > Signed-off-by: Yangchao Zhou > --- > lib/kni/rte_kni.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c > index 8ab6c47153..bfa6a001ff 100644 > --- a/lib/kni/rte_kni.c > +++ b/lib/kni/rte_kni.c > @@ -634,8 +634,8 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned int num) > { > unsigned int ret = kni_fifo_get(kni->tx_q, (void **)mbufs, num); > > - /* If buffers removed, allocate mbufs and then put them into alloc_q */ > - if (ret) > + /* If buffers removed or alloc_q is empty, allocate mbufs and then put them into alloc_q */ > + if (ret || (kni_fifo_count(kni->alloc_q) == 0)) > kni_allocate_mbufs(kni); > > return ret;