Message ID | 20230624092130.174409-1-tanghui20@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6291123vqr; Sat, 24 Jun 2023 02:25:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7JPTBXxdvzBReeFjifixrsSYyvQkyHt/5pvQDxMSq6FmIkMpiBoURW/aMC+a/3O+FenhTj X-Received: by 2002:a25:7406:0:b0:bff:bef9:660e with SMTP id p6-20020a257406000000b00bffbef9660emr8890549ybc.50.1687598754918; Sat, 24 Jun 2023 02:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687598754; cv=none; d=google.com; s=arc-20160816; b=MZoA2A3Ct2ZrrJxdeS9I31uTe4Up45fc8xNWo4xazDWUUmVOHRA1ab+jJZkPVtPy/f oOswpx+XzH0QW6z4daDpwqjixtPzH7uCDfT4BQcdDAvO8jGi5EHZLNKWjmidw62v6pi2 Rosv3dtoktyQbRnJAeu6KkOglKxlHjyMF1sR2Sc1WSgWxNAFMZnmqkb2JB5AlFm8TZS0 q2/81m48EtZOksnOyUH+ByA20NiA/dcnh8VPRowpo+DJPEisgZ44Ima0au+6MRmR/wUi 7oPt9ZH+cvFE86oQifgde4L5G5E6HmSDH5g3+drBsFpSjze2UrVYpaEXypA46EvpOACm wMsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=lfDgTNys5HpS+vZJO8ngSVoptNBNf/9yLW0ySC6VUkk=; fh=oAoJK9ofmdO+ONy0OOEzxZuOFzGAd8lvMpXTYeVlYys=; b=XYb17g4UdSOWufVxE1oDGkJlEAQdv++UAIvWperAYYh5JgdOpxQH/flJV44HeYG2OI B/sog068bby74eYMmB6VuUJPHMBwfE7dYRXfnMRCWwdjeKAWFH1sigeagUcGHojiXXtK VVBbaAaMx86EP7svRX0fprwiadSpqK/MpzBAELaUoTZ4XoOAVmGHK3rs9fum7vb4uqQH AkWFdBAfN4/7OeuAh2z1hkdTFfc0+l5k2cddM74mJKM6HjfYGs31suMhC3UOFO5j1641 PB86jFG6tuQJiiwghVXBXSHQHfXbB9T0xGYf96mALwAm/AMdyNMVdAv65F8+LaCxr8Ee qIQA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 20-20020a630f54000000b00551bb2b99besi1121805pgp.85.2023.06.24.02.25.40; Sat, 24 Jun 2023 02:25:54 -0700 (PDT) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232440AbjFXJWr (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Sat, 24 Jun 2023 05:22:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231609AbjFXJWi (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 24 Jun 2023 05:22:38 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C10F10FD for <linux-kernel@vger.kernel.org>; Sat, 24 Jun 2023 02:22:36 -0700 (PDT) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Qp7qD6ww7ztQcG; Sat, 24 Jun 2023 17:19:52 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.175.30) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sat, 24 Jun 2023 17:22:32 +0800 From: Hui Tang <tanghui20@huawei.com> To: <mingo@redhat.com>, <peterz@infradead.org>, <juri.lelli@redhat.com>, <vincent.guittot@linaro.org> CC: <linux-kernel@vger.kernel.org>, <tanghui20@huawei.com>, <judy.chenhui@huawei.com>, <zhangqiao22@huawei.com> Subject: [PATCH] sched/rt: Fix possible warn when push_rt_task Date: Sat, 24 Jun 2023 17:21:30 +0800 Message-ID: <20230624092130.174409-1-tanghui20@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.175.30] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500017.china.huawei.com (7.221.188.110) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769575552326544788?= X-GMAIL-MSGID: =?utf-8?q?1769575552326544788?= |
Series |
sched/rt: Fix possible warn when push_rt_task
|
|
Commit Message
Hui Tang
June 24, 2023, 9:21 a.m. UTC
A warn may be triggered during reboot, as follows:
reboot
->kernel_restart
->machine_restart
->smp_send_stop --- ipi handler set_cpu_online(cpu, false)
balance_callback
-> __balance_callback
->push_rt_task
-> find_lock_lowest_rq --- offline cpu in vec->mask not be cleared
-> find_lowest_rq
-> cpupri_find
-> cpupri_find_fitness
-> __cpupri_find [cpumask_and(..., vec->mask)]
-> set_task_cpu(next_task, lowest_rq->cpu) --- WARN_ON(!oneline(cpu)
So add !cpu_online(lowest_rq->cpu) check before set_task_cpu().
The fix does not completely fix the problem, since cpu_online_mask may
be cleared after check.
Fixes: 4ff9083b8a9a8 ("sched/core: WARN() when migrating to an offline CPU")
Signed-off-by: Hui Tang <tanghui20@huawei.com>
---
kernel/sched/rt.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On Sat, Jun 24, 2023 at 05:21:30PM +0800, Hui Tang wrote: > A warn may be triggered during reboot, as follows: > > reboot > ->kernel_restart > ->machine_restart > ->smp_send_stop --- ipi handler set_cpu_online(cpu, false) > > balance_callback > -> __balance_callback > ->push_rt_task > -> find_lock_lowest_rq --- offline cpu in vec->mask not be cleared > -> find_lowest_rq > -> cpupri_find > -> cpupri_find_fitness > -> __cpupri_find [cpumask_and(..., vec->mask)] > -> set_task_cpu(next_task, lowest_rq->cpu) --- WARN_ON(!oneline(cpu) > > So add !cpu_online(lowest_rq->cpu) check before set_task_cpu(). > The fix does not completely fix the problem, since cpu_online_mask may > be cleared after check. This is tinkering.. at best. I'm sure there's a score of other issues, not in the least the very same issue in deadline.c. But since this doesn't actually fix anything, this clearly isn't the right way. > Fixes: 4ff9083b8a9a8 ("sched/core: WARN() when migrating to an offline CPU") > Signed-off-by: Hui Tang <tanghui20@huawei.com> > --- > kernel/sched/rt.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c > index 00e0e5074115..852ef18b6a50 100644 > --- a/kernel/sched/rt.c > +++ b/kernel/sched/rt.c > @@ -2159,6 +2159,9 @@ static int push_rt_task(struct rq *rq, bool pull) > goto retry; > } > > + if (unlikely(!cpu_online(lowest_rq->cpu))) > + goto out; > + > deactivate_task(rq, next_task, 0); > set_task_cpu(next_task, lowest_rq->cpu); > activate_task(lowest_rq, next_task, 0); > -- > 2.17.1 >
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 00e0e5074115..852ef18b6a50 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -2159,6 +2159,9 @@ static int push_rt_task(struct rq *rq, bool pull) goto retry; } + if (unlikely(!cpu_online(lowest_rq->cpu))) + goto out; + deactivate_task(rq, next_task, 0); set_task_cpu(next_task, lowest_rq->cpu); activate_task(lowest_rq, next_task, 0);