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 67238A0542; Sun, 9 Oct 2022 15:19:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5BD9E4113F; Sun, 9 Oct 2022 15:19:32 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id E4124410D7 for ; Sun, 9 Oct 2022 15:19:30 +0200 (CEST) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 84C4C66; Sun, 9 Oct 2022 16:19:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 84C4C66 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1665321570; bh=hfYglcnzP2iBtUuVdSveJwNsk8DaWrOVleF1qJmjl5c=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=KE3HjWSMwG76sv6pEU71l3N2+pfH+H0jlOr7yN+w8web3p7osOcGKzH9ClwKSng14 7oWoMlF39LJqAoJULog06gxIesohbIHsn6j+Aov8Czt/Hmarw2z7WF9sZCPZ+yOxbq 72oyLmdtLecp3hTJc1xIVlbWqMpNlgyY/GwuQ8uU= Message-ID: <60372c04-3393-a14c-3aef-0ffdfcdd69d6@oktetlabs.ru> Date: Sun, 9 Oct 2022 16:19:30 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH v4] mempool: fix mempool cache flushing algorithm Content-Language: en-US To: =?UTF-8?Q?Morten_Br=c3=b8rup?= , olivier.matz@6wind.com Cc: bruce.richardson@intel.com, jerinjacobk@gmail.com, dev@dpdk.org References: <98CBD80474FA8B44BF855DF32C47DC35D86DB2@smartserver.smartshare.dk> <20220202103354.79832-1-mb@smartsharesystems.com> From: Andrew Rybchenko Organization: OKTET Labs In-Reply-To: <20220202103354.79832-1-mb@smartsharesystems.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 > diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h > index 1e7a3c1527..e7e09e48fc 100644 > --- a/lib/mempool/rte_mempool.h > +++ b/lib/mempool/rte_mempool.h > @@ -1344,31 +1344,41 @@ rte_mempool_do_generic_put(struct rte_mempool *mp, void * const *obj_table, > if (unlikely(cache == NULL || n > RTE_MEMPOOL_CACHE_MAX_SIZE)) > goto ring_enqueue; > > - cache_objs = &cache->objs[cache->len]; > + /* If the request itself is too big for the cache */ > + if (unlikely(n > cache->flushthresh)) > + goto ring_enqueue; > n is checked twice above and it is not actually required. Just the later check is required. Check vs RTE_MEMPOOL_CACHE_MAX_SIZE was required to ensure that we do not overflow cache objects since we copied to cache before flushing, but it is not the case now. We never cross flush threshold now. I'll send v5 were I split the most questionable part into a separate patch at the end.