From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5E5FFA0471 for ; Wed, 17 Jul 2019 07:20:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1C7ED152A; Wed, 17 Jul 2019 07:20:02 +0200 (CEST) Received: from mr85p00im-zteg06022001.me.com (mr85p00im-zteg06022001.me.com [17.58.23.193]) by dpdk.org (Postfix) with ESMTP id 2378D271 for ; Wed, 17 Jul 2019 07:20:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1563340799; bh=75EoXhfIhXwGOS8DEfU4odCZNmihuZoI1CXWJdOuF18=; h=To:From:Subject:Date:Message-id:Content-Type; b=wBF9O2SKBQmW2XeL42ZSmDmLX5AbmO9sJrgm/PD6pZ3slR2Dv9CDGXF1b9UBY4hB6 yr5THo7VkR5+Pcg4gsSVE/wBZzAp/+nnXu9nSqsk7LpC8YnD2kygpOQPJCD/S93hch NhoQOwWEBn0LhzPp21u4dXDSYFF/kGoZ10MxT2fobvOX/HKBqRTTup/ZOraQERvCXd Iqv2FY+1GmEoWxQT+jwCY4hHcjXhYAbImeVwHyZQcwWkY2zxmRRzmywVOzY0Kq74/s pZ842gi3HhjFRQVCNtIyjiB8JUN4/Zv34N/Ac4ee0+IHTeGQtsKGVZRVhh056qrPib O+nr7QVufjDBA== Received: from localhost (pv33p03im-webms003.me.com [17.142.224.114]) by mr85p00im-zteg06022001.me.com (Postfix) with ESMTP id 17BCE900F8B; Wed, 17 Jul 2019 05:19:59 +0000 (UTC) To: Stephen Hemminger Cc: dev@dpdk.org From: He Peng Date: Wed, 17 Jul 2019 05:19:55 GMT X-Mailer: iCloud MailClient1912Project36 MailServer1913B46.10000-1913B-0-be2a8866e288 Message-id: <4228595c-d41b-48a5-bf51-b54c4dce8885@me.com> 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=1011 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" Hi=EF=BC=8C=0A=0A=0A=0A2019=E5=B9=B47=E6=9C=8816=E6=97=A5 =E4=B8=8B=E5=8D=88= 9: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_malloc.c:=0A=0A=0A/*=0A* Allocate memory on default heap.=0A*/=0Avoid = *=0Arte_malloc(const char *type, size_t size, unsigned align)=0A{=0A=C2=A0= =C2=A0return rte_malloc_socket(type, size, align, SOCKET_ID_ANY);=0A}=0A=0A= =0A/*=0A* Allocate zero'd memory on specified heap.=0A*/=0Avoid *=0Arte_zm= alloc_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=0ALooks like the *rte_malloc* and *rte_zmalloc_socket* is the same, th= en, how the latter function ensure the memory allocated by is zeroed?=0A=0A= This is done because touching the memory on free is faster than cache cold= memory during allocation.=0A=0AIf you look at recent DPDK the behavior ch= anges slightly if MALLOC_DEBUG is enabled.=0AIf DEBUG is enabled freed mem= ory is clobbered with a 0x6b so that any buggy program=0Ais likely to cras= h when using freed memory.=0A=C2=A0=0A=0ABut is it possible that one memor= y free resulting in two memory elements combined,=C2=A0however=C2=A0=0Athe= code might forget=C2=A0to memset the metadata?=0A=0A=0A=0A