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 DBC68A034E; Thu, 6 Jan 2022 11:45:24 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5720041142; Thu, 6 Jan 2022 11:45:24 +0100 (CET) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mails.dpdk.org (Postfix) with ESMTP id 3A99841140 for ; Thu, 6 Jan 2022 11:45:23 +0100 (CET) Received: by mail-wr1-f41.google.com with SMTP id k18so3870851wrg.11 for ; Thu, 06 Jan 2022 02:45:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=uJQPhErQtUiZVHtbzXdzZq8QxZUQM8kHqGNzSiQnKeg=; b=HBgVfyYEPZH5A3GCdQ7geysBxk8mtsDMNuHSXWyv1JJfYttnhpTElMMIdPjgiG5B6b 4bSlI3Vkv38XJpw0lBrryOi9DhPUrTwn4v4RphG7e1p6bCfWsCT1ka7ISIniyT7Th4ul Pou9U5cbBL1RFV+Y2tO0KRL5x2Va3oYac+F4fPqNGAiAAgtCZCqVOSSqASRzCqU2Pvr/ ViI527Fp1oHKGmPq5SEMu0Cfot1DUFT9fadS766p0vFBf1FTRYWI3OUVjR6EmvJRAmSo 5t4znRvCo9u80IzcIEmhR7bW1nLbM0jyubK4irkKz0QSx5DzBEh9EQtfX42I82jASyDA N9xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=uJQPhErQtUiZVHtbzXdzZq8QxZUQM8kHqGNzSiQnKeg=; b=1zpRCnUYZD1JaPetmWkYIhc+XLtmn8ody0rgzBmixMTR/YjzNZagD0XyHP220TlHuP Ywu/J0Aa+6hEj1jdX97lZ+GRTmFGX881aZZLQwLL1O6MXLd5Y4yYpJvgs7H9ishACTm7 F6x7vD1e027bLuA69BJ3MYt5lm5A7kmS7HRWRutB1jdGBg8ITc1ORemXHOW1GwM2K5Np FDBYsO5g1aBVmEMrhMnJWuK3RCgYrPPn9F0M7NUGbNNUKLnp03xrrEQrHe78EK3Pa5LW ZvZpJRriF0zMF4n/0rJcUwX2hXT8fKhZx4Lg38ji8OWBO2yYkqsBKCVqZLaeW8sl10re IPxQ== X-Gm-Message-State: AOAM533RJoBnm+Dn6kln5qvRNowv7GBY3jbNNxwBQRNj+xQrIJYPSKDU MSm0EVLsEd/2wJjuSQlevRTbxQ== X-Google-Smtp-Source: ABdhPJxndw7eqxBEfM8k+uR1fAAAP+J1U5/WMmCkL2a93jnE0u7FxvxBnWl5jt0Pkw+EOolDnGJRtg== X-Received: by 2002:adf:f410:: with SMTP id g16mr50452809wro.290.1641465922963; Thu, 06 Jan 2022 02:45:22 -0800 (PST) Received: from 6wind.com ([2a01:e0a:5ac:6460:c065:401d:87eb:9b25]) by smtp.gmail.com with ESMTPSA id l13sm1931533wrs.73.2022.01.06.02.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 02:45:22 -0800 (PST) Date: Thu, 6 Jan 2022 11:45:21 +0100 From: Olivier Matz To: Andrzej Ostruszka Cc: dev@dpdk.org, upstream@semihalf.com Subject: Re: [PATCH 1/1] ring: fix off by 1 mistake Message-ID: References: <20220103142201.475552-1-amo@semihalf.com> <20220103142201.475552-2-amo@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220103142201.475552-2-amo@semihalf.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 Hi Andrzej, On Mon, Jan 03, 2022 at 03:22:01PM +0100, Andrzej Ostruszka wrote: > ring: fix off by 1 mistake I suggest something less scary for the title: ring: optimize corner case for enqueue/dequeue > When enqueueing/dequeueing to/from the ring we try to optimize by manual > loop unrolling. The check for this optimization looks like: > > if (likely(idx + n < size)) { > > where 'idx' points to the first usable element (empty slot for enqueue, > data for dequeue). The correct comparison here should be '<=' instead > of '<'. > > This is not a functional error since we fall back to the loop with > correct checks on indexes. Just a minor suboptimal behaviour for the > case when we want to enqueue/dequeue exactly the number of elements that > we have in the ring before wrapping to its beginning. > > Signed-off-by: Andrzej Ostruszka Reviewed-by: Olivier Matz I'll tend to add: Fixes: cc4b218790f6 ("ring: support configurable element size") But the same error was in the ENQUEUE_PTRS()/DEQUEUE_PTRS() macros since the beginning, so we may also add: Fixes: 286bd05bf70d ("ring: optimisations") This macro was removed in commit 2d6ed071a8b9 ("ring: use custom element for fixed size API") Thanks!