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=1.2 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MALFORMED_FREEMAIL,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 DA280C76186 for ; Wed, 17 Jul 2019 05:22:24 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 6EFE720818 for ; Wed, 17 Jul 2019 05:22:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="FYs8PasG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6EFE720818 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=icloud.com 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 9B2EB2BAB; Wed, 17 Jul 2019 07:22:23 +0200 (CEST) Received: from pv50p00im-ztbu10011701.me.com (pv50p00im-ztbu10011701.me.com [17.58.6.53]) by dpdk.org (Postfix) with ESMTP id 3D7F7271 for ; Wed, 17 Jul 2019 07:22:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1563340941; bh=lNdRbGe7zmnR2OU+yOTP9kCoDUD4XQjjbjNfrkEc9Ss=; h=To:From:Subject:Date:Message-id:Content-Type; b=FYs8PasG0dxT7esFnUddT82dqgA2LZU2aEfyY1r+QqAt45TDHLJbymagwug29+J6i ir3tfL16aZitPDXDhxtZnMAsLJ2KLIcqRU63t4OxL5lEGeNLNChrTAObYmW2SP+/Qx hRw+eLmojtEsrmjH1RROUb8Kb7QJm/xPU+ihgX7LExthvcSkLiuKuebeNVflVBIIyL o7Kld3NUWIs/oai4gXoXfancKnc2d3ByGMdZ1EDxgmOqTh4C24zyFqn6onwWJ9HwGp U/U9gHykynAASo5Dy9YRzkf4iL6cfUVJWZt9Gd5ElY0m9WFyuEFfnAk5P8cdV97xlB MbWcjBOFR4RyQ== Received: from localhost (pv33p03im-webms003.me.com [17.142.224.114]) by pv50p00im-ztbu10011701.me.com (Postfix) with ESMTP id 3FB6E8A0E3B; Wed, 17 Jul 2019 05:22:21 +0000 (UTC) To: Stephen Hemminger Cc: dev@dpdk.org From: He Peng Date: Wed, 17 Jul 2019 05:22:18 GMT X-Mailer: iCloud MailClient1912Project36 MailServer1913B46.10000-1913B-0-be2a8866e288 Message-id: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-17_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1812120000 definitions=main-1907170065 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] =?utf-8?q?=C2=A0_How_*rte=5Fzmalloc=5Fsocket*_ensure_t?= =?utf-8?q?hat_the_memory_is_zero=27d_=3F?= 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" =0A=0A=0A2019=E5=B9=B47=E6=9C=8816=E6=97=A5 =E4=B8=8B=E5=8D=8810:19=EF=BC=8C= He Peng =E5=86=99=E9=81=93=EF=BC=9A=0A=0A=0AHi=EF=BC= =8C=0A=0A=0A=0A2019=E5=B9=B47=E6=9C=8816=E6=97=A5 =E4=B8=8B=E5=8D=889:51=EF= =BC=8CStephen Hemminger =E5=86=99=E9=81=93=EF= =BC=9A=0A=0A=0AOn Wed, 17 Jul 2019 02:26:57 GMT=0AHe Peng wrote:=0A=0A=0AHi,=0A=0A=0AIn file dpdk/lib/librte_eal/common/rte_ma= lloc.c:=0A=0A=0A/*=0A* Allocate memory on default heap.=0A*/=0Avoid *=0Art= e_malloc(const char *type, size_t size, unsigned align)=0A{=0A=C2=A0=C2=A0= return rte_malloc_socket(type, size, align, SOCKET_ID_ANY);=0A}=0A=0A=0A/*= =0A* Allocate zero'd memory on specified heap.=0A*/=0Avoid *=0Arte_zmalloc= _socket(const char *type, size_t size, unsigned align, int socket)=0A{=0A=C2= =A0=C2=A0return rte_malloc_socket(type, size, align, socket);=0A}=0A=0A=0A= Looks like the *rte_malloc* and *rte_zmalloc_socket* is the same, then, ho= w the latter function ensure the memory allocated by is zeroed?=0A=0AThis = is done because touching the memory on free is faster than cache cold memo= ry during allocation.=0A=0AIf you look at recent DPDK the behavior changes= slightly if MALLOC_DEBUG is enabled.=0AIf DEBUG is enabled freed memory i= s clobbered with a 0x6b so that any buggy program=0Ais likely to crash whe= n using freed memory.=0A=C2=A0=0A=0ABut is it possible that one memory fre= e resulting in two memory elements combined,=C2=A0however=C2=A0=0Athe code= might forget=C2=A0to memset the metadata?=0A=0A=0A=0A=0ASorry, check the = code, it is done in the *join_elem*.=0A=C2=A0