From patchwork Tue Mar 26 19:24:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 10872109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35C7E15AC for ; Tue, 26 Mar 2019 19:24:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1934328BE7 for ; Tue, 26 Mar 2019 19:24:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CFE828DB1; Tue, 26 Mar 2019 19:24:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F214628D01 for ; Tue, 26 Mar 2019 19:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728314AbfCZTYb (ORCPT ); Tue, 26 Mar 2019 15:24:31 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:42214 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729693AbfCZTYb (ORCPT ); Tue, 26 Mar 2019 15:24:31 -0400 Received: by mail-pl1-f194.google.com with SMTP id cv12so2099533plb.9 for ; Tue, 26 Mar 2019 12:24:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cBJLe6/JGplG+Cy8Q3/cMVi7Shc7ruJGMSA1cWOMVqY=; b=WIyBizMngixWEhCS5V1bN1IbboWlbBa/zzrPjtzcGpBAqm9dDvsYykZKnRKho5FZvm waFLFVy194hEvmK7je9hxoDmUOzvW8fiSsEkt+sz2wr9ghG5955KLCCx49DjcgSR9E3z m0cbfO0jiIvx7ys5FH0c4R6IZ/KvKyvBD6wfc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cBJLe6/JGplG+Cy8Q3/cMVi7Shc7ruJGMSA1cWOMVqY=; b=iXsNU7oQMxL+WL0YSMLuPDX0NkPRZip7NPYTA6qxtmJLKrfq9OC5rrvn+1Yxncw+El tlPAO80yTACrYqL68t/aFRvehZDw/wddoyuP6gIrRs+3sUqNqqkCxv24DrtmNMdQmZrM 5ItJ+hDXE9Zh3whbMB/yPY2JGoxY50BUcuZy5tdDAE8St7Uws++/9S7N937knHKPayCw MDy3h9a6S2plW0ajc7a5sRkpVwyg1Q5BbZBjN/3guEN8XhK6Gzxb2Ui+mU44RqB//hRs 8t7is7b7NwUtzut2a0SsPoDVdre6i82prmTrcIaCeJhHF29UwuyTVL1PBqBTgqePSdL7 dgbQ== X-Gm-Message-State: APjAAAVfaRSgbXnSVDOBr5ELkosDHYZcd9oIeRuh1aGYgJig1gyLp8Sy z5FHc7Pwm/yuovJMS4GLYoxwCw== X-Google-Smtp-Source: APXvYqypEKPXcoQJgDVy5MvfSX2VsoZ1x9Ur4x5YtgQwDWYTEU/kZATCqD9coRmyBcoDdt/Dx7aYRw== X-Received: by 2002:a17:902:20e5:: with SMTP id v34mr33077657plg.319.1553628270382; Tue, 26 Mar 2019 12:24:30 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id l12sm36761889pgn.83.2019.03.26.12.24.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 12:24:29 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Steven Rostedt , kernel-team@android.com, rcu@vger.kernel.org, byungchul.park@lge.com, Ingo Molnar , Josh Triplett , Lai Jiangshan , linux-kselftest@vger.kernel.org, Mathieu Desnoyers , "Paul E. McKenney" , Peter Zijlstra , Shuah Khan , Will Deacon Subject: [PATCH v2 1/4] lockdep: Add assertion to check if in an interrupt Date: Tue, 26 Mar 2019 15:24:08 -0400 Message-Id: <20190326192411.198070-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In rcu_rrupt_from_idle, we want to check if it is called from within an interrupt, but want to do such checking only for debug builds. lockdep already tracks when we enter an interrupt. Let us expose it as an assertion macro so it can be used to assert this. Suggested-by: Steven Rostedt Cc: kernel-team@android.com Cc: rcu@vger.kernel.org Signed-off-by: Joel Fernandes (Google) --- include/linux/lockdep.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index c5335df2372f..d24f564823d3 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -601,11 +601,18 @@ do { \ "IRQs not disabled as expected\n"); \ } while (0) +#define lockdep_assert_in_irq() do { \ + WARN_ONCE(debug_locks && !current->lockdep_recursion && \ + !current->hardirq_context, \ + "Not in hardirq as expected\n"); \ + } while (0) + #else # define might_lock(lock) do { } while (0) # define might_lock_read(lock) do { } while (0) # define lockdep_assert_irqs_enabled() do { } while (0) # define lockdep_assert_irqs_disabled() do { } while (0) +# define lockdep_assert_in_irq() do { } while (0) #endif #ifdef CONFIG_LOCKDEP From patchwork Tue Mar 26 19:24:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 10872115 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E1AF17E6 for ; Tue, 26 Mar 2019 19:24:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BEE820950 for ; Tue, 26 Mar 2019 19:24:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 804F628DC9; Tue, 26 Mar 2019 19:24:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD51320950 for ; Tue, 26 Mar 2019 19:24:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732193AbfCZTYf (ORCPT ); Tue, 26 Mar 2019 15:24:35 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:40277 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730451AbfCZTYd (ORCPT ); Tue, 26 Mar 2019 15:24:33 -0400 Received: by mail-pl1-f195.google.com with SMTP id b11so2088181plr.7 for ; Tue, 26 Mar 2019 12:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=03p3ODFVQvd6EJVrQdS1N5Fn4xNiqjPABgOQRHIhcDc=; b=wR28RfZ8qqW/OhBxbQWwxK1hqfOW99Wi+R5C9zwy0N/m8KsbEDa+ocRieqjAOL1vBl fpzjl+d4iZstuTiyCkdV/5Hp3gFaJQu5KiKH4UOlGzTjOeyYQxQj/+2h5Koi7FMfDpZ4 cLu6YD37NBR4qIYEP5ZrsWo3itletofOp1DqA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=03p3ODFVQvd6EJVrQdS1N5Fn4xNiqjPABgOQRHIhcDc=; b=BJ9llFHRS2CtKYP83jHgeexktZzXJoRHYDqKf4tPoFs5KJXprQJpQZagnPmGs8P5Fz 1kXszVb6tF/aBo71eKUtXHk14x4IO9BARpPoxoZtbqv5oLf8ZIIODlIXl42E+e8oesXF /hgBq3uazQhw5yKWvX5wAGTjgOTy1GEs/A1dDKFuwZtbxRRnRk89JP/NGmVQPHkS1RKA QXOfEhBlSgl7iFR0Dmw+Kqlsw+DKk6wJP7Z7jRcdcxW46AfyZkElD+jr8fgTjrJ2S3Cv wqY+kezqSm854e1rhYaQfm8RKffrj4r3gWze6zRLtxD53UaGtVwfU5QnqVtAErTz0KMz ksMA== X-Gm-Message-State: APjAAAW5CF6qH3kw4bYu7uBFMJ4MtN/Wuczrgs08XbY0WjpGLfX5Pxo5 Xk+dvvH8MMAsNeU0QMniNBpqAw== X-Google-Smtp-Source: APXvYqz0CpZVgoinljCuzSh12Y9Mbmv/Ll+Vo/kIttOgigpinJboA+vihBRBMjMLEiV4rhip7GywxQ== X-Received: by 2002:a17:902:2963:: with SMTP id g90mr33228185plb.182.1553628272923; Tue, 26 Mar 2019 12:24:32 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id l12sm36761889pgn.83.2019.03.26.12.24.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 12:24:32 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , byungchul.park@lge.com, kernel-team@android.com, rcu@vger.kernel.org, Ingo Molnar , Josh Triplett , Lai Jiangshan , linux-kselftest@vger.kernel.org, Mathieu Desnoyers , "Paul E. McKenney" , Peter Zijlstra , Shuah Khan , Steven Rostedt , Will Deacon Subject: [PATCH v2 2/4] rcutree: Add checks for dynticks counters in rcu_is_cpu_rrupt_from_idle Date: Tue, 26 Mar 2019 15:24:09 -0400 Message-Id: <20190326192411.198070-2-joel@joelfernandes.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog In-Reply-To: <20190326192411.198070-1-joel@joelfernandes.org> References: <20190326192411.198070-1-joel@joelfernandes.org> MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the future we would like to combine the dynticks and dynticks_nesting counters thus leading to simplifying the code. At the moment we cannot do that due to concerns about usermode upcalls appearing to RCU as half of an interrupt. Byungchul tried to do it in [1] but the "half-interrupt" concern was raised. It is half because, what RCU expects is rcu_irq_enter() and rcu_irq_exit() pairs when the usermode exception happens. However, only rcu_irq_enter() is observed. This concern may not be valid anymore, but at least it used to be the case. Out of abundance of caution, Paul added warnings [2] in the RCU code which if not fired by 2021 may allow us to assume that such half-interrupt scenario cannot happen any more, which can lead to simplification of this code. Summary of the changes are the following: (1) In preparation for this combination of counters in the future, we first need to first be sure that rcu_rrupt_from_idle cannot be called from anywhere but a hard-interrupt because previously, the comments suggested otherwise so let us be sure. We discussed this here [3]. We use the services of lockdep to accomplish this. (2) Further rcu_rrupt_from_idle() is not explicit about how it is using the counters which can lead to weird future bugs. This patch therefore makes it more explicit about the specific counter values being tested (3) Lastly, we check for counter underflows just to be sure these are not happening, because the previous code in rcu_rrupt_from_idle() was allowing the case where the counters can underflow, and the function would still return true. Now we are checking for specific values so let us be confident by additional checking, that such underflows don't happen. Any case, if they do, we should fix them and the screaming warning is appropriate. All these checks checks are NOOPs if PROVE_RCU and PROVE_LOCKING are disabled. [1] https://lore.kernel.org/patchwork/patch/952349/ [2] Commit e11ec65cc8d6 ("rcu: Add warning to detect half-interrupts") [3] https://lore.kernel.org/lkml/20190312150514.GB249405@google.com/ Cc: byungchul.park@lge.com Cc: kernel-team@android.com Cc: rcu@vger.kernel.org Signed-off-by: Joel Fernandes (Google) Reviewed-by: Joel Fernandes (Google) --- kernel/rcu/tree.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 9180158756d2..dbff8a274c46 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -381,16 +381,29 @@ static void __maybe_unused rcu_momentary_dyntick_idle(void) } /** - * rcu_is_cpu_rrupt_from_idle - see if idle or immediately interrupted from idle + * rcu_is_cpu_rrupt_from_idle - see if interrupted from idle * - * If the current CPU is idle or running at a first-level (not nested) + * If the current CPU is idle and running at a first-level (not nested) * interrupt from idle, return true. The caller must have at least * disabled preemption. */ static int rcu_is_cpu_rrupt_from_idle(void) { - return __this_cpu_read(rcu_data.dynticks_nesting) <= 0 && - __this_cpu_read(rcu_data.dynticks_nmi_nesting) <= 1; + /* Called only from within the scheduling-clock interrupt */ + lockdep_assert_in_irq(); + + /* Check for counter underflows */ + RCU_LOCKDEP_WARN(__this_cpu_read(rcu_data.dynticks_nesting) < 0, + "RCU dynticks_nesting counter underflow!"); + RCU_LOCKDEP_WARN(__this_cpu_read(rcu_data.dynticks_nmi_nesting) <= 0, + "RCU dynticks_nmi_nesting counter underflow/zero!"); + + /* Are we at first interrupt nesting level? */ + if (__this_cpu_read(rcu_data.dynticks_nmi_nesting) != 1) + return false; + + /* Does CPU appear to be idle from an RCU standpoint? */ + return __this_cpu_read(rcu_data.dynticks_nesting) == 0; } #define DEFAULT_RCU_BLIMIT 10 /* Maximum callbacks per rcu_do_batch. */ From patchwork Tue Mar 26 19:24:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 10872113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E5E31669 for ; Tue, 26 Mar 2019 19:24:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CAB028DC4 for ; Tue, 26 Mar 2019 19:24:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DD2C28DCB; Tue, 26 Mar 2019 19:24:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E859A28DC4 for ; Tue, 26 Mar 2019 19:24:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732196AbfCZTYu (ORCPT ); Tue, 26 Mar 2019 15:24:50 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37615 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732201AbfCZTYg (ORCPT ); Tue, 26 Mar 2019 15:24:36 -0400 Received: by mail-pf1-f196.google.com with SMTP id 8so8525825pfr.4 for ; Tue, 26 Mar 2019 12:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VpO+kH5n/TCwOCtL6i6LDDDwCLUmaIA5kDbeBwsenW8=; b=ic2pO6JrvwEPAs1CnVuT7xWHP8ABOKGkFUt9H1s0OLBDzjFRw1epxg+DmzlHEGONnX IixtodF2vh92KGgKTGRYdCz8Qfg7aK04HlZJQmLZZu6bgaA7wzxGBDOf24vFPGpVK2hJ cmIfAFVEayqe/33wv7JRMHW2vxfovfoZ/Y5Ck= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VpO+kH5n/TCwOCtL6i6LDDDwCLUmaIA5kDbeBwsenW8=; b=hqX0c8RPwEQY6gq/9HbLoCYipeMMJ4zMiLtlV/Lu0NTqN9BomZOINnOA+mzO6ArywK 6RxWPnEkRaNcs+a9qGwz7LCNyceqEIrCotuj7fQUtRG0lkyIpwD2uT1J0z3l5SrXVfez +nro+ev0ZfO0k0y5YedmFfjTbX0LnQlYCr9mEFSGAMsgaUTvUaIBY7KXPgNiRPHMsNOc npDvfjpsIg+6wwrJ7jwIM8Ll8ljfaphq8MmyHj6Pj/Q7kCvzeA3mlr7GFz/MHqldgGUX y8YjKeRx5/oBvh9ISepiwKAro7H5uTAX9VU5YLVnHKWO1T8wstruWrv+PVDnHQeVQ94b 1clA== X-Gm-Message-State: APjAAAWBNTOMhosRXl3CBhSQkYOoTPMQvcdeQpSYA3z+eKwDjN5zshH4 pkV3B6ebtw67VarxBfwLkqriVA== X-Google-Smtp-Source: APXvYqxRuFbNRDdKaMGu2pfXId9tLkyI2m9Vc5ldX1d4DDCuVuNBaT6qoRUfJTbviF9W9099+n61Lg== X-Received: by 2002:a62:e502:: with SMTP id n2mr31731079pff.242.1553628275495; Tue, 26 Mar 2019 12:24:35 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id l12sm36761889pgn.83.2019.03.26.12.24.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 12:24:34 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , rcu@vger.kernel.org, byungchul.park@lge.com, Ingo Molnar , Josh Triplett , kernel-team@android.com, Lai Jiangshan , linux-kselftest@vger.kernel.org, Mathieu Desnoyers , "Paul E. McKenney" , Peter Zijlstra , Shuah Khan , Steven Rostedt , Will Deacon Subject: [PATCH v2 3/4] rcutorture: Select from only online CPUs Date: Tue, 26 Mar 2019 15:24:10 -0400 Message-Id: <20190326192411.198070-3-joel@joelfernandes.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog In-Reply-To: <20190326192411.198070-1-joel@joelfernandes.org> References: <20190326192411.198070-1-joel@joelfernandes.org> MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The rcutorture jitter.sh script selects a random CPU but does not check if it is offline or online. This leads to taskset errors many times. On my machine, hyper threading is disabled so half the cores are offline causing taskset errors a lot of times. Let us fix this by checking from only the online CPUs on the system. Cc: rcu@vger.kernel.org Signed-off-by: Joel Fernandes (Google) --- tools/testing/selftests/rcutorture/bin/jitter.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/rcutorture/bin/jitter.sh b/tools/testing/selftests/rcutorture/bin/jitter.sh index 3633828375e3..47bd9829dc55 100755 --- a/tools/testing/selftests/rcutorture/bin/jitter.sh +++ b/tools/testing/selftests/rcutorture/bin/jitter.sh @@ -47,10 +47,11 @@ do exit 0; fi - # Set affinity to randomly selected CPU - cpus=`ls /sys/devices/system/cpu/*/online | + # Set affinity to randomly selected online CPU + cpus=`grep 1 /sys/devices/system/cpu/*/online | sed -e 's,/[^/]*$,,' -e 's/^[^0-9]*//' | grep -v '^0*$'` + cpumask=`awk -v cpus="$cpus" -v me=$me -v n=$n 'BEGIN { srand(n + me + systime()); ncpus = split(cpus, ca); From patchwork Tue Mar 26 19:24:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 10872111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCC3C15AC for ; Tue, 26 Mar 2019 19:24:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9E6120950 for ; Tue, 26 Mar 2019 19:24:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD0A728AB8; Tue, 26 Mar 2019 19:24:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CA4F20950 for ; Tue, 26 Mar 2019 19:24:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732636AbfCZTYj (ORCPT ); Tue, 26 Mar 2019 15:24:39 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43441 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732622AbfCZTYi (ORCPT ); Tue, 26 Mar 2019 15:24:38 -0400 Received: by mail-pl1-f196.google.com with SMTP id m10so2092980plt.10 for ; Tue, 26 Mar 2019 12:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9xe2cnKgj2u/5e350AhnUZqGhZDwjch2potbZGjEHUM=; b=v/VOm10tv19N25u4AXHbxwGBxHou9OBjaSYgwhqnd9yTlGqrc6cJ0pZyoTS1BIvrpJ r4fvbu/5qL9sC0M4MnERILS/2oPRyhlTlSjFPLbSOdYmZsmuF67L3ISWgQOtHavmn9SM H/DTQ/dbDqIiWwZd5Hi26iBq9B6ZYC65e3e2M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9xe2cnKgj2u/5e350AhnUZqGhZDwjch2potbZGjEHUM=; b=kLANae5DtYkW2x+XU30v4dbAvLInvJlAVTbsG9em0uIq8eeCcmvBp7Beu0WpQCCb9O 5b1Fw8Wg3f+bX27Q1N3ulOpXbRBzToqLo2gpYVXYXg5pHtUa/VE/PH9y1yCg3TZ1Rsyj 48Ot43TMLxyzvjEahCdr7FAvnJSCPkrLSdMMRg+FQUDnFynkA3QJaXgz5w8v/BC9CQPX VgWzNnD6C5FcIn1B4m816N5k/i2olX+2bKwsoUmcCSBM6ZNWgGn7asKDIwLy2nmuGaNT M+g1N6HgpynkVsiQPlLWVfFmpQjqd+gZewKLTntgiXCBINage9nv52EDe4zJAEBcfdCn 1c9w== X-Gm-Message-State: APjAAAX9OgOejMzVDfaRsGNQareIYVwTGL9BV7lGYQnHUR/oV3N9jsVz 8aq/ZjrCvUExVsrDM9ZsxDJMPQ== X-Google-Smtp-Source: APXvYqwMJ3hs4xED/sxyQLZzrjezrjuatGt1jM2/TtrZQmpPXSsOJnh8yMCjdjiUOwVv9nMh0rSFxQ== X-Received: by 2002:a17:902:2c01:: with SMTP id m1mr32840752plb.186.1553628278149; Tue, 26 Mar 2019 12:24:38 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id l12sm36761889pgn.83.2019.03.26.12.24.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 12:24:37 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , byungchul.park@lge.com, Ingo Molnar , Josh Triplett , kernel-team@android.com, Lai Jiangshan , linux-kselftest@vger.kernel.org, Mathieu Desnoyers , "Paul E. McKenney" , Peter Zijlstra , rcu@vger.kernel.org, Shuah Khan , Steven Rostedt , Will Deacon Subject: [PATCH v2 4/4] rcutorture: Add cpu0 to the set of CPUs to add jitter Date: Tue, 26 Mar 2019 15:24:11 -0400 Message-Id: <20190326192411.198070-4-joel@joelfernandes.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog In-Reply-To: <20190326192411.198070-1-joel@joelfernandes.org> References: <20190326192411.198070-1-joel@joelfernandes.org> MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP jitter.sh currently does not add CPU0 to the list of CPUs for adding of jitter. Let us add it to this list even when it is not hot-pluggable. Signed-off-by: Joel Fernandes (Google) --- tools/testing/selftests/rcutorture/bin/jitter.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/rcutorture/bin/jitter.sh b/tools/testing/selftests/rcutorture/bin/jitter.sh index 47bd9829dc55..26faf5824a1f 100755 --- a/tools/testing/selftests/rcutorture/bin/jitter.sh +++ b/tools/testing/selftests/rcutorture/bin/jitter.sh @@ -49,8 +49,12 @@ do # Set affinity to randomly selected online CPU cpus=`grep 1 /sys/devices/system/cpu/*/online | - sed -e 's,/[^/]*$,,' -e 's/^[^0-9]*//' | - grep -v '^0*$'` + sed -e 's,/[^/]*$,,' -e 's/^[^0-9]*//'` + + # Do not leave out poor old cpu0 which may not be hot-pluggable + if [ ! -f "/sys/devices/system/cpu/cpu0/online" ]; then + cpus="0 $cpus" + fi cpumask=`awk -v cpus="$cpus" -v me=$me -v n=$n 'BEGIN { srand(n + me + systime());