Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1283385rdb; Fri, 16 Feb 2024 10:32:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWm6ZYlX0odkXi/bMY7nkFjI/T4syPZ+suIJ07Tq0V9GrtutQr5Qc/KPCN20ipnnPGCxdSfGIN+2NkNkxTXHdahSC2euR5s8MyxayHsLg== X-Google-Smtp-Source: AGHT+IG3CJ2n8LM7zRf+1Jkv+WNwyJo5Z5H/+KcFGcxrrBeYjYI2wZPoA1HVYIBQz4klgHAImSC7 X-Received: by 2002:a17:902:c1d5:b0:1db:c1f7:35ac with SMTP id c21-20020a170902c1d500b001dbc1f735acmr207179plc.45.1708108351182; Fri, 16 Feb 2024 10:32:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708108351; cv=pass; d=google.com; s=arc-20160816; b=kLAHn/NQWNcwCK+3C/yIytj/Cz7wTdgD75NSy387eC7ji+21JHSfsARC5sLMra9g2d JjiLU4NHqgauVmN3iPKUSh5KmnBWOktOcDykYDPOVkY221xPsY37Tzjv6cwko+wGBlHl 5fslm2SYNyS5UDHZDeeAxRo1j9c/AmTgp4wdgjl1gQ6CSTQ1G7bhxPKcFUcPAL0Jr/5R srhckpa3ftmA0b7UilFiA95W/kxqFHV8pR59Dk/cVbmBPmAcMb8l7mEwJfVtDoS/xHrv hqmJ338XUHiThuMTMNtpMwFQfS1arlYE7fN648skiJN1y2QwBA2HwaljM33p47RrLiBG PDRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=OS0mEpzEEFGetzR6NtkyoXN8TWiVnIyPmeWduyYdhXs=; fh=M2d0eEwkotGwrCl/QH/u/fnmeLJn9ZwWPiMveRgwy+8=; b=FOFv9WQsrs/M1Hz6r7KXafJydEYudRHgm3iLvDYzk9IlwrUlQ6q2oiM51PeaooJPCh D2fPBhj4pdPxwG6k2XZZBCMcmkPaEa4DfB8u2fU0yTYa1n2ogx8C10mGJoZjA9nteLYO ZEAqpoB7BFfXCtCIhD7OxBVrC7ehOj4h4x24WTZxu/SZ/ayXnWAHFZZta8qibMUPY8xr Fu8Q09R890oNPaTSVyLrQv5axr/I/saU6gXFvomJBRXxOYBfrr+s7LM6Zl4uPdWiilx/ qCpvNBnAgeFCVQzLsQUX8xYLlKXjPOd72y7pb2Nr1M8vd5LGQwf9Ki8gGf8xptxw8x9F 1+4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=affI+dTq; arc=pass (i=1 spf=pass spfdomain=joelfernandes.org dkim=pass dkdomain=joelfernandes.org); spf=pass (google.com: domain of linux-kernel+bounces-69162-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69162-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m8-20020a170902db0800b001d9a51ca7d7si235038plx.280.2024.02.16.10.32.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:32:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69162-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=affI+dTq; arc=pass (i=1 spf=pass spfdomain=joelfernandes.org dkim=pass dkdomain=joelfernandes.org); spf=pass (google.com: domain of linux-kernel+bounces-69162-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69162-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D9BDF282901 for ; Fri, 16 Feb 2024 18:32:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 192F9135A49; Fri, 16 Feb 2024 18:31:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="affI+dTq" Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.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 924BE1353E5 for ; Fri, 16 Feb 2024 18:31:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108306; cv=none; b=kU62QZ2j6tKTqrOha/28zw58wx3S72sMhrKstVkXj9ghHz4A6GlD6ZU2mSb0hYvL68eFDhDsmzHi0iLTcNK3ph1ZAFIkLpWhDm8ETLOmi+GUuNhqlirjdCZs3W7xn/GsT33rS4O6jBTizfV9E/mwPQmiQUE/UgBGfk1/WqRT42c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108306; c=relaxed/simple; bh=BiiWEkX4I10hm0Y+ah7m6xE4dk8P54pifKn/ZYznW2g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OiKIgvF8AxSI+vro7C02ozjVfpp4HVmklJLcM7hQDahj73lRON2rN15k5A6UmjNYD/E1sQspIeKx25xo7EPGdHZ0qyxD8AYDcQsef1vV0LBWyG5UEOieT/mjUbnApduVVlQnvwVac0akdjH4WYaYMTA42Exxh0r7BttH9KPKWiY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org; spf=pass smtp.mailfrom=joelfernandes.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b=affI+dTq; arc=none smtp.client-ip=209.85.219.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=joelfernandes.org Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6818a9fe380so13862416d6.2 for ; Fri, 16 Feb 2024 10:31:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1708108303; x=1708713103; 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=OS0mEpzEEFGetzR6NtkyoXN8TWiVnIyPmeWduyYdhXs=; b=affI+dTqhOv2xxiSZ+dyvFmb9JgvjzInrIzZuv5+cVOuNMWSXyYCPrRBeu5iS4mj4c e3ZZi19gmrTb9jmmBE86fqdT6OByBU8C9BGmkOSvKzc8oYoqF7jQvVD2cClauReYKhqn 45LMMyZ5Og0zZl0zp7vEoRXaxykck4RXtdQdE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108303; x=1708713103; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OS0mEpzEEFGetzR6NtkyoXN8TWiVnIyPmeWduyYdhXs=; b=diZ2AmVR7USHZIE+eyrDqc8V+zoHfghYKUqi8Ordkbri3mL0dIbEWf38Wi0bE8/E6R dRWlbaRoBF5MLq8xokYr3zEpI97SCMDsh0VQovECaYuaL2N5NxDnRdkcbKZex7kr7N8i biLLYirQmQOA0JdLPfxotrYSKJuJmcS3mZZx8WMnenvjkU9e7LoQqBMpzR60YdMxLFGk qGqccW7Np0X3pJ/5gubNYwkYsqU+9DPDUp4iwfiYeruL0E5uL1L5aeM1Pjx6reWi4yO6 qVO56/jL764PIdgRXLHYVNsd5hHKROYI8TA0fAwtoLrvDI1cBAsNaaeuxBiQ0UQXpQn2 SHmQ== X-Gm-Message-State: AOJu0YxhI8TbtyzbPLpZfyeTC+75zt2cMTuS25M1Cn57fIaPZ/MU2oi0 QFwFqhmBXdMTGcMS2w1o1MS5odrpBaABtUnxgg4rACyDIsP0RC5RZ6MMSSpjFy+17glFEynuufu L X-Received: by 2002:a0c:e38e:0:b0:68f:3ecd:840b with SMTP id a14-20020a0ce38e000000b0068f3ecd840bmr1086525qvl.23.1708108302915; Fri, 16 Feb 2024 10:31:42 -0800 (PST) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id nd13-20020a056214420d00b0068cdadb5e7esm159722qvb.31.2024.02.16.10.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:31:42 -0800 (PST) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: Suleiman Souhlal , Youssef Esmat , David Vernet , Thomas Gleixner , "Paul E . McKenney" , joseph.salisbury@canonical.com, Luca Abeni , Tommaso Cucinotta , Vineeth Pillai , Shuah Khan , Phil Auld , "Joel Fernandes (Google)" Subject: [PATCH 03/10] sched/core: Fix priority checking for DL server picks Date: Fri, 16 Feb 2024 13:31:01 -0500 Message-Id: <20240216183108.1564958-4-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216183108.1564958-1-joel@joelfernandes.org> References: <20240216183108.1564958-1-joel@joelfernandes.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In core scheduling, a DL server pick (which is CFS task) should be given higher priority than tasks in other classes. Not doing so causes CFS starvation. A kselftest is added later to demonstrate this. A CFS task that is competing with RT tasks can be completely starved without this and the DL server's boosting completely ignored. Fix these problems. Reviewed-by: Vineeth Pillai Reported-by: Suleiman Souhlal Signed-off-by: Joel Fernandes (Google) --- kernel/sched/core.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 63f41453b79e..0a05caf9d3d7 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -162,6 +162,9 @@ static inline int __task_prio(const struct task_struct *p) if (p->sched_class == &stop_sched_class) /* trumps deadline */ return -2; + if (p->dl_server) + return -1; /* deadline */ + if (rt_prio(p->prio)) /* includes deadline */ return p->prio; /* [-1, 99] */ @@ -191,8 +194,24 @@ static inline bool prio_less(const struct task_struct *a, if (-pb < -pa) return false; - if (pa == -1) /* dl_prio() doesn't work because of stop_class above */ - return !dl_time_before(a->dl.deadline, b->dl.deadline); + if (pa == -1) { /* dl_prio() doesn't work because of stop_class above */ + const struct sched_dl_entity *a_dl, *b_dl; + + a_dl = &a->dl; + /* + * Since,'a' and 'b' can be CFS tasks served by DL server, + * __task_prio() can return -1 (for DL) even for those. In that + * case, get to the dl_server's DL entity. + */ + if (a->dl_server) + a_dl = a->dl_server; + + b_dl = &b->dl; + if (b->dl_server) + b_dl = b->dl_server; + + return !dl_time_before(a_dl->deadline, b_dl->deadline); + } if (pa == MAX_RT_PRIO + MAX_NICE) /* fair */ return cfs_prio_less(a, b, in_fi); -- 2.34.1