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 A2F6E45A96; Wed, 2 Oct 2024 09:06:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D9B140268; Wed, 2 Oct 2024 09:06:56 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id CCEAA4003C for ; Wed, 2 Oct 2024 09:06:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727852814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tKntG1/EssKHDjmNWXWukpNq5LVCPv1GqessYP9d7d0=; b=BEZRTQcI1eQ5Xb18a7OhUKFZ6qdXNgscK4JpRtl42+fepzxnYTa+NKLk/Rl7Qj9IOM6eq9 /azUvoMMo/L5FODR/e0Wyk5YXrRA3eSAEgrw8RamF0Wl/stGBHa9CiAFSVd56xow5Y1u5G vQcCP8IUHqEOeAdjb7Q/0GaEeXP50M0= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-286-DuWVBLiKOFWgC5Ubj3XcLg-1; Wed, 02 Oct 2024 03:06:53 -0400 X-MC-Unique: DuWVBLiKOFWgC5Ubj3XcLg-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-53996a1e52bso2764114e87.0 for ; Wed, 02 Oct 2024 00:06:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727852812; x=1728457612; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tKntG1/EssKHDjmNWXWukpNq5LVCPv1GqessYP9d7d0=; b=oqgMep6ZORajpLZpjKiJ7j1tGHNoQfUnZDC30YWY+8+vPosCxCoo+6a0SrcrYsfWKT wNP3I/dd1mDwsP29S/DAcpppl+a9YcWGLEFpUtmtE4kTjU0JlUN7ml6E9yTIYELPIMTZ YyW7uWVscXQ2yqSegozLd6qS7LbowkOhG51P/X/to6QE+J4MsPrNJSeEh9ByMfQVoN8M z8PZVhK9WKOxv8Pgb/koczy33j84c0YG2qbXAEwJz82eva3d7V8JqYuvYpvuePX2WC5H 76wtoBn28Jlr20ece1jRPXUYzcjuYom7wdJtLmziGjw8VDTbz83/fyEYWC6KSvymmOsv sthQ== X-Gm-Message-State: AOJu0Yz/Jhs4Z1elX5EAgkJDFh8Y0tfAfz3WqbXsW7CV3snR8wUIKQQ8 gK3mxJLF2L4wvlWyRf2fyoeZnfDjBYMrwc5Qz6aserZ1gKUPkxPzN1MfmhmRvc93FwbutGZcc0P YGe5W5+E3CgEY7Kk9itg3gYhyXvdyI1XjiuF1hZiVi0+719E1SCVy2HEdsb6Z4bWmYAcp9/OguS QYsL6emdyJpAsoGos= X-Received: by 2002:a05:6512:4018:b0:539:8f2d:a3bc with SMTP id 2adb3069b0e04-539a07a9d79mr984807e87.49.1727852811680; Wed, 02 Oct 2024 00:06:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPl9GfEur220mCLU09zqrldmnghzC1hScTivApT1TyCh+E2xTYKWy9lIxRZ6eLW/qnFkoRDgvJqwOWHn2m1Ok= X-Received: by 2002:a05:6512:4018:b0:539:8f2d:a3bc with SMTP id 2adb3069b0e04-539a07a9d79mr984796e87.49.1727852811280; Wed, 02 Oct 2024 00:06:51 -0700 (PDT) MIME-Version: 1.0 References: <20240927204742.546164-1-stephen@networkplumber.org> <20241001163708.355128-1-stephen@networkplumber.org> <20241001163708.355128-18-stephen@networkplumber.org> In-Reply-To: <20241001163708.355128-18-stephen@networkplumber.org> From: David Marchand Date: Wed, 2 Oct 2024 09:06:40 +0200 Message-ID: Subject: Re: [PATCH v5 17/17] eal: add function attributes for allocation functions To: Stephen Hemminger Cc: dev@dpdk.org, Chengwen Feng , Anatoly Burakov , Tyler Retzlaff , =?UTF-8?Q?Morten_Br=C3=B8rup?= X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Tue, Oct 1, 2024 at 6:39=E2=80=AFPM Stephen Hemminger wrote: > diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h > index eec0400dad..595cadd5b8 100644 > --- a/lib/eal/include/rte_common.h > +++ b/lib/eal/include/rte_common.h > @@ -228,6 +228,40 @@ typedef uint16_t unaligned_uint16_t; > #define __rte_alloc_size(...) > #endif > > +/** > + * Tells the compiler that the function returns a value that points to > + * memory aligned by a function argument. > + * > + * Note: not enabled on Clang because it warns if align argument is zero= . > + */ > +#if defined(RTE_CC_GCC) > +#define __rte_alloc_align(argno) __attribute__((alloc_align(argno))) > +#else > +#define __rte_alloc_align(argno) > +#endif > + > +/** > + * Tells the compiler this is a function like malloc and that the pointe= r > + * returned cannot alias any other pointer (ie new memory). > + */ > +#if defined(RTE_CC_GCC) || defined(RTE_CC_CLANG) > +#define __rte_malloc __attribute__((malloc)) > +#else > +#define __rte_malloc > +#endif > + > +/** > + * With recent GCC versions also able to track that proper > + * dealloctor function is used for this pointer. deallocator* > + */ > +#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >=3D 110000) > +#define __rte_dealloc(dealloc, argno) __attribute__((malloc(dealloc, arg= no))) > +#define __rte_dealloc_free __rte_dealloc(rte_free, 1) __rte_dealloc_free should not be in rte_common.h but in rte_malloc.h. > +#else > +#define __rte_dealloc(dealloc, argno) > +#define __rte_dealloc_free > +#endif > + > #define RTE_PRIORITY_LOG 101 > #define RTE_PRIORITY_BUS 110 > #define RTE_PRIORITY_CLASS 120 > diff --git a/lib/eal/include/rte_malloc.h b/lib/eal/include/rte_malloc.h > index 1f91e7bdde..9261605939 100644 > --- a/lib/eal/include/rte_malloc.h > +++ b/lib/eal/include/rte_malloc.h > @@ -31,6 +31,22 @@ struct rte_malloc_socket_stats { > size_t heap_allocsz_bytes; /**< Total allocated bytes on heap */ > }; > > + Nit: no need for extra line. > +/** > + * Frees the memory space pointed to by the provided pointer. > + * > + * This pointer must have been returned by a previous call to > + * rte_malloc(), rte_zmalloc(), rte_calloc() or rte_realloc(). The behav= iour of > + * rte_free() is undefined if the pointer does not match this requiremen= t. > + * --=20 David Marchand