Message ID | 20230307030457.3499834-1-joel@joelfernandes.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2211670wrd; Mon, 6 Mar 2023 19:13:25 -0800 (PST) X-Google-Smtp-Source: AK7set/x/itukwLkfQr0RJyoFnH6BGKKtQ5tr6iAZlF+zUY6Y41pOw8t5B0TZKLc5Zf51u32s6Bk X-Received: by 2002:a17:907:a508:b0:878:545b:e540 with SMTP id vr8-20020a170907a50800b00878545be540mr13200377ejc.51.1678158805726; Mon, 06 Mar 2023 19:13:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678158805; cv=none; d=google.com; s=arc-20160816; b=I3q7RIR35wSudriARyAD3JCFVC/aYkvFY6HtHifmPefkLjUyCACzasWPDQZlqcNv85 IIVhB/kO0/BobGHV3pfGHl3wInl8c3cZXEShmc48UN0JTEm3cYNzAjzkkhqMfT08kl9T sQqBy86vyMM1GzjUgtaT4E4vC0ahlVb2ZAw9bMrBUze/BmercAsM3HHgy4aT4mKQTfWX BR8QwIRnRPnf5JRrUmCBNv9cT0uXt81YDx/Zrp1CMEKPf5uAty2mJOhy2T9TC1/AXzip uf3rlZzcVt4ZqFkeljCGlpxxI+ofdBN8/Fdss6sSiyZSGFZP1S3sOy8pOCZbwMNf/k2Y A5mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=lY+Nip7wJV+VZxdEHCUjTyczS4FvHFA8te+MeEMaKDU=; b=LqAPDr5vyneIABQsmZ8YuncZmzeo32KPVg0l5JnscXp6jsuROasEkeldbbUonajYPb SA4Y9TWAjPc+rvP1oRrxcZ41aggAyKuSfbLsnK8nx48J79iZ3COSiS3dk3hXaDg85igp zEgCt0hMCbZCnFzZP4VY/VdJuXgk9nQx/5Yve0QThCAxRDmAwM2dIvyEWYrC9rrd677Y UsjzivYccudlJmtl75dFrDu59c08UU21gOGr/i5nQSWFxoQ/IQTSi7ehyIsbSFgITbmc O8ITwd3dJ9EeEITR4bQ5q3HKRkWg8SwTAp5s2VFEoIExGl4lah4YkGpaBjLhAI60eRrC ur9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=VY3fQPmt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc8-20020a1709071c0800b008ddf3c18310si2539928ejc.757.2023.03.06.19.13.01; Mon, 06 Mar 2023 19:13:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=VY3fQPmt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230189AbjCGDFT (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 6 Mar 2023 22:05:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbjCGDFQ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 6 Mar 2023 22:05:16 -0500 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C6456BC1E for <linux-kernel@vger.kernel.org>; Mon, 6 Mar 2023 19:05:07 -0800 (PST) Received: by mail-qt1-x82a.google.com with SMTP id z6so13149033qtv.0 for <linux-kernel@vger.kernel.org>; Mon, 06 Mar 2023 19:05:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1678158306; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lY+Nip7wJV+VZxdEHCUjTyczS4FvHFA8te+MeEMaKDU=; b=VY3fQPmtNzN3/ulBjNppq6O9TVhTu+wLj3D+zS2FhPOvqhTV4J4erHGGTi4mPDTeJ9 gi8QGD7M3n5PKLiQEbD4mFyizskOVqicIsxodD83AjdMrkDPnfi2Qt+bQRpvpQQRPwpi 5eDhCelSy4RGLI+u119OXmzMC0BJIxBM2LPqs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678158306; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lY+Nip7wJV+VZxdEHCUjTyczS4FvHFA8te+MeEMaKDU=; b=mXndUypNvhKxc3uIbp9AK1yiYb9+bhKqUpRaaWeLTZrnyXhPJ9lJVoYlgIuAMsCDnc pibTsYmE35/e93qLBW/FF++pagbvY2c+AshxIF3LMXay/JFR6Vs9851AiKimo0oqnMaC iYyYGtRSVgqIBAyPbh+wFEp34djSSKMrRZq66BQJJTUEKxeXn8EFy92HQILsJ8xX4Jmn REUVfjbAeOPzrWCjmUuNot+9pCPDyCZzzQUTibFWd/WH4BHn453hQf6C+n8grxG0U6Hb WvMbgEXYRyzs3X8/fl/MX7HV6NOTIL/ubPWD01w1u5cPQbI731m/Yto3T112L1jciyhT kmUg== X-Gm-Message-State: AO0yUKXv1rl2w15h3VlaLZnQUBPR7qblGmx4tG2lXLK29sh5udDRN/Jl MZifdKVKb0+B7c4BcEyg0llgrSr7ikEmrSSfNf4= X-Received: by 2002:ac8:5b15:0:b0:3b6:33c6:c5ac with SMTP id m21-20020ac85b15000000b003b633c6c5acmr21594114qtw.4.1678158305773; Mon, 06 Mar 2023 19:05:05 -0800 (PST) Received: from joelboxx.c.googlers.com.com (129.239.188.35.bc.googleusercontent.com. [35.188.239.129]) by smtp.gmail.com with ESMTPSA id dt11-20020a05620a478b00b0073b399700adsm8664833qkb.3.2023.03.06.19.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 19:05:04 -0800 (PST) From: "Joel Fernandes (Google)" <joel@joelfernandes.org> To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" <joel@joelfernandes.org>, Andy Whitcroft <apw@canonical.com>, Dwaipayan Ray <dwaipayanray1@gmail.com>, Joe Perches <joe@perches.com>, Lukas Bulwahn <lukas.bulwahn@gmail.com>, "Paul E. McKenney" <paulmck@kernel.org>, RCU <rcu@vger.kernel.org>, Oleksiy Avramchenko <oleksiy.avramchenko@sony.com>, Jens Axboe <axboe@kernel.dk>, Philipp Reisner <philipp.reisner@linbit.com>, Bryan Tan <bryantan@vmware.com>, Steven Rostedt <rostedt@goodmis.org>, Eric Dumazet <edumazet@google.com>, Bob Pearson <rpearsonhpe@gmail.com>, Ariel Levkovich <lariel@nvidia.com>, "Theodore Ts'o" <tytso@mit.edu>, Julian Anastasov <ja@ssi.bg>, Uladzislau Rezki <urezki@gmail.com> Subject: [PATCH] checkpatch: Error out if deprecated RCU API used Date: Tue, 7 Mar 2023 03:04:57 +0000 Message-Id: <20230307030457.3499834-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759677047803614950?= X-GMAIL-MSGID: =?utf-8?q?1759677047803614950?= |
Series |
checkpatch: Error out if deprecated RCU API used
|
|
Commit Message
Joel Fernandes
March 7, 2023, 3:04 a.m. UTC
Single-argument kvfree_rcu() usage is being deprecated [1] [2] as it is
error-prone. However, till all users are converted, we would like to introduce
checkpatch errors for new patches submitted.
This patch adds support for the same. Tested with a trial patch.
For now, we are only considering usages that don't have compound
nesting, for example ignore: kvfree_rcu( (rcu_head_obj), rcu_head_name).
This is sufficient as such usages are unlikely.
Once all users are converted and we remove the old API, we can also revert this
checkpatch patch then.
[1] https://lore.kernel.org/rcu/CAEXW_YRhHaVuq+5f+VgCZM=SF+9xO+QXaxe0yE7oA9iCXK-XPg@mail.gmail.com/
[2] https://lore.kernel.org/rcu/CAEXW_YSY=q2_uaE2qo4XSGjzs4+C102YMVJ7kWwuT5LGmJGGew@mail.gmail.com/
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
scripts/checkpatch.pl | 9 +++++++++
1 file changed, 9 insertions(+)
Comments
On Tue, 2023-03-07 at 03:04 +0000, Joel Fernandes (Google) wrote: > Single-argument kvfree_rcu() usage is being deprecated [1] [2] as it is > error-prone. However, till all users are converted, we would like to introduce > checkpatch errors for new patches submitted. > > This patch adds support for the same. Tested with a trial patch. > > For now, we are only considering usages that don't have compound > nesting, for example ignore: kvfree_rcu( (rcu_head_obj), rcu_head_name). > This is sufficient as such usages are unlikely. > > Once all users are converted and we remove the old API, we can also revert this > checkpatch patch then. I think this should be added to the deprecated_apis hash instead our %deprecated_apis = ( "synchronize_rcu_bh" => "synchronize_rcu", "synchronize_rcu_bh_expedited" => "synchronize_rcu_expedited", "call_rcu_bh" => "call_rcu", "rcu_barrier_bh" => "rcu_barrier", "synchronize_sched" => "synchronize_rcu", "synchronize_sched_expedited" => "synchronize_rcu_expedited", "call_rcu_sched" => "call_rcu", "rcu_barrier_sched" => "rcu_barrier", "get_state_synchronize_sched" => "get_state_synchronize_rcu", "cond_synchronize_sched" => "cond_synchronize_rcu", "kmap" => "kmap_local_page", "kunmap" => "kunmap_local", "kmap_atomic" => "kmap_local_page", "kunmap_atomic" => "kunmap_local", );
On Mon, Mar 6, 2023 at 10:08 PM Joe Perches <joe@perches.com> wrote: > > On Tue, 2023-03-07 at 03:04 +0000, Joel Fernandes (Google) wrote: > > Single-argument kvfree_rcu() usage is being deprecated [1] [2] as it is > > error-prone. However, till all users are converted, we would like to introduce > > checkpatch errors for new patches submitted. > > > > This patch adds support for the same. Tested with a trial patch. > > > > For now, we are only considering usages that don't have compound > > nesting, for example ignore: kvfree_rcu( (rcu_head_obj), rcu_head_name). > > This is sufficient as such usages are unlikely. > > > > Once all users are converted and we remove the old API, we can also revert this > > checkpatch patch then. > > I think this should be added to the deprecated_apis hash instead > > our %deprecated_apis = ( > "synchronize_rcu_bh" => "synchronize_rcu", > "synchronize_rcu_bh_expedited" => "synchronize_rcu_expedited", > "call_rcu_bh" => "call_rcu", > "rcu_barrier_bh" => "rcu_barrier", > "synchronize_sched" => "synchronize_rcu", > "synchronize_sched_expedited" => "synchronize_rcu_expedited", > "call_rcu_sched" => "call_rcu", > "rcu_barrier_sched" => "rcu_barrier", > "get_state_synchronize_sched" => "get_state_synchronize_rcu", > "cond_synchronize_sched" => "cond_synchronize_rcu", > "kmap" => "kmap_local_page", > "kunmap" => "kunmap_local", > "kmap_atomic" => "kmap_local_page", > "kunmap_atomic" => "kunmap_local", > ); This is not an API name change though, it is a "number of arguments" or argument list change. Is there a different way to do it? thanks, - Joel
On Mon, 2023-03-06 at 22:10 -0500, Joel Fernandes wrote: > On Mon, Mar 6, 2023 at 10:08 PM Joe Perches <joe@perches.com> wrote: > > > > On Tue, 2023-03-07 at 03:04 +0000, Joel Fernandes (Google) wrote: > > > Single-argument kvfree_rcu() usage is being deprecated [1] [2] as it is > > > error-prone. However, till all users are converted, we would like to introduce > > > checkpatch errors for new patches submitted. > > > > > > This patch adds support for the same. Tested with a trial patch. > > > > > > For now, we are only considering usages that don't have compound > > > nesting, for example ignore: kvfree_rcu( (rcu_head_obj), rcu_head_name). > > > This is sufficient as such usages are unlikely. > > > > > > Once all users are converted and we remove the old API, we can also revert this > > > checkpatch patch then. > > > > I think this should be added to the deprecated_apis hash instead > > > > our %deprecated_apis = ( > > "synchronize_rcu_bh" => "synchronize_rcu", > > "synchronize_rcu_bh_expedited" => "synchronize_rcu_expedited", > > "call_rcu_bh" => "call_rcu", > > "rcu_barrier_bh" => "rcu_barrier", > > "synchronize_sched" => "synchronize_rcu", > > "synchronize_sched_expedited" => "synchronize_rcu_expedited", > > "call_rcu_sched" => "call_rcu", > > "rcu_barrier_sched" => "rcu_barrier", > > "get_state_synchronize_sched" => "get_state_synchronize_rcu", > > "cond_synchronize_sched" => "cond_synchronize_rcu", > > "kmap" => "kmap_local_page", > > "kunmap" => "kunmap_local", > > "kmap_atomic" => "kmap_local_page", > > "kunmap_atomic" => "kunmap_local", > > ); > > This is not an API name change though, it is a "number of arguments" > or argument list change. Is there a different way to do it? Ah, no, not really. btw: I don't see a single use of this call without a comma in the tree.
On Mon, Mar 06, 2023 at 07:23:23PM -0800, Joe Perches wrote: > On Mon, 2023-03-06 at 22:10 -0500, Joel Fernandes wrote: > > On Mon, Mar 6, 2023 at 10:08 PM Joe Perches <joe@perches.com> wrote: > > > > > > On Tue, 2023-03-07 at 03:04 +0000, Joel Fernandes (Google) wrote: > > > > Single-argument kvfree_rcu() usage is being deprecated [1] [2] as it is > > > > error-prone. However, till all users are converted, we would like to introduce > > > > checkpatch errors for new patches submitted. > > > > > > > > This patch adds support for the same. Tested with a trial patch. > > > > > > > > For now, we are only considering usages that don't have compound > > > > nesting, for example ignore: kvfree_rcu( (rcu_head_obj), rcu_head_name). > > > > This is sufficient as such usages are unlikely. > > > > > > > > Once all users are converted and we remove the old API, we can also revert this > > > > checkpatch patch then. > > > > > > I think this should be added to the deprecated_apis hash instead > > > > > > our %deprecated_apis = ( > > > "synchronize_rcu_bh" => "synchronize_rcu", > > > "synchronize_rcu_bh_expedited" => "synchronize_rcu_expedited", > > > "call_rcu_bh" => "call_rcu", > > > "rcu_barrier_bh" => "rcu_barrier", > > > "synchronize_sched" => "synchronize_rcu", > > > "synchronize_sched_expedited" => "synchronize_rcu_expedited", > > > "call_rcu_sched" => "call_rcu", > > > "rcu_barrier_sched" => "rcu_barrier", > > > "get_state_synchronize_sched" => "get_state_synchronize_rcu", > > > "cond_synchronize_sched" => "cond_synchronize_rcu", > > > "kmap" => "kmap_local_page", > > > "kunmap" => "kunmap_local", > > > "kmap_atomic" => "kmap_local_page", > > > "kunmap_atomic" => "kunmap_local", > > > ); > > > > This is not an API name change though, it is a "number of arguments" > > or argument list change. Is there a different way to do it? > > Ah, no, not really. > > btw: I don't see a single use of this call without a comma in the tree. > Did you look for kvfree_rcu? It is either kvfree_rcu() or kfree_rcu(). thanks, - Joel
On Tue, 2023-03-07 at 04:41 +0000, Joel Fernandes wrote: > On Mon, Mar 06, 2023 at 07:23:23PM -0800, Joe Perches wrote: > > On Mon, 2023-03-06 at 22:10 -0500, Joel Fernandes wrote: > > > On Mon, Mar 6, 2023 at 10:08 PM Joe Perches <joe@perches.com> wrote: > > > > > > > > On Tue, 2023-03-07 at 03:04 +0000, Joel Fernandes (Google) wrote: > > > > > Single-argument kvfree_rcu() usage is being deprecated [1] [2] as it is > > > > > error-prone. However, till all users are converted, we would like to introduce > > > > > checkpatch errors for new patches submitted. > > > > > > > > > > This patch adds support for the same. Tested with a trial patch. > > > > > > > > > > For now, we are only considering usages that don't have compound > > > > > nesting, for example ignore: kvfree_rcu( (rcu_head_obj), rcu_head_name). > > > > > This is sufficient as such usages are unlikely. > > > > > > > > > > Once all users are converted and we remove the old API, we can also revert this > > > > > checkpatch patch then. > > > > > > > > I think this should be added to the deprecated_apis hash instead > > > > > > > > our %deprecated_apis = ( > > > > "synchronize_rcu_bh" => "synchronize_rcu", > > > > "synchronize_rcu_bh_expedited" => "synchronize_rcu_expedited", > > > > "call_rcu_bh" => "call_rcu", > > > > "rcu_barrier_bh" => "rcu_barrier", > > > > "synchronize_sched" => "synchronize_rcu", > > > > "synchronize_sched_expedited" => "synchronize_rcu_expedited", > > > > "call_rcu_sched" => "call_rcu", > > > > "rcu_barrier_sched" => "rcu_barrier", > > > > "get_state_synchronize_sched" => "get_state_synchronize_rcu", > > > > "cond_synchronize_sched" => "cond_synchronize_rcu", > > > > "kmap" => "kmap_local_page", > > > > "kunmap" => "kunmap_local", > > > > "kmap_atomic" => "kmap_local_page", > > > > "kunmap_atomic" => "kunmap_local", > > > > ); > > > > > > This is not an API name change though, it is a "number of arguments" > > > or argument list change. Is there a different way to do it? > > > > Ah, no, not really. > > > > btw: I don't see a single use of this call without a comma in the tree. > > Did you look for kvfree_rcu? It is either kvfree_rcu() or kfree_rcu(). $ git grep -P '\bkv?free_rcu\s*\(' -- '*.[ch]' | grep -v -P 'kv?free_rcu\s*\([^,]+,.*\)' drivers/infiniband/core/device.c: kfree_rcu(container_of(dev->port_data, struct ib_port_data_rcu, drivers/infiniband/core/rdma_core.c: * kfree_rcu(). However the object may still have been released and drivers/target/target_core_configfs.c: * callbacks to complete post kfree_rcu(), before allowing include/linux/rcupdate.h: * kvfree_rcu(ptr); include/linux/rcupdate.h:#define kvfree_rcu(...) KVFREE_GET_MACRO(__VA_ARGS__, \ include/linux/rcutiny.h: // kvfree_rcu(one_arg) call. include/rdma/ib_verbs.h: struct rcu_head rcu; /* kfree_rcu() overhead */ include/scsi/scsi_device.h: * @rcu: For kfree_rcu(). kernel/rcu/rcuscale.c: pr_alert("CONFIG_RCU_LAZY is disabled, falling back to kfree_rcu() for delayed RCU kfree'ing\n"); kernel/rcu/tree.c: * struct kvfree_rcu_bulk_data - single block to store kvfree_rcu() pointers kernel/rcu/tree.c: * @records: Array of the kvfree_rcu() pointers kernel/rcu/tree.c: * struct kfree_rcu_cpu_work - single batch of kfree_rcu() requests kernel/rcu/tree.c: * @head_free: List of kfree_rcu() objects waiting for a grace period kernel/rcu/tree.c: * @bulk_head_free: Bulk-List of kvfree_rcu() objects waiting for a grace period kernel/rcu/tree.c: * struct kfree_rcu_cpu - batch up kfree_rcu() requests for RCU grace period kernel/rcu/tree.c: * @head: List of kfree_rcu() objects not yet waiting for a grace period kernel/rcu/tree.c: * @bulk_head: Bulk-List of kvfree_rcu() objects not yet waiting for a grace period kernel/rcu/tree.c: * @krw_arr: Array of batches of kfree_rcu() objects waiting for a grace period kernel/rcu/tree.c: * double-argument of kvfree_rcu(). This happens when the kernel/rcu/tree.c: * reduce the number of grace periods during heavy kfree_rcu()/kvfree_rcu() load. kernel/rcu/tree.c: // Probable double kfree_rcu(), just leak. net/core/pktgen.c: /* Don't need rcu_barrier() due to use of kfree_rcu() */
On Mon, Mar 6, 2023 at 11:53 PM Joe Perches <joe@perches.com> wrote: > > On Tue, 2023-03-07 at 04:41 +0000, Joel Fernandes wrote: > > On Mon, Mar 06, 2023 at 07:23:23PM -0800, Joe Perches wrote: > > > On Mon, 2023-03-06 at 22:10 -0500, Joel Fernandes wrote: > > > > On Mon, Mar 6, 2023 at 10:08 PM Joe Perches <joe@perches.com> wrote: > > > > > > > > > > On Tue, 2023-03-07 at 03:04 +0000, Joel Fernandes (Google) wrote: > > > > > > Single-argument kvfree_rcu() usage is being deprecated [1] [2] as it is > > > > > > error-prone. However, till all users are converted, we would like to introduce > > > > > > checkpatch errors for new patches submitted. > > > > > > > > > > > > This patch adds support for the same. Tested with a trial patch. > > > > > > > > > > > > For now, we are only considering usages that don't have compound > > > > > > nesting, for example ignore: kvfree_rcu( (rcu_head_obj), rcu_head_name). > > > > > > This is sufficient as such usages are unlikely. > > > > > > > > > > > > Once all users are converted and we remove the old API, we can also revert this > > > > > > checkpatch patch then. > > > > > > > > > > I think this should be added to the deprecated_apis hash instead > > > > > > > > > > our %deprecated_apis = ( > > > > > "synchronize_rcu_bh" => "synchronize_rcu", > > > > > "synchronize_rcu_bh_expedited" => "synchronize_rcu_expedited", > > > > > "call_rcu_bh" => "call_rcu", > > > > > "rcu_barrier_bh" => "rcu_barrier", > > > > > "synchronize_sched" => "synchronize_rcu", > > > > > "synchronize_sched_expedited" => "synchronize_rcu_expedited", > > > > > "call_rcu_sched" => "call_rcu", > > > > > "rcu_barrier_sched" => "rcu_barrier", > > > > > "get_state_synchronize_sched" => "get_state_synchronize_rcu", > > > > > "cond_synchronize_sched" => "cond_synchronize_rcu", > > > > > "kmap" => "kmap_local_page", > > > > > "kunmap" => "kunmap_local", > > > > > "kmap_atomic" => "kmap_local_page", > > > > > "kunmap_atomic" => "kunmap_local", > > > > > ); > > > > > > > > This is not an API name change though, it is a "number of arguments" > > > > or argument list change. Is there a different way to do it? > > > > > > Ah, no, not really. > > > > > > btw: I don't see a single use of this call without a comma in the tree. > > > > Did you look for kvfree_rcu? It is either kvfree_rcu() or kfree_rcu(). > > $ git grep -P '\bkv?free_rcu\s*\(' -- '*.[ch]' | grep -v -P 'kv?free_rcu\s*\([^,]+,.*\)' > drivers/infiniband/core/device.c: kfree_rcu(container_of(dev->port_data, struct ib_port_data_rcu, > drivers/infiniband/core/rdma_core.c: * kfree_rcu(). However the object may still have been released and > drivers/target/target_core_configfs.c: * callbacks to complete post kfree_rcu(), before allowing > include/linux/rcupdate.h: * kvfree_rcu(ptr); > include/linux/rcupdate.h:#define kvfree_rcu(...) KVFREE_GET_MACRO(__VA_ARGS__, \ > include/linux/rcutiny.h: // kvfree_rcu(one_arg) call. > include/rdma/ib_verbs.h: struct rcu_head rcu; /* kfree_rcu() overhead */ > include/scsi/scsi_device.h: * @rcu: For kfree_rcu(). > kernel/rcu/rcuscale.c: pr_alert("CONFIG_RCU_LAZY is disabled, falling back to kfree_rcu() for delayed RCU kfree'ing\n"); > kernel/rcu/tree.c: * struct kvfree_rcu_bulk_data - single block to store kvfree_rcu() pointers > kernel/rcu/tree.c: * @records: Array of the kvfree_rcu() pointers > kernel/rcu/tree.c: * struct kfree_rcu_cpu_work - single batch of kfree_rcu() requests > kernel/rcu/tree.c: * @head_free: List of kfree_rcu() objects waiting for a grace period > kernel/rcu/tree.c: * @bulk_head_free: Bulk-List of kvfree_rcu() objects waiting for a grace period > kernel/rcu/tree.c: * struct kfree_rcu_cpu - batch up kfree_rcu() requests for RCU grace period > kernel/rcu/tree.c: * @head: List of kfree_rcu() objects not yet waiting for a grace period > kernel/rcu/tree.c: * @bulk_head: Bulk-List of kvfree_rcu() objects not yet waiting for a grace period > kernel/rcu/tree.c: * @krw_arr: Array of batches of kfree_rcu() objects waiting for a grace period > kernel/rcu/tree.c: * double-argument of kvfree_rcu(). This happens when the > kernel/rcu/tree.c: * reduce the number of grace periods during heavy kfree_rcu()/kvfree_rcu() load. > kernel/rcu/tree.c: // Probable double kfree_rcu(), just leak. > net/core/pktgen.c: /* Don't need rcu_barrier() due to use of kfree_rcu() */ > Do you mind sharing which tree you are looking at? I checked both 6.3-rc1 and linux-next. Your grep returned: kernel/trace/trace_osnoise.c: kvfree_rcu(inst); kernel/trace/trace_probe.c: kvfree_rcu(link); lib/test_vmalloc.c: kvfree_rcu(p); mm/list_lru.c: * We need kvfree_rcu() here. And the walking of the list net/core/pktgen.c: /* Don't need rcu_barrier() due to use of kfree_rcu() */ net/core/sysctl_net_core.c: kvfree_rcu(orig_sock_table); net/core/sysctl_net_core.c: kfree_rcu(cur); net/mac802154/scan.c: kfree_rcu(request); net/mac802154/scan.c: kfree_rcu(request);
On Tue, 2023-03-07 at 00:11 -0500, Joel Fernandes wrote: > Do you mind sharing which tree you are looking at? I checked both > 6.3-rc1 and linux-next. > > Your grep returned: > > kernel/trace/trace_osnoise.c: kvfree_rcu(inst); > kernel/trace/trace_probe.c: kvfree_rcu(link); > lib/test_vmalloc.c: kvfree_rcu(p); > mm/list_lru.c: * We need kvfree_rcu() here. And the walking of the list > net/core/pktgen.c: /* Don't need rcu_barrier() due to use of kfree_rcu() */ > net/core/sysctl_net_core.c: > kvfree_rcu(orig_sock_table); > net/core/sysctl_net_core.c: kfree_rcu(cur); > net/mac802154/scan.c: kfree_rcu(request); > net/mac802154/scan.c: kfree_rcu(request); rather old. I'm not subscribed and haven't been following much. Add linux-next specific files for 20230217 Updating to today's next: Add linux-next specific files for 20230307 I get several instances: $ git grep -P '\bkv?free_rcu\s*\(' -- '*.[ch]' | grep -v -P 'kv?free_rcu\s*\([^,]+,.*\)' drivers/block/drbd/drbd_nl.c: kvfree_rcu(old_disk_conf); drivers/block/drbd/drbd_nl.c: kvfree_rcu(old_net_conf); drivers/block/drbd/drbd_nl.c: kvfree_rcu(old_disk_conf); drivers/block/drbd/drbd_receiver.c: kvfree_rcu(old_net_conf); drivers/block/drbd/drbd_receiver.c: kvfree_rcu(old_disk_conf); drivers/block/drbd/drbd_state.c: kvfree_rcu(old_conf); drivers/infiniband/core/device.c: kfree_rcu(container_of(dev->port_data, struct ib_port_data_rcu, drivers/infiniband/core/rdma_core.c: * kfree_rcu(). However the object may still have been released and drivers/infiniband/sw/rxe/rxe_mr.c: kfree_rcu(mr); drivers/misc/vmw_vmci/vmci_context.c: kvfree_rcu(notifier); drivers/misc/vmw_vmci/vmci_event.c: kvfree_rcu(s); drivers/net/ethernet/mellanox/mlx5/core/en/tc/int_port.c: kfree_rcu(int_port); drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c: kfree_rcu(tx_sa); drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c: kfree_rcu(rx_sc); drivers/target/target_core_configfs.c: * callbacks to complete post kfree_rcu(), before allowing fs/ext4/super.c: kfree_rcu(qname); include/linux/rcupdate.h: * kvfree_rcu(ptr); include/linux/rcupdate.h:#define kvfree_rcu(...) KVFREE_GET_MACRO(__VA_ARGS__, \ include/linux/rcutiny.h: // kvfree_rcu(one_arg) call. include/rdma/ib_verbs.h: struct rcu_head rcu; /* kfree_rcu() overhead */ include/scsi/scsi_device.h: * @rcu: For kfree_rcu(). kernel/rcu/rcuscale.c: pr_alert("CONFIG_RCU_LAZY is disabled, falling back to kfree_rcu() for delayed RCU kfree'ing\n"); kernel/rcu/tree.c: * struct kvfree_rcu_bulk_data - single block to store kvfree_rcu() pointers kernel/rcu/tree.c: * @records: Array of the kvfree_rcu() pointers kernel/rcu/tree.c: * struct kfree_rcu_cpu_work - single batch of kfree_rcu() requests kernel/rcu/tree.c: * @head_free: List of kfree_rcu() objects waiting for a grace period kernel/rcu/tree.c: * @bulk_head_free: Bulk-List of kvfree_rcu() objects waiting for a grace period kernel/rcu/tree.c: * struct kfree_rcu_cpu - batch up kfree_rcu() requests for RCU grace period kernel/rcu/tree.c: * @head: List of kfree_rcu() objects not yet waiting for a grace period kernel/rcu/tree.c: * @bulk_head: Bulk-List of kvfree_rcu() objects not yet waiting for a grace period kernel/rcu/tree.c: * @krw_arr: Array of batches of kfree_rcu() objects waiting for a grace period kernel/rcu/tree.c: * double-argument of kvfree_rcu(). This happens when the kernel/rcu/tree.c: * reduce the number of grace periods during heavy kfree_rcu()/kvfree_rcu() load. kernel/rcu/tree.c: // Probable double kfree_rcu(), just leak. kernel/trace/trace_osnoise.c: kvfree_rcu(inst); kernel/trace/trace_probe.c: kvfree_rcu(link); net/core/pktgen.c: /* Don't need rcu_barrier() due to use of kfree_rcu() */ net/core/sysctl_net_core.c: kvfree_rcu(orig_sock_table); net/core/sysctl_net_core.c: kfree_rcu(cur);
On Tue, Mar 7, 2023 at 12:22 AM Joe Perches <joe@perches.com> wrote: > > On Tue, 2023-03-07 at 00:11 -0500, Joel Fernandes wrote: > > > Do you mind sharing which tree you are looking at? I checked both > > 6.3-rc1 and linux-next. > > > > Your grep returned: > > > > kernel/trace/trace_osnoise.c: kvfree_rcu(inst); > > kernel/trace/trace_probe.c: kvfree_rcu(link); > > lib/test_vmalloc.c: kvfree_rcu(p); > > mm/list_lru.c: * We need kvfree_rcu() here. And the walking of the list > > net/core/pktgen.c: /* Don't need rcu_barrier() due to use of kfree_rcu() */ > > net/core/sysctl_net_core.c: > > kvfree_rcu(orig_sock_table); > > net/core/sysctl_net_core.c: kfree_rcu(cur); > > net/mac802154/scan.c: kfree_rcu(request); > > net/mac802154/scan.c: kfree_rcu(request); > > rather old. I'm not subscribed and haven't been following much. > > Add linux-next specific files for 20230217 I am surprised though why you don't see the usage in trace_osnoise.c though because that was added in 2021 (see diff below). Anyway, I take it you are Ok with the checkpatch patch. If so, do provide your Ack tag in advance. We can push from our side only if needed. There is a chance that we may not need it if we are successful in having made the conversions to the "good API" in time for the next merge window. diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c index 7520d43aed55..4719a848bf17 100644 --- a/kernel/trace/trace_osnoise.c +++ b/kernel/trace/trace_osnoise.c @@ -138,8 +138,7 @@ static void osnoise_unregister_instance(struct trace_array *tr) if (!found) return; - synchronize_rcu(); - kfree(inst); + kvfree_rcu(inst); } /* > > Updating to today's next: > > Add linux-next specific files for 20230307 > > I get several instances: > > $ git grep -P '\bkv?free_rcu\s*\(' -- '*.[ch]' | grep -v -P 'kv?free_rcu\s*\([^,]+,.*\)' > drivers/block/drbd/drbd_nl.c: kvfree_rcu(old_disk_conf); > drivers/block/drbd/drbd_nl.c: kvfree_rcu(old_net_conf); > drivers/block/drbd/drbd_nl.c: kvfree_rcu(old_disk_conf); > drivers/block/drbd/drbd_receiver.c: kvfree_rcu(old_net_conf); > drivers/block/drbd/drbd_receiver.c: kvfree_rcu(old_disk_conf); > drivers/block/drbd/drbd_state.c: kvfree_rcu(old_conf); > drivers/infiniband/core/device.c: kfree_rcu(container_of(dev->port_data, struct ib_port_data_rcu, > drivers/infiniband/core/rdma_core.c: * kfree_rcu(). However the object may still have been released and > drivers/infiniband/sw/rxe/rxe_mr.c: kfree_rcu(mr); > drivers/misc/vmw_vmci/vmci_context.c: kvfree_rcu(notifier); > drivers/misc/vmw_vmci/vmci_event.c: kvfree_rcu(s); > drivers/net/ethernet/mellanox/mlx5/core/en/tc/int_port.c: kfree_rcu(int_port); > drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c: kfree_rcu(tx_sa); > drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c: kfree_rcu(rx_sc); > drivers/target/target_core_configfs.c: * callbacks to complete post kfree_rcu(), before allowing > fs/ext4/super.c: kfree_rcu(qname); > include/linux/rcupdate.h: * kvfree_rcu(ptr); > include/linux/rcupdate.h:#define kvfree_rcu(...) KVFREE_GET_MACRO(__VA_ARGS__, \ > include/linux/rcutiny.h: // kvfree_rcu(one_arg) call. > include/rdma/ib_verbs.h: struct rcu_head rcu; /* kfree_rcu() overhead */ > include/scsi/scsi_device.h: * @rcu: For kfree_rcu(). > kernel/rcu/rcuscale.c: pr_alert("CONFIG_RCU_LAZY is disabled, falling back to kfree_rcu() for delayed RCU kfree'ing\n"); > kernel/rcu/tree.c: * struct kvfree_rcu_bulk_data - single block to store kvfree_rcu() pointers > kernel/rcu/tree.c: * @records: Array of the kvfree_rcu() pointers > kernel/rcu/tree.c: * struct kfree_rcu_cpu_work - single batch of kfree_rcu() requests > kernel/rcu/tree.c: * @head_free: List of kfree_rcu() objects waiting for a grace period > kernel/rcu/tree.c: * @bulk_head_free: Bulk-List of kvfree_rcu() objects waiting for a grace period > kernel/rcu/tree.c: * struct kfree_rcu_cpu - batch up kfree_rcu() requests for RCU grace period > kernel/rcu/tree.c: * @head: List of kfree_rcu() objects not yet waiting for a grace period > kernel/rcu/tree.c: * @bulk_head: Bulk-List of kvfree_rcu() objects not yet waiting for a grace period > kernel/rcu/tree.c: * @krw_arr: Array of batches of kfree_rcu() objects waiting for a grace period > kernel/rcu/tree.c: * double-argument of kvfree_rcu(). This happens when the > kernel/rcu/tree.c: * reduce the number of grace periods during heavy kfree_rcu()/kvfree_rcu() load. > kernel/rcu/tree.c: // Probable double kfree_rcu(), just leak. > kernel/trace/trace_osnoise.c: kvfree_rcu(inst); > kernel/trace/trace_probe.c: kvfree_rcu(link); > net/core/pktgen.c: /* Don't need rcu_barrier() due to use of kfree_rcu() */ > net/core/sysctl_net_core.c: kvfree_rcu(orig_sock_table); > net/core/sysctl_net_core.c: kfree_rcu(cur); >
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index bd44d12965c9..9da0a3cb1615 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6388,6 +6388,15 @@ sub process { } } +# check for soon-to-be-deprecated single-argument k[v]free_rcu() API + if ($line =~ /\bk[v]?free_rcu\s*\([^(]+\)/) { + if ($line =~ /\bk[v]?free_rcu\s*\([^,]+\)/) { + ERROR("DEPRECATED_API", + "Single-argument k[v]free_rcu() API is deprecated, please call the API with an rcu_head object passed, like: k[v]free_rcu(object_ptr, rcu_head_name); " . $herecurr); + } + } + + # check for unnecessary "Out of Memory" messages if ($line =~ /^\+.*\b$logFunctions\s*\(/ && $prevline =~ /^[ \+]\s*if\s*\(\s*(\!\s*|NULL\s*==\s*)?($Lval)(\s*==\s*NULL\s*)?\s*\)/ &&