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 8A450A034E; Thu, 6 Jan 2022 13:41:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 34D8C41150; Thu, 6 Jan 2022 13:41:31 +0100 (CET) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by mails.dpdk.org (Postfix) with ESMTP id 8A8084114F for ; Thu, 6 Jan 2022 13:41:29 +0100 (CET) Received: by mail-wm1-f54.google.com with SMTP id az31-20020a05600c601f00b003475c3c3d03so156458wmb.0 for ; Thu, 06 Jan 2022 04:41:29 -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:content-transfer-encoding:in-reply-to; bh=Gy7P5qMNBl2hMjpef2tVpzunEDaqxZ6Ub8eVT3MqGT4=; b=VeeXx1CUOU5zq7H7zbMG96Hh6Te8gbRaMBjme8RRF3kYvWNC5Ritl0eQD5LfClqEmC j06PggmC2Kdt8rfdJDWUtmBJLv4o7RWflZy2m8Lnd+4hHrkZBHHHJLU5+Wa/EPsraOoc 9BpI5TaAVmTVcbebcd2TMjwCFOUV3s7XLqzKjbyJH2EAF5+vwDn8BWT9RGYvnbc2WoxU U18ad07tQeZSe0GEz5zlr5S9Ox4AMhBD/Xg7nOs0BRYyaq5E5YNpWRGMIhi5PxFCLAkt uX1rFcXGL1Fc0MRji8GNQsmFecUSvmZl5PgEik20yQAAKJW/TAuTcxqv47KYdKQoiAuc M0jA== 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:content-transfer-encoding :in-reply-to; bh=Gy7P5qMNBl2hMjpef2tVpzunEDaqxZ6Ub8eVT3MqGT4=; b=DgtVHuXrnI0o6L1ExMKOj2Vpq5ZVs8F+dMo/GgKkkxznfi90P9FZxrvB0m/jRxtup8 9DBFNZbLWPpAsPh645KJvHby5rmyvQ/3/+mLBKNKnOm7YzJQt50fMlzQemzGQi4gyvk3 oqhrP3bu43ToDe9kkkxtQ9xJNNr8uDryiOlQPgqDcNmAYNiz2R3s0MAbDerL9kZ9Yqfo CtSsuX8TdVLhZmXFRLIgkMiUuxPqM5kia0HbL0byjKIvAP8jNt7D9I2xNOBEDwPA5qqp UtGqpF0n8D2uWN/KkXpRiRHCNMehfWY3Du4JsAirYLLuHyXoqF3F2fHS5ITcr0/TCOxa 5WQg== X-Gm-Message-State: AOAM531OUHngfGmBwLgj2L/wmQqQdIsGiG2LBhluaA2VOWyJJob1WzBu vtqQ3E6h4AvslGtox/xQNe4SL8jjxR/nzQ== X-Google-Smtp-Source: ABdhPJzAR7txCQ+s6U32jO+Lpq0i6ZwjAbvmqWSsMWnFfz9H9kvs4RmRHfhWUDk0iy1i6jt7Ii0fQA== X-Received: by 2002:a05:600c:8a7:: with SMTP id l39mr7092759wmp.138.1641472889187; Thu, 06 Jan 2022 04:41:29 -0800 (PST) Received: from 6wind.com ([2a01:e0a:5ac:6460:c065:401d:87eb:9b25]) by smtp.gmail.com with ESMTPSA id p18sm5586499wmq.23.2022.01.06.04.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 04:41:28 -0800 (PST) Date: Thu, 6 Jan 2022 13:41:27 +0100 From: Olivier Matz To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: dev@dpdk.org Subject: Re: mbuf headroom question Message-ID: References: <98CBD80474FA8B44BF855DF32C47DC35D86DE0@smartserver.smartshare.dk> <98CBD80474FA8B44BF855DF32C47DC35D86DE2@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D86DE2@smartserver.smartshare.dk> 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 Thu, Jan 06, 2022 at 11:50:54AM +0100, Morten Brørup wrote: > > From: Olivier Matz [mailto:olivier.matz@6wind.com] > > Sent: Thursday, 6 January 2022 10.49 > > Thank you for the thorough explanation, Olivier. > > Somewhat exotic scenarios, but they do make sense! > > As you might have guessed, I was wondering if rte_pktmbuf_reset_headroom() could be optimized by simply using RTE_PKTMBUF_HEADROOM. I still think that it might, but I realize that it would have wider reaching consequences... > > > > > Hi Morten, > > > > On Thu, Jan 06, 2022 at 10:29:11AM +0100, Morten Brørup wrote: > > > Hi Olivier, > > > > > > The data_room_size parameter description for the mbuf pool creation > > functions says: > > > "Size of data buffer in each mbuf, including RTE_PKTMBUF_HEADROOM." > > > > > > Furthermore, both rte_mbuf_data_iova_default() and > > rte_mbuf_data_addr_default() simply add RTE_PKTMBUF_HEADROOM to the > > return value. > > > > > > Based on the above, I would think that it is impossible for m- > > >buf_len to be smaller than RTE_PKTMBUF_HEADROOM. > > > > > > So why does rte_pktmbuf_reset_headroom() use RTE_MIN(m->buf_len, > > RTE_PKTMBUF_HEADROOM), instead of just RTE_PKTMBUF_HEADROOM? What am I > > missing here? > > > > It is legal to create a packet pool that has no data buffer: this pool > > can be used to allocate packets clones that will be attached to mbufs > > containing data. There is an example in test_mbuf.c. > > In this case, m->data_off is unused, and could be RTE_PKTMBUF_HEADROOM without causing problems. > > > > > It is also technically possible to create a packet pool with small > > mbufs (whose buffer length is less than RTE_PKTMBUF_HEADROOM). These > > mbufs cannot be used by drivers which use rte_mbuf_data_iova_default(), > > but they could be used internally. > > In this case, all of the mbuf's data buffer would be headroom, so the internal use be application/drivers would need to ignore m->data_ off anyway, and could be RTE_PKTMBUF_HEADROOM without causing problems. Well, not really ignore data_off. The application can use rte_pktmbuf_prepend(). > > To create valid mbufs in these 2 cases, this is why RTE_MIN(m->buf_len, > > RTE_PKTMBUF_HEADROOM) is used ; "valid" means that headroom is not > > larger > > than buffer length. > > Validity is important! So if we optimized rte_pktmbuf_reset_headroom(), all the related validation functions would need to be updated accordingly. And the description of the data_off field in the mbuf. Yes. Currently, it is possible to use rte_pktmbuf_prepend(), rte_pktmbuf_append(), and others on these mbufs. They will return an error if data cannot be added. > > It is probably not worth the effort pursuing this idea any further. :-) > > > > > > > Olivier >