From patchwork Tue Nov 26 23:21:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2480ED66BAB for ; Tue, 26 Nov 2024 23:23:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844046.1259596 (Exim 4.92) (envelope-from ) id 1tG4tm-0000OO-40; Tue, 26 Nov 2024 23:23:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844046.1259596; Tue, 26 Nov 2024 23:23:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tl-0000Ni-VH; Tue, 26 Nov 2024 23:23:13 +0000 Received: by outflank-mailman (input) for mailman id 844046; Tue, 26 Nov 2024 23:22:01 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sb-0000Ao-I9 for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:01 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3aa60ca8-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:21:57 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 8DBEA5C5C0D; Tue, 26 Nov 2024 23:21:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 79CDAC4CEDD; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BC62D66B89; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3aa60ca8-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNhYTYwY2E4LWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzE4LjA5Nzk5Miwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663315; bh=xRl/VI33XtcNQyJ8toSM7CxORY63SAcLHHhJDp/5VHE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=RdupsLJVIRafQLWxJMPEhpP/XHYk4ho+6qgZbdxC8XWaZKfDeIdNdkxnFyp5JmVMD bymk/6NP2NGllgK/rnULmAZNoSi9ArJupKYHrs8c7J4eOO87gCwDmpd+kP8TW7chPq GPtg76P4sN/1vs8Wc3mg82ZjzroFo8mLGeCEzAjgM0OZ65hkvaaL8cKSGU9BT2t9tB T8Q92HbKVu7M9XePQndcz3RfJ1J21soYc9KCRwMHiSmGY0C1Uc07qblTocMmoburKs 9Yy6Y9xAmpK+dwHCcX9WGZJZjUQUWe8kSEhqaBf9S/XeHwEfsdCpl/P9JTwfUGi8Aq HFQgAR3Tfy4HA== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:21:55 -0800 Subject: [PATCH 05/36] xen/xmalloc: add kmalloc() and kfree() aliases MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-5-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=2077; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=izvZS5PqvGBio87RDretaNG85fhbAWhHk9N0az9Fz9c=; b=DxooxiraEmxSjKMVEBBQD4C5YYEkrJbAOK1wZaShOd6buUxM3dQFSSYYVIfElWUereMJvfwLg Wj8gFWn4yIjB0TL6qPikxL3D5RpBO5Qg26QYelUQogHdovGoR4kWouc X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Move existing aliases to a common header so those could be used in the new code. The code looks simpler w/ kmalloc(): type specification of the object being allocated is not required, e.g.: ... struct my_obj_s *obj; obj = kmalloc(sizeof(*obj), 0); ... Signed-off-by: Denis Mukhin --- xen/drivers/passthrough/arm/smmu.c | 4 ---- xen/include/xen/xmalloc.h | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index aa6a968b574dce7cc753e8070fad3a6e585cd9e7..b343dbc32282136ccb95654ae2756eaa8a51149f 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -136,11 +136,7 @@ typedef enum irqreturn irqreturn_t; #define dev_name(dev) dt_node_full_name(dev_to_dt(dev)) /* Alias to Xen allocation helpers */ -#define kfree xfree -#define kmalloc(size, flags) _xmalloc(size, sizeof(void *)) -#define kzalloc(size, flags) _xzalloc(size, sizeof(void *)) #define devm_kzalloc(dev, size, flags) _xzalloc(size, sizeof(void *)) -#define kmalloc_array(size, n, flags) _xmalloc_array(size, sizeof(void *), n) #define devm_kcalloc(dev, n, size, flags) \ _xzalloc_array(size, sizeof(void *), n) diff --git a/xen/include/xen/xmalloc.h b/xen/include/xen/xmalloc.h index b903fa2e26e198fc80fc6010c3165cc50b1197c7..eea8cced51d9fe784b558201a68648e1672d624f 100644 --- a/xen/include/xen/xmalloc.h +++ b/xen/include/xen/xmalloc.h @@ -16,6 +16,11 @@ #define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type))) #define xzalloc(_type) ((_type *)_xzalloc(sizeof(_type), __alignof__(_type))) +#define kfree xfree +#define kmalloc(size, flags) _xmalloc(size, sizeof(void *)) +#define kzalloc(size, flags) _xzalloc(size, sizeof(void *)) +#define kmalloc_array(size, n, flags) _xmalloc_array(size, sizeof(void *), n) + /* * Allocate space for a typed object and copy an existing instance. *