* Re: [PATCH 1/2] rcuscale: Do a proper cleanup if kfree_scale_init() fails
@ 2024-10-27 9:16 kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2024-10-27 9:16 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20241024164558.715296-1-urezki@gmail.com>
References: <20241024164558.715296-1-urezki@gmail.com>
TO: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
TO: "Paul E . McKenney" <paulmck@kernel.org>
CC: Frederic Weisbecker <frederic@kernel.org>
CC: RCU <rcu@vger.kernel.org>
CC: LKML <linux-kernel@vger.kernel.org>
CC: Neeraj upadhyay <Neeraj.Upadhyay@amd.com>
CC: Boqun Feng <boqun.feng@gmail.com>
CC: Joel Fernandes <joel@joelfernandes.org>
CC: Uladzislau Rezki <urezki@gmail.com>
CC: Oleksiy Avramchenko <oleksiy.avramchenko@sony.com>
CC: Dan Carpenter <error27@gmail.com>
Hi Uladzislau,
kernel test robot noticed the following build warnings:
[auto build test WARNING on paulmck-rcu/dev]
[also build test WARNING on linus/master v6.12-rc4 next-20241025]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Uladzislau-Rezki-Sony/rcuscale-Remove-redundant-WARN_ON_ONCE-splat/20241025-004751
base: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
patch link: https://lore.kernel.org/r/20241024164558.715296-1-urezki%40gmail.com
patch subject: [PATCH 1/2] rcuscale: Do a proper cleanup if kfree_scale_init() fails
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: x86_64-randconfig-161-20241026 (https://download.01.org/0day-ci/archive/20241027/202410271601.WIHqAStZ-lkp@intel.com/config)
compiler: clang version 19.1.2 (https://github.com/llvm/llvm-project 7ba7d8e2f7b6445b60679da826210cdde29eaf8b)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202410271601.WIHqAStZ-lkp@intel.com/
smatch warnings:
kernel/rcu/rcuscale.c:893 kfree_scale_init() warn: missing error code 'firsterr'
vim +/firsterr +893 kernel/rcu/rcuscale.c
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 855)
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 856) static int __init
4e88ec4a9eb175 kernel/rcu/rcuscale.c Paul E. McKenney 2020-08-11 857 kfree_scale_init(void)
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 858) {
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 859) int firsterr = 0;
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 860) long i;
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 861) unsigned long jif_start;
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 862) unsigned long orig_jif;
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 863)
bb7bad3dae42b6 kernel/rcu/rcuscale.c Paul E. McKenney 2023-05-16 864 pr_alert("%s" SCALE_FLAG
bb7bad3dae42b6 kernel/rcu/rcuscale.c Paul E. McKenney 2023-05-16 865 "--- kfree_rcu_test: kfree_mult=%d kfree_by_call_rcu=%d kfree_nthreads=%d kfree_alloc_num=%d kfree_loops=%d kfree_rcu_test_double=%d kfree_rcu_test_single=%d\n",
bb7bad3dae42b6 kernel/rcu/rcuscale.c Paul E. McKenney 2023-05-16 866 scale_type, kfree_mult, kfree_by_call_rcu, kfree_nthreads, kfree_alloc_num, kfree_loops, kfree_rcu_test_double, kfree_rcu_test_single);
bb7bad3dae42b6 kernel/rcu/rcuscale.c Paul E. McKenney 2023-05-16 867
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 868) // Also, do a quick self-test to ensure laziness is as much as
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 869) // expected.
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 870) if (kfree_by_call_rcu && !IS_ENABLED(CONFIG_RCU_LAZY)) {
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 871) pr_alert("CONFIG_RCU_LAZY is disabled, falling back to kfree_rcu() for delayed RCU kfree'ing\n");
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 872) kfree_by_call_rcu = 0;
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 873) }
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 874)
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 875) if (kfree_by_call_rcu) {
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 876) /* do a test to check the timeout. */
499d7e7e83d25f kernel/rcu/rcuscale.c Frederic Weisbecker 2023-11-15 877 orig_jif = rcu_get_jiffies_lazy_flush();
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 878)
499d7e7e83d25f kernel/rcu/rcuscale.c Frederic Weisbecker 2023-11-15 879 rcu_set_jiffies_lazy_flush(2 * HZ);
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 880) rcu_barrier();
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 881)
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 882) jif_start = jiffies;
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 883) jiffies_at_lazy_cb = 0;
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 884) call_rcu(&lazy_test1_rh, call_rcu_lazy_test1);
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 885)
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 886) smp_cond_load_relaxed(&rcu_lazy_test1_cb_called, VAL == 1);
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 887)
499d7e7e83d25f kernel/rcu/rcuscale.c Frederic Weisbecker 2023-11-15 888 rcu_set_jiffies_lazy_flush(orig_jif);
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 889)
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 890) if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start < 2 * HZ)) {
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 891) pr_alert("ERROR: call_rcu() CBs are not being lazy as expected!\n");
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 892) WARN_ON_ONCE(1);
c17a39e335231a kernel/rcu/rcuscale.c Uladzislau Rezki (Sony 2024-10-24 @893) goto unwind;
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 894) }
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 895)
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 896) if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start > 3 * HZ)) {
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 897) pr_alert("ERROR: call_rcu() CBs are being too lazy!\n");
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 898) WARN_ON_ONCE(1);
c17a39e335231a kernel/rcu/rcuscale.c Uladzislau Rezki (Sony 2024-10-24 899) goto unwind;
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 900) }
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 901) }
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 902)
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 903) kfree_nrealthreads = compute_real(kfree_nthreads);
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 904) /* Start up the kthreads. */
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 905) if (shutdown) {
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 906) init_waitqueue_head(&shutdown_wq);
4e88ec4a9eb175 kernel/rcu/rcuscale.c Paul E. McKenney 2020-08-11 907 firsterr = torture_create_kthread(kfree_scale_shutdown, NULL,
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 908) shutdown_task);
eb77abfdeed29d kernel/rcu/rcuscale.c Paul E. McKenney 2021-08-05 909 if (torture_init_error(firsterr))
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 910) goto unwind;
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 911) schedule_timeout_uninterruptible(1);
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 912) }
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 913)
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 914) pr_alert("kfree object size=%zu, kfree_by_call_rcu=%d\n",
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 915) kfree_mult * sizeof(struct kfree_obj),
084e04fff16017 kernel/rcu/rcuscale.c Joel Fernandes (Google 2022-10-16 916) kfree_by_call_rcu);
f87dc808009ac8 kernel/rcu/rcuperf.c Joel Fernandes (Google 2020-03-16 917)
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 918) kfree_reader_tasks = kcalloc(kfree_nrealthreads, sizeof(kfree_reader_tasks[0]),
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 919) GFP_KERNEL);
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 920) if (kfree_reader_tasks == NULL) {
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 921) firsterr = -ENOMEM;
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 922) goto unwind;
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 923) }
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 924)
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 925) for (i = 0; i < kfree_nrealthreads; i++) {
4e88ec4a9eb175 kernel/rcu/rcuscale.c Paul E. McKenney 2020-08-11 926 firsterr = torture_create_kthread(kfree_scale_thread, (void *)i,
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 927) kfree_reader_tasks[i]);
eb77abfdeed29d kernel/rcu/rcuscale.c Paul E. McKenney 2021-08-05 928 if (torture_init_error(firsterr))
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 929) goto unwind;
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 930) }
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 931)
4e88ec4a9eb175 kernel/rcu/rcuscale.c Paul E. McKenney 2020-08-11 932 while (atomic_read(&n_kfree_scale_thread_started) < kfree_nrealthreads)
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 933) schedule_timeout_uninterruptible(1);
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 934)
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 935) torture_init_end();
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 936) return 0;
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 937)
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 938) unwind:
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 939) torture_init_end();
4e88ec4a9eb175 kernel/rcu/rcuscale.c Paul E. McKenney 2020-08-11 940 kfree_scale_cleanup();
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 941) return firsterr;
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 942) }
e6e78b004fa7e0 kernel/rcu/rcuperf.c Joel Fernandes (Google 2019-08-30 943)
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH 1/2] rcuscale: Do a proper cleanup if kfree_scale_init() fails
@ 2024-10-24 16:45 Uladzislau Rezki (Sony)
0 siblings, 0 replies; 2+ messages in thread
From: Uladzislau Rezki (Sony) @ 2024-10-24 16:45 UTC (permalink / raw)
To: Paul E . McKenney
Cc: Frederic Weisbecker, RCU, LKML, Neeraj upadhyay, Boqun Feng,
Joel Fernandes, Uladzislau Rezki, Oleksiy Avramchenko,
Dan Carpenter
A static analyzer for C, Smatch, reports and triggers below
warnings:
kernel/rcu/rcuscale.c:1215 rcu_scale_init()
warn: inconsistent returns 'global &fullstop_mutex'.
The checker complains about, we do not unlock the "fullstop_mutex"
mutex, in case of hitting below error path:
<snip>
...
if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start < 2 * HZ)) {
pr_alert("ERROR: call_rcu() CBs are not being lazy as expected!\n");
WARN_ON_ONCE(1);
return -1;
^^^^^^^^^^
...
<snip>
it happens because "-1" is returned right away instead of
doing a proper unwinding.
Fix it by jumping to "unwind" label instead of returning -1.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/rcu/ZxfTrHuEGtgnOYWp@pc636/T/
Fixes: 084e04fff160 ("rcuscale: Add laziness and kfree tests")
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
kernel/rcu/rcuscale.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c
index 6d37596deb1f..de7d511e6be4 100644
--- a/kernel/rcu/rcuscale.c
+++ b/kernel/rcu/rcuscale.c
@@ -890,13 +890,13 @@ kfree_scale_init(void)
if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start < 2 * HZ)) {
pr_alert("ERROR: call_rcu() CBs are not being lazy as expected!\n");
WARN_ON_ONCE(1);
- return -1;
+ goto unwind;
}
if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start > 3 * HZ)) {
pr_alert("ERROR: call_rcu() CBs are being too lazy!\n");
WARN_ON_ONCE(1);
- return -1;
+ goto unwind;
}
}
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-27 9:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-27 9:16 [PATCH 1/2] rcuscale: Do a proper cleanup if kfree_scale_init() fails kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2024-10-24 16:45 Uladzislau Rezki (Sony)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.