Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp237290rdg; Tue, 10 Oct 2023 08:53:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOyS06WrYSF2HaiRUF4Js2ds67vnkRMQP0EoMsSQ+T0AaEXvRM4TJPWxcSSNQQmgb96Qnn X-Received: by 2002:a05:6a00:23ce:b0:68e:3f0b:5e6f with SMTP id g14-20020a056a0023ce00b0068e3f0b5e6fmr19356605pfc.24.1696953232642; Tue, 10 Oct 2023 08:53:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696953232; cv=none; d=google.com; s=arc-20160816; b=NVlt1FV8UOoC+qhSXxDybjSeYEIEL2UgYcZjphbxWXtFsFx9cKoAaY9jZ/t6ZIqgpn CmaPg37rH5uADDE5eVvlTDnlQxuZHVoS1u9wps0ICrRQT7npeX7s7k9vs98yjbf1JJvx iAjySFkmLmCKys4CK6lbqviBlPTQAo+pkjSC55W3fWScNiuCWl2KZQ5KyLLy105Jn/db h7806rPZ5igLGDiEH2PuhlQHXu5IXfmvQyc2avkGag4Kakd4LQ+ASy03to9KDc1KrrAa NAw0ROKz1w8jUqXW79AP3/HDE3J03loTtuTZJf5yj0tFtmIuJzmT8ceydBq/MJJK56L0 Khng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=TofhIUjCjwev74+LXBJil6BsMJnojZ6Nh6DjFlLE254=; fh=1lQxHWBXXM5W3P1i6wlRHTETJPY/TDYhdVr6B5VHaT8=; b=ghZMVzDPALaIJ+OlmWWf/9haP8S4J48tIll+j8spilZAs+kgI18/3sxUmcbEFhUV1Y phK3s/Y+ob4yYdFkFeYJ6/pM6CcfSsCDmRE3SCB8SAlrlBwFG6MLo0i/Dkk8KXIHPqhE ZVWQOgVHIOGkcFexnEIC0/WLP68YZ4qD911RjqNCKXbcReul5tjvg+a/tiZq+mw8ounF sUOOmPcR3ot+42IfMe9BnR+S9eQh8IIikRIInTTaE+m8m9+Aa9h5PqJjlUsd1nAFxEhI O0gezATHKYwSZrqHr/vLrqW+NRciKXwAkx+GDK3Iq9tzponICA9eSFZpfACpS4IE9GIr a8Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KkgRaUuf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o1-20020a634101000000b00573f6ee58fasi11909462pga.376.2023.10.10.08.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 08:53:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KkgRaUuf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id B1B28817C3E4; Tue, 10 Oct 2023 08:53:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233403AbjJJPxj (ORCPT + 99 others); Tue, 10 Oct 2023 11:53:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232226AbjJJPxi (ORCPT ); Tue, 10 Oct 2023 11:53:38 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B553893; Tue, 10 Oct 2023 08:53:37 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 569FFC433C7; Tue, 10 Oct 2023 15:53:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696953217; bh=dJilxtsFO/qehFaC1MAIXeHjdS9M64JARVtLJnq4Gcs=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=KkgRaUufLL5SjMzVSiyv0sN529gh9ETW+Ycgy2Z/tjdr0zoKaJhjr3wUZono0wTT4 x5ALHQiuMwfHlS9s4BqJ1ZZGXCYpR4H6608KKTPubfx17Keh5C/Ho1BujqiDszPuyk gU4H9vPRK5wKEURRuhEAIV/6dIzSYXuOgqNpZaXXwcETkZMR/96K85UYAqj0nDozs2 VvRq+XG2w5Nk5GJVAFy4AfdwbQlnl5khQsL4QDhgYDG3PPTthLjfrGFWXYUZsflH+C S/4mlO6t595T0zWCTlnLvArov8i0o4Wv/JRjjVl4y3RPtbHknUUBJCry5TO/IIHlPV xd4aVmz8NRx3A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E3074CE0D02; Tue, 10 Oct 2023 08:53:36 -0700 (PDT) Date: Tue, 10 Oct 2023 08:53:36 -0700 From: "Paul E. McKenney" To: Dan Carpenter Cc: Frederic Weisbecker , LKML , Boqun Feng , Joel Fernandes , Josh Triplett , Mathieu Desnoyers , Neeraj Upadhyay , Steven Rostedt , Uladzislau Rezki , rcu Subject: Re: [PATCH 23/23] locktorture: Check the correct variable for allocation failure Message-ID: Reply-To: paulmck@kernel.org References: <20231010115921.988766-1-frederic@kernel.org> <20231010115921.988766-24-frederic@kernel.org> <97ecfb49-e500-45f4-86bb-769b2d32e91c@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 10 Oct 2023 08:53:47 -0700 (PDT) X-Spam-Level: ** On Tue, Oct 10, 2023 at 05:07:00PM +0300, Dan Carpenter wrote: > On Tue, Oct 10, 2023 at 06:55:40AM -0700, Paul E. McKenney wrote: > > On Tue, Oct 10, 2023 at 01:59:21PM +0200, Frederic Weisbecker wrote: > > > From: Dan Carpenter > > > > > > There is a typo so this checks the wrong variable. "chains" plural vs > > > "chain" singular. We already know that "chains" is non-zero. > > > > > > Fixes: 7f993623e9eb ("locktorture: Add call_rcu_chains module parameter") > > > Signed-off-by: Dan Carpenter > > > Signed-off-by: Frederic Weisbecker > > > > Reviewed-by: Paul E. McKenney > > > > A name change to increase the Hamming distance would of course also be > > good, though less urgent. ;-) > > "Hamming distance" is such a great phrase. I'm going to use that every > time I complain about confusingly similar variable names going forward. Glad you like it! But the horrible thing is that I first heard that phrase back in the 1970s, and I am the guilty party who created these particular too-similar variable names. (Why has the phrase fallen out of favor? No idea, really, but one guess has to do with the fact that current error-correcting codes must deal with different probabilities of different bits flipping in different directions, so you would instead needs a weirdly weighted variant of Hamming distance to accomplish anything with modern error-correcting codes.) But how about something like the following? Thanx, paul ------------------------------------------------------------------------ diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c index 991496afc0d9..48fd4562a754 100644 --- a/kernel/locking/locktorture.c +++ b/kernel/locking/locktorture.c @@ -126,7 +126,7 @@ struct call_rcu_chain { struct rcu_head crc_rh; bool crc_stop; }; -struct call_rcu_chain *call_rcu_chain; +struct call_rcu_chain *call_rcu_chain_list; /* Forward reference. */ static void lock_torture_cleanup(void); @@ -1106,12 +1106,12 @@ static int call_rcu_chain_init(void) if (call_rcu_chains <= 0) return 0; - call_rcu_chain = kcalloc(call_rcu_chains, sizeof(*call_rcu_chain), GFP_KERNEL); - if (!call_rcu_chain) + call_rcu_chain_list = kcalloc(call_rcu_chains, sizeof(*call_rcu_chain_list), GFP_KERNEL); + if (!call_rcu_chain_list) return -ENOMEM; for (i = 0; i < call_rcu_chains; i++) { - call_rcu_chain[i].crc_stop = false; - call_rcu(&call_rcu_chain[i].crc_rh, call_rcu_chain_cb); + call_rcu_chain_list[i].crc_stop = false; + call_rcu(&call_rcu_chain_list[i].crc_rh, call_rcu_chain_cb); } return 0; } @@ -1121,13 +1121,13 @@ static void call_rcu_chain_cleanup(void) { int i; - if (!call_rcu_chain) + if (!call_rcu_chain_list) return; for (i = 0; i < call_rcu_chains; i++) - smp_store_release(&call_rcu_chain[i].crc_stop, true); + smp_store_release(&call_rcu_chain_list[i].crc_stop, true); rcu_barrier(); - kfree(call_rcu_chain); - call_rcu_chain = NULL; + kfree(call_rcu_chain_list); + call_rcu_chain_list = NULL; } static struct notifier_block lock_torture_stall_block;