From patchwork Wed Mar 15 18:18:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 13176512 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CB32C61DA4 for ; Wed, 15 Mar 2023 18:19:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232108AbjCOSTz (ORCPT ); Wed, 15 Mar 2023 14:19:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232555AbjCOSTl (ORCPT ); Wed, 15 Mar 2023 14:19:41 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 628A77DD0A for ; Wed, 15 Mar 2023 11:19:34 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id r16so17191470qtx.9 for ; Wed, 15 Mar 2023 11:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1678904373; 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=/Bvd7KqU+0UJPbIZv2ZisqXKCDIddIzWkPhDnOppke0=; b=Bj88++U5M+bx+xrI+ueEqEmtvkt/BQxGm9alRbvENUNQgW/XLsUqKg+0i9rYjVwo/U xCkd8SkXbBn5uwMwDpOTp4ud+QYb1pA6hKv6CViFcxzUXknbgDo+WJAOH8ZGPY5Q4kih eJkADceCNkzHpKA9rKi6gN8oC5ABQXKSF5mo8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678904373; 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=/Bvd7KqU+0UJPbIZv2ZisqXKCDIddIzWkPhDnOppke0=; b=mSCRZBz9omU39kGAIU2DKiVGSY2MVNkD0BRl674S4Rf0t5rk/f3T/po280CNz3gn08 VKYUkJKIly6fBxUSGXHZwmQY4cCEQRHaCOf4XvfZbdFVgtgPn4XEiGB4h/R7O9aD6ifD am8hIMFYJDMaF7YJfoIBntMVvKpHVfRnAa4T1DrsfwH3O+qqf0c/NecvTzzk9Egp6KiL lBs+K+VU2dfoL3/npCXlqKdPCWQhQZJILAfHu+al28Hw5XJ/MMpCMdK63lZh880us39s fbRUlltjYb0C5on5flBo55bUQ6YlbcNgmkZ8wyPnnIM5qVae/b0GrJ7fm3OKS0uWFiqB tm7Q== X-Gm-Message-State: AO0yUKX/kj/g6BbM5BxJ2nqEGtYKDXqqNHswpE+Ndnvk8COccp6I8t9L XxR7s21DTRNOWzhbRkp29zsqKQ== X-Google-Smtp-Source: AK7set9+egTI2wMDAMY8dnTaLEBRl12RRV7zCaE7OSYn+8iy+tPhMG7McRQkufAEB31HwULzaVxfUg== X-Received: by 2002:ac8:7c50:0:b0:3b8:4adb:c604 with SMTP id o16-20020ac87c50000000b003b84adbc604mr1513701qtv.14.1678904373115; Wed, 15 Mar 2023 11:19:33 -0700 (PDT) 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 v125-20020a379383000000b007458ae32290sm4113974qkd.128.2023.03.15.11.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 11:19:32 -0700 (PDT) From: "Joel Fernandes (Google)" To: Davidlohr Bueso , "Paul E. McKenney" , Josh Triplett , Frederic Weisbecker , Neeraj Upadhyay , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes Cc: "Uladzislau Rezki (Sony)" , linux-kernel@vger.kernel.org, rcu@vger.kernel.org Subject: [PATCH v2 08/14] rcuscale: Rename kfree_rcu() to kfree_rcu_mightsleep() Date: Wed, 15 Mar 2023 18:18:55 +0000 Message-Id: <20230315181902.4177819-8-joel@joelfernandes.org> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog In-Reply-To: <20230315181902.4177819-1-joel@joelfernandes.org> References: <20230315181902.4177819-1-joel@joelfernandes.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org From: "Uladzislau Rezki (Sony)" The kfree_rcu() and kvfree_rcu() macros' single-argument forms are deprecated. Therefore switch to the new kfree_rcu_mightsleep() and kvfree_rcu_mightsleep() variants. The goal is to avoid accidental use of the single-argument forms, which can introduce functionality bugs in atomic contexts and latency bugs in non-atomic contexts. Signed-off-by: Uladzislau Rezki (Sony) Signed-off-by: Paul E. McKenney Signed-off-by: Joel Fernandes (Google) --- kernel/rcu/rcuscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c index 91fb5905a008..98b75995b680 100644 --- a/kernel/rcu/rcuscale.c +++ b/kernel/rcu/rcuscale.c @@ -716,7 +716,7 @@ kfree_scale_thread(void *arg) // is tested. if ((kfree_rcu_test_single && !kfree_rcu_test_double) || (kfree_rcu_test_both && torture_random(&tr) & 0x800)) - kfree_rcu(alloc_ptr); + kfree_rcu_mightsleep(alloc_ptr); else kfree_rcu(alloc_ptr, rh); } From patchwork Wed Mar 15 18:18:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 13176511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C371C7619A for ; Wed, 15 Mar 2023 18:19:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229602AbjCOSTx (ORCPT ); Wed, 15 Mar 2023 14:19:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232561AbjCOSTm (ORCPT ); Wed, 15 Mar 2023 14:19:42 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8CA67DD25 for ; Wed, 15 Mar 2023 11:19:34 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id cf14so17177730qtb.10 for ; Wed, 15 Mar 2023 11:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1678904374; 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=lSsc7hzk/lL5hF/xvXJ1JSJwgr8pnxi74tQwwkfBkI4=; b=PqxQOwNl8FLQlZ0wb/ZC52nN9ZdX6CCNAYQcZPAXaYrpYU0hoWExe1OhVcwOi1H5n/ tohphBPoVr0QvcXjNSUxMn9KZ7gpbKM+U6MnHgj/YBjDbP7VpaVzoTMaQ6DzfIFXxWKt s150z+ZCa5wg6JrUs4FzWZglQlefFPSLnrV6M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678904374; 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=lSsc7hzk/lL5hF/xvXJ1JSJwgr8pnxi74tQwwkfBkI4=; b=8K08ZdVqhtEgId+xeoZnjHeMlGB+Kwlw7499pDiyH5eGsCK87V5dXTfQHKOnMKYt5G EB9/Gt8MUvb/jB3H9phtgzo/tBYJ6W5Dk8FRNZSHzOJMFmHYLBYYV63R9EqbnsZmGfv1 KUc2MNCrSLxzKnvawbM/O6ZG8JhgHrwbpNBT2XFLKXzH7BRGqYYNoDOk+5wBQpBkBtj0 WpySHMDsUblzD1tOo/enlrhTGkngsb5T+8jm7DJ+X421eb1SZoTZ4SGq71CcV0F70Gh2 +5fJfeLef+HrUPpaCPuB6Usa6XtAhMeEQ6BoitnnFVXOzx76Cdh1ZwJFLlCgfE1TyYjK cO7A== X-Gm-Message-State: AO0yUKXfXae+C85LdY+WUWwF6WVJKeOTnJnHoe+EesS2Lc81PkUpw16N +RwG3DGb7k8pFkpiwtkA3zgVnw== X-Google-Smtp-Source: AK7set8JXw73dwtTVWf2o1rrh79neNXmuiIN9SfzBb2Ehts755m8MFms900eo19kDXSQnwjRKYHqkg== X-Received: by 2002:ac8:574d:0:b0:3c0:3b79:9fb0 with SMTP id 13-20020ac8574d000000b003c03b799fb0mr1372546qtx.47.1678904374217; Wed, 15 Mar 2023 11:19:34 -0700 (PDT) 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 v125-20020a379383000000b007458ae32290sm4113974qkd.128.2023.03.15.11.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 11:19:33 -0700 (PDT) From: "Joel Fernandes (Google)" To: "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Shuah Khan Cc: Joel Fernandes , rcu@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 09/14] torture: Enable clocksource watchdog with "tsc=watchdog" Date: Wed, 15 Mar 2023 18:18:56 +0000 Message-Id: <20230315181902.4177819-9-joel@joelfernandes.org> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog In-Reply-To: <20230315181902.4177819-1-joel@joelfernandes.org> References: <20230315181902.4177819-1-joel@joelfernandes.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org From: "Paul E. McKenney" This commit tests the "tsc=watchdog" kernel boot parameter when running the clocksourcewd torture tests. Signed-off-by: Paul E. McKenney Signed-off-by: Joel Fernandes (Google) --- tools/testing/selftests/rcutorture/bin/torture.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/testing/selftests/rcutorture/bin/torture.sh index 130d0de4c3bb..5a2ae2264403 100755 --- a/tools/testing/selftests/rcutorture/bin/torture.sh +++ b/tools/testing/selftests/rcutorture/bin/torture.sh @@ -497,16 +497,16 @@ fi if test "$do_clocksourcewd" = "yes" then - torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000" + torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 tsc=watchdog" torture_set "clocksourcewd-1" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --kconfig "CONFIG_TEST_CLOCKSOURCE_WATCHDOG=y" --trust-make - torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 clocksource.max_cswd_read_retries=1" + torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 clocksource.max_cswd_read_retries=1 tsc=watchdog" torture_set "clocksourcewd-2" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --kconfig "CONFIG_TEST_CLOCKSOURCE_WATCHDOG=y" --trust-make # In case our work is already done... if test "$do_rcutorture" != "yes" then - torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000" + torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 tsc=watchdog" torture_set "clocksourcewd-3" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --trust-make fi fi From patchwork Wed Mar 15 18:18:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 13176513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E518C6FD1D for ; Wed, 15 Mar 2023 18:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232543AbjCOST4 (ORCPT ); Wed, 15 Mar 2023 14:19:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232596AbjCOSTm (ORCPT ); Wed, 15 Mar 2023 14:19:42 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FAAA81CF1 for ; Wed, 15 Mar 2023 11:19:36 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id y10so17247619qtj.2 for ; Wed, 15 Mar 2023 11:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1678904375; 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=j5YdSl/dl9DoJC+jKcZh9kCRHqYQQP7O2cdVc7Sb2ak=; b=RsVsQ4s1t13v0tdqWA51fkEfKF52Wabe0BT7RvouKtsN3SK0//3iMefFvaIvGSPk3y SMfbIluc3bKhAJGiA56yuTxrMPHfSZ3IYJfnGbhREPp5HrIbhQ48sEbDHHmB5GOlCPs6 ibsxdEx3Lz1874eR10BibIZlrij+HeWqH43x8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678904375; 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=j5YdSl/dl9DoJC+jKcZh9kCRHqYQQP7O2cdVc7Sb2ak=; b=zTcnr9kZgqA/ixRFGDVT6HFpBclrA/joFDHGtoQZqr7XMsPGLNOvy7HZTkJu54oPac cHDx0RikTB8uliLcQ3ga95jS3eVNrt2hUdpr+owDLOJYx9nQfpXMDq84qNXEmpytIWQx OPkBzsT0SmdjBcRVuODA4+TMMf2rmIfuwN2P2NHUDn2R3/8Am6T5HKcC8ajA50cE/VLy lLElmYar6h9O4lSoktOPoxbcS6YJZOppzSRt1dCHMLSU5jRQBYLptAvwTXsEzVAViGuF tYKmbQiIMyssm6gGK/4w2Bcj41qWDHpwy7KDgeGdOa1nl5FVmhWjUX9hLHrXI9jeTUni MO/w== X-Gm-Message-State: AO0yUKVOpHcUuFux3SSoe3oYlCieECuEuMglOlQMLe7zb21kBRwBS/aO EigE5KFJ0moExDEAq3PyVlNCfQ== X-Google-Smtp-Source: AK7set+w/Bt6e/x/yy6K0dkN6uYT2fGt0eAwmnOwDheSYTZWX82N4YPJ8IfFATBHdM3YIhXA6lLZIA== X-Received: by 2002:ac8:4cd9:0:b0:3bf:cd81:3a31 with SMTP id l25-20020ac84cd9000000b003bfcd813a31mr758797qtv.65.1678904375328; Wed, 15 Mar 2023 11:19:35 -0700 (PDT) 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 v125-20020a379383000000b007458ae32290sm4113974qkd.128.2023.03.15.11.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 11:19:34 -0700 (PDT) From: "Joel Fernandes (Google)" To: Davidlohr Bueso , "Paul E. McKenney" , Josh Triplett , Frederic Weisbecker , Neeraj Upadhyay , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes Cc: Zqiang , linux-kernel@vger.kernel.org, rcu@vger.kernel.org Subject: [PATCH v2 10/14] rcutorture: Create nocb kthreads only when testing rcu in CONFIG_RCU_NOCB_CPU=y kernels Date: Wed, 15 Mar 2023 18:18:57 +0000 Message-Id: <20230315181902.4177819-10-joel@joelfernandes.org> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog In-Reply-To: <20230315181902.4177819-1-joel@joelfernandes.org> References: <20230315181902.4177819-1-joel@joelfernandes.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org From: Zqiang Given a non-zero rcutorture.nocbs_nthreads module parameter, the specified number of nocb kthreads will be created, regardless of whether or not the RCU implementation under test is capable of offloading callbacks. Please note that even vanilla RCU is incapable of offloading in kernels built with CONFIG_RCU_NOCB_CPU=n. And when the RCU implementation is incapable of offloading callbacks, there is no point in creating those kthreads. This commit therefore checks the cur_ops.torture_type module parameter and CONFIG_RCU_NOCB_CPU Kconfig option in order to avoid creating unnecessary nocb tasks. Signed-off-by: Zqiang Reviewed-by: Joel Fernandes (Google) Signed-off-by: Paul E. McKenney Signed-off-by: Joel Fernandes (Google) --- kernel/rcu/rcutorture.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 8e6c023212cb..83870c4ae1b8 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -3501,6 +3501,12 @@ rcu_torture_init(void) pr_alert("rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n"); fqs_duration = 0; } + if (nocbs_nthreads != 0 && (cur_ops != &rcu_ops || + !IS_ENABLED(CONFIG_RCU_NOCB_CPU))) { + pr_alert("rcu-torture types: %s and CONFIG_RCU_NOCB_CPU=%d, nocb toggle disabled.\n", + cur_ops->name, IS_ENABLED(CONFIG_RCU_NOCB_CPU)); + nocbs_nthreads = 0; + } if (cur_ops->init) cur_ops->init(); From patchwork Wed Mar 15 18:18:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 13176514 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 546F3C6FD1D for ; Wed, 15 Mar 2023 18:20:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232653AbjCOSUQ (ORCPT ); Wed, 15 Mar 2023 14:20:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232701AbjCOSTv (ORCPT ); Wed, 15 Mar 2023 14:19:51 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCAB8664EE for ; Wed, 15 Mar 2023 11:19:36 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id cf14so17177845qtb.10 for ; Wed, 15 Mar 2023 11:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1678904376; 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=6C875UW3frLz1lRISgaVupsCOUcY7ixEg8V710uhHfA=; b=DPSkv5UuukMQB08VeLhWDOZpTsKRs7XRm8Z7PYEO2J1A3Fp78UTsApYrFQwlOxMViU KlIZY+sUHHk4B22w99eFw5THO2D8yPtupryB73gk56KlbQQEhhQukLDCu+ytVgTy+DM+ V819OE0WU+vOdwSGrLQboPd96Y//tbADX9h2Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678904376; 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=6C875UW3frLz1lRISgaVupsCOUcY7ixEg8V710uhHfA=; b=jNvRQTBo4dEmHi9Aks1xt0PaCy7OVGxhutANpjxGxJSvstHIfxyiZnrvDc2TR1wDtQ pot0/alaTweevWfl6SfruINl11y7g5toonD4N1UTa7xYXg1Hx5u0H1+hW0SZj9zQau3E VMUNRMN9oHULDrNjpCb1X+uFseQ33XyhnS9+Zw4Osin53ZF9GAAlL/hgccLY5fyhN+lj HxaJ4HMunUMOqR80K6w4wPn7OvwIJrOo+cLQx3/N+R2xidwHnTxENBWwKdsYMMD/iGkh DD0Z2CLdljUodAmuEl3IxcmzobLUK0v5CispZCpPr+xPvKA3JV4eUN1UAVm3dZEWl+DA tS7w== X-Gm-Message-State: AO0yUKXITUMbZcHUS3A5CPPRMYH/Nah/nOhN6zLtqeOqVEOvIdYOH8ax g+m5F/oT+mWW0Z/OMoo3ePovdg== X-Google-Smtp-Source: AK7set/+DQUInzPQv7zg0jpqq9Z8pFaM3HKmCv83UgP5J0Ng/wXnoIoKyNsPk0qA4oLZ+MhQ5btm7Q== X-Received: by 2002:a05:622a:14c8:b0:3d4:6185:72eb with SMTP id u8-20020a05622a14c800b003d4618572ebmr1282272qtx.34.1678904376337; Wed, 15 Mar 2023 11:19:36 -0700 (PDT) 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 v125-20020a379383000000b007458ae32290sm4113974qkd.128.2023.03.15.11.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 11:19:36 -0700 (PDT) From: "Joel Fernandes (Google)" To: "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes Cc: "Uladzislau Rezki (Sony)" , rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 11/14] rcu/kvfree: Eliminate k[v]free_rcu() single argument macro Date: Wed, 15 Mar 2023 18:18:58 +0000 Message-Id: <20230315181902.4177819-11-joel@joelfernandes.org> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog In-Reply-To: <20230315181902.4177819-1-joel@joelfernandes.org> References: <20230315181902.4177819-1-joel@joelfernandes.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org From: "Uladzislau Rezki (Sony)" 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 removes the single-argument kvfree_rcu() and kfree_rcu() macros. Code that would have previously used these single-argument kvfree_rcu() and kfree_rcu() macros should instead use kvfree_rcu_mightsleep() or kfree_rcu_mightsleep(). [ paulmck: Apply Joel Fernandes feedback. ] Signed-off-by: Uladzislau Rezki (Sony) Signed-off-by: Paul E. McKenney Signed-off-by: Joel Fernandes (Google) --- include/linux/rcupdate.h | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 094321c17e48..7571dbfecb18 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -957,9 +957,8 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) /** * kfree_rcu() - kfree an object after a grace period. - * @ptr: pointer to kfree for both single- and double-argument invocations. - * @rhf: the name of the struct rcu_head within the type of @ptr, - * but only for double-argument invocations. + * @ptr: pointer to kfree for double-argument invocations. + * @rhf: the name of the struct rcu_head within the type of @ptr. * * Many rcu callbacks functions just call kfree() on the base structure. * These functions are trivial, but their size adds up, and furthermore @@ -982,26 +981,18 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) * The BUILD_BUG_ON check must not involve any function calls, hence the * checks are done in macros here. */ -#define kfree_rcu(ptr, rhf...) kvfree_rcu(ptr, ## rhf) +#define kfree_rcu(ptr, rhf) kvfree_rcu_arg_2(ptr, rhf) +#define kvfree_rcu(ptr, rhf) kvfree_rcu_arg_2(ptr, rhf) /** - * kvfree_rcu() - kvfree an object after a grace period. - * - * This macro consists of one or two arguments and it is - * based on whether an object is head-less or not. If it - * has a head then a semantic stays the same as it used - * to be before: - * - * kvfree_rcu(ptr, rhf); - * - * where @ptr is a pointer to kvfree(), @rhf is the name - * of the rcu_head structure within the type of @ptr. + * kfree_rcu_mightsleep() - kfree an object after a grace period. + * @ptr: pointer to kfree for single-argument invocations. * * When it comes to head-less variant, only one argument * is passed and that is just a pointer which has to be * freed after a grace period. Therefore the semantic is * - * kvfree_rcu(ptr); + * kfree_rcu_mightsleep(ptr); * * where @ptr is the pointer to be freed by kvfree(). * @@ -1010,13 +1001,9 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) * annotation. Otherwise, please switch and embed the * rcu_head structure within the type of @ptr. */ -#define kvfree_rcu(...) KVFREE_GET_MACRO(__VA_ARGS__, \ - kvfree_rcu_arg_2, kvfree_rcu_arg_1)(__VA_ARGS__) - +#define kfree_rcu_mightsleep(ptr) kvfree_rcu_arg_1(ptr) #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 { \ typeof (ptr) ___p = (ptr); \