Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1286359rdb; Wed, 24 Jan 2024 10:11:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYGbviAs5j0AtblUpf0Sdhmf86fStHMX2w9cOJZhXHpnr3AqtSeEBU9ckHkemDgEyW/qcs X-Received: by 2002:ad4:576f:0:b0:685:3e97:28be with SMTP id r15-20020ad4576f000000b006853e9728bemr3059903qvx.83.1706119862452; Wed, 24 Jan 2024 10:11:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706119862; cv=pass; d=google.com; s=arc-20160816; b=iwmB/473OCY69mFUHdaR860SHoBfYxLLI3kwR7Ye2HgbW4LNNu7XFFWZ65znc6fnoZ xCYpQFgvXzmuciLTDnVWlJNMOJE2UXZ1i/TJ/ipmSI8ZO1LHIeDKj0F/lyh9SU5GYrJq nBL/aSuZ+98i5N9CTGQrJyejkGfSB1pn8m/zPKFgkgJyTdFQs8QE9QxFNsW+WmIonjgk jpbiKjINOhZY5BZDm9F8QcnCEt1tTOPIvUhVdj228iScULhY2C8OyoFSDd4jHtPqts03 qytnKh13BWIIqWpb61DzyAB7IkS+xyXifX13Hw6OANTylPN4eW57Cq09db/+X95OurWB Y3iQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:subject:from:cc:to :content-language:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=tcaTYT9XLlgub7zVxU5yN++R8fNU1BKmqhWIRrUYMVY=; fh=7qlLB3DJMk6jWnyatd+BDFmU28YZAnxeKHtOQTe/TYM=; b=nt7TJ72AOM9JH3asa5kJgew5W7SoPE4NGklwO82qBw4D21x3ESs22UnLw9FEryn9dq CYZKDLf4EQGYgOfUkmvaHpU5cu94nukZdq3FRBCTsC9k8/Hg+GNWnFdc9Bz2qxW2sKyX wSz9onTBupGnoULtIhy5l32bLaRKb26flUlUYSMCPKtcJrydBD+nXP90OHHXNH7/xETD wcP2iAfjv2KLqPzyWnL4hRE7GDlQZNQbZWu+uJVGsmvXtpayqNTMS01bdf8NLGl2UTJo 1GfMwMudl3hNpnIQ5rxiz/knKWZboqgBuTJdIGBgEP4lsta5YLsCXF1uNXSq2kwJocfO qYVg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=LCDlsrHU; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-kernel+bounces-37487-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37487-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r26-20020a0cb29a000000b00686a076dec1si4203841qve.483.2024.01.24.10.11.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 10:11:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37487-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=LCDlsrHU; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-kernel+bounces-37487-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37487-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5BC4E1C22022 for ; Wed, 24 Jan 2024 18:10:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2D9412A159; Wed, 24 Jan 2024 18:09:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="LCDlsrHU" Received: from mout.web.de (mout.web.de [212.227.17.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F0B112AADB; Wed, 24 Jan 2024 18:09:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706119777; cv=none; b=k4gCQdpV4eWN2orUWiRMgpCg7QIzZgbzsKuO3xBPw4ZuRkKEuK6u/iaV7DT+xiimnXLl7LrFqyjsS141gwKsDNkMlV+h4jMERHhjrV38BzIC/XMjKqKQlbTh5OwDSncERxCJP2WalhptroSxVFHdpF8rGOtUIBRrUInFaZISwrE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706119777; c=relaxed/simple; bh=tcaTYT9XLlgub7zVxU5yN++R8fNU1BKmqhWIRrUYMVY=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=aw3kgHm4zw7nM/z4cN+xkaMNXvYru/esKl5VRQfp+u8UfHqdjgH6QV9UYqTjLtuovXXab7T1J4Ohw8cfFtuIbCZ6AtcrdksiiJhSmt+fehOJg5rHF7HVRtCbXxO/+u+2OzKZV8onB8FiCj4MLqBtGu0qPWVc/oAw1LswpW0epk0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b=LCDlsrHU; arc=none smtp.client-ip=212.227.17.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1706119753; x=1706724553; i=markus.elfring@web.de; bh=tcaTYT9XLlgub7zVxU5yN++R8fNU1BKmqhWIRrUYMVY=; h=X-UI-Sender-Class:Date:To:Cc:From:Subject; b=LCDlsrHUztOXda8WecVV3myWPXt97jl6PoJ/xExvT1yzsGkdAt1mFRb3tkHNooiz uPAyoP74GYydQ2M63gcXlmLA8nP2Ue7Hz0/7MQwGvwd+4tA2DK6WPQDKLEKRIm3eJ fN09k23zdW3N24xmyidKv2HwxEH0Lm+dZ/g/OL/9hjbT40XNx4gENLa+UIqzWSuD1 LCg5qVFkcuUFLsNUpbe7QOtv3P0hO1bzxTV0ZHdbLRLDyDZNDRNm+Bt6mFmhenWDK cIyrAxVxdsdTU15HAc4ef/3R9PCQhK/Rih9JO/6kjjXhtJYCxoIifmcn7xKgBr5+n w1jQAelrwrTSC9Y+CA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.81.95]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MWzCt-1rYzCq0Gc5-00XOul; Wed, 24 Jan 2024 19:09:13 +0100 Message-ID: <8d53ac92-9693-4ff9-948c-29b7fb252b89@web.de> Date: Wed, 24 Jan 2024 19:09:10 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-GB To: cocci@inria.fr, kernel-janitors@vger.kernel.org, Julia Lawall , Nicolas Palix Cc: LKML , Kunwu Chan From: Markus Elfring Subject: =?UTF-8?Q?=5BPATCH=5D_Coccinelle=3A_api=3A_Add_SmPL_script_?= =?UTF-8?B?4oCcdXNlX0tNRU1fQ0FDSEUuY29jY2nigJ0=?= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:R+R+0lFc93rU0ByW3WjO8aNyBaw+zZ0nWeefyndetMWQjTB/K2F 5Qs9KmaTDM8lc+hBShh1Jsdd9rCRklmtn9O/axOuDeVu6CAQUm+Xb83MeY1hIJNUMZuhQ6A UodX6lzF+blrzcYd+ls9CN9K2ksUX2Y6OWtA8+gl9ioK7rn328uTHXrFRrs6vKJcLUP5nir Gl14Wh7ywvGEzSKFM+bTg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:t6CMuhiGozs=;C7xlARAWolS5eb6itI9pt00VJi/ 4CUWvA7WSWEt4RQZgh8ygzv69tSq8oyVYDKOmTMSkOAwHIYXkTrS2Ot9Wa73Ljuf7/8igDyD1 8g/t1HxR4peObdDVivgVUWq6MZjpvVyvKfxmbzJt5ukjKblOkVJ2hpmIcRrzeND8zwS2J4T+x SbFXbqOMMFW/5dlHxHR47CUoSbdCMDrPakk4reRYvIP8DhAbIYNAFb57V83xz5g9h4Jol6OKy r10omdKMW2RmVBnkCFsgZVy+HnoRl6WkhSIJRMT1EniNCPRlu0sNZOmvPaGh+FAW5D16NZi+i rkn7sFVfHyp43eeTM+2omt7FU5GbLm9IaIcnStBAKNlHdpMqAjF7/k43r7X1wgulsgQrMJKI7 U4J5BLfXO0puWdufADxxC/8FNJIdsyM5nFYPp57qOCP2Dfx8rMYqSsfTcpImqhb6L3WyatxDb M+jEGBwf73Jp28OIbpNb6DJh6eqGckdqHl2pcLWLEUvrf2GBOwx/a5ArRL0GsqQZ6HrVIOBJo 1u8lly/QZORv724G2EY4F/lcCI0VmfKuaXEGNBw6ADC3DIEzBJCb6bwWdCXCFxcnLqsh3aVpq jvoZ6qOTHkyHL+zeWwBV2IRcdkMYhEBPgP7420X+7O7Cf8CsnAy8cS2D+W8rb7YzuTeLl4LUj FNEkGDPryls8Lk7RehHRG8+yGBmiu4IFC7dUKnUTS615+ax/MRM6GfQoE3vzx+p1+cAqpn8lL E1roYgG0uQ4t7j1abzv3M19U/0s4jBNklFCI2xQVnGUThiaJyd2J6gQ08U6Tkx+ZIc9+t1SsE komaH+oOd4NSZzTRWQDKCd7mxTNqhGRsUMa5g6I/XE7teHMqP6J3Mfg4iQ01ZgrUKhx2wE9AB J4G2s8//n5uwugciYUtXJeM7E6ehuMxR6u87ZPBFNksMTLmrTXLbFVEplZPjlV1QWV2gLB8uP SBd0DQ== From: Markus Elfring Date: Wed, 24 Jan 2024 18:38:39 +0100 A wrapper macro is available since the commit 8eb8284b412906181357c2b0110d= 879d5af95e52 ("usercopy: Prepare for usercopy whitelisting"). Provide design options for the adjustment of affected source code by the means of the semantic patch language (Coccinelle software). Signed-off-by: Markus Elfring =2D-- scripts/coccinelle/api/use_KMEM_CACHE.cocci | 48 +++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 scripts/coccinelle/api/use_KMEM_CACHE.cocci diff --git a/scripts/coccinelle/api/use_KMEM_CACHE.cocci b/scripts/coccine= lle/api/use_KMEM_CACHE.cocci new file mode 100644 index 000000000000..259a8c998bb1 =2D-- /dev/null +++ b/scripts/coccinelle/api/use_KMEM_CACHE.cocci @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0 +/// Simplify a function call by using a known wrapper macro. +// +// Keywords: wrapper macro conversion cache creation +// Confidence: High +// Options: --no-includes --include-headers + +virtual context, patch, report, org + +@depends on context disable sizeof_type_expr@ +constant char[] text; +expression alignment, flags; +identifier name; +@@ +*kmem_cache_create(text, sizeof(struct name), alignment, flags, NULL) + +@depends on patch disable sizeof_type_expr@ +constant char[] text; +expression alignment, flags; +identifier name; +@@ +-kmem_cache_create ++KMEM_CACHE + ( +-text, sizeof(struct + name +-), alignment + , flags +-, NULL + ) + +@x depends on org || report disable sizeof_type_expr@ +constant char[] text; +expression alignment, flags; +identifier name; +position p; +@@ + kmem_cache_create@p(text, sizeof(struct name), alignment, flags, NULL) + +@script:python depends on org@ +p << x.p; +@@ +coccilib.org.print_todo(p[0], "WARNING: opportunity for KMEM_CACHE()") + +@script:python depends on report@ +p << x.p; +@@ +coccilib.report.print_report(p[0], "WARNING: opportunity for KMEM_CACHE()= ") =2D- 2.43.0