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 41C94A0C53; Wed, 25 Aug 2021 09:26:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D34E740041; Wed, 25 Aug 2021 09:26:57 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by mails.dpdk.org (Postfix) with ESMTP id A76F44003D for ; Wed, 25 Aug 2021 09:26:56 +0200 (CEST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 4BC095C013E; Wed, 25 Aug 2021 03:26:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 25 Aug 2021 03:26:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm2; bh= yDS8KSp+YgdO4qggvbu5Nrt0uGPMfrOpXxht4Tjfw9Q=; b=ZwBCAXfzrOdRMypT 6OSfSpu1yD8dZVqW1U42uvkVXUJs55oDE7g/FjUdoP8rUsbzEk/HJFMJRbW5c2Jo cQXEvbEdxCLwxaLwNLV159CebKg+t6eNB55sPUbuSkgj0kRXJ0z2il93NoxTJF2t 1FBfVVfTUhdqQEuY73o1buVibr19inkcEkbrT9IW9uek9MPZiXRsncxIV7pUPOsb i2TMArm+sCsSGNPInLczxElsNFg6YGKuj6NuAVC6NvBdtGOzDeK00/6/iC5gT4cO f1iQma3iwQ//uZGYhKGYgPRAi8JT4WF3Cazteh0csJc29JeKekbg+54HkPnBy2Gl 71Nfhg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=yDS8KSp+YgdO4qggvbu5Nrt0uGPMfrOpXxht4Tjfw 9Q=; b=EULsBj3ZuiNFTHQHtAWoBAVuvXtWctemvCiYLOahMQ1HZPXXbOxCmg7s0 zTQ05ZU28e8DAfZpva/Ki+VZ5sFoN/YcUben+2eEO1uihTLPCt8m6x9YllDuHFHY QCvipWeMu+3E28HgUGNYyRZ4Lf4opvBJ+yVhC+uhWXD5jVJJJq6k96Z8tE14dUHG B32RTKJ6ndG0kP30plaWy7qCAcg61j3rV4aITaYXjdESVuQpeueWUuAjND/21JYE JPwoYP7Om7IJ0bLOhU+PpPKb8JaUc+F8AaiUQey4C6B7Dg/B0V1OgMDg2qfeevpo OOa9PF0NqUSHgOsM2/mDTnDEGQaRg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddtkedguddvtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedugefgvdefudfftdefgeelgffhueekgfffhfeujedtteeutdej ueeiiedvffegheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 25 Aug 2021 03:26:53 -0400 (EDT) From: Thomas Monjalon To: Dmitry Kozlyuk Cc: "dev@dpdk.org" , Anatoly Burakov , "Xueming(Steven) Li" , david.marchand@redhat.com, bruce.richardson@intel.com Date: Wed, 25 Aug 2021 09:26:51 +0200 Message-ID: <1730403.MaGYrl2sIR@thomas> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] Zeroing out memory on free 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 Sender: "dev" 24/08/2021 12:58, Dmitry Kozlyuk: > Hello, > > Me and Xueming are wondering why DPDK clears the memory on free > and not only when it's explicitly requested (rte_zmalloc). > > It's been so for a while: > > commit ea0bddbd14e68fb42d9774bc3543e51b510e48d3 > Author: Sergio Gonzalez Monroy > Date: Tue Jul 5 12:01:15 2016 +0100 > > mem: zero out memory on free > > Since commit fafcc11985a2, memzones are not guaranteed to be zeroed out. > This could potentially cause issues as applications might have been > relying on the allocated memory being zeroed out. > > On init all allocated memory is zeroed by the kernel, so by zeroing out > memory on free, all available dpdk memory is always zeroed. > > Fixes: fafcc11985a2 ("mem: rework memzone to be allocated by malloc") > > Signed-off-by: Sergio Gonzalez Monroy > > At present this explanation doesn't look satisfying: > 1. Memzone API does not promise they will be zeroed out. > Memzones are mostly used for DMA, so their content will likely be overwritten. > 2. If application assumptions are wrong, DPDK should not try to fix it. > Memory manager poisons memory in debug mode to detect such errors. > > Zeroing memory is quite slow, but in many cases unneeded. > It looks attractive to only do it in rte_zmalloc(). > AFAIK what prohibits moving memset() there unconditionally > is that the kernel already gives us cleared pages, > so the first allocation of each piece of memory would do unnecessary work. > This can be solved by giving the user a choice in EAL options No I don't think it should be workarounded in EAL options. > or with more elaborate tracking of memory dirtiness in MM. Looks a good idea. > Are there any other reasons why clearing is done the current way? I think the only reason was to avoid doing reset for the first usage. You're right it is not optimal when reusing memory without any zeroing need.