From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32CB5C76186 for ; Wed, 17 Jul 2019 04:51:18 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id B2CB720818 for ; Wed, 17 Jul 2019 04:51:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="ml+n3fEA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2CB720818 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=networkplumber.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9AA1C2BE1; Wed, 17 Jul 2019 06:51:16 +0200 (CEST) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by dpdk.org (Postfix) with ESMTP id AA8F9F04 for ; Wed, 17 Jul 2019 06:51:15 +0200 (CEST) Received: by mail-pl1-f176.google.com with SMTP id w24so11284190plp.2 for ; Tue, 16 Jul 2019 21:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WTMwJGQHk4kC6iWdBNKKYqoLXNDiDO2u5KOycF1qJp4=; b=ml+n3fEA2ZJhb0nZIcF7c9/36tDRuws6P/0EpPG7bn+GhQH1LXSZH/oJxl9jV6w2zU EoIHD6K2oruvm6kOnidQmDLgsGxYttrVTo5+rCKVRAHYvAscf9UMkffarHmTBMkMknfc MB0WpxbRGzpee/0Dd5Z6oE8+VvqUI0Oz1CJRKcWggr81H8UUJhXx5MvY7p1I4a1yO1lU YTx7lC5l87Csx+HJZrU+45Ap6GE2x0FKSouYeSVdWRn4uf3JUZTTBbsfb0UvXu6847yI uH0ECAuMi4uOGGnl5JOw9toAC9nR9WR0VLg8MlpIu5fz7Kj/1sjONmIlQZ2WbQ258acK Tp1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WTMwJGQHk4kC6iWdBNKKYqoLXNDiDO2u5KOycF1qJp4=; b=NgfOyDbSV/Ab/qhzXxQnjxUrpK40fGW1Ukcsu0JUnkCJWMyG4ChYztt/pEBLIT6qZg /ILJLRl/F0GwDgh455+ehPLVnAWxmmb1CjYwGRjiy1hiimNDc1DcpclKpjEvD/HdL6EE 9HR/wvySaoXlHlUCPkoAyCmggcG4XeJSsNu0BHJnuGvn7oHLSM49NpewPC+tsISNG9gY Tcv54fvy7VdqcfNw9vedDFHsOBYvLWDzLBEfiCoKOkS5kPJzmA0968o44MhVicNd1LMf kaXWzM+UnCkcsmPIjuB713hi0jxkHtIaktzHey8p9HY264jyUlghaqZHiLTHFD9NAuYZ rmzA== X-Gm-Message-State: APjAAAWFInsu0iYNc56Vhzabuv9C/wVUNsl6tIfMFw0VGXOsW4weufN9 3F6c00FV/9epBDO518yL1DU= X-Google-Smtp-Source: APXvYqxuIeCywi2MYGFGB7F3xTc5fW36AyuT5VDaGHJMBlkfBeIUJ4xHb2DcfcYPJBxKZIMcy/ebKw== X-Received: by 2002:a17:902:8c83:: with SMTP id t3mr40224641plo.93.1563339074828; Tue, 16 Jul 2019 21:51:14 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l44sm20138879pje.29.2019.07.16.21.51.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 21:51:14 -0700 (PDT) Date: Tue, 16 Jul 2019 21:51:06 -0700 From: Stephen Hemminger To: He Peng Cc: dev@dpdk.org Message-ID: <20190716215106.2fd8e042@hermes.lan> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] How *rte_zmalloc_socket* ensure that the memory is zero'd ? 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, 17 Jul 2019 02:26:57 GMT He Peng wrote: > Hi, >=20 > In file dpdk/lib/librte_eal/common/rte_malloc.c: >=20 > /* > * Allocate memory on default heap. > */ > void * > rte_malloc(const char *type, size_t size, unsigned align) > { > =C2=A0=C2=A0return rte_malloc_socket(type, size, align, SOCKET_ID_ANY); > } >=20 > /* > * Allocate zero'd memory on specified heap. > */ > void * > rte_zmalloc_socket(const char *type, size_t size, unsigned align, int soc= ket) > { > =C2=A0=C2=A0return rte_malloc_socket(type, size, align, socket); > } >=20 > Looks like the *rte_malloc* and *rte_zmalloc_socket* is the same, then, h= ow the latter function ensure the memory allocated by is zeroed? This is done because touching the memory on free is faster than cache cold = memory during allocation. If you look at recent DPDK the behavior changes slightly if MALLOC_DEBUG is= enabled. If DEBUG is enabled freed memory is clobbered with a 0x6b so that any buggy= program is likely to crash when using freed memory.=20