Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4684718rwb; Sat, 21 Jan 2023 17:28:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXsu3k2NJnRfQQE4+jkrMOrGrhlkB+UWbbOfsTt1CFSe1lkVTD63g88tKYUZGJoyg/717bwm X-Received: by 2002:a05:6402:230c:b0:48d:91a9:2cd0 with SMTP id l12-20020a056402230c00b0048d91a92cd0mr17738902eda.29.1674350910035; Sat, 21 Jan 2023 17:28:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674350910; cv=none; d=google.com; s=arc-20160816; b=G4gcWNO45trYXNAd2bPySNS464rcAeVr9SoH3xTIsDEkd0zOUAuTD9CSZUSgGxnp9e RMVcEtZ8IV19l7zEGUTiEa3fHP3FYa+C1v9wNvecUvsKD2A1VVR7QEPPZI7IjNI46ArT N72fyoOkN/WzTt2rqLHsrYdDIC510ckZjBz5RzndvVcQngbSVRZ8irOH1mNdl9UUl8Fh UMos5FqiPwUEW8HzuyxaLve6/qV35+wNo7fX1hjlR/wZWJGxzaRkCX7vnEvboGKc9W8G NYh8WBrTIte3gSj9SaqxexmRopwPOv/YE156zdYbIxOZgNBxNa6JhciN5utIGEe9USfC ML5g== 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=MPeXWU7uazxuuecNvkp333uWqq+3BuE2WxWXlrKxhQg=; b=tlKXGsGmJIAq96lODFidmPWxvO60yg2DXXw9F+Ygehxtnd1LUikGGstduJ5yIvwRVU Oi8kgM0NQjP/OzK1kOkhPJUJR2pYQV+kfjmc56OjbAz11S44VBwE/Jv2m0kB7eTRJX6p pPd5R+qJdNM7doIG7tSk1edzdgFUenvBCSk3plt8eITRmfpTYDB9gzreJ6dwYy5avDKi MysygvNqKb3lMVvlnYNZv+6oMIorWhUyEYD855jVV4loiCFfHayyBP46kl4Lw/fhMhmn 7wQk5xZec5OAiR47WZwxiClh1N45pJt0/WBnysMWevklzxX4GLqDdxwCIZ3S1zjjD4GF t+jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=H8cgwMSs; 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 q23-20020a056402249700b00499b2eb6a0csi18937145eda.348.2023.01.21.17.28.16; Sat, 21 Jan 2023 17:28:30 -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=H8cgwMSs; 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 S229778AbjAVBX1 (ORCPT + 53 others); Sat, 21 Jan 2023 20:23:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbjAVBXZ (ORCPT ); Sat, 21 Jan 2023 20:23:25 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9686CEFBF; Sat, 21 Jan 2023 17:23:24 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id y3-20020a17090a390300b00229add7bb36so8263404pjb.4; Sat, 21 Jan 2023 17:23:24 -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=MPeXWU7uazxuuecNvkp333uWqq+3BuE2WxWXlrKxhQg=; b=H8cgwMSsaiG1wZbVT62aXlARvOdlb2OWnw3w7tVLpxrZSC+DXDkjJPW/Xg7WH2AQur i66AMwod58rIpinoZxSp1bd4AVaBpMvCOAcovSmer3tQAImI5FCrz46VPlqlaUs3vUh8 PjpMNy8sknv0x/Z+/0NE/J12uvMZajfQYx3cKVWJADMnU22dmXF0bSLbKgaQoWYNiaIO XIq80S8whS2DLo6RPUtF6pR6p4kBi3Sp9sCe763ZJxtN6nIaVk+7eeWp/ZYSKhMKe9Y8 DmkG2ez3EMrvnmHumfJcZctYSRmO9tvJOlaMKC6X7mW5YW5vz5pVWbce40usIkGKnqZq tOYg== 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=MPeXWU7uazxuuecNvkp333uWqq+3BuE2WxWXlrKxhQg=; b=FDSlqqxX4oFslT6RbCRKcQFwni0Xj0U7qg6YnXD9nYhBn2EuD6EWtUh8qQtI1vdP+Q +lnl+zhvt8QnCeeKnFfGu8T7IxGQLljfktbdEEueat+PsjgHXcStqKxnE/UYlJrrd2lb f7PE6xsfpcZ+dBQN1QQJXGBZAOV1gkOy/Bz+rkMCPUcUUUbCmeYnyal0VTLyjIGXLGam Haam+/ihaBg75AEDPByb73H/GyRy4iS0xN9kanKxW6WPfKruOXJ/mlZjq9XWgGiVICwb KcDvg2UzoMIt2HDRc7xEgoOueYkSWHwlFXOadMc+WLWFW0L87jc10PjJQ6i/EDkz2i4A Qxeg== X-Gm-Message-State: AFqh2kq5UWYJNRl+Yjmob8X/HnvkEQUpc3oC3PtP+w5SHt2diHBG8kIx WzmgVv25DEJcn70Blo5tuSFbdW64e1+qfNcRvPE= X-Received: by 2002:a17:90b:f0a:b0:229:55bb:e575 with SMTP id br10-20020a17090b0f0a00b0022955bbe575mr2093134pjb.144.1674350604047; Sat, 21 Jan 2023 17:23:24 -0800 (PST) MIME-Version: 1.0 References: <20230119204434.4017605-1-joel@joelfernandes.org> In-Reply-To: From: Zhouyi Zhou Date: Sun, 22 Jan 2023 09:23:11 +0800 Message-ID: Subject: Re: [PATCH] tick/nohz: Fix cpu_is_hotpluggable() by checking with nohz subsystem To: "Joel Fernandes (Google)" Cc: linux-kernel@vger.kernel.org, Frederic Weisbecker , "Paul E. McKenney" , Will Deacon , Marc Zyngier , rcu , Frederic Weisbecker , Greg Kroah-Hartman , Ingo Molnar , "Rafael J. Wysocki" , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NORMAL_HTTP_TO_IP, NUMERIC_HTTP_ADDR,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 Fri, Jan 20, 2023 at 7:53 AM Zhouyi Zhou wrote: > > On Fri, Jan 20, 2023 at 4:45 AM Joel Fernandes (Google) > wrote: > > > > For CONFIG_NO_HZ_FULL systems, the tick_do_timer_cpu cannot be offlined. > > However, cpu_is_hotpluggable() still returns true for those CPUs. This causes > > torture tests that do offlining to end up trying to offline this CPU causing > > test failures. Such failure happens on all architectures. > > > > Fix it by asking the opinion of the nohz subsystem on whether the CPU can > > be hotplugged. > > > > [ Apply Frederic Weisbecker feedback on refactoring tick_nohz_cpu_down(). ] > Thanks for your fantastic work > I applied this fix to linux-5.15.y, and perform new round of rcu > torture test on PPC VM of Open Source Lab of Oregon State University. > Could you please wait for the test to finish? > > The test results of linux-5.15.y before your patch can be viewed at [1] > The patched source code of linux-5.15.y can be viewed at [2] > The ongoing test of patched linux-5.15.y can be viewed at [3] > > [1] http://140.211.169.189/linux-stable-rc/tools/testing/selftests/rcutorture/res/2023.01.18-13.22.39-torture/ > [2] http://140.211.169.189/linux-stable-rc/ > [3] http://140.211.169.189/linux-stable-rc/tools/testing/selftests/rcutorture/res/2023.01.19-23.40.55-torture/ The rcutorture test on [3] has finished, by comparing the logs of [1] and [3], we can see Joel's patch fix the HOTPLUG problem without bring any new issues. Tested-by: Zhouyi Zhou Thanks Zhouyi > > Hope to continue to benefit the community. > > Thank you all > Zhouyi > > > > Cc: Frederic Weisbecker > > Cc: "Paul E. McKenney" > > Cc: Zhouyi Zhou > > Cc: Will Deacon > > Cc: Marc Zyngier > > Cc: rcu > > Fixes: 2987557f52b9 ("driver-core/cpu: Expose hotpluggability to the rest of the kernel") > > Signed-off-by: Joel Fernandes (Google) > > --- > > drivers/base/cpu.c | 3 ++- > > include/linux/tick.h | 2 ++ > > kernel/time/tick-sched.c | 12 +++++++++++- > > 3 files changed, 15 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c > > index 55405ebf23ab..450dca235a2f 100644 > > --- a/drivers/base/cpu.c > > +++ b/drivers/base/cpu.c > > @@ -487,7 +487,8 @@ static const struct attribute_group *cpu_root_attr_groups[] = { > > bool cpu_is_hotpluggable(unsigned int cpu) > > { > > struct device *dev = get_cpu_device(cpu); > > - return dev && container_of(dev, struct cpu, dev)->hotpluggable; > > + return dev && container_of(dev, struct cpu, dev)->hotpluggable > > + && tick_nohz_cpu_hotpluggable(cpu); > > } > > EXPORT_SYMBOL_GPL(cpu_is_hotpluggable); > > > > diff --git a/include/linux/tick.h b/include/linux/tick.h > > index bfd571f18cfd..9459fef5b857 100644 > > --- a/include/linux/tick.h > > +++ b/include/linux/tick.h > > @@ -216,6 +216,7 @@ extern void tick_nohz_dep_set_signal(struct task_struct *tsk, > > enum tick_dep_bits bit); > > extern void tick_nohz_dep_clear_signal(struct signal_struct *signal, > > enum tick_dep_bits bit); > > +extern bool tick_nohz_cpu_hotpluggable(unsigned int cpu); > > > > /* > > * The below are tick_nohz_[set,clear]_dep() wrappers that optimize off-cases > > @@ -280,6 +281,7 @@ static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask) { } > > > > static inline void tick_nohz_dep_set_cpu(int cpu, enum tick_dep_bits bit) { } > > static inline void tick_nohz_dep_clear_cpu(int cpu, enum tick_dep_bits bit) { } > > +static inline bool tick_nohz_cpu_hotpluggable(unsigned int cpu) { return true; } > > > > static inline void tick_dep_set(enum tick_dep_bits bit) { } > > static inline void tick_dep_clear(enum tick_dep_bits bit) { } > > diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c > > index 9c6f661fb436..383a060f30c5 100644 > > --- a/kernel/time/tick-sched.c > > +++ b/kernel/time/tick-sched.c > > @@ -510,7 +510,7 @@ void __init tick_nohz_full_setup(cpumask_var_t cpumask) > > tick_nohz_full_running = true; > > } > > > > -static int tick_nohz_cpu_down(unsigned int cpu) > > +static int tick_nohz_cpu_hotplug_ret(unsigned int cpu) > > { > > /* > > * The tick_do_timer_cpu CPU handles housekeeping duty (unbound > > @@ -522,6 +522,16 @@ static int tick_nohz_cpu_down(unsigned int cpu) > > return 0; > > } > > > > +static int tick_nohz_cpu_down(unsigned int cpu) > > +{ > > + return tick_nohz_cpu_hotplug_ret(cpu); > > +} > > + > > +bool tick_nohz_cpu_hotpluggable(unsigned int cpu) > > +{ > > + return tick_nohz_cpu_hotplug_ret(cpu) == 0; > > +} > > + > > void __init tick_nohz_init(void) > > { > > int cpu, ret; > > -- > > 2.39.0.246.g2a6d74b583-goog > >