From patchwork Mon Mar 13 06:57:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yicong Yang X-Patchwork-Id: 68642 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1041174wrd; Mon, 13 Mar 2023 00:15:17 -0700 (PDT) X-Google-Smtp-Source: AK7set+dz6o3wJAXoEk0yITlCeonX3tBVlrweL6roG5ug/igWX2z3K/v8aWgEqvS8X9JiNIXq7Nl X-Received: by 2002:a17:903:1103:b0:19e:b2f3:e8c4 with SMTP id n3-20020a170903110300b0019eb2f3e8c4mr30775090plh.25.1678691717238; Mon, 13 Mar 2023 00:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678691717; cv=none; d=google.com; s=arc-20160816; b=jNR7gMQTtKmAR1eIIaWRQOQp4Qc8z4JXRbFVnfgKsbqT1db+0TS+/soX4JLmtph+/D fTEMzvHMLRnvoLXoCqXWHnmZfsYvTDBKUKXBGdiglxgax4zkLq6ky9A+Jfva4YZJX+H8 5s+nr5TDS7fGAJrLGQIHZGIzJGE6RFDzTr3Jgx7mLksD9jRVZtYhufx9rNmCO0RDTrbX aLzxhBXMHldoh/ZvB1bYI83goZZByQgzy+7cTZy8chJTiCEfE3iuA8E50Pqf3+3MDfMR zv1t1zH0+oEN7qTABKFUjNXVLvRaTSdtbGrclH/Xry4B+UO4VjZrVMTp1XzDpaUdqXE3 FB6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=2VNsZHv7kNkkEmwmWvazKSFK9LOTF6z47uGB8F1Mdp4=; b=aawdShcdfk2GezDM4Ckoujc2NE+pUw+1kDq7LVj3tQA/gd3X/EC0sJZPP8P+ItwDvw tjc0pJ3b2ZfhEosdNggGCRR41Sfrduvw8b8ZcbtZlByccWf1OX4GZRKLYvtq3GH9vSM+ 9JZwohDxFg2cTfewoVsd85FPCWEVpWi9PVGZ0oN1arwnqxbOsxK7q3rP6bAl/kmeqo5N VhadR0o3wG0+hSxo8YZhYI6MxwcwJz8E+X+YXGSzoLsOV+92yhCeYwsGQFxTrH0vAq5+ 7nHxo6pax9BRsBlK8OTp2UYnJqMhSfsgezdLzrnm5rGEHszE9lSWr/B8rtmqjaNEX28p /6lQ== 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 z7-20020a170902ccc700b0019e9f6cd049si6327831ple.416.2023.03.13.00.15.02; Mon, 13 Mar 2023 00:15:17 -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 S229514AbjCMG6h (ORCPT + 99 others); Mon, 13 Mar 2023 02:58:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229528AbjCMG6f (ORCPT ); Mon, 13 Mar 2023 02:58:35 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D13D627D50 for ; Sun, 12 Mar 2023 23:58:28 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PZnTv0GLCzSkd4; Mon, 13 Mar 2023 14:55:15 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 13 Mar 2023 14:58:26 +0800 From: Yicong Yang To: , , , , CC: , , , , , , , , , Subject: [PATCH] sched/fair: Don't balance migration disabled tasks Date: Mon, 13 Mar 2023 14:57:59 +0800 Message-ID: <20230313065759.39698-1-yangyicong@huawei.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500009.china.huawei.com (7.192.105.203) 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760235846370614360?= X-GMAIL-MSGID: =?utf-8?q?1760235846370614360?= From: Yicong Yang On load balance we didn't check whether the candidate task is migration disabled or not, this may hit the WARN_ON in set_task_cpu() since the migration disabled tasks are expected to run on their current CPU. We've run into this case several times on our server: ------------[ cut here ]------------ WARNING: CPU: 7 PID: 0 at kernel/sched/core.c:3115 set_task_cpu+0x188/0x240 Modules linked in: hclgevf xt_CHECKSUM ipt_REJECT nf_reject_ipv4 <...snip> CPU: 7 PID: 0 Comm: swapper/7 Kdump: loaded Tainted: G O 6.1.0-rc4+ #1 Hardware name: Huawei TaiShan 2280 V2/BC82AMDC, BIOS 2280-V2 CS V5.B221.01 12/09/2021 pstate: 604000c9 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : set_task_cpu+0x188/0x240 lr : load_balance+0x5d0/0xc60 sp : ffff80000803bc70 x29: ffff80000803bc70 x28: ffff004089e190e8 x27: ffff004089e19040 x26: ffff007effcabc38 x25: 0000000000000000 x24: 0000000000000001 x23: ffff80000803be84 x22: 000000000000000c x21: ffffb093e79e2a78 x20: 000000000000000c x19: ffff004089e19040 x18: 0000000000000000 x17: 0000000000001fad x16: 0000000000000030 x15: 0000000000000000 x14: 0000000000000003 x13: 0000000000000000 x12: 0000000000000000 x11: 0000000000000001 x10: 0000000000000400 x9 : ffffb093e4cee530 x8 : 00000000fffffffe x7 : 0000000000ce168a x6 : 000000000000013e x5 : 00000000ffffffe1 x4 : 0000000000000001 x3 : 0000000000000b2a x2 : 0000000000000b2a x1 : ffffb093e6d6c510 x0 : 0000000000000001 Call trace: set_task_cpu+0x188/0x240 load_balance+0x5d0/0xc60 rebalance_domains+0x26c/0x380 _nohz_idle_balance.isra.0+0x1e0/0x370 run_rebalance_domains+0x6c/0x80 __do_softirq+0x128/0x3d8 ____do_softirq+0x18/0x24 call_on_irq_stack+0x2c/0x38 do_softirq_own_stack+0x24/0x3c __irq_exit_rcu+0xcc/0xf4 irq_exit_rcu+0x18/0x24 el1_interrupt+0x4c/0xe4 el1h_64_irq_handler+0x18/0x2c el1h_64_irq+0x74/0x78 arch_cpu_idle+0x18/0x4c default_idle_call+0x58/0x194 do_idle+0x244/0x2b0 cpu_startup_entry+0x30/0x3c secondary_start_kernel+0x14c/0x190 __secondary_switched+0xb0/0xb4 ---[ end trace 0000000000000000 ]--- Signed-off-by: Yicong Yang Reviewed-by: Chen Yu --- kernel/sched/fair.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 7a1b1f855b96..8fe767362d22 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8433,6 +8433,10 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env) if (kthread_is_per_cpu(p)) return 0; + /* Migration disabled tasks need to be kept on their running CPU. */ + if (is_migration_disabled(p)) + return 0; + if (!cpumask_test_cpu(env->dst_cpu, p->cpus_ptr)) { int cpu;