From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id AEC7858FE for ; Mon, 10 Dec 2018 11:26:28 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2018 02:26:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,338,1539673200"; d="scan'208";a="117503032" Received: from bricha3-mobl.ger.corp.intel.com ([10.237.221.32]) by orsmga001.jf.intel.com with SMTP; 10 Dec 2018 02:26:25 -0800 Received: by (sSMTP sendmail emulation); Mon, 10 Dec 2018 03:26:22 -0700 Date: Mon, 10 Dec 2018 03:26:22 -0700 From: Bruce Richardson To: David Harton Cc: dev@dpdk.org, anatoly.burakov@intel.com Message-ID: <20181210102622.GA10896@bricha3-MOBL.ger.corp.intel.com> References: <20181207222420.9508-1-dharton@cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181207222420.9508-1-dharton@cisco.com> Organization: Intel Research and Development Ireland Ltd. User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [dpdk-dev] [PATCH] eal: fix rte_zalloc_socket to zero memory X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Dec 2018 10:26:29 -0000 On Fri, Dec 07, 2018 at 05:24:20PM -0500, David Harton wrote: > The zalloc and calloc functions do not actually zero the memory. > Added memset to rte_zmalloc_socket() so allocated memory is cleared. > > Signed-off-by: David Harton > --- > lib/librte_eal/common/rte_malloc.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c > index 0da5ad5e8..be382e534 100644 > --- a/lib/librte_eal/common/rte_malloc.c > +++ b/lib/librte_eal/common/rte_malloc.c > @@ -74,7 +74,9 @@ rte_malloc(const char *type, size_t size, unsigned align) > void * > rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket) > { > - return rte_malloc_socket(type, size, align, socket); > + void *new_ptr = rte_malloc_socket(type, size, align, socket); > + if (new_ptr) memset(new_ptr, 0, size); > + return new_ptr; > } While this is functionally correct, I believe this memset should not actually be needed. A few years back we changed the behaviour in DPDK to always zero memory on free, rather than zeroing on allocate. This worked fine because the kernel always gave us zeroed hugepages and zeroing them a second time was a waste of cycles. The percentage of memory that was subsequently freed and reallocated was small so zeroing on free saved quite a bit of processing time, especially at app startup. If, following all the memory rework in recent releases, this scheme of zeroing on free no longer works, I'd rather see that fixed than go back to the scheme of zeroing on allocation. [Assuming we do fix it, a comment explaining the missing memset would also be good to avoid future patches here] Regards, /Bruce