Message ID | 20230201150815.409582-2-urezki@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp334549wrn; Wed, 1 Feb 2023 07:14:43 -0800 (PST) X-Google-Smtp-Source: AK7set9xzqFluSJEZMP/iWN0A0OlbpaCMFUkAHCW9XRSj4tfebzA5W51ldpdDcpmBPMyPcM+/uqm X-Received: by 2002:a17:902:dac6:b0:196:8124:dbe8 with SMTP id q6-20020a170902dac600b001968124dbe8mr3790640plx.61.1675264483034; Wed, 01 Feb 2023 07:14:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675264483; cv=none; d=google.com; s=arc-20160816; b=bTH3IUv1Ed2kkxhPYFOi4Fja3F8e0VL3Eu3lr2LgsLirnTQkbwoJWPx+SMFP2v5B8j DZDgUDkBnMa3vhcOTHrWWI8D4RuLkmtRZYC/R4+asbr24lW6+Af4ASFF0ujZG4Xg+mD7 ORxOkEZfJOyWpUHM3Yf6CKT4HF2iBypLTu0/PUWsWl4Q8S+HVvmKpdf5/Bd7/rMDnFZV XeSMT6bf1ASJ4A2H3oSpb5gGqTQ2dxyNSsjdphaCjipLCuV+n6nZ227YhDpTNn1svZ++ 6LYlkDS9dwYh2nx+HcBoW8/DNaxvamm7M6Uc0lu2BoeeUnYvXfoYH6SXhhRtJAlRV698 ydDQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FL6Oc4kZz3pEC+42YRGjUorvq4as+oQYBQ3Rk/f90Ak=; b=P7Sn2V8aFqI5undizFWgX918vUkTkpBvC7rUxWnpnnYXA/YUyxS8X5HubYNDOZ+KeD 7BXT5PFRAB70cTjjyX9q/dMTwRpFTrpXfbXMVa+siGlg/CMsjw0zfeeNq7zau/V/DosJ 1hcVC2kWFRdgBQArrv2++zPhxNlVvxq9UGBVcIDHIUQYJhjwrEnTARjGvEZb40BwDwfF a9O0qAuG5IrDEMBxQ2EEwBNSYjzZuJ3BAAkg+qRLqMna7VBonQvGiEh894HgxWCEFDJu gpQ32MzpI6mjY1L+dn1ScOWWW63TgQGZDa37azzxDXlUCmiZ4TOU+jumvETP3z74VA1h J6Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AR9ckEL0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a170902ce8700b00188e5c9e026si21897875plg.102.2023.02.01.07.14.29; Wed, 01 Feb 2023 07:14:43 -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=@gmail.com header.s=20210112 header.b=AR9ckEL0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232680AbjBAPKf (ORCPT <rfc822;duw91626@gmail.com> + 99 others); Wed, 1 Feb 2023 10:10:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232866AbjBAPJl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 1 Feb 2023 10:09:41 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41FDE65EDE; Wed, 1 Feb 2023 07:08:20 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id ml19so28739296ejb.0; Wed, 01 Feb 2023 07:08:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=FL6Oc4kZz3pEC+42YRGjUorvq4as+oQYBQ3Rk/f90Ak=; b=AR9ckEL0F6ZlprE/CI0uy/u3yv2fo+PiSDAmBvbENe1OfrVUEbQDzo787z9Qz2f98J KYsAwCWWlKRXvfc+isW1EQ4+JPh1HFDHb030whCmUfp2nvHij65eBd0h20MXAYMefaz7 f4k/AH/xdVeiMmiCKZ3VfuABC+Q4fV8j7Og3nyrMa2uT2fCdjHlDUbCtaCD9O8T2eWDa jBLaHtRgA+mWDSWTAWrczod4M+9/U2XItsPOwNoq//gupzLKVZWkpYxV+76/U/1IvI9f SS9DBVc9Kx3ogTtVLloOSrU3Ok820OMZer0l3KY1TxiBhMuNJPXdt6soiX0BF1866IBV +XtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=FL6Oc4kZz3pEC+42YRGjUorvq4as+oQYBQ3Rk/f90Ak=; b=LuPCSeVYCnJh87105yL8LGsPRUkv/NUtKjwzPGVylWGd72DmS3u3hCZj2uHRwqYLOP VofinvRz66QIQuP0VSmSFzWg0vyvZtAAhdPPjjPaHzOLX1+VggnDRyPkweAv7HtXWeZ2 d+sjxvx/OaCTSKS8SBbfgS8KrpoWLPbRZc01bkMkAHV6FYK9sBIuE16nsI9Je0Q6GokK np71aFwU/Y4oJF5XajVV7SmYTgnjwFS0V9l0ziDHK7Un79K8mGJ1QDKAD5WMWXldq2pz bFlJvTv6vegARy1eL9bhaDT8NRqicbmsxrCGXNZmF1VEgaIfklX0b1sK7ogzeFVtlc1H chMw== X-Gm-Message-State: AO0yUKVxkcYaDu09iddSXiCfylUOGcF6LWVsAT84t8tvq9wlUp/v2bLq bF1nlSs0aZ/jqr9OjAnWyC+b8LciDpsS0A== X-Received: by 2002:a17:906:7050:b0:886:8cd4:ef9d with SMTP id r16-20020a170906705000b008868cd4ef9dmr2685887ejj.22.1675264098637; Wed, 01 Feb 2023 07:08:18 -0800 (PST) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id qc26-20020a170906d8ba00b008787e94c5ccsm9585774ejb.184.2023.02.01.07.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 07:08:18 -0800 (PST) From: "Uladzislau Rezki (Sony)" <urezki@gmail.com> To: LKML <linux-kernel@vger.kernel.org>, RCU <rcu@vger.kernel.org>, "Paul E . McKenney" <paulmck@kernel.org> Cc: Uladzislau Rezki <urezki@gmail.com>, 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> Subject: [PATCH 01/13] rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep() Date: Wed, 1 Feb 2023 16:08:07 +0100 Message-Id: <20230201150815.409582-2-urezki@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201150815.409582-1-urezki@gmail.com> References: <20230201150815.409582-1-urezki@gmail.com> 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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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?1756642130699177188?= X-GMAIL-MSGID: =?utf-8?q?1756642130699177188?= |
Series |
Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
|
|
Commit Message
Uladzislau Rezki
Feb. 1, 2023, 3:08 p.m. UTC
These two macroses will replace single-argument k[v]free_rcu() ones.
By adding an extra _mightsleep prefix we can avoid of situations when
someone intended to give a second argument but forgot to do it in a
code where sleeping is illegal.
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
include/linux/rcupdate.h | 3 +++
1 file changed, 3 insertions(+)
Comments
> From: Uladzislau Rezki (Sony) <urezki@gmail.com> > Sent: Wednesday, February 1, 2023 11:08 PM > To: LKML <linux-kernel@vger.kernel.org>; RCU <rcu@vger.kernel.org>; Paul E . > McKenney <paulmck@kernel.org> > Cc: Uladzislau Rezki <urezki@gmail.com>; 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> > Subject: [PATCH 01/13] rcu/kvfree: Add kvfree_rcu_mightsleep() and > kfree_rcu_mightsleep() > > These two macroses will replace single-argument k[v]free_rcu() ones. > By adding an extra _mightsleep prefix we can avoid of situations when someone s/prefix/suffix > intended to give a second argument but forgot to do it in a code where sleeping > is illegal. > > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com> > ...
On Thu, Feb 02, 2023 at 07:54:31AM +0000, Zhuo, Qiuxu wrote: > > From: Uladzislau Rezki (Sony) <urezki@gmail.com> > > Sent: Wednesday, February 1, 2023 11:08 PM > > To: LKML <linux-kernel@vger.kernel.org>; RCU <rcu@vger.kernel.org>; Paul E . > > McKenney <paulmck@kernel.org> > > Cc: Uladzislau Rezki <urezki@gmail.com>; 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> > > Subject: [PATCH 01/13] rcu/kvfree: Add kvfree_rcu_mightsleep() and > > kfree_rcu_mightsleep() > > > > These two macroses will replace single-argument k[v]free_rcu() ones. > > By adding an extra _mightsleep prefix we can avoid of situations when someone > > s/prefix/suffix Good eyes, thank you! Please see below for the version currently queued in the -rcu tree. Thanx, Paul > > intended to give a second argument but forgot to do it in a code where sleeping > > is illegal. > > > > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com> > > ... ------------------------------------------------------------------------ commit d6b54a44de23c83944d042b6f6fd9d19ccd3f1b8 Author: Uladzislau Rezki (Sony) <urezki@gmail.com> Date: Wed Feb 1 16:08:07 2023 +0100 rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep() The kvfree_rcu() and kfree_rcu() APIs are hazardous in that if you forget the second argument, it works, but might sleep. This sleeping can be a correctness bug from atomic contexts, and even in non-atomic contexts it might introduce unacceptable latencies. This commit therefore adds kvfree_rcu_mightsleep() and kfree_rcu_mightsleep(), which will replace the single-argument kvfree_rcu() and kfree_rcu(), respectively. This commit enables a series of commits that switch from single-argument kvfree_rcu() and kfree_rcu() to their _mightsleep() counterparts. Once all of these commits land, the single-argument versions will be removed. Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 822ff7b4bb1ed..094321c17e48a 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -1013,6 +1013,9 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) #define kvfree_rcu(...) KVFREE_GET_MACRO(__VA_ARGS__, \ kvfree_rcu_arg_2, kvfree_rcu_arg_1)(__VA_ARGS__) +#define kvfree_rcu_mightsleep(ptr) kvfree_rcu_arg_1(ptr) +#define kfree_rcu_mightsleep(ptr) kvfree_rcu_mightsleep(ptr) + #define KVFREE_GET_MACRO(_1, _2, NAME, ...) NAME #define kvfree_rcu_arg_2(ptr, rhf) \ do { \
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 822ff7b4bb1e..094321c17e48 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -1013,6 +1013,9 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) #define kvfree_rcu(...) KVFREE_GET_MACRO(__VA_ARGS__, \ kvfree_rcu_arg_2, kvfree_rcu_arg_1)(__VA_ARGS__) +#define kvfree_rcu_mightsleep(ptr) kvfree_rcu_arg_1(ptr) +#define kfree_rcu_mightsleep(ptr) kvfree_rcu_mightsleep(ptr) + #define KVFREE_GET_MACRO(_1, _2, NAME, ...) NAME #define kvfree_rcu_arg_2(ptr, rhf) \ do { \