From patchwork Fri Apr 5 16:53:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 139135 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 628F543E0C; Fri, 5 Apr 2024 18:55:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 146384067D; Fri, 5 Apr 2024 18:55:40 +0200 (CEST) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by mails.dpdk.org (Postfix) with ESMTP id DF8CF402CE for ; Fri, 5 Apr 2024 18:55:37 +0200 (CEST) Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6ecc9f0bdaaso1865060b3a.1 for ; Fri, 05 Apr 2024 09:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1712336137; x=1712940937; 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=lN/P2ynaspZBYC0V2kpB/XNQsVjxxcNkYZCwr4zPgSA=; b=bYHZ6PbFv63WOrHff5dEGBR+SdLCgpuaEkI6IdeLw7hO9dImhQtllIjQBlc/wU1rT1 NQgqyqVU41LM2ZAV9A1tzC3AfmEMCUrSuNOKbc4lWibm5vRgX3+TewByfhuEcstEBJHp hQl2wBg/Zk06BcMDUWMA3sTWDLw7L8p0k0PDtQOTWdsb8ahZr2XllSNC9e8rqZIJ4NcR LKXZOXYQZIKrHKRtqlUT9DmjG+SLunNF2xZxNsac3wuFI4wlKBdwTXoFGZvwospdOJyC HHrsmadBkjUNah6dm4ahMC6b9gg06XQEha0frpui7Px3OHWmLGpQg/TvM6iJ+vR1HTih fSYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712336137; x=1712940937; 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=lN/P2ynaspZBYC0V2kpB/XNQsVjxxcNkYZCwr4zPgSA=; b=SRC5q+CSLeE/W34FqlfkBZGph/GTKALV/zqjiT+JSbN/DZwLFijCH1fnjDToLYEQ3n SjHWs+VmbUkarrciFNdQauCdRmULdP1PC4ORSqJzDnIsEZNHwgH1Cxui8vB0DuwD/W+p Lc9mabDANBhG0+9AZXt7E2RIPaPjXA1zOU22ML1VwWDYti9MQaPgEeUffetwzUhxveB5 fdd5b2yIhGHxBkvxnpM/Yt0Ea/4/Nhe0hGwuPEoY7lqTBobhe1Q9dRvKmNAMzS1/kk4B lnY/YouuAqKZMkeMZrjheOikzLm8RaV+tkKKh/89l3dQrjfh4MAddR0nAu9+Q43KyJNJ ow+g== X-Gm-Message-State: AOJu0Yw/E5pbnDYV82tsBu2CDIt4VrbNGQ6RKy0356bpslBwidEKSpf1 fMwqFVrLOfDMN6QLyAoaAiEsHJwhaVzPn4peDikqp7NsXxtZdeKiW9vGfuqLdA+zN9bTMh3MYUN 4hc8= X-Google-Smtp-Source: AGHT+IECQdGy/zAkSuA5I8+2M4mKHMl9qBUsp44b0AncpQpi8MlpENGy5cvNF7+9L5+yHVPvpywnRg== X-Received: by 2002:a05:6a00:1acb:b0:6ec:fcfc:de6a with SMTP id f11-20020a056a001acb00b006ecfcfcde6amr2203670pfv.32.1712336136867; Fri, 05 Apr 2024 09:55:36 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id c2-20020aa781c2000000b006e6c0f8ce1bsm1728555pfn.47.2024.04.05.09.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 09:55:36 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v4 01/30] cocci/rte_memcpy: add script to eliminate fixed size rte_memcpy Date: Fri, 5 Apr 2024 09:53:12 -0700 Message-ID: <20240405165518.367503-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240405165518.367503-1-stephen@networkplumber.org> References: <20240403163432.437275-1-stephen@networkplumber.org> <20240405165518.367503-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 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. Signed-off-by: Stephen Hemminger Acked-by: Morten Brørup --- 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 0000000000..fa1038fc06 --- /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. +// +@@ +expression src, dst; constant size; +@@ +( +- rte_memcpy(dst, src, size) ++ memcpy(dst, src, size) +)