Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8284221rwb; Wed, 23 Nov 2022 19:08:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf47wWB9qpv5l3pSwpiJVS3wJtd2Fsion0v1hgVryyQPYHlyqEaz2XvAt95429WWjmXFa+DK X-Received: by 2002:a17:907:986c:b0:7a0:b505:e8f9 with SMTP id ko12-20020a170907986c00b007a0b505e8f9mr15116155ejc.216.1669259318616; Wed, 23 Nov 2022 19:08:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669259318; cv=none; d=google.com; s=arc-20160816; b=L0L367tlOAvCPnNt51TO94tRaDbtMI4n+Hw3m2BO4/C9KSujM4/6fk4CaAhXdWlJ+u LF4q6nGbwHPRpilRIs4784pR0bsj3ulbFWL75b6oQ2O3uKq7kGXFog/gYy8jV8HSX/Y6 Q7ElZboqGnAwlJH6V6H8tCRuw8cBL+vQapukEFibUuZK7DUDvikiF7ztrqY0D5yuzJqN yPyssTGkEmHc5v24yvw0vUQ98m9SsGpS5NfDxzfcQ0uKN6qWjs/cV/YGcGo0rb3A9mV0 LzLa0KaJB37CqAfeyP/+H6QI1qpJZs2EPIsJX7rCgHYSVdO1fgc81zSrFJvjMFhmYbu3 3RHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=21lSEg2vXSFoHO1msB/0t+aM934kgEehRE9bwrPsG98=; b=WXukYKlxglIkPXE9N4TBzDoXcPBJO3Ki8h3JWrHRnVgN7J8EM2B8vTf2nmFvOwCY1x v7huahUzY5FDYkvsrPIBFSW6nZW0xm/73Ij8hOyGTsAyX81QJ5jjdb4C4iwfG0Bd3Jxt ik8HUxkwT4okNnUtZPUQbBinZ64A9YzdjLGtuOavxV5Gf6C+h7vCiFYHrtwdOE35EfW+ uzqunz/JGIIH4eKbTgUX7SubEKv+JsjcN9UjqShbKf8EMqwV0HRpUZYwkwSrR39cOeNv vNvcNm/W/O51gQgs31tLJp2UNOhCCjxwMKiCeMr3zmbphL3iP+Mr4cKFKtWXjWWQ6Pnh FAFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=M++o8EzB; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr25-20020a1709073f9900b007b4d76f5b17si784884ejc.82.2022.11.23.19.08.17; Wed, 23 Nov 2022 19:08:38 -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=M++o8EzB; 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 S229652AbiKXCTJ (ORCPT + 88 others); Wed, 23 Nov 2022 21:19:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbiKXCTE (ORCPT ); Wed, 23 Nov 2022 21:19:04 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4889898FF for ; Wed, 23 Nov 2022 18:19:02 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id ci10so258344pjb.1 for ; Wed, 23 Nov 2022 18:19:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=21lSEg2vXSFoHO1msB/0t+aM934kgEehRE9bwrPsG98=; b=M++o8EzByfjyBaiqS+e8UmHNUp76zCjYvMqojZ3+KoXa0b1R3CqyVD8fjxyaB74FAX neRRiN4/Q1GD7r9njMwcThpT7w4oJWkGBCW5TPD9DCrrMIIE8Is7bQidYJ1Ceyrm8YIE e5DClzN4jeOXladpv5A5uDUcyOiGRu8UCad8XPNGOPLameYXrKL/1M89sVflNue7u8Uo 784jqZ+R7yYVOs14A3OxfrZci4O7oYV9kaEhs2guYgyGdk40wYXIV2COwqDFrDhhcDpu 5STo2CrgeMM83O9xrhjpdG9jqoxn/G6By3ujxqdqZWFbIe4+U3uPemVLlsVJR4tWN9Z8 6aJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=21lSEg2vXSFoHO1msB/0t+aM934kgEehRE9bwrPsG98=; b=ZjocblTnjHYc5tRFL2VIZyDCGLRkjQSwuvA4ewTYQfzs6FYLtACvRuBbPSJJ74kPOJ +W9qhUI8+y1Q8R/va70S1fcn4+4g5aBZSuoKviD/GqYER3vjbKVDXCOTFlNlRyzlbXAS IzHyzQIy7HYaSTFJNUIngeaZOeD2e/jmqE82Uxv2JEYFjYJC+63NoVheApK4gl44qzzd C1hPJpcChRPhtS1M7+cB+I9Zq9Cl8a93bZNQzRG5PUsTL/fMGR5XXJu2XwzpX1Mt9oIY TxtfjnbtQj6tCRLcto7hTPqYaFRbFQ6aRSiBBwXGsKtMGm7VIxMJTA1BWvh/JD0btAXK TUxA== X-Gm-Message-State: ANoB5pn/FrgVMcr/lGG/N4J89byc2SXrDflWNcaU/0Ol8xdHQ3ekQIRQ RugNAwmu7MlJCgHO0NeDQHEzEuqHB+snp6sCor4= X-Received: by 2002:a17:90a:2a09:b0:218:7040:886e with SMTP id i9-20020a17090a2a0900b002187040886emr3119248pjd.1.1669256342183; Wed, 23 Nov 2022 18:19:02 -0800 (PST) MIME-Version: 1.0 References: <20221121035140.118651-1-zhouzhouyi@gmail.com> <20221123223658.GC1395324@lothringen> In-Reply-To: <20221123223658.GC1395324@lothringen> From: Zhouyi Zhou Date: Thu, 24 Nov 2022 10:18:51 +0800 Message-ID: Subject: Re: [PATCH linux-next][RFC]torture: avoid offline tick_do_timer_cpu To: Frederic Weisbecker Cc: fweisbec@gmail.com, tglx@linutronix.de, mingo@kernel.org, dave@stgolabs.net, paulmck@kernel.org, josh@joshtriplett.org, mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 24, 2022 at 6:37 AM Frederic Weisbecker wrote: > > On Mon, Nov 21, 2022 at 11:51:40AM +0800, Zhouyi Zhou wrote: > > During CPU-hotplug torture (CONFIG_NO_HZ_FULL=y), if we try to > > offline tick_do_timer_cpu, the operation will fail because in > > function tick_nohz_cpu_down: > > ``` > > if (tick_nohz_full_running && tick_do_timer_cpu == cpu) > > return -EBUSY; > > ``` > > Above bug was first discovered in torture tests performed in PPC VM > > of Open Source Lab of Oregon State University, and reproducable in RISC-V > > and X86-64 (with additional kernel commandline cpu0_hotplug). > > > > In this patch, we avoid offline tick_do_timer_cpu by distribute > > the offlining cpu among remaining cpus. > > > > Signed-off-by: Zhouyi Zhou > > --- > > include/linux/tick.h | 1 + > > kernel/time/tick-common.c | 1 + > > kernel/time/tick-internal.h | 1 - > > kernel/torture.c | 10 ++++++++++ > > 4 files changed, 12 insertions(+), 1 deletion(-) > > > > diff --git a/include/linux/tick.h b/include/linux/tick.h > > index bfd571f18cfd..23cc0b205853 100644 > > --- a/include/linux/tick.h > > +++ b/include/linux/tick.h > > @@ -14,6 +14,7 @@ > > #include > > > > #ifdef CONFIG_GENERIC_CLOCKEVENTS > > +extern int tick_do_timer_cpu __read_mostly; > > extern void __init tick_init(void); > > /* Should be core only, but ARM BL switcher requires it */ > > extern void tick_suspend_local(void); > > diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c > > index 46789356f856..87b9b9afa320 100644 > > --- a/kernel/time/tick-common.c > > +++ b/kernel/time/tick-common.c > > @@ -48,6 +48,7 @@ ktime_t tick_next_period; > > * procedure also covers cpu hotplug. > > */ > > int tick_do_timer_cpu __read_mostly = TICK_DO_TIMER_BOOT; > > +EXPORT_SYMBOL_GPL(tick_do_timer_cpu); > > Please rather make a function for this. This is an internal value > that we don't want to expose to modules. > > This can be: > > int tick_nohz_full_timekeeper(void) > { > if (tick_nohz_full_enabled() && tick_do_timer_cpu >= 0) > return tick_do_timer_cpu; > else > return nr_cpu_ids; > } > > And then just check if the value is below nr_cpu_ids. Thank Paul and Frederic both for your guidance! Things are much easier;-) and I will do it. Cheers Zhouyi > > Thanks.