Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp536287imw; Wed, 13 Jul 2022 03:25:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sryzpfAAkkPa9Dj7v8QSZgqCCkGI8JLTk5KVJKxMSmrvPxYgtgFt5aUZlm7KrQbeHLsPq3 X-Received: by 2002:a05:6402:2816:b0:434:ed38:16f3 with SMTP id h22-20020a056402281600b00434ed3816f3mr3818301ede.116.1657707909771; Wed, 13 Jul 2022 03:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657707909; cv=none; d=google.com; s=arc-20160816; b=uUrH4ZGHe0yWiUSgtDxZsi4rPwLPbEKCJCUxsvr7NQ0J0VsZG4ESyA4kb2/4/Wc/6f CuRapeQE9z6+Vlf7pdta4CdhTOpY/ADHf19pz4+hj6vbMoo2L5mpmeMeAnE26JqqpBN8 0VVfiIC3zcCRew1at0ikRJsqkeJziTehwpQd3F+cSlpfTV0I3JFB/wF9fWssxgODWNsf eCf/Svra8h6qNn3gcaxt61duA7hSFH+mYowtUEvvQJfj0z/aB7oQu3nAlBlbi9sQtOkl JELPqalxihponWKGqTicCSXKHK0tKNI2C8DvPQSkyj4zR8is7g22Nyl3YjZEKqWlNOEt gldQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=b3GMK+2R7AWb7RBeKIiSIs63rXIJ9Zfth40q69QM/ZY=; b=XaC4yhZ1gVGWNDFew1yWvEzUfp/MoPSc17CABMjoY+d9l5uQ6NWcR3MZDFY6ajpH9H 83oGqkLHvPGjh9E1AQ9t3W8mqO+GSqXlPCYDhgnaq81b1c4hDBTknLsHY3utaIqAZaBz 4hDvbvPPXQlXIa9DzlqOx19S2v8tq4awLt2Sd9T4U1bkRbs4/yZ+N+lBD2tgxi6coFlq QmE2vyGhHGyC1MQdPYVRYSBJwoTVPvZxHa3OZUyG+DLKFLgDX1jtTeG2mF/FA3Fdlkyh /O+kOQjatHHSW3cHkGJo/2OpiveZif1+AeqvraRHe+UdgSOFn11FPNl4AE4zfpWPDksJ vnSg== 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=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs15-20020a1709072d0f00b0072af7d4a334si3190748ejc.646.2022.07.13.03.24.44; Wed, 13 Jul 2022 03:25:09 -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=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234457AbiGMJoO (ORCPT + 99 others); Wed, 13 Jul 2022 05:44:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235701AbiGMJoJ (ORCPT ); Wed, 13 Jul 2022 05:44:09 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7163F22B2C for ; Wed, 13 Jul 2022 02:44:08 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 87BA91424; Wed, 13 Jul 2022 02:44:08 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7AB1F3F792; Wed, 13 Jul 2022 02:44:06 -0700 (PDT) Message-ID: <76169a43-cda0-177a-2b1f-7dcdad900935@arm.com> Date: Wed, 13 Jul 2022 11:43:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v6 1/2] sched/rt: fix bad task migration for rt tasks Content-Language: en-US To: Schspa Shi Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org References: <20220712150506.632304-1-schspa@gmail.com> From: Dietmar Eggemann In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,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: X-Mailing-List: linux-kernel@vger.kernel.org On 12/07/2022 17:35, Schspa Shi wrote: > > Dietmar Eggemann writes: > >> On 12/07/2022 17:05, Schspa Shi wrote: [...] >> What code-base is this? > > This is the logs from 5.10.59-rt > Link: https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git > v5.10.59-rt52 (9007b684f615750b0ee4ec57b5e547a4bf4a223e). Thanks. >> IMHO, currently this `WARN_ON_ONCE(is_migration_disabled(p))` in >> set_task_cpu() is at > line 3000. >> > > But the master code have this BUG too. I see. It's just that need_to_push in task_woken_rt() triggers push_rt_tasks() much more often on preempt-rt. [...] >>> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c >>> index 8c9ed96648409..7bd3e6ecbe45e 100644 >>> --- a/kernel/sched/rt.c >>> +++ b/kernel/sched/rt.c >>> @@ -1998,11 +1998,15 @@ static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq) >>> * the mean time, task could have >>> * migrated already or had its affinity changed. >>> * Also make sure that it wasn't scheduled on its rq. >>> + * It is possible the task was scheduled, set >>> + * "migrate_disabled" and then got preempted, so we must >>> + * check the task migration disable flag here too. >>> */ >>> if (unlikely(task_rq(task) != rq || >>> !cpumask_test_cpu(lowest_rq->cpu, &task->cpus_mask) || >>> task_running(rq, task) || >>> !rt_task(task) || >>> + is_migration_disabled(task) || >> >> I wonder why this isn't covered by `task_rq(task) != rq` in this condition? >> > > It's because thie task is not migrated, it just get scheduled and > calling migrate_disable(); and then got preempted by it's CPU core > before enable migrate_enable(). the task_rq not changed in this > scenarios. Yes, get it now. Essentially we need `current CPU (CPU0) != rq->cpu (CPU1)`. Now I see that you had the discussion with Steven already on v3 ;-)