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 ABD8843C39; Sat, 2 Mar 2024 12:19:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 74F004025E; Sat, 2 Mar 2024 12:19:16 +0100 (CET) Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) by mails.dpdk.org (Postfix) with ESMTP id F1CF2400D5 for ; Sat, 2 Mar 2024 12:19:15 +0100 (CET) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 94CFE11DF for ; Sat, 2 Mar 2024 12:19:15 +0100 (CET) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id 888E411DD; Sat, 2 Mar 2024 12:19:15 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on hermod.lysator.liu.se X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED,AWL, T_SCC_BODY_TEXT_LINE autolearn=disabled version=4.0.0 X-Spam-Score: -1.4 Received: from [192.168.1.59] (h-62-63-215-114.A163.priv.bahnhof.se [62.63.215.114]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 12004115A; Sat, 2 Mar 2024 12:19:14 +0100 (CET) Message-ID: <35267b46-f3cb-4967-a09c-9f512104afca@lysator.liu.se> Date: Sat, 2 Mar 2024 12:19:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 01/71] cocci/rte_memcpy: add script to eliminate fixed size rte_memcpy Content-Language: en-US To: Stephen Hemminger , dev@dpdk.org References: <20240229225936.483472-1-stephen@networkplumber.org> <20240301171707.95242-1-stephen@networkplumber.org> <20240301171707.95242-2-stephen@networkplumber.org> From: =?UTF-8?Q?Mattias_R=C3=B6nnblom?= In-Reply-To: <20240301171707.95242-2-stephen@networkplumber.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP 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 2024-03-01 18:14, Stephen Hemminger wrote: > Rte_memcpy should not be used for the simple case of copying > a fix size structure because it is slower and will hide problems > from code analysis tools. Coverity, fortify and other analyzers > special case memcpy(). > > Gcc (and Clang) are smart enough to inline copies which > will be faster. > Are you suggesting rte_memcpy() calls aren't inlined? > Signed-off-by: Stephen Hemminger > --- > devtools/cocci/rte_memcpy.cocci | 11 +++++++++++ > 1 file changed, 11 insertions(+) > create mode 100644 devtools/cocci/rte_memcpy.cocci > > diff --git a/devtools/cocci/rte_memcpy.cocci b/devtools/cocci/rte_memcpy.cocci > new file mode 100644 > index 000000000000..fa1038fc066d > --- /dev/null > +++ b/devtools/cocci/rte_memcpy.cocci > @@ -0,0 +1,11 @@ > +// > +// rte_memcpy should not be used for simple fixed size structure > +// because compiler's are smart enough to inline these. > +// What do you do in code where it's not known if the size will be constant or not? > +@@ > +expression src, dst; constant size; > +@@ > +( > +- rte_memcpy(dst, src, size) > ++ memcpy(dst, src, size) > +)