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 43B7AA054A; Sat, 27 Aug 2022 11:26:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E6B3D40DF7; Sat, 27 Aug 2022 11:26:24 +0200 (CEST) Received: from out162-62-57-137.mail.qq.com (out162-62-57-137.mail.qq.com [162.62.57.137]) by mails.dpdk.org (Postfix) with ESMTP id 821AB40696 for ; Sat, 27 Aug 2022 11:26:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1661592380; bh=SOzd1dOvhL+Jsux10CU+QlQtXUxWVJO4QVbtX9HHthI=; h=From:To:Cc:Subject:Date; b=RfmwTq7bc3V8Vn+crrcId5eWiUUE6nRuCP78DDyEY/m11z+MfROnY0jpPDZxuCn1+ H0DnLVk5oDpi9BoZ7TNmkloAJ5nK7Zu/BQTmOpwY/2LDGKjhnpOA/um1thNxhq9VTD 8NCV18yo4gUMvszoY5ugLrp2nwCoZJXSrThY1nrE= Received: from vscode.localdomain ([218.88.39.146]) by newxmesmtplogicsvrszc8.qq.com (NewEsmtp) with SMTP id 6928DAC7; Sat, 27 Aug 2022 17:26:18 +0800 X-QQ-mid: xmsmtpt1661592378t4yqzqq3m Message-ID: X-QQ-XMAILINFO: MqN/FiDJuNHiSvU9z+hrdeVSS1QufAOx23Sn80RJ5LN/d/BNd7s3Ypq/WCEhxE EmsG1BGowuU9TLJOeAcOYMfbqVcezWIFPo9DXu3zhhcQNZpcUB10xhMpHaOLyfqZkfIPhAHW7Kic 3Nbpjom5ZwHeKH1v9CsFHIf9Ss8LUTGmlHxHAy4Sadt0B/oMbdNxNUagBy6ZbJSrRaoh234f7zKd FpHugYcTxoMVlsPqgFzc3+M6H9DzMONfNYsl9DmZV9brP1roGZGbNID/PcfUN6PUDpa9oJDapwty inXhkTNRrmLcQhO2YgyxD5qGUGWOAvpmqX3+6iCtvQTh3QSS+EvLqpNf9Ah8AGQrGUE2Y/e1xRXz Ie69atwgyxCHY0XaiRBb0w3kRpvFqPhjrbXfXanY/g3wnz17D2tc0pGQTGCDn2kBxQNGwbP0t6Zn 6aMW/Zqp4z2LeMZ7OLx2DhXG40xBWy5Lra0b9KMoVVAd1Ge2mK1G+9PcEsd+y/qSeiu7EwqPVmmK rqYph+U5F5PUplsXVO0m/MgQTRNLRID7NLxJI9JnVFfb0riQgYClhqU91ImapmBcRDCIQ/Y/l885 biH41jB24AIgvfLxIqoa1T4Ffc2xDOnFsSqXaGQ3qviuqFAcbw+STouTWZcSI6z280zTUBVkN+we Re6kLjyGRpg/IUIglZI5zxLdqQZ6ikjqmsRblIRV0FOVuzsWUI6O2zA9bhuNCSTnB+PlII09Hmyp PdoJVWURqXTu1LMizaO07X9vtQr8nOrwIs9kLF0KV7vIRUOb2JrAgN8MaMl2MTh/z/u2xySBhvbX G2fPPcGPhg4ob6b7+//YjcNY8jtt2BBRdaFOOLw+5btetBEw6RlRoovr06tf/EAa4PSbbaRnqF84 WZPa7bbblOM3ToraTfxGVLh2uM0591lzUejwiBIMbaeye7VC6iubaR8OZOuDUlbnjYQtKN0+hg From: chengtcli@qq.com To: dev@dpdk.org Cc: lic121 Subject: [PATCH] eal: zero out new added memory Date: Sat, 27 Aug 2022 09:25:47 +0000 X-OQ-MSGID: <1661592347-31533-1-git-send-email-chengtcli@qq.com> X-Mailer: git-send-email 1.8.3.1 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 From: lic121 When RTE_MALLOC_DEBUG not configured, rte_zmalloc_socket() doens't zero oute allocaed memory. Because memory are zeroed out when free in malloc_elem_free(). But seems the initial allocated memory is not zeroed out as expected. This patch zero out initial allocated memory in malloc_heap_add_memory(). With dpdk 20.11.5, "QLogic Corp. FastLinQ QL41000" probe triggers this problem. ``` Stack trace of thread 412780: #0 0x0000000000e5fb99 ecore_int_igu_read_cam (dpdk-testpmd) #1 0x0000000000e4df54 ecore_get_hw_info (dpdk-testpmd) #2 0x0000000000e504aa ecore_hw_prepare (dpdk-testpmd) #3 0x0000000000e8a7ca qed_probe (dpdk-testpmd) #4 0x0000000000e83c59 qede_common_dev_init (dpdk-testpmd) #5 0x0000000000e84c8e qede_eth_dev_init (dpdk-testpmd) #6 0x00000000009dd5a7 rte_pci_probe_one_driver (dpdk-testpmd) #7 0x00000000009734e3 rte_bus_probe (dpdk-testpmd) #8 0x00000000009933bd rte_eal_init (dpdk-testpmd) #9 0x000000000041768f main (dpdk-testpmd) #10 0x00007f41a7001b17 __libc_start_main (libc.so.6) #11 0x000000000067e34a _start (dpdk-testpmd) ``` Signed-off-by: lic121 --- lib/librte_eal/common/malloc_heap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c index f4e20ea..1607401 100644 --- a/lib/librte_eal/common/malloc_heap.c +++ b/lib/librte_eal/common/malloc_heap.c @@ -96,11 +96,19 @@ void *start, size_t len) { struct malloc_elem *elem = start; + void *ptr; + size_t data_len + malloc_elem_init(elem, heap, msl, len, elem, len); malloc_elem_insert(elem); + /* Zero out new added memory. */ + *ptr = RTE_PTR_ADD(elem, MALLOC_ELEM_HEADER_LEN); + data_len = elem->size - MALLOC_ELEM_OVERHEAD; + memset(ptr, 0, data_len); + elem = malloc_elem_join_adjacent_free(elem); malloc_elem_free_list_insert(elem); -- 1.8.3.1