From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD4263D7D91 for ; Thu, 30 Apr 2026 21:39:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777585170; cv=none; b=YT1eTUQFyTEw70Kg1EHbWBjMo9bR6+F0s2RlLEgV4yeNywj1yaHnPZ0No9KXweENri4upBahw2FLF8K0nyQBMTqQJmBeCFT0nzyzFrEFAVqb5Sbw7HP/OlxkRYKAUsVmWA8UnWwapM0jqMxBdPopPVaO/oc6OKlU7UjjEfTL+yc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777585170; c=relaxed/simple; bh=84Uvtc2E1CX4uSHDFqwHEKEKikKyqDb0EjoeCOl7h8E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gDtuJc1DGIOjm+HU7MMciuZmnUNfICQPVwFFJVXCClhFu+Topy9jYDruG9d/umymKf6uzEbYqRwdnkmmwnkecOVom92RiSLUbNtiA5eSSctNzbovKiIWKbwENw2CMugaa8lsYVhtCHJk2AqrYuEHXpb6BHfS6m/CNtg1rDtyK44= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DA0bL13t; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DA0bL13t" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-43eb012ac4fso838518f8f.0 for ; Thu, 30 Apr 2026 14:39:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777585167; x=1778189967; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xQO/KziHXiXlUh9U2VuvhVYN2sshdGCBqM9ngH/VryU=; b=DA0bL13tdqxELbXITc5iLZcLbesMfAKxqt8Kwi0isYtnVegE0zX8fNRMwlOJMsKQ5t MvjFZ5zfDqh0ALtcaD7EgwMMKX7zfgQrciRh6/GI5QwhThswPnRXUu0aBYsCGIXLSSXg VEoFmXy8IyknNygjgvamROzBVfqSuWZMBi28+fSuL2Tf0LkP16ta9ivNChTr4PxAQUnm 4EQNMy/hI8XN0b+t5SMNkrYfEQZHdDbVZ0ClVcKsi6n0lGrWqu0rtRuo1Nl2BCDjJI7v KpTs0s5JiAltfJnKO4aOeVIUHupQ5PXzLsoOv7bUFm0OiYde6YZe3JnPPiz9eA8bs8Fg ndUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777585167; x=1778189967; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xQO/KziHXiXlUh9U2VuvhVYN2sshdGCBqM9ngH/VryU=; b=QGSaQ4AwtHfrlBXdKAZaVW1s4RfbXImcj5dnLer7Eny4kABkoXfvft4yL4GHD8uuAI If5N+XIe+Sd80IUa+Mi5WLJ/+mp7UbCgfwacrHlTiE0/jZ4w8ZCS8GSt1fSDfvcQFwga Fbya9742Z9QqrtLNOBDmu+VmFpdNWbr4uQGvokBCOoU1qccDuPA20uxrU0fiR6Ej+zIl 2oPfPSW6RTapNhHZZ8ONZ+FQ10mh4F40D+8dW79wHUYtrq3GGQueJKNC4vGLrD+zmGnU q/e0gbj6dcid2kru++b+S+cTny9vGseebIojM4gjH0muFW1YPXSNJE5tNfnKMzdGFllS o46w== X-Gm-Message-State: AOJu0YxqItcBH80fgekURz+MixmwhnVK8WqXmLnpOeZqNh6zyMczRy7M 28Rdo9jw9Uent77wkgSOtfM+bKU1tFQ+RuPQ0KnSIIQlceWe74QB33uL X-Gm-Gg: AeBDievDekN1SPVO5f0VBO8ifd16vDpCYV+mTbUkmaIW9eCeVVpMwboJOFSc6/VzOdr 1T6AhI9Ks9tCKzKL2NB8mRnnXfVe0I0J0kbD/deBcW81HoalN4EnngeEg0tzSCAdS4HnMKgvDKg gQ1/FFTCv63TysecIyrJqkh+jEUdMXdyefbx/QFtOsHv+yljWLqUZxphsSmpajvd8bTNPHaLhMg 36qNMCh7IMldLnhO1bZ2KXoScue3WQb3IFS6eVLlZuv/h37CKkfPa0iMk0lA/48HouKhKO0KlVG 6M/dPw66G2AyGdwHwrFtRWzPiHKs4bHtIuJaYgeCXYMCpkI2XvJ+Rznwh5AypHvqXfRTd1eKijQ aHqoweXkoehUubQvUfN34hWX0HdHJ3nLv1nCMQUj9eTtEFZZ7d8HxNpoHIAJvrE3jxVOKIO2F5Y 1JQnl6fDMXjC72boWxct5ixbl73QZnVUQ+3tuLh/Wx X-Received: by 2002:a05:6000:18a9:b0:43d:73d4:b34 with SMTP id ffacd0b85a97d-4493d4122f2mr8443333f8f.16.1777585167270; Thu, 30 Apr 2026 14:39:27 -0700 (PDT) Received: from yuri-framework13 ([78.211.51.156]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-44a9879ef89sm418510f8f.30.2026.04.30.14.39.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 14:39:26 -0700 (PDT) From: Yuri Andriaccio To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: linux-kernel@vger.kernel.org, Luca Abeni , Yuri Andriaccio Subject: [RFC PATCH v5 29/29] sched/rt: Add debug BUG_ONs in migration code Date: Thu, 30 Apr 2026 23:38:33 +0200 Message-ID: <20260430213835.62217-30-yurand2000@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260430213835.62217-1-yurand2000@gmail.com> References: <20260430213835.62217-1-yurand2000@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add debug BUG_ONs in group specific migration functions. Can be safely added after all the migration patches. These are extra asserts which are only useful to debug the kernel code and are not meant to be part of the final patchset. Signed-off-by: Yuri Andriaccio --- kernel/sched/rt.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 6cecda2ce812..9f938ce84485 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -370,6 +370,9 @@ static void rt_queue_push_from_group(struct rt_rq *rt_rq) struct rq *rq = served_rq_of_rt_rq(rt_rq); struct rq *global_rq = cpu_rq(rq->cpu); + BUG_ON(rt_rq == NULL); + BUG_ON(rq == global_rq); + if (global_rq->rq_to_push_from) return; @@ -387,6 +390,10 @@ static void rt_queue_pull_to_group(struct rt_rq *rt_rq) struct rq *global_rq = cpu_rq(rq->cpu); struct sched_dl_entity *dl_se = dl_group_of(rt_rq); + BUG_ON(rt_rq == NULL); + BUG_ON(!is_dl_group(rt_rq)); + BUG_ON(rq == global_rq); + if (dl_se->dl_throttled || global_rq->rq_to_pull_to) return; @@ -1408,6 +1415,8 @@ static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq) */ static int push_rt_task(struct rq *rq, bool pull) { + BUG_ON(is_dl_group(&rq->rt)); + struct task_struct *next_task; struct rq *lowest_rq; int ret = 0; @@ -1709,6 +1718,8 @@ void rto_push_irq_work_func(struct irq_work *work) static void pull_rt_task(struct rq *this_rq) { + BUG_ON(is_dl_group(&this_rq->rt)); + int this_cpu = this_rq->cpu, cpu; bool resched = false; struct task_struct *p, *push_task; @@ -1833,6 +1844,8 @@ static int group_find_lowest_rt_rq(struct task_struct *task, struct rt_rq *task_ int prio, lowest_prio; int cpu, this_cpu = smp_processor_id(); + BUG_ON(task->sched_task_group != task_rt_rq->tg); + if (task->nr_cpus_allowed == 1) return -1; /* No other targets possible */ @@ -1931,6 +1944,8 @@ static struct rt_rq *group_find_lock_lowest_rt_rq(struct task_struct *task, stru struct sched_dl_entity *lowest_dl_se; int tries, cpu; + BUG_ON(task->sched_task_group != rt_rq->tg); + for (tries = 0; tries < RT_MAX_TRIES; tries++) { cpu = group_find_lowest_rt_rq(task, rt_rq); @@ -1984,6 +1999,8 @@ static struct rt_rq *group_find_lock_lowest_rt_rq(struct task_struct *task, stru static int group_push_rt_task(struct rt_rq *rt_rq, bool pull) { + BUG_ON(!is_dl_group(rt_rq)); + struct rq *rq = rq_of_rt_rq(rt_rq); struct task_struct *next_task; struct rq *lowest_rq; @@ -2103,6 +2120,8 @@ static int group_push_rt_task(struct rt_rq *rt_rq, bool pull) static void group_pull_rt_task(struct rt_rq *this_rt_rq) { + BUG_ON(!is_dl_group(this_rt_rq)); + struct rq *this_rq = rq_of_rt_rq(this_rt_rq); int this_cpu = this_rq->cpu, cpu; bool resched = false; @@ -2215,6 +2234,9 @@ static void group_push_rt_tasks_callback(struct rq *global_rq) { struct rt_rq *rt_rq = &global_rq->rq_to_push_from->rt; + BUG_ON(global_rq->rq_to_push_from == NULL); + BUG_ON(served_rq_of_rt_rq(rt_rq) == global_rq); + if ((rt_rq->rt_nr_running > 1) || (dl_group_of(rt_rq)->dl_throttled == 1)) { @@ -2228,6 +2250,9 @@ static void group_pull_rt_task_callback(struct rq *global_rq) { struct rt_rq *rt_rq = &global_rq->rq_to_pull_to->rt; + BUG_ON(global_rq->rq_to_pull_to == NULL); + BUG_ON(served_rq_of_rt_rq(rt_rq) == global_rq); + group_pull_rt_task(rt_rq); global_rq->rq_to_pull_to = NULL; } -- 2.53.0