From patchwork Thu Apr 25 18:23:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 139683 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D1F5643F09; Thu, 25 Apr 2024 20:27:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B36414394F; Thu, 25 Apr 2024 20:27:52 +0200 (CEST) Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by mails.dpdk.org (Postfix) with ESMTP id 304E040A67 for ; Thu, 25 Apr 2024 20:27:50 +0200 (CEST) Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6edb76d83d0so1215798b3a.0 for ; Thu, 25 Apr 2024 11:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1714069669; x=1714674469; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hFC5DzGzPNzUJ3Kfg57UBXCUkgZk/ncI+/kVAITVyJM=; b=rQuW3UF0+xA1Ywdugyy3h47HXsG4SHQTiKhVu4oqRSC/oskHqPIHf6kWhNEvll75LM tqNp5Pa47N1eIbKvVe0HHaAjSOFnGcOEsKD/9ajokj8G4qpog92cKCwfOtVbmewvsOCs Ups98eFWDNZxPBzdTounBWC3vjyOWJwVdp6sx5Y4y+7PiCJ+ka5xxlExhGC0G9pbovnM MbHtCrvB+sfFgIvdhZTQ2eqnDcwrecmsGvDls9AQDkGVEcgpg347dEVsMLq5ziCJo6bT 5HzpKKjSmneXxgWGJyWRAk1HKIGQCct79V/Fg7158cA5kc7MDD+w9yctfXws7sNiA+eD wIuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714069669; x=1714674469; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hFC5DzGzPNzUJ3Kfg57UBXCUkgZk/ncI+/kVAITVyJM=; b=reeBK/28q6AcYbfQECHNxm0GsHh6v/KR/Ir5ojiFMX2vi+OGqlLOsF98IydgIOMdCh aSdYNmCLtZjp9fWElb4g1qpODMCZqa8QpL1iMX2+5fALnlfeAzuLtLXd379pVKBv+DGL zvUXiOiv55JolcoUSXFSf8KjvjnXeMDF1fAJYoldi2AOcOEzd+ez5H1ILoJ66NxbuWMI QPxSOwr4jBoQTBraD4j7yZscFVLJepPEnfTsX19rHbcG0EihQkGGXpoQA+5/0nPnZ/Ao TtQyzbDLCBdN4pNwSzVw7i4D7V7ExG2MKDfb6sSMhsa+gYJQURmDE8mcvRvGhezw8GfX Cwpg== X-Gm-Message-State: AOJu0YzXqKF409pCHld5am1RHEFKJTTiZvPsOjGxF3DEc9p4NBwdVdnT kjQKIA9kxT42uASM2QZnY2GM+d9L+yv4WUh+znYuwzbg8dIYN2Nf9WlA4ghVBoP/CRoTSX5gklJ j X-Google-Smtp-Source: AGHT+IE+gTl0bktDiKpqeVY2HsE+8slKd3q3S3gw1r+yq03xxQOHRn4RrKDZJv6+ocQbqHoatomBbw== X-Received: by 2002:a05:6a20:6a1d:b0:1ad:84ca:88f0 with SMTP id p29-20020a056a206a1d00b001ad84ca88f0mr709533pzk.4.1714069669158; Thu, 25 Apr 2024 11:27:49 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d7-20020a056a00244700b006f0ba1c8ddesm4067006pfj.184.2024.04.25.11.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 11:27:48 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC 1/4] rte_malloc: document that type is unused Date: Thu, 25 Apr 2024 11:23:58 -0700 Message-ID: <20240425182738.4771-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240425182738.4771-1-stephen@networkplumber.org> References: <20240425182738.4771-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The string type is left over from first version of DPDK and was never implemented. Signed-off-by: Stephen Hemminger --- lib/eal/include/rte_malloc.h | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/eal/include/rte_malloc.h b/lib/eal/include/rte_malloc.h index 54a8ac211e..91c9214c57 100644 --- a/lib/eal/include/rte_malloc.h +++ b/lib/eal/include/rte_malloc.h @@ -37,8 +37,7 @@ struct rte_malloc_socket_stats { * NUMA socket as the core that calls this function. * * @param type - * A string identifying the type of allocated objects (useful for debug - * purposes, such as identifying the cause of a memory leak). Can be NULL. + * Legacy argument, never unused should be NULL. * @param size * Size (in bytes) to be allocated. * @param align @@ -64,8 +63,7 @@ rte_malloc(const char *type, size_t size, unsigned align) * same NUMA socket as the core that calls this function. * * @param type - * A string identifying the type of allocated objects (useful for debug - * purposes, such as identifying the cause of a memory leak). Can be NULL. + * Legacy argument, never unused should be NULL. * @param size * Size (in bytes) to be allocated. * @param align @@ -89,8 +87,7 @@ rte_zmalloc(const char *type, size_t size, unsigned align) * same NUMA socket as the core that calls this function. * * @param type - * A string identifying the type of allocated objects (useful for debug - * purposes, such as identifying the cause of a memory leak). Can be NULL. + * Legacy argument, never unused should be NULL. * @param num * Number of elements to be allocated. * @param size @@ -165,8 +162,7 @@ rte_realloc_socket(void *ptr, size_t size, unsigned int align, int socket) * is not cleared. * * @param type - * A string identifying the type of allocated objects (useful for debug - * purposes, such as identifying the cause of a memory leak). Can be NULL. + * Legacy argument, never unused should be NULL. * @param size * Size (in bytes) to be allocated. * @param align @@ -194,8 +190,7 @@ rte_malloc_socket(const char *type, size_t size, unsigned align, int socket) * initialised with zeros. * * @param type - * A string identifying the type of allocated objects (useful for debug - * purposes, such as identifying the cause of a memory leak). Can be NULL. + * Legacy argument, never unused should be NULL. * @param size * Size (in bytes) to be allocated. * @param align @@ -221,8 +216,7 @@ rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket) * initialised with zeros. * * @param type - * A string identifying the type of allocated objects (useful for debug - * purposes, such as identifying the cause of a memory leak). Can be NULL. + * Legacy argument, never unused should be NULL. * @param num * Number of elements to be allocated. * @param size @@ -502,8 +496,7 @@ rte_malloc_heap_socket_is_external(int socket_id); * @param f * A pointer to a file for output * @param type - * A string identifying the type of objects to dump, or NULL - * to dump all objects. + * Legacy argument, never unused should be NULL. */ void rte_malloc_dump_stats(FILE *f, const char *type); From patchwork Thu Apr 25 18:23:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 139684 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D048F43F09; Thu, 25 Apr 2024 20:28:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 694E24395C; Thu, 25 Apr 2024 20:27:54 +0200 (CEST) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mails.dpdk.org (Postfix) with ESMTP id D480240A67 for ; Thu, 25 Apr 2024 20:27:50 +0200 (CEST) Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6eced6fd98aso1329633b3a.0 for ; Thu, 25 Apr 2024 11:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1714069670; x=1714674470; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OQpbZytS+kY1nG/fJPKUeiyFHYXqSezxflaAnAyheNE=; b=wJN3n+NlO729GVqA/yl4w60D0sDMkuK/MbCZXWQ46b5ILZ/X3HStPm+f3wXuKNdmJH WaC0rEewZEBt/x4QSgwzunpni3Ra9gXwTdouxUK4yglaoax4u69TIlKI4XWcPK66j7rU NK+F2KJHHdwSLYrfgHOMi0f52T7BpdeOO//5Or9QmUjU0V3sRUH+acJeLtvwpDBXFzGi aJplioCXeNfi1Ek9xl4qp2PxRgTkgEMTpfPUFT3IHuQ1SsUr6BdVLWa8RDCZ838yYgkI zkPUmAwIyzhtcjBhXSXD9D+yy+Vb5qVOoAsL2zRgN6h881xkI7knj673sD07lYUNHnqZ 3s+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714069670; x=1714674470; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OQpbZytS+kY1nG/fJPKUeiyFHYXqSezxflaAnAyheNE=; b=aJAY4G3q1La1qdeoD58Qd9mHQkofApuo8ZCOx3jrDssxfNe4nTXSLTzjF7RxG+7O6B cDK+FLc/Hye0U8iP2/L64q3tWf7rbgnAmZ1VjvJ3Zkss7/jSNFJQG2BKrjEyR645w1Re Y6K/gm4VFFrnR4zaTwKN54sSXtp3jUh4BLAUTJM5ZKIl15323Lvy3pXoQIRCireTP2// S2Q3q7Klkc5ub25ZEvUk06uAvz3CLRer6uCJ0kN6mcFyfAlHhs7MPdcV8E0cIKpF6ixo PCawYLEk8Uq2QClhpgl0PZ0cTw8Dkyzd7BmTVipuHrYJwJmYO6pV0LyVCHg+gr6aonj4 SY5A== X-Gm-Message-State: AOJu0Yxx3KICOceaQbmPLdD+I0PvF7KjlDHb0Z3nYT2ntkxaOT3zKlZn CWRhGMTRQ5V0zrtQN/kpDznHiOJZfjcXR2twX581efIMp9aH31gWRLp1irZ5rXqcomiQIMSbfaA p X-Google-Smtp-Source: AGHT+IHduJBmRpJurMZgunEeAYsSzK75fdFqb0wn7mzveMz/DoqH3f0nVduJ035+IjuXXBtcRN74FA== X-Received: by 2002:a05:6a00:a82:b0:6ed:1c7:8c61 with SMTP id b2-20020a056a000a8200b006ed01c78c61mr857411pfl.12.1714069670012; Thu, 25 Apr 2024 11:27:50 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d7-20020a056a00244700b006f0ba1c8ddesm4067006pfj.184.2024.04.25.11.27.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 11:27:49 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC 2/4] devtools/cocci: add script to find unnecessary malloc type Date: Thu, 25 Apr 2024 11:23:59 -0700 Message-ID: <20240425182738.4771-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240425182738.4771-1-stephen@networkplumber.org> References: <20240425182738.4771-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The malloc type argument is unused and should be NULL. This script finds and fixes those places. Signed-off-by: Stephen Hemminger --- devtools/cocci/malloc-type.cocci | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 devtools/cocci/malloc-type.cocci diff --git a/devtools/cocci/malloc-type.cocci b/devtools/cocci/malloc-type.cocci new file mode 100644 index 0000000000..d1101927e0 --- /dev/null +++ b/devtools/cocci/malloc-type.cocci @@ -0,0 +1,27 @@ +// +// The allocation name field in malloc routines was never +// implemented and should be NULL +// +@@ +expression T != NULL; +expression num, socket, size, align; +@@ +( +- rte_malloc(T, size, align) ++ rte_malloc(NULL, size, align) +| +- rte_zmalloc(T, size, align) ++ rte_zmalloc(NULL, size, align) +| +- rte_calloc(T, num, size, align) ++ rte_calloc(NULL, num, size, align) +| +- rte_malloc_socket(T, size, align, socket) ++ rte_malloc_socket(NULL, size, align, socket) +| +- rte_zmalloc_socket(T, size, align, socket) ++ rte_zmalloc_socket(NULL, size, align, socket) +| +- rte_calloc_socket(T, num, size, align, socket) ++ rte_calloc_socket(NULL, num, size, align, socket) +) From patchwork Thu Apr 25 18:24:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 139685 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 427B043F09; Thu, 25 Apr 2024 20:28:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A5FC84395E; Thu, 25 Apr 2024 20:27:55 +0200 (CEST) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mails.dpdk.org (Postfix) with ESMTP id A22EE4394A for ; Thu, 25 Apr 2024 20:27:51 +0200 (CEST) Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6ece8991654so1296263b3a.3 for ; Thu, 25 Apr 2024 11:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1714069671; x=1714674471; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4lICNWD6f1kOwiNNkYWwsph11CvhG6Y5VOkX6jzLgqs=; b=ZSyOfuXA4INhieou9uUr2KM027hf7mJjkNd24492Qs9XizGs809RYdrglaMwRQq0hf mGVUZUQlYjOKcFtw8MUTPNJvEpNYzTbqgJkX4mfbLDuLziP55mJVOnXGo/PZxN3L/Rs2 QNUx+NrRvyb1C6K+BOOOttbzMsx/6OT71O+7iM2QWlY9WUSlYuA5OQ6wYKLoIrftRB53 vPLsSZufDSkwsGfF4m/rpFjGgFsdpwZTB5sTzT0VPKT6cs5CLckk8DWJXR7HxIIi5jx3 TNbXqgPHpqlfS7FmZKeogt8y9svHP0RCjLVqRdFhuc9Tj3oYC56kV58Y7b7ZbSH/XoEU auNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714069671; x=1714674471; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4lICNWD6f1kOwiNNkYWwsph11CvhG6Y5VOkX6jzLgqs=; b=qWs/xn4sciLmhm86/mFfXmhnYDv4gyeFg2fBCJur4rnET4y5dBhK7Oi4pqB/6IqQrZ 47F66s+EOmJG5aqEiAU3aUixGNQQpXTUcUaqPUtSKUVfxeI8FDewxJBvFXhdrgro9MZm kPPDlCs5nFlWFk9WG6VSilrqqpoE7k6eo170xviGpcvrwqgurmeGLTwnnb3JeMYLegdc Z4cGa7CchFIS9aJISF+t3nIA031wW91VqiLvrdm+DaTXHgJtBk+7sTddJJHagqaeiEGl lt4tQvpAIfhK0Mrq7qhb0hACwRaNAjju1/IR915apR/lWk+mpBdOhpdcE0O2aVunGW44 1YpA== X-Gm-Message-State: AOJu0YwBOzpPxyk79okwYBEE1iblYovO9IDjmWfgA1ogh9YNuIPDAOjw tJDYj/pskz+DzIWn/BxjQG2T6ZVAdxhHF0fOappsNAP7IC0Mqv/KXIbwmuWvvCkbFMMwaYWVitf S X-Google-Smtp-Source: AGHT+IHt5aAEtBtPlg+ucnYleBU5io9I7MyceFH68UnWKhfNAtHQeyE7nM2tp9A7HhRNK/2IcQqkPQ== X-Received: by 2002:a05:6a20:918e:b0:1aa:92b3:acd0 with SMTP id v14-20020a056a20918e00b001aa92b3acd0mr696849pzd.25.1714069670831; Thu, 25 Apr 2024 11:27:50 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d7-20020a056a00244700b006f0ba1c8ddesm4067006pfj.184.2024.04.25.11.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 11:27:50 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC 3/4] devtools/cocci: add script to find where rte_calloc should be used Date: Thu, 25 Apr 2024 11:24:00 -0700 Message-ID: <20240425182738.4771-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240425182738.4771-1-stephen@networkplumber.org> References: <20240425182738.4771-1-stephen@networkplumber.org> MIME-Version: 1.0 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 Better to use ret_calloc() than directly multiply up the sizes of objects. Signed-off-by: Stephen Hemminger --- devtools/cocci/prefer-calloc.cocci | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 devtools/cocci/prefer-calloc.cocci diff --git a/devtools/cocci/prefer-calloc.cocci b/devtools/cocci/prefer-calloc.cocci new file mode 100644 index 0000000000..77defed9f6 --- /dev/null +++ b/devtools/cocci/prefer-calloc.cocci @@ -0,0 +1,19 @@ +// +// Prefer use of calloc over zmalloc when allocating multiple objects +// +@@ +expression name, T, num, socket, align; +@@ +( +- rte_zmalloc(name, num * sizeof(T), align) ++ rte_calloc(name, num, sizeof(T), align) +| +- rte_zmalloc(name, sizeof(T) * num, align) ++ rte_calloc(name, num, sizeof(T), align) +| +- rte_zmalloc_socket(name, num * sizeof(T), align, socket) ++ rte_calloc_socket(name, num, sizeof(T), align, socket) +| +- rte_zmalloc_socket(name, sizeof(T) * num, align, socket) ++ rte_calloc_socket(name, num, sizeof(T), align, socket) +) From patchwork Thu Apr 25 18:24:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 139686 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F34F343F09; Thu, 25 Apr 2024 20:28:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 09AE143962; Thu, 25 Apr 2024 20:27:57 +0200 (CEST) Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by mails.dpdk.org (Postfix) with ESMTP id 5D32B4394C for ; Thu, 25 Apr 2024 20:27:52 +0200 (CEST) Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6f07de6ab93so1272751b3a.2 for ; Thu, 25 Apr 2024 11:27:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1714069671; x=1714674471; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eToGpaZd1km8aJMGcaBIZz+3ftXcaJlJuBtSwUPoz8U=; b=AeMjrlYI+mrKfk0oLJc/nv1Tn0JhPesIRurfFORh9z7Td6MD2P2Hh1U8+fDLqDreAP vuu1fLROGj56/N6q8IEOKt6Dh6wrDE3FbXdaHYVVXM3bYzILpKjY7xoXWC+LcNOdLdFa CM4NdKf0L+x+6qyhFNDudTqUQONG7yEmobIqL1eDwER3+L5K8UuN95JBXr8XhGQNEizR 5zzNfK4plq66DK6Vmgh+3sTflRPvhTpaFZVDVB3upM/qGjI1K2cfG6f1t0WWgil6W9xt yMrNJindV2ABC3F43rlacgui5iPrFeGJvVb21/7EFkVK3KopFHXmF1HQmC0t9cueLb0U trxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714069671; x=1714674471; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eToGpaZd1km8aJMGcaBIZz+3ftXcaJlJuBtSwUPoz8U=; b=L8I0vfQ/kLg7Ub2drDWCm3Ym5N9YxjnZu3wXHhIs73z30ZmgVJ5Tloux+gqrS/a0vO RrljIbA2kFvIk/Hu4XOZf9NLtVeGnC9r1E/gakfBjQoTma25foZfgycYopy2E8O2gWqH fz6ZyT5U+TGnp4qDEPOOIWVPh6fgMYxaek4Ra6ST2BKHLaOE3eAM1K72csE+K976Z4G/ 5QXUhouCyjKcWoVEfwO849MhEsm1OqICcUHo/zBP4WRSC1hqjtc8ieP8bgGv1biQGaPw gopHjjyykXGiD+9x0tcgKrDR5+8PMdYFCfeEHY99avxL84bA8MC4QWIXeKlEsT03Ybnr GNEQ== X-Gm-Message-State: AOJu0Yw0xRqTb014TSuHkZSnLwID3IOGxLnndx+5MZQR5v1jj2A/3gXz /Z6iM4AToIDBDGlSgsNA8Q+WkETgqFIfP38LMy9jXoWbccNnvZ13QTHGLpE9BkxYNFLurW3Qu+p O X-Google-Smtp-Source: AGHT+IGAI4Udb8TU58DHFIDzZycafT2UzwkH7RQAUrKflKoGxfOF/Bbycu+09ErvPlI1sRjP2RuBgw== X-Received: by 2002:a05:6a21:144c:b0:1a7:1b6e:4d4 with SMTP id oc12-20020a056a21144c00b001a71b6e04d4mr460494pzb.23.1714069671495; Thu, 25 Apr 2024 11:27:51 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d7-20020a056a00244700b006f0ba1c8ddesm4067006pfj.184.2024.04.25.11.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 11:27:51 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC 4/4] eal/malloc: remove type argument from internal malloc routines Date: Thu, 25 Apr 2024 11:24:01 -0700 Message-ID: <20240425182738.4771-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240425182738.4771-1-stephen@networkplumber.org> References: <20240425182738.4771-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The type argument is carried through malloc heap routines but never used. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_memzone.c | 6 ++--- lib/eal/common/malloc_heap.c | 39 ++++++++++++---------------- lib/eal/common/malloc_heap.h | 7 +++-- lib/eal/common/rte_malloc.c | 16 +++++------- lib/eal/include/eal_trace_internal.h | 4 +-- 5 files changed, 29 insertions(+), 43 deletions(-) diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c index 32e6b78f87..2d9b6aa3e3 100644 --- a/lib/eal/common/eal_common_memzone.c +++ b/lib/eal/common/eal_common_memzone.c @@ -191,14 +191,12 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, if (len == 0 && bound == 0) { /* no size constraints were placed, so use malloc elem len */ requested_len = 0; - mz_addr = malloc_heap_alloc_biggest(NULL, socket_id, flags, - align, contig); + mz_addr = malloc_heap_alloc_biggest(socket_id, flags, align, contig); } else { if (len == 0) requested_len = bound; /* allocate memory on heap */ - mz_addr = malloc_heap_alloc(NULL, requested_len, socket_id, - flags, align, bound, contig); + mz_addr = malloc_heap_alloc(requested_len, socket_id, flags, align, bound, contig); } if (mz_addr == NULL) { rte_errno = ENOMEM; diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index 5ff27548ff..058aaf4209 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -229,8 +229,8 @@ find_biggest_element(struct malloc_heap *heap, size_t *size, * the new element after releasing the lock. */ static void * -heap_alloc(struct malloc_heap *heap, const char *type __rte_unused, size_t size, - unsigned int flags, size_t align, size_t bound, bool contig) +heap_alloc(struct malloc_heap *heap, size_t size, unsigned int flags, + size_t align, size_t bound, bool contig) { struct malloc_elem *elem; size_t user_size = size; @@ -255,8 +255,7 @@ heap_alloc(struct malloc_heap *heap, const char *type __rte_unused, size_t size, } static void * -heap_alloc_biggest(struct malloc_heap *heap, const char *type __rte_unused, - unsigned int flags, size_t align, bool contig) +heap_alloc_biggest(struct malloc_heap *heap, unsigned int flags, size_t align, bool contig) { struct malloc_elem *elem; size_t size; @@ -640,8 +639,7 @@ alloc_more_mem_on_socket(struct malloc_heap *heap, size_t size, int socket, /* this will try lower page sizes first */ static void * -malloc_heap_alloc_on_heap_id(const char *type, size_t size, - unsigned int heap_id, unsigned int flags, size_t align, +malloc_heap_alloc_on_heap_id(size_t size, unsigned int heap_id, unsigned int flags, size_t align, size_t bound, bool contig) { struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; @@ -658,7 +656,7 @@ malloc_heap_alloc_on_heap_id(const char *type, size_t size, /* for legacy mode, try once and with all flags */ if (internal_conf->legacy_mem) { - ret = heap_alloc(heap, type, size, flags, align, bound, contig); + ret = heap_alloc(heap, size, flags, align, bound, contig); goto alloc_unlock; } @@ -679,7 +677,7 @@ malloc_heap_alloc_on_heap_id(const char *type, size_t size, if (socket_id < 0) size_flags |= RTE_MEMZONE_SIZE_HINT_ONLY; - ret = heap_alloc(heap, type, size, size_flags, align, bound, contig); + ret = heap_alloc(heap, size, size_flags, align, bound, contig); if (ret != NULL) goto alloc_unlock; @@ -689,7 +687,7 @@ malloc_heap_alloc_on_heap_id(const char *type, size_t size, if (!alloc_more_mem_on_socket(heap, size, socket_id, flags, align, bound, contig)) { - ret = heap_alloc(heap, type, size, flags, align, bound, contig); + ret = heap_alloc(heap, size, flags, align, bound, contig); /* this should have succeeded */ if (ret == NULL) @@ -730,8 +728,8 @@ malloc_get_numa_socket(void) } void * -malloc_heap_alloc(const char *type, size_t size, int socket_arg, - unsigned int flags, size_t align, size_t bound, bool contig) +malloc_heap_alloc(size_t size, int socket_arg, unsigned int flags, + size_t align, size_t bound, bool contig) { int socket, heap_id, i; void *ret; @@ -754,8 +752,7 @@ malloc_heap_alloc(const char *type, size_t size, int socket_arg, if (heap_id < 0) return NULL; - ret = malloc_heap_alloc_on_heap_id(type, size, heap_id, flags, align, - bound, contig); + ret = malloc_heap_alloc_on_heap_id(size, heap_id, flags, align, bound, contig); if (ret != NULL || socket_arg != SOCKET_ID_ANY) return ret; @@ -765,8 +762,7 @@ malloc_heap_alloc(const char *type, size_t size, int socket_arg, for (i = 0; i < (int) rte_socket_count(); i++) { if (i == heap_id) continue; - ret = malloc_heap_alloc_on_heap_id(type, size, i, flags, align, - bound, contig); + ret = malloc_heap_alloc_on_heap_id(size, i, flags, align, bound, contig); if (ret != NULL) return ret; } @@ -774,7 +770,7 @@ malloc_heap_alloc(const char *type, size_t size, int socket_arg, } static void * -heap_alloc_biggest_on_heap_id(const char *type, unsigned int heap_id, +heap_alloc_biggest_on_heap_id(unsigned int heap_id, unsigned int flags, size_t align, bool contig) { struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; @@ -785,7 +781,7 @@ heap_alloc_biggest_on_heap_id(const char *type, unsigned int heap_id, align = align == 0 ? 1 : align; - ret = heap_alloc_biggest(heap, type, flags, align, contig); + ret = heap_alloc_biggest(heap, flags, align, contig); rte_spinlock_unlock(&(heap->lock)); @@ -793,8 +789,7 @@ heap_alloc_biggest_on_heap_id(const char *type, unsigned int heap_id, } void * -malloc_heap_alloc_biggest(const char *type, int socket_arg, unsigned int flags, - size_t align, bool contig) +malloc_heap_alloc_biggest(int socket_arg, unsigned int flags, size_t align, bool contig) { int socket, i, cur_socket, heap_id; void *ret; @@ -817,8 +812,7 @@ malloc_heap_alloc_biggest(const char *type, int socket_arg, unsigned int flags, if (heap_id < 0) return NULL; - ret = heap_alloc_biggest_on_heap_id(type, heap_id, flags, align, - contig); + ret = heap_alloc_biggest_on_heap_id(heap_id, flags, align, contig); if (ret != NULL || socket_arg != SOCKET_ID_ANY) return ret; @@ -827,8 +821,7 @@ malloc_heap_alloc_biggest(const char *type, int socket_arg, unsigned int flags, cur_socket = rte_socket_id_by_idx(i); if (cur_socket == socket) continue; - ret = heap_alloc_biggest_on_heap_id(type, i, flags, align, - contig); + ret = heap_alloc_biggest_on_heap_id(i, flags, align, contig); if (ret != NULL) return ret; } diff --git a/lib/eal/common/malloc_heap.h b/lib/eal/common/malloc_heap.h index 0c49588005..dfc56d4ae3 100644 --- a/lib/eal/common/malloc_heap.h +++ b/lib/eal/common/malloc_heap.h @@ -34,12 +34,11 @@ struct __rte_cache_aligned malloc_heap { }; void * -malloc_heap_alloc(const char *type, size_t size, int socket, unsigned int flags, - size_t align, size_t bound, bool contig); +malloc_heap_alloc(size_t size, int socket, unsigned int flags, size_t align, + size_t bound, bool contig); void * -malloc_heap_alloc_biggest(const char *type, int socket, unsigned int flags, - size_t align, bool contig); +malloc_heap_alloc_biggest(int socket, unsigned int flags, size_t align, bool contig); int malloc_heap_create(struct malloc_heap *heap, const char *heap_name); diff --git a/lib/eal/common/rte_malloc.c b/lib/eal/common/rte_malloc.c index 6d3c301a23..d1fcb2eff6 100644 --- a/lib/eal/common/rte_malloc.c +++ b/lib/eal/common/rte_malloc.c @@ -51,8 +51,7 @@ eal_free_no_trace(void *addr) } static void * -malloc_socket(const char *type, size_t size, unsigned int align, - int socket_arg, const bool trace_ena) +malloc_socket(size_t size, unsigned int align, int socket_arg, const bool trace_ena) { void *ptr; @@ -69,11 +68,11 @@ malloc_socket(const char *type, size_t size, unsigned int align, !rte_eal_has_hugepages()) socket_arg = SOCKET_ID_ANY; - ptr = malloc_heap_alloc(type, size, socket_arg, 0, + ptr = malloc_heap_alloc(size, socket_arg, 0, align == 0 ? 1 : align, 0, false); if (trace_ena) - rte_eal_trace_mem_malloc(type, size, align, socket_arg, ptr); + rte_eal_trace_mem_malloc(size, align, socket_arg, ptr); return ptr; } @@ -81,16 +80,15 @@ malloc_socket(const char *type, size_t size, unsigned int align, * Allocate memory on specified heap. */ void * -rte_malloc_socket(const char *type, size_t size, unsigned int align, - int socket_arg) +rte_malloc_socket(const char *type __rte_unused, size_t size, unsigned int align, int socket_arg) { - return malloc_socket(type, size, align, socket_arg, true); + return malloc_socket(size, align, socket_arg, true); } void * -eal_malloc_no_trace(const char *type, size_t size, unsigned int align) +eal_malloc_no_trace(const char *type __rte_unused, size_t size, unsigned int align) { - return malloc_socket(type, size, align, SOCKET_ID_ANY, false); + return malloc_socket(size, align, SOCKET_ID_ANY, false); } /* diff --git a/lib/eal/include/eal_trace_internal.h b/lib/eal/include/eal_trace_internal.h index 09c354717f..fa104c975f 100644 --- a/lib/eal/include/eal_trace_internal.h +++ b/lib/eal/include/eal_trace_internal.h @@ -103,9 +103,7 @@ RTE_TRACE_POINT( RTE_TRACE_POINT( rte_eal_trace_mem_malloc, - RTE_TRACE_POINT_ARGS(const char *type, size_t size, unsigned int align, - int socket, void *ptr), - rte_trace_point_emit_string(type); + RTE_TRACE_POINT_ARGS(size_t size, unsigned int align, int socket, void *ptr), rte_trace_point_emit_size_t(size); rte_trace_point_emit_u32(align); rte_trace_point_emit_int(socket);