From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-f175.google.com (mail-we0-f175.google.com [74.125.82.175]) by dpdk.org (Postfix) with ESMTP id D36C6B411 for ; Wed, 18 Feb 2015 11:14:41 +0100 (CET) Received: by wevk48 with SMTP id k48so171498wev.3 for ; Wed, 18 Feb 2015 02:14:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=YC/YG3Pkb7/LwEHwHnx2TnBC3P+Z2yjxErvok6hi3O8=; b=CTJNLi+4HA/EvCUuGl0yZQACnvkKumdoGBHNQbfoHHuEhHxQYb1R+VeAGtfc8bZfgb LxLScWLub1qhV51/QhMncQmi/aYvmZ5GO9MNAzWpRhjTI4eCZskZSQAYdI24o7o3niCQ o5Uy9Ov3G5SsXYAVKkvi7VIOxmH3wuC7itKdoTTTUSJstH2JLiw1RWBUftdG6Tidw2X7 T9Zh0/DREsWtvq1/BXpGm+ayecEk1Fx8JYFdL0JX2urGORxFnOeBN7Uh7vl7riLfsbwp JmqQw0k5Tf4rFsUX9JrjsyZfiKGWexxCwPAJ2nCmwjECYpfJB0F/mQ/Zn4TjyGyvlk4h oclg== X-Gm-Message-State: ALoCoQmKQXIFRhklZCigMWkDBAngoSpbf3e5a+ne0tpG4DZnMGLMsZV7KfL1nhcDrE+qoyF/2TC+ X-Received: by 10.194.61.244 with SMTP id t20mr6967086wjr.83.1424254481605; Wed, 18 Feb 2015 02:14:41 -0800 (PST) Received: from [10.16.0.195] (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id fo8sm6265089wib.14.2015.02.18.02.14.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Feb 2015 02:14:41 -0800 (PST) Message-ID: <54E46612.7050809@6wind.com> Date: Wed, 18 Feb 2015 11:14:42 +0100 From: Olivier MATZ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 MIME-Version: 1.0 To: Bruce Richardson , "Ananyev, Konstantin" References: <1424102913-18944-1-git-send-email-sergio.gonzalez.monroy@intel.com> <1424102913-18944-3-git-send-email-sergio.gonzalez.monroy@intel.com> <54E45888.7070603@6wind.com> <20150218093548.GA14884@bricha3-MOBL3> <2601191342CEEE43887BDE71AB977258213EF5E4@irsmsx105.ger.corp.intel.com> <20150218100003.GA14728@bricha3-MOBL3> In-Reply-To: <20150218100003.GA14728@bricha3-MOBL3> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH 2/2] Remove RTE_MBUF_REFCNT references X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2015 10:14:42 -0000 On 02/18/2015 11:00 AM, Bruce Richardson wrote: > On Wed, Feb 18, 2015 at 09:48:58AM +0000, Ananyev, Konstantin wrote: >> Hi lads, >> >>> -----Original Message----- >>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson >>> Sent: Wednesday, February 18, 2015 9:36 AM >>> To: Olivier MATZ >>> Cc: dev@dpdk.org >>> Subject: Re: [dpdk-dev] [PATCH 2/2] Remove RTE_MBUF_REFCNT references >>> >>> On Wed, Feb 18, 2015 at 10:16:56AM +0100, Olivier MATZ wrote: >>>> Hi Sergio, >>>> >>>> On 02/16/2015 05:08 PM, Sergio Gonzalez Monroy wrote: >>>>> This patch removes all references to RTE_MBUF_REFCNT, setting the refcnt >>>>> field in the mbuf struct permanently. >>>>> >>>>> Signed-off-by: Sergio Gonzalez Monroy >>>> >>>> I think removing the refcount compile option goes in the right >>>> direction. However, activating the refcount will break the applications >>>> that reserve a private zone in mbufs. This is due to the macros >>>> RTE_MBUF_TO_BADDR() and RTE_MBUF_FROM_BADDR() that suppose that >>>> the beginning of the mbuf is 128 bytes (sizeof mbuf) before the >>>> data buffer. >>>> >>> >>> While I understand how the macros make certain assumptions, how does activating >>> the refcnt specifically lead to the problems you describe? Could you explain >>> that part in a bit more detail? >>> >>> Thanks, >>> /Bruce >>> >> >> Olivier, I also don't understand your concern here. >> As I can see, that patch has nothing to do with RTE_MBUF_FROM_BADDR/ RTE_MBUF_FROM_BADDR macros. >> They are still there, for example rte_pktmbuf_detach() still uses it to restore mbuf's buf_addr. >> The only principal change here, is that we don't rely more on RTE_MBUF_FROM_BADDR to determine, >> Is that indirect mbuf or not. >> Instead we use a special falg for that purpose: >> >> -#define RTE_MBUF_INDIRECT(mb) (RTE_MBUF_FROM_BADDR((mb)->buf_addr) != (mb)) >> +#define RTE_MBUF_INDIRECT(mb) (mb->ol_flags & IND_ATTACHED_MBUF) >> >> BTW, Sergio as I said before, I think it should be: >> #define RTE_MBUF_INDIRECT(mb) ((mb)->ol_flags & IND_ATTACHED_MBUF) >> >> Konstantin >> >> >>>> For RTE_MBUF_TO_BADDR(), it's relatively easy to replace it. The >>>> mbuf pool could store the size of the private size like it's done >>>> for mbp_priv->mbuf_data_room_size. Using rte_mempool_from_obj(m) >>>> or m->pool, we can retrieve the mbuf pool and this value, then >>>> compute the buffer address. > > Agreed, that makes sense. > >>>> >>>> For RTE_MBUF_FROM_BADDR(), it's more complex. We could ensure that >>>> a backpointer to the mbuf is always located before the data buffer, >>>> but it looks difficult to do. > > On the other hand, with the proposed refcnt change Sergio proposes, we no > longer use this macro in any of the built-in mbuf handling for freeing mbufs. > Does this need to be solved at anything other than the application level? It's still used in __rte_pktmbuf_prefree_seg() to retrieve the parent mbuf (direct) from the indirect mbuf beeing freed. >>>> >>>> Another idea would be to add a field in indirect mbufs that stores >>>> the pointer to the "parent" mbuf. >>>> >>>> Regards, >>>> Olivier >>>>