From nobody Sun Feb 8 11:06:11 2026 Received: from mail-vs1-f42.google.com (mail-vs1-f42.google.com [209.85.217.42]) (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 19F78A93C for ; Wed, 13 Mar 2024 01:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293108; cv=none; b=j0K3QF0ndi9/y3RoGxLmpdmOGFC/xNSefyvY7cs/1lr2l2gNwD7a7T0ti4tnUsSQPlscdBMzCg3EG7ejibcahgjDdi0BtXFN10nR5wAnBlhLtYkZpkuYun23rIJjvmPOOdt2ftnGXOaSK3gKcVRk3KKsDvYgumY3g+nvO+QfFko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293108; c=relaxed/simple; bh=/tum2WF4xPzP3d2/oUJvAp904N/cyC9DIis13Mprwms=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hoZ1lN09s2KSufeChy9XOKZPs9YqU+lM0dqKYivsb47mL06yLasQxgWgG+/grcrkju9wZrkjIz+MdyuFuGZjILzQNoe70pi+8rWNzjdZw0U2co3EPQ7eD1Knism/w7nhqW7iCrRmzlI76tp6MgG22rorKVR2zO8f+98tY6E2Y+E= 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=AXh1/gNI; arc=none smtp.client-ip=209.85.217.42 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="AXh1/gNI" Received: by mail-vs1-f42.google.com with SMTP id ada2fe7eead31-473ac7bbe64so386267137.1 for ; Tue, 12 Mar 2024 18:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293105; x=1710897905; 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=dVFjYg00n2ZAFDWX2JpqdHNuxugRyfOJfGbuxjDxV/Q=; b=AXh1/gNIRiIYRyHi/5afgdmUDcJxiLlFhc4sqZ7s3rfWa/RqRyuQNDIjOHlL5s04Du k+wmmxCUx3oz89sr7U9l5PRyv4oSxIXqkr2fVh5Dt/8ChgGx3nKqLDg4DZ7mBYNfCi3N x9cTAq7RWzgzFYvexyDR5a+Tk7XZWdEI5i9CA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293105; x=1710897905; 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=dVFjYg00n2ZAFDWX2JpqdHNuxugRyfOJfGbuxjDxV/Q=; b=NqziyTuASk6p7HYvQ1Hb2R28vE3C+MbCcuSuwyOoUzRZV/RPef35+s0lI0rKx1u9gZ JVKI/DQWl/XeiTZI3gTmlKi5Qq6UV+Di4OmVI2sVytatbQF6u/7t0SgudslszXVp2P4w GhIK6fPu0zzrXzJ1aA23rf0CaRUdUf9o0IVT7QLBypbTDDgZBKQuFClzgCieEIHDg9cn jSk0bhrupxULsHofTArAKO7vFTFFhx4ZmSkOR8C2QlIklMQTUfPEPKgWfGVWF57VsLX6 wnv8tssIg8IjPD946dFyIhmD0s01MOzdgV5R4kpZCp/SUyXQBAUKQKr8l0peKJTbU8XV nO6g== X-Gm-Message-State: AOJu0YxLnsina4ulKf8Y9534gNsotk4zBic1COGAupD0VYMa+AsB97oO Rmho6sFUkP6AyvEXJA2zuPiVlndg3aXny9OTuugOSZOaZrwJcQISqGECNiIqlrC0+QVsvvvxjbZ D X-Google-Smtp-Source: AGHT+IEXEUJofH0D0+hQCIBelr5x7iiFfSw5Npn4vbtW58PtqlERPNfEzwBLL4rsFAlZJvZQqR6xyw== X-Received: by 2002:a67:e290:0:b0:472:53e0:6549 with SMTP id g16-20020a67e290000000b0047253e06549mr2130218vsf.14.1710293104735; Tue, 12 Mar 2024 18:25:04 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:03 -0700 (PDT) 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 v2 01/15] sched/core: Add clearing of ->dl_server in put_prev_task_balance() Date: Tue, 12 Mar 2024 21:24:37 -0400 Message-Id: <20240313012451.1693807-2-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" Paths using put_prev_task_balance() need to do a pick shortly after. Make s= ure they also clear the ->dl_server on prev as a part of that. Signed-off-by: Joel Fernandes (Google) --- kernel/sched/core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 973fd610d089..7f3a2596c1ed 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5998,6 +5998,14 @@ static void put_prev_task_balance(struct rq *rq, str= uct task_struct *prev, #endif =20 put_prev_task(rq, prev); + + /* + * We've updated @prev and no longer need the server link, clear it. + * Must be done before ->pick_next_task() because that can (re)set + * ->dl_server. + */ + if (prev->dl_server) + prev->dl_server =3D NULL; } =20 /* @@ -6041,14 +6049,6 @@ __pick_next_task(struct rq *rq, struct task_struct *= prev, struct rq_flags *rf) restart: put_prev_task_balance(rq, prev, rf); =20 - /* - * We've updated @prev and no longer need the server link, clear it. - * Must be done before ->pick_next_task() because that can (re)set - * ->dl_server. - */ - if (prev->dl_server) - prev->dl_server =3D NULL; - for_each_class(class) { p =3D class->pick_next_task(rq); if (p) --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (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 BD566BA2D for ; Wed, 13 Mar 2024 01:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293110; cv=none; b=ASN3kY4rzK5piSEHTJoXt5W1BQluBH2gMvQEigDDqMQmPhTTW44fcjVXLSX8iV/4fSsQWWLDWwwSSjgHinUm/Eg1zkOEWhAO58kA8JJrB12O+ayQzHRcyqYq62lVOOrjZb4pD3pqXpFpvWhESjF8gxH+BhtFqwaWI+67lEEqPcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293110; c=relaxed/simple; bh=ZOaTdU6+mkYKcu73jBNLA/JSAJmZHt+8O8zlVTj/AiM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Agtm3yqktSlEAoaTH/nyRjQUsfLuo7gxziGCijoYc6tgTeec6Cqm42Xc8KAR4xv6xzA0cXJXEhAofuhwHc/7xwUm+MpqDjXfnkKaIl7Jx/KefY6BIdOMBJS/ZCnrVnveTT86qTGgIdUksC+RbBcHTMQyT8U3y+o8qBs7ts4XVCE= 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=w0SRTMg6; arc=none smtp.client-ip=209.85.219.48 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="w0SRTMg6" Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-690b7ce0f59so29559736d6.3 for ; Tue, 12 Mar 2024 18:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293107; x=1710897907; 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=eIq/RsKJ+ZDmqaV4DNR53VSSNnL2VAVCUisag/qJ124=; b=w0SRTMg66QtBoU7h+Z5j+J5aWX6/gFxCfpQxwqeNuIBHTFJaz7lRwD3JDScgLJj0Ig qlB7+LRw0JURaKW62YheWAAL5yAUDD7Ls61oWyNG/8AEq5/kirbuvZjdjK2dagK0Famw 6ZaYGfSRr3n29cXqyCfFkOdSh/XVB2hnkb+G8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293107; x=1710897907; 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=eIq/RsKJ+ZDmqaV4DNR53VSSNnL2VAVCUisag/qJ124=; b=iaCuzAtdZVEwsKXypVr6z8lGdJ9nGLMCgoFc054ZllR6Non3wYsBu0syA7dzeABFZN bgYPTvHyf3shwjmmQHdkY/ibyGGhPNpCEXk5RpRPLfFG2p7rHVTPdNFQYHnG1BWMnP2U MJP3CoLm+i7H4LIdW0xHd8EyTb7hstxmHwvyc2DBQ/wYcJhnz7iAvgbQG11NVWifr/jy dQLAs35pSjf9JH1aRhxgn+BNKQEC6ftxrxs/XrpyAw1cPXV5PRUvHiC8pw6AlMl4OnMw 01XOaicwU/x3xRQOPZ8xm1JRoTqTup4nTzxDo5MCEcrIDbi6QOFrlQ/S4rmhNdGoBaaX ps7A== X-Gm-Message-State: AOJu0Yx/RzQdVLQioPS4eJbrMRrgiD+y/K4Ff/b2OQ2DftGLjS7GSGHo +MLtzmihN2hr3iu0kCq+NtJUDoRmDDmE+iyFPCxpCkl1aS9rPQvJgJdK8E5ATZG1ixFIQwXrHO9 U X-Google-Smtp-Source: AGHT+IEo3qLwxTzSVUZ92CVnWSt4p1RkIwgvb8H6YC7a+n6trhN/r0aCvm8ypkHWszNoBkdIwgnCBA== X-Received: by 2002:a05:6214:888:b0:690:e2b5:9219 with SMTP id cz8-20020a056214088800b00690e2b59219mr4643667qvb.22.1710293106976; Tue, 12 Mar 2024 18:25:06 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:06 -0700 (PDT) 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 Subject: [PATCH v2 02/15] sched/core: Clear prev->dl_server in CFS pick fast path Date: Tue, 12 Mar 2024 21:24:38 -0400 Message-Id: <20240313012451.1693807-3-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Youssef Esmat In case the previous pick was a DL server pick, ->dl_server might be set. Clear it in the fast path as well. Signed-off-by: Youssef Esmat Signed-off-by: Joel Fernandes (Google) --- kernel/sched/core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 7f3a2596c1ed..63f41453b79e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6036,6 +6036,13 @@ __pick_next_task(struct rq *rq, struct task_struct *= prev, struct rq_flags *rf) p =3D pick_next_task_idle(rq); } =20 + /* + * This is a normal CFS pick, but the previous could be a DL pick. + * Clear it as previous is no longer picked. + */ + if (prev->dl_server) + prev->dl_server =3D NULL; + /* * This is the fast path; it cannot be a DL server pick; * therefore even if @p =3D=3D @prev, ->dl_server must be NULL. --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (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 6E8E5101E3 for ; Wed, 13 Mar 2024 01:25:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293113; cv=none; b=lwyDUkw0oUt8eNd+/AiliEWrRXkjcmo2rdC2EUpenxVpCvtoQZ1junum4RzUoQS6fo+D5OmEMchjR9Iol1/v69a91j8tR/ulnZGYvseehSbdbE2dMOGgf2dUt2uuJStzeMHoauaEAEu46ocyQP5gGCOD/9EUpJdZn1ubtnbsXFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293113; c=relaxed/simple; bh=BiiWEkX4I10hm0Y+ah7m6xE4dk8P54pifKn/ZYznW2g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SOPo+Z2++NBilC5T1nvW/74R6drIKQz1dmy5t4ATVSnLjwY3jE7DB+7zIMdu896eyc9eHubmdET4ZiNx7b+p/UGjzhJboLbRznmbxb3WLfVJm1xpCcHjpCU5ZdZvgt5b2jNFwv6/upyqrjuY13EbTD+KU5EesdUWcBWETgEawWg= 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=Lmd5F7kS; arc=none smtp.client-ip=209.85.219.44 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="Lmd5F7kS" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-68f41af71ebso4403916d6.1 for ; Tue, 12 Mar 2024 18:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293109; x=1710897909; 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=Lmd5F7kSHB3CLxMAkPjZn1u6p0d2e5Kaihz2g0kj7lwpdaK+TMQ5bO6PVVAk+zU+M5 ubAZH5dFRB4kMEtp9njI6OSfLkaWFEqJutfFabBOaOdFpEv2bf/gs5N81GFVEoSPuZ3n rppy4tBzbDui+7jD14LgMUvop85SmcaE9dOII= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293109; x=1710897909; 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=wXYdQwA68/9I7CwwQ1vg2NvQb+t17yC/FXc1PfJV1S1MDcJqkeMesgQxGMB5cXEaaI 456Vv6KfQcM7fP2vuwM0BPA4Xl1ed8qOGz/9OpT8+fX4K0YZVeqx9a6gsF/KfKVP6zLl zbhWe3Lvt+fYgLBZdKbtSME5eZGNyhM+9uHodm35CfDy3hneDQIjdBYgb1Ul2hYV8MNY n5jua4Cep3Ia1UkekY4iT5Lqk9mHDIhewk5EH4Zslf+rIh8k7c5B2+FfNjQeAyr6Xacj vVm9o5KxfmWBTjSCZeUqIiDvlz9TOhaaySuU2bX2Cnt6AW2WWVTC4Ph+gcHX/ufIjYiD pNrg== X-Gm-Message-State: AOJu0YxQHlvZRQdm0J9Cb6kcs3F6c8WhgqGKzs2My4WhZfONCFtwntXh xAMjMef+LZdDbjMVJLPWXlgfDNKDdkGPS3txrzrh14mZDLnUQW42qL3H5L6sFNL1LBmRgq1p8YH 5 X-Google-Smtp-Source: AGHT+IElQlhXgi/ZRZZUbYfXr5ht+BVJzWT9InU24HMdotNnyf9v8L7jWcfpx6nCWo49v7x7q+0ZuQ== X-Received: by 2002:a05:6214:c4e:b0:690:de5f:2127 with SMTP id r14-20020a0562140c4e00b00690de5f2127mr2730090qvj.36.1710293109232; Tue, 12 Mar 2024 18:25:09 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:08 -0700 (PDT) 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 v2 03/15] sched/core: Fix priority checking for DL server picks Date: Tue, 12 Mar 2024 21:24:39 -0400 Message-Id: <20240313012451.1693807-4-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" In core scheduling, a DL server pick (which is CFS task) should be given hi= gher priority than tasks in other classes. Not doing so causes CFS starvation. A kselftest is added later to demonstra= te 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 =3D=3D &stop_sched_class) /* trumps deadline */ return -2; =20 + if (p->dl_server) + return -1; /* deadline */ + if (rt_prio(p->prio)) /* includes deadline */ return p->prio; /* [-1, 99] */ =20 @@ -191,8 +194,24 @@ static inline bool prio_less(const struct task_struct = *a, if (-pb < -pa) return false; =20 - if (pa =3D=3D -1) /* dl_prio() doesn't work because of stop_class above */ - return !dl_time_before(a->dl.deadline, b->dl.deadline); + if (pa =3D=3D -1) { /* dl_prio() doesn't work because of stop_class above= */ + const struct sched_dl_entity *a_dl, *b_dl; + + a_dl =3D &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 =3D a->dl_server; + + b_dl =3D &b->dl; + if (b->dl_server) + b_dl =3D b->dl_server; + + return !dl_time_before(a_dl->deadline, b_dl->deadline); + } =20 if (pa =3D=3D MAX_RT_PRIO + MAX_NICE) /* fair */ return cfs_prio_less(a, b, in_fi); --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 E4BA41118C for ; Wed, 13 Mar 2024 01:25:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293115; cv=none; b=eB5dv8WmiPZ/H4X675J64dRS0elCtcUNLd75hKO29N72wNMWxJoInlWEQg6o8YgmRZMSb71XK17o5NKDNtpAg4jACWuDoBCxpDWmxjUXNScpl0v4oxuX9lZSlm23PXnOlrVUuTejHiRYbV8b681ghA6oZwFG3S8zMm8/lkVTg5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293115; c=relaxed/simple; bh=hNtzJxrNKpS3WmLYndaWMBO3so/VD/gQO0uqcJZ9FDc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DGRHI66L1RYKOILKHQIXZWwDgi1/prnhQdOH6/JB9+ZWM+4cqFVPhRaajbvGWdBntY5WTOvG0LdHcZwqphwZAgnVsNIh2dmkSBSLgKEYmLXgjpC1R9GRFXN8w0/YvDhLzcrZSkTgDEgnMmbK2GM4uNT26KQPSY/RNJR9Z13UnI4= 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=swMwzoG2; arc=none smtp.client-ip=209.85.219.47 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="swMwzoG2" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-690d75c73f4so3174536d6.2 for ; Tue, 12 Mar 2024 18:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293112; x=1710897912; 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=SWiejWekyqz80XlkFsn0hVk2ugnWY0u297YrWVho63A=; b=swMwzoG2VIbORp8/S6NBBQYCyEVgeGngsMs57wited+u03NlC5ufxN/6TTZuPKqIuQ zXlbRn5m9VrgmkIbubaHW+d2J+zLTCIrhvcpEGGHvuxmBMVcJSiQiYRE1FNAPXy9Tmfd bZa2+jBoZF1lA0zBHhrxwVB22eJcDbrrZggKg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293112; x=1710897912; 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=SWiejWekyqz80XlkFsn0hVk2ugnWY0u297YrWVho63A=; b=E8YaOKwbPKTGIfZjh4Z/uY7m7vrtdBAVTx9TEym9047HLquK7+o/XC+4igkS5bAlWq 0PIjSZulol7o7ne6ec2HiYwaDVq5vFIG4AsssHmqoWWQZhtesY80zQfrqGDy15yxj3nn FrGupOyWaYVCPqe785B86Y0VvNcizfIOk8AMix8E0AOfkXjVD/6XkeA2qKM3lRi3B52b vgkzB308jM4f0kdPPz1ia2M+PS1q6xscmtDysx1J05uoXSrjiBKRrVPo81e/5gaXd1Zh MpbCtIKPaq/bBwv2AphNLltJ/6XzVLUEKrmdi6U0Qses+BWJHx5T5yVcchaoKjpW7Fce YiQg== X-Gm-Message-State: AOJu0YyRg9sRjslakdaJPC2X0/czPVtw5/s598IdHUOt246QIl5Mcae9 EI3uR5YVkZxg16/ccQuK6icVaQEyYapI/c4JUgm1dAzma85b7sj0tRm+ccQl8qleeN0v5A4XBk3 + X-Google-Smtp-Source: AGHT+IFSu/SsNjZq+nLX5Zr5I4foqpNC570CwqJS/49KTVhFC/Y2PX7gbXw0Yf5FwpGv30qTpLiBHg== X-Received: by 2002:a0c:f687:0:b0:690:cc96:ba2d with SMTP id p7-20020a0cf687000000b00690cc96ba2dmr1899593qvn.60.1710293111644; Tue, 12 Mar 2024 18:25:11 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:10 -0700 (PDT) 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 v2 04/15] sched/core: Fix picking of tasks for core scheduling with DL server Date: Tue, 12 Mar 2024 21:24:40 -0400 Message-Id: <20240313012451.1693807-5-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" * Use simple CFS pick_task for DL pick_task DL server's pick_task calls CFS's pick_next_task_fair(), this is wrong because core scheduling's pick_task only calls CFS's pick_task() for evaluation / checking of the CFS task (comparing across CPUs), not for actually affirmatively picking the next task. This causes RB tree corrupt= ion issues in CFS that were found by syzbot. * Make pick_task_fair clear DL server A DL task pick might set ->dl_server, but it is possible the task will never run (say the other HT has a stop task). If the CFS task is picked in the future directly (say without DL server), ->dl_server will be set. So clear it in pick_task_fair(). This fixes the KASAN issue reported by syzbot in set_next_entity(). (DL refactoring suggestions by Vineeth Pillai). Reviewed-by: Vineeth Pillai Reported-by: Suleiman Souhlal Signed-off-by: Joel Fernandes (Google) --- include/linux/sched.h | 3 ++- kernel/sched/deadline.c | 27 ++++++++++++++++++++++----- kernel/sched/fair.c | 22 ++++++++++++++++++++-- kernel/sched/sched.h | 3 ++- 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index a1f918674383..e5ad1f232b35 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -672,7 +672,8 @@ struct sched_dl_entity { */ struct rq *rq; dl_server_has_tasks_f server_has_tasks; - dl_server_pick_f server_pick; + dl_server_pick_f server_pick_next; + dl_server_pick_f server_pick_task; =20 #ifdef CONFIG_RT_MUTEXES /* diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index f5aaa3adac94..8fafe3f8b59c 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1567,11 +1567,13 @@ void dl_server_stop(struct sched_dl_entity *dl_se) =20 void dl_server_init(struct sched_dl_entity *dl_se, struct rq *rq, dl_server_has_tasks_f has_tasks, - dl_server_pick_f pick) + dl_server_pick_f pick_next, + dl_server_pick_f pick_task) { dl_se->rq =3D rq; dl_se->server_has_tasks =3D has_tasks; - dl_se->server_pick =3D pick; + dl_se->server_pick_next =3D pick_next; + dl_se->server_pick_task =3D pick_task; } =20 int dl_server_apply_params(struct sched_dl_entity *dl_se, u64 runtime, u64= period, bool init) @@ -2271,7 +2273,12 @@ static struct sched_dl_entity *pick_next_dl_entity(s= truct dl_rq *dl_rq) return __node_2_dle(left); } =20 -static struct task_struct *pick_task_dl(struct rq *rq) +/* + * __pick_next_task_dl - Helper to pick the next -deadline task to run. + * @rq: The runqueue to pick the next task from. + * @peek: If true, just peek at the next task. Only relevant for dlserver. + */ +static struct task_struct *__pick_next_task_dl(struct rq *rq, bool peek) { struct sched_dl_entity *dl_se; struct dl_rq *dl_rq =3D &rq->dl; @@ -2285,7 +2292,10 @@ static struct task_struct *pick_task_dl(struct rq *r= q) WARN_ON_ONCE(!dl_se); =20 if (dl_server(dl_se)) { - p =3D dl_se->server_pick(dl_se); + if (IS_ENABLED(CONFIG_SMP) && peek) + p =3D dl_se->server_pick_task(dl_se); + else + p =3D dl_se->server_pick_next(dl_se); if (!p) { WARN_ON_ONCE(1); dl_se->dl_yielded =3D 1; @@ -2300,11 +2310,18 @@ static struct task_struct *pick_task_dl(struct rq *= rq) return p; } =20 +#ifdef CONFIG_SMP +static struct task_struct *pick_task_dl(struct rq *rq) +{ + return __pick_next_task_dl(rq, true); +} +#endif + static struct task_struct *pick_next_task_dl(struct rq *rq) { struct task_struct *p; =20 - p =3D pick_task_dl(rq); + p =3D __pick_next_task_dl(rq, false); if (!p) return p; =20 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index b48287629610..9cc528a14001 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8392,6 +8392,14 @@ static struct task_struct *pick_task_fair(struct rq = *rq) cfs_rq =3D group_cfs_rq(se); } while (cfs_rq); =20 + /* + * This can be called from directly from CFS's ->pick_task() or indirectly + * from DL's ->pick_task when fair server is enabled. In the indirect cas= e, + * DL will set ->dl_server just after this function is called, so its Ok = to + * clear. In the direct case, we are picking directly so we must clear it. + */ + task_of(se)->dl_server =3D NULL; + return task_of(se); } #endif @@ -8551,7 +8559,16 @@ static bool fair_server_has_tasks(struct sched_dl_en= tity *dl_se) return !!dl_se->rq->cfs.nr_running; } =20 -static struct task_struct *fair_server_pick(struct sched_dl_entity *dl_se) +static struct task_struct *fair_server_pick_task(struct sched_dl_entity *d= l_se) +{ +#ifdef CONFIG_SMP + return pick_task_fair(dl_se->rq); +#else + return NULL; +#endif +} + +static struct task_struct *fair_server_pick_next(struct sched_dl_entity *d= l_se) { return pick_next_task_fair(dl_se->rq, NULL, NULL); } @@ -8561,7 +8578,8 @@ void fair_server_init(struct rq *rq) struct sched_dl_entity *dl_se =3D &rq->fair_server; =20 init_dl_entity(dl_se); - dl_server_init(dl_se, rq, fair_server_has_tasks, fair_server_pick); + dl_server_init(dl_se, rq, fair_server_has_tasks, fair_server_pick_next, + fair_server_pick_task); } =20 /* diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 4d2c216049cb..bfb15037489c 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -338,7 +338,8 @@ extern void dl_server_start(struct sched_dl_entity *dl_= se); extern void dl_server_stop(struct sched_dl_entity *dl_se); extern void dl_server_init(struct sched_dl_entity *dl_se, struct rq *rq, dl_server_has_tasks_f has_tasks, - dl_server_pick_f pick); + dl_server_pick_f pick_next, + dl_server_pick_f pick_task); =20 extern void fair_server_init(struct rq *); extern int dl_server_apply_params(struct sched_dl_entity *dl_se, --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (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 9E56B12E4E for ; Wed, 13 Mar 2024 01:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293117; cv=none; b=l7ULVDAnFuGoMhUMnaV7obUI6D/YMWCMsS68WL+CSMzSVzVAbhWa16+tpb8M3wh6Pv6qkFoxL1Klqsco7lNn39qmIAR4jCfHJn6OEdC/90mfK3X7DLcYyoDu8QNc9bgQzeNiEHth8xrcYDCd9z13ZTF2MRYNAOjiEwuGjhddMKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293117; c=relaxed/simple; bh=BdbG0yYlQpcAJTV+cb1BRObS/3sDHMAKLat6xu5MQUI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ky3kREDB4lF+G7cFB3Do90NnlweABiNxcowm8dB6QK7NMbH0Fus6q8ZBQlXJDQ1ggu4xbaKUU8d8OfqIiXRRuL2wW2+hi79RTTRsqeuSAx/3G0nXmGlr80mLJ2XeCGLyojqWXTtdvbK5aw53RVaX8gsS01GXoaIRc84CdkktxAo= 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=fvt2DG9i; arc=none smtp.client-ip=209.85.219.44 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="fvt2DG9i" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-68f41af71ebso4404396d6.1 for ; Tue, 12 Mar 2024 18:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293114; x=1710897914; 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=zgoJ2Cj2+UUPtAnwZcQw+JcHc1DVxxL4Tm75yla0jg4=; b=fvt2DG9i08ArM6uUdv35//9sTm3nLCxklABUyuAKmRC6TVmgFS9Qono92GNuB4fNmL 6Rp32oN7Hl1NJyDrmtq+Xj9dNNa0rJJV4hHgIfBIqYabgCIHOpa30hxr2rR2tv05VF4T SHPWdf7Zliz3KPDjRpfEUeW6oVV0aS79PxQZU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293114; x=1710897914; 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=zgoJ2Cj2+UUPtAnwZcQw+JcHc1DVxxL4Tm75yla0jg4=; b=g26RCNzYtSA6BKz97AQ5JMm4Mda4psmeLm6g6n3OUkd46IcTNDwZIOjXlvITzE7nap wSiHUBS9NuanVq1Q+BlrO1uzvME1ipwk+Z8KBs6mkve/8YThJ7nfWZISTQTuZnQubDV2 wWMsrxg+5mf1pgzWdfdnDwwgN15JrvVLgy4lTtlQ39eoIutQI9C+NItewqEVdb6aznzn RLk+m05VhCtkT06E0lbLxCkf37B0RoB+M2vbqBh5hwYp1mn8o3x0ShJjJklZlsXcEFUx 4PvOAZiU03F3A7r2wnHgqO4H0XsJRQTO4iMJNqtNaXrm/h7/qRLcvn5GvBm5gqxqBw4j Jp8Q== X-Gm-Message-State: AOJu0YziTh/G0sVHb18ylnjcbs8QKJK005Wz5Vvgp00ESSJOGoiJv/E9 2YMR8e+UbYhhW7gVH79FjDsSjwRg6g+nTqeygDaz+mIHr8jJQ6roG4AbLcuL7ctg8vbw78hYuCy h X-Google-Smtp-Source: AGHT+IGrnT4NaK5dgEfbg6BsheeR1Bp46xKOKlinXlRpGxwicEeQcbXPiAZiOr+R4nhkDUtlf00cVg== X-Received: by 2002:a0c:ecca:0:b0:690:9a95:d8f9 with SMTP id o10-20020a0cecca000000b006909a95d8f9mr1796667qvq.2.1710293113824; Tue, 12 Mar 2024 18:25:13 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:12 -0700 (PDT) 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 , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt 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)" , llvm@lists.linux.dev Subject: [PATCH v2 05/15] sched/debug: Use unsigned long for cpu variable to prevent cast errors Date: Tue, 12 Mar 2024 21:24:41 -0400 Message-Id: <20240313012451.1693807-6-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" This avoids compiler errors seen with clang: In file included from kernel/sched/build_utility.c:72: kernel/sched/debug.c:532:47: error: cast to 'void *' from smaller integer type 'unsigned int' [-Werror,-Wint-to-void-pointer-cast] debugfs_create_file("runtime", 0644, d_cpu, (void *) cpu, &fair_server_runt= ime_fops); Signed-off-by: Joel Fernandes (Google) Reviewed-by: Chris Hyser --- kernel/sched/debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index c6c0120ff105..2590041696bc 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -516,7 +516,7 @@ static struct dentry *debugfs_sched; static void debugfs_fair_server_init(void) { struct dentry *d_fair; - unsigned int cpu; + unsigned long cpu; =20 d_fair =3D debugfs_create_dir("fair_server", debugfs_sched); if (!d_fair) @@ -526,7 +526,7 @@ static void debugfs_fair_server_init(void) struct dentry *d_cpu; char buf[32]; =20 - snprintf(buf, sizeof(buf), "cpu%d", cpu); + snprintf(buf, sizeof(buf), "cpu%lu", cpu); d_cpu =3D debugfs_create_dir(buf, d_fair); =20 debugfs_create_file("runtime", 0644, d_cpu, (void *) cpu, &fair_server_r= untime_fops); --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (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 EDF4A14A97 for ; Wed, 13 Mar 2024 01:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293119; cv=none; b=ZjVU2qiir+3grSWlKXrAnLW2HBXzdU2Xlbz9jYpHZDbXh2cDVSuG8/R/blsS1PFHWjzontOGGX6WzFgVcY4M522Tm1fbmiCUVoUDQxQ+G3dV9ORvruaWBVdbc6J8eL/QgNAqtf77uNjx9rjqbloLnqvcP88q8mOSNnQ15qAl0q0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293119; c=relaxed/simple; bh=G1fDd4qTQBCk+lDij0THy4jcCMe3hYb5TF5caIUyaxo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oqk4Cm8T0TCtQdl+MJ1g4Oq9hTFxT8PYOM5RM1tcuSUR4gQvxcP5Od0lYTvWWlDOOkzO6Jf77CeBlI8/OkiZ7RFKFkO30lrZFDfOaRHWlsF1wxoqLOrGs4RVYJJ4NP3S9ps+PoSd1Hz34p3A5qcq1FoPxkO01O3qV37WlbqIz5k= 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=Yj5qNxpO; arc=none smtp.client-ip=209.85.219.49 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="Yj5qNxpO" Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-69107859bedso3472436d6.2 for ; Tue, 12 Mar 2024 18:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293116; x=1710897916; 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=NIgRVY95Czz2uvDMLBT/P8lHA/YSLsxu7WXMaEzsDZ8=; b=Yj5qNxpOM9DBANALmv+Kiut7N14/5IeMZUkpI+zPYYoC0UbLInDVOP0fBHq95RakIk nQ6oZAKM7KXWOKe3vyFRmRzEZUE45kEYYFTOPP7dUzkFWs+9HoVT6WIeYqLr0O0hU/uY yPnk6JswUFMhsVaqRkaSHHpMOpsb/4gwkMrzc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293116; x=1710897916; 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=NIgRVY95Czz2uvDMLBT/P8lHA/YSLsxu7WXMaEzsDZ8=; b=SInlx4seYqkRzrLvYie2fgaZUvZ3Dyxgwyt4O7YlGlNZWEeCl1p8JalEfnWx82GEr+ w3yMC2Go5Q/4tEzWXm36YLrSI4jY9nWtB4HPL6o4V9E2rSl6NbQ9zbu774NoJ5B2oxd5 47I9qilKwdbWbB6In9mISDQ1nnHafhbgnCBp45DRkhMsS3/l6W/SXBbuhstf67GDgSqQ q5ZeooEN8CLSVVTxkxFZnjqf9e1G8XVu1jaO0Lk20R6jIgeRhlNZdnxTg6gAoceFhuFo Ihb8YgEOmXP4Mn9VDC3uYyXhHOFVIGpWJRZXaabDctubAs3NF2YY4iIExZEaMDKhsLuh W04g== X-Gm-Message-State: AOJu0Yw5euQVXhu5+tQWVEoyGomtUoDkc4m8UMpbtxLsh+Dl73b0Be58 UUxTfJ3DKfmu1A2xg0sE00PsoREPlKMRiVWWOVUGnzJC2AD6MPfj2DoCbPULpeNr0CphLEK0Ej2 8 X-Google-Smtp-Source: AGHT+IGDvfbapxrZkVxMym6KQupINN2xVHHvjKMlG2VhI6KAqiOpH9z9LYAoPfehJ8VFbhJq3AOnkQ== X-Received: by 2002:a05:6214:2e14:b0:690:7c8e:afcf with SMTP id mx20-20020a0562142e1400b006907c8eafcfmr5071713qvb.43.1710293115705; Tue, 12 Mar 2024 18:25:15 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:15 -0700 (PDT) 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 Subject: [PATCH v2 06/15] sched: server: Don't start hrtick for DL server tasks Date: Tue, 12 Mar 2024 21:24:42 -0400 Message-Id: <20240313012451.1693807-7-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Suleiman Souhlal Otherwise, we might start it even for tasks in a sched class that should have it off. Signed-off-by: Suleiman Souhlal --- kernel/sched/deadline.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 8fafe3f8b59c..5adfc15803c3 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2325,11 +2325,12 @@ static struct task_struct *pick_next_task_dl(struct= rq *rq) if (!p) return p; =20 - if (!p->dl_server) + if (!p->dl_server) { set_next_task_dl(rq, p, true); =20 - if (hrtick_enabled(rq)) - start_hrtick_dl(rq, &p->dl); + if (hrtick_enabled(rq)) + start_hrtick_dl(rq, &p->dl); + } =20 return p; } --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 Received: from mail-vk1-f182.google.com (mail-vk1-f182.google.com [209.85.221.182]) (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 0DAF6171CE for ; Wed, 13 Mar 2024 01:25:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293122; cv=none; b=RSQ7cXBu9vdQtzSEeCEW+3zjR3qNhVc9mth/FCvljy50KeVRLy2n2CebcE0lw3rslabzbHgbO7v+JAB2vBLRLgegXnte0U1SXrg9/FJHgIhGjEZ5xfqcxARHcK71kEvSRbTojNUbAF9Cu34eh5rbeaY5n+SPeHB2F/N1bTbePJo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293122; c=relaxed/simple; bh=OSrAg2NG3ZYsMO+/bzATjsRdKuLLDdxyzjpAKJt8kcI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GE0F+409MkM6E/EL3b1QjBfG70k93eyBwiBAgmUT6KC3XpzFq2hy3jvZstGhOfpeBKd3/r+f9zlkcU5cU0P05Nc2WSexAj7Rw5YOhJPjLck9jOApCb8L/OoAQCQDjtMzW7+V8Jz6uHwzZ0isEe0Kqx/B0DqRbC1fvAIsfCvL61I= 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=xggoGQ3M; arc=none smtp.client-ip=209.85.221.182 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="xggoGQ3M" Received: by mail-vk1-f182.google.com with SMTP id 71dfb90a1353d-4d419b03fd9so33093e0c.2 for ; Tue, 12 Mar 2024 18:25:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293118; x=1710897918; 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=KGM3mRROwFt6krNu3XhZIaE8fo5xphzgJ2jbr0QsLYo=; b=xggoGQ3MTZkpILwwcMCVN6uKH5tJd64VfD1xbGeVMh6QOeB/hLapWMRehjfv/aR9+b 2kWRI1PShBPbyeapgG/FTRUSMo8WEFL2XEBlLypNoA3ZntIYwoa3+KgU9ypGMbDBQUWU KhqVdi+jH3F1JF9reNSQGyUfVIpWV+CoP2f4E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293118; x=1710897918; 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=KGM3mRROwFt6krNu3XhZIaE8fo5xphzgJ2jbr0QsLYo=; b=Kt3D+LSRO6qKco0ZPrdb17djq/iGMT5cxSxw/992MpK5FJBFXqmiD4t0M7mtDiMUyz 8jJMs6H6gEoE7hTTCHcSYwm5ikvjLjJ302Sy5GJYuRNaDGfbWurSnL/+XdD9dZXZrwr5 S6BldwQjVXEhw0hxmrn82ZGskK6zuN6Vv7UfhTl59KdRB2GRlLEeYuO5T7/ZaNWTCB9n QK7n37/6u/JRpXBI9eeznvWkRTykxg5/s+fAtfZZMarzj+wUcXkr6RAyWMrztNfPo9pf MrOmh6UOnwCvZbkbhmB7sjQkuGpuvPQC2rS+lCLfjwF2L0JP2CJlkeLa/MLJQ3BrYqc/ YC+w== X-Gm-Message-State: AOJu0Yx+oPcq6+fBOzjzdEZ4FMbgavnrvhXMR/n7p7+Guu5xp7JHFvm4 KFXAk+pbw0ojgbl50CfD4cIq3fc6HLroGX+dWTzEc+xxW3U3L6BvRGrF/XWaySRTA24QvCVWT5r Z X-Google-Smtp-Source: AGHT+IH2n7iY4beQVKg78epng1qg9X6GYztiNS5gYmb2epJqipro1s1s7yzW1VnAX10RJPFI7WmrUw== X-Received: by 2002:a05:6122:4e8f:b0:4d3:3a8c:13ad with SMTP id gf15-20020a0561224e8f00b004d33a8c13admr7939547vkb.8.1710293118309; Tue, 12 Mar 2024 18:25:18 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:17 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Suleiman Souhlal , Youssef Esmat , Steven Rostedt , David Vernet , Thomas Gleixner , "Paul E . McKenney" , joseph.salisbury@canonical.com, Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Luca Abeni , Tommaso Cucinotta , Vineeth Pillai , Shuah Khan , Phil Auld , "Joel Fernandes (Google)" , linux-kselftest@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v2 07/15] selftests/sched: Add a test to verify that DL server works with core scheduling Date: Tue, 12 Mar 2024 21:24:43 -0400 Message-Id: <20240313012451.1693807-8-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" This test verifies that DL server infrastructure gives CFS tasks a fixed bandwidth even when RT tasks are being "core scheduled" on a core. Verify that they are getting the expected bandwidth (and thus not being starved). Also verified that not having core scheduling fixes makes the test fail as the CFS task gets no bandwidth. Sample output: # Runtime of PID 97 is 4.440000 seconds # Runtime of PID 98 is 4.560000 seconds # Runtime of PID 99 is 4.550000 seconds ok 1 PASS Notes about test that generated the sample output: The test runs for 12 seconds. We check the runtimes at 9 seconds. We expect the CFS task (PID 7) to get ~50% of the 9 seconds. The DL server is configured for 50% bandwidth. The RT tasks (PID 98, 99) each get 50% as well, because they run concurrently on 2 hyperthreads of a core. Signed-off-by: Joel Fernandes (Google) --- tools/testing/selftests/sched/Makefile | 13 +- tools/testing/selftests/sched/common.c | 24 ++ tools/testing/selftests/sched/common.h | 8 + .../selftests/sched/cs_dlserver_test.c | 254 ++++++++++++++++++ 4 files changed, 290 insertions(+), 9 deletions(-) create mode 100644 tools/testing/selftests/sched/common.c create mode 100644 tools/testing/selftests/sched/common.h create mode 100644 tools/testing/selftests/sched/cs_dlserver_test.c diff --git a/tools/testing/selftests/sched/Makefile b/tools/testing/selftes= ts/sched/Makefile index 099ee9213557..f491d741cb45 100644 --- a/tools/testing/selftests/sched/Makefile +++ b/tools/testing/selftests/sched/Makefile @@ -1,14 +1,9 @@ # SPDX-License-Identifier: GPL-2.0+ +TEST_GEN_PROGS :=3D cs_dlserver_test =20 -ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) -CLANG_FLAGS +=3D -no-integrated-as -endif +cs_dlserver_test: cs_dlserver_test.c common.c =20 -CFLAGS +=3D -O2 -Wall -g -I./ $(KHDR_INCLUDES) -Wl,-rpath=3D./ \ - $(CLANG_FLAGS) -LDLIBS +=3D -lpthread - -TEST_GEN_FILES :=3D cs_prctl_test -TEST_PROGS :=3D cs_prctl_test +CFLAGS +=3D $(KHDR_INCLUDES) +CFLAGS +=3D -Wall =20 include ../lib.mk diff --git a/tools/testing/selftests/sched/common.c b/tools/testing/selftes= ts/sched/common.c new file mode 100644 index 000000000000..5cf0022acc8d --- /dev/null +++ b/tools/testing/selftests/sched/common.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include "common.h" + +bool hyperthreading_enabled(void) +{ + FILE *file =3D fopen("/sys/devices/system/cpu/smt/active", "r"); + char smt_active[2]; + + if (file =3D=3D NULL) { + ksft_print_msg("Could not determine if hyperthreading is enabled\n"); + return false; + } + + if (fgets(smt_active, sizeof(smt_active), file) =3D=3D NULL) { + perror("Failed to read smt_active"); + return false; + } + fclose(file); + + if (smt_active[0] !=3D '1') + return false; + return true; +} diff --git a/tools/testing/selftests/sched/common.h b/tools/testing/selftes= ts/sched/common.h new file mode 100644 index 000000000000..7bcedbd0ed99 --- /dev/null +++ b/tools/testing/selftests/sched/common.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#include +#include +#include +#include "../kselftest.h" + +bool hyperthreading_enabled(void); diff --git a/tools/testing/selftests/sched/cs_dlserver_test.c b/tools/testi= ng/selftests/sched/cs_dlserver_test.c new file mode 100644 index 000000000000..9f2a74a25686 --- /dev/null +++ b/tools/testing/selftests/sched/cs_dlserver_test.c @@ -0,0 +1,254 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Use the DL server infrastructure to give CFS tasks a fixed bandwidth + * even when RT tasks are being "core scheduled" on a core. Verify that + * they are getting the expected bandwidth (and thus not being starved). + * + * Copyright (c) 2024 Google. + * Author: Joel Fernandes + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of version 2.1 of the GNU Lesser General Public License= as + * published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public Li= cense + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common.h" + +enum pid_type {PIDTYPE_PID =3D 0, PIDTYPE_TGID, PIDTYPE_PGID}; + +#define RUN_TIME 12 // Running time of the test in seconds +#define CORE_ID 0 // Assuming we're pinning processes to the first core +#define DL_SERVER_DEBUGFS "/sys/kernel/debug/sched/fair_server" + +void write_server_debugfs(char *file, char *type, unsigned long value) +{ + char path[1024], buf[1024]; + int fd, n; + + snprintf(path, sizeof(path), "%s/%s/%s", DL_SERVER_DEBUGFS, file, type); + fd =3D open(path, O_WRONLY); + if (fd =3D=3D -1) { + perror("Failed to open file for writing"); + return; + } + n =3D snprintf(buf, sizeof(buf), "%lu\n", value); + n =3D write(fd, buf, n); + if (n =3D=3D -1) + perror("Failed to write file"); + + close(fd); +} + +void write_dl_server_params(void) +{ + DIR *dir; + struct dirent *entry; + + if (access(DL_SERVER_DEBUGFS, F_OK) =3D=3D -1) { + perror("DL server debugfs not found, cannot set DL parameters."); + exit(EXIT_FAILURE); + } + + dir =3D opendir(DL_SERVER_DEBUGFS); + if (dir =3D=3D NULL) { + perror("Failed to open directory"); + exit(EXIT_FAILURE); + } + + while ((entry =3D readdir(dir)) !=3D NULL) { + if (strcmp(entry->d_name, ".") =3D=3D 0 || strcmp(entry->d_name, "..") = =3D=3D 0) + continue; + + write_server_debugfs(entry->d_name, "period", 100000000); + write_server_debugfs(entry->d_name, "runtime", 50000000); + } + closedir(dir); +} + +void process_func(void) +{ + unsigned long long count =3D 0; + time_t end; + + // Busy loop for RUN_TIME seconds + end =3D time(NULL) + RUN_TIME; + while (time(NULL) < end) { + count++; // Just a dummy operation + } +} + +void set_affinity(int cpu_id) +{ + cpu_set_t cpuset; + + CPU_ZERO(&cpuset); + CPU_SET(cpu_id, &cpuset); + CPU_SET(cpu_id + 1, &cpuset); + + if (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset) !=3D 0) { + perror("sched_setaffinity"); + exit(EXIT_FAILURE); + } +} + +void set_sched(int policy, int priority) +{ + struct sched_param param; + + param.sched_priority =3D priority; + if (sched_setscheduler(0, policy, ¶m) !=3D 0) { + perror("sched_setscheduler"); + exit(EXIT_FAILURE); + } +} + +float get_process_runtime(int pid) +{ + char path[256]; + FILE *file; + long utime, stime; + int fields; + + snprintf(path, sizeof(path), "/proc/%d/stat", pid); + file =3D fopen(path, "r"); + if (file =3D=3D NULL) { + perror("Failed to open stat file"); + return -1; // Indicate failure + } + + // Skip the first 13 fields and read the 14th and 15th + fields =3D fscanf(file, + "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %lu %lu", + &utime, &stime); + fclose(file); + + if (fields !=3D 2) { + fprintf(stderr, "Failed to read stat file\n"); + return -1; // Indicate failure + } + + // Calculate the total time spent in the process + long total_time =3D utime + stime; + long ticks_per_second =3D sysconf(_SC_CLK_TCK); + float runtime_seconds =3D total_time * 1.0 / ticks_per_second; + + return runtime_seconds; +} + +int main(void) +{ + float runtime1, runtime2, runtime3; + int pid1, pid2, pid3; + + if (!hyperthreading_enabled()) + ksft_test_result_skip("This test requires hyperthreading to be enabled\n= "); + + write_dl_server_params(); + + ksft_print_header(); + ksft_set_plan(1); + + // Create and set up a CFS task + pid1 =3D fork(); + if (pid1 =3D=3D 0) { + set_affinity(CORE_ID); + process_func(); + exit(0); + } else if (pid1 < 0) { + perror("fork for p1"); + ksft_exit_fail(); + } + + // Create a new unique cookie for the CFS task + if (prctl(PR_SCHED_CORE, PR_SCHED_CORE_CREATE, pid1, PIDTYPE_TGID, 0) < 0= ) { + perror("prctl for pid1"); + ksft_exit_fail(); + } + + // Create a new unique cookie for the current process. Future + // forks will inherit this cookie. + if (prctl(PR_SCHED_CORE, PR_SCHED_CORE_CREATE, 0, PIDTYPE_TGID, 0) < 0) { + perror("prctl for current process"); + ksft_exit_fail(); + } + + // Create an RT task which inherits the parent's cookie + pid2 =3D fork(); + if (pid2 =3D=3D 0) { + set_affinity(CORE_ID); + set_sched(SCHED_FIFO, 50); + process_func(); + exit(0); + } else if (pid2 < 0) { + perror("fork for p2"); + ksft_exit_fail(); + } + + // Create another RT task which inherits the parent's cookie + pid3 =3D fork(); + if (pid3 =3D=3D 0) { + set_affinity(CORE_ID); + set_sched(SCHED_FIFO, 50); + process_func(); + exit(0); + } else if (pid3 < 0) { + perror("fork for p3"); + ksft_exit_fail(); + } + + sleep(RUN_TIME * 3 / 4); + runtime1 =3D get_process_runtime(pid1); + if (runtime1 !=3D -1) + ksft_print_msg("Runtime of PID %d is %f seconds\n", pid1, runtime1); + else + ksft_exit_fail_msg("Error getting runtime for PID %d\n", pid1); + + runtime2 =3D get_process_runtime(pid2); + if (runtime2 !=3D -1) + ksft_print_msg("Runtime of PID %d is %f seconds\n", pid2, runtime2); + else + ksft_exit_fail_msg("Error getting runtime for PID %d\n", pid2); + + runtime3 =3D get_process_runtime(pid3); + if (runtime3 !=3D -1) + ksft_print_msg("Runtime of PID %d is %f seconds\n", pid3, runtime3); + else + ksft_exit_fail_msg("Error getting runtime for PID %d\n", pid3); + + // Make sure runtime1 is within 30% of runtime2 + if (runtime1 < 0.7 * runtime2 || runtime1 > 1.3 * runtime2) + ksft_exit_fail_msg("Runtime of PID %d is not within 30%% of runtime of P= ID %d\n", + pid1, pid2); + + // Make sure runtime1 is within 30% of runtime3 + if (runtime1 < 0.7 * runtime3 || runtime1 > 1.3 * runtime3) + ksft_exit_fail_msg("Runtime of PID %d is not within 30%% of runtime of P= ID %d\n", + pid1, pid3); + + waitpid(pid1, NULL, 0); + waitpid(pid2, NULL, 0); + waitpid(pid3, NULL, 0); + + ksft_test_result_pass("PASS\n"); + return 0; +} --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 BC859B664 for ; Wed, 13 Mar 2024 01:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293124; cv=none; b=nQnjHpzHlMLk9SoNLpQzgi7oc03qPh1jxyBoq/xRfsY9n28/k+dmVIigFULMJ7Iu0BukWLUO4/8bVcDI8dke3pLtdEsy0OXH/uR9anM+TNlOFwqobKnTMbMJGVFr5/QXH/7wv3PjQZSri6KgjW+wICo3RO6dxQ6aGFFbUMmXF8I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293124; c=relaxed/simple; bh=mZ2gOIXcUxYPUWs6+iWh+plbgTcX3Uoy+H9V33hkCIo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kFyN9CU7S3KYjR5V1u0sHtlTcmqwJyM7gHMxPKMeLhD59TEFODqhFKyTQ+Evusm/LihcfNxGTcXOOL4Ta21RbWGBZDjKmmfHYDz3dpGZHabhKDSRvQ4uiK6VyeUA0krhZ1lQXnh2ncG0ioj1SEP+T9X4xjPJrmO08ENjCol/BGk= 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=uRyUeg6m; arc=none smtp.client-ip=209.85.219.47 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="uRyUeg6m" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-690d054fff2so21045056d6.3 for ; Tue, 12 Mar 2024 18:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293120; x=1710897920; 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=CDhDd9Kfjsqh4jLKpVf7J36w/JnuAi2f5V71QMuGAEk=; b=uRyUeg6mq6wGU32l6MxYSiTZqgw6xdBruInJR55ukKU4OudSjzGrWvmc7BTi0iGU7a r1yxcXLtap7K8ZovCrlYbRFxR6Ivv3ofQcR8hc1yOY8cpbEDErChwilRnKhPO6ao4pbW n6RdtUnnr9BKqahguNNeaxxNdch24fjAFd8Ko= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293120; x=1710897920; 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=CDhDd9Kfjsqh4jLKpVf7J36w/JnuAi2f5V71QMuGAEk=; b=X3nDFC1+VuExbqOL6Sd1OfSlA25q7V4tGxq8tpsT325JhcP+Z23v2X7W+Ja2Pybr9z QLwFrlljEkUJJnZUX5B0DapnKmrrT7SWy6G8QbAIF62wkrTJcY20UqFQ0GIuFNcXW2Wu A0TVLbJT7aWl8qpISM9eggAEChK9t6escdUtZOuLn+GrVY7VFbRyLLLC5MlVGpUnuf4p mcRmCnf+HRdXzFNVB+cCJWODogMZyartScp7Fy+qEx/f+34stU5HSK1xZLN0FomM2S2C nCgAd7nJWc8+sYnfCqxNdGj2yiH375hYQXtMpY3xbg7BklRe7Qro0Kn0kYOB1dSVDGJq lvkQ== X-Gm-Message-State: AOJu0YxMVewCXEpnjIVTklFzceL5AmtJx4WZ3Fr32GI0GvK2rbiYhhUz yOahx7CoOvr6VsCOCyVTStMGgtqr9qYkFvPZHIFKX2qGtgbL7uJjRuG+jgmWBxCFv8Ablrbv/Hy m X-Google-Smtp-Source: AGHT+IEQH9hW6ZLKUNZbHpb/tPDT6brgu43x+Rcv6hHFE3facBemyF7mOFSe8xs2p97QGgaE6gVu9w== X-Received: by 2002:a05:6214:1398:b0:68f:3c36:1b74 with SMTP id pp24-20020a056214139800b0068f3c361b74mr12801088qvb.41.1710293120342; Tue, 12 Mar 2024 18:25:20 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:19 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, Shuah Khan Cc: Suleiman Souhlal , Youssef Esmat , Steven Rostedt , David Vernet , Thomas Gleixner , "Paul E . McKenney" , joseph.salisbury@canonical.com, Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Luca Abeni , Tommaso Cucinotta , Vineeth Pillai , Shuah Khan , Phil Auld , "Joel Fernandes (Google)" , linux-kselftest@vger.kernel.org Subject: [PATCH v2 08/15] selftests/sched: Migrate cs_prctl_test to kselfttest Date: Tue, 12 Mar 2024 21:24:44 -0400 Message-Id: <20240313012451.1693807-9-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" This test begs to be a kselftest, is in the kselftest hierarchy and does not even use a single kselftest API. Convert it. It simplifies some of the code and the output also looks much nicer now: Totals: pass:17 fail:0 xfail:0 xpass:0 skip:0 error:0 Signed-off-by: Joel Fernandes (Google) Reviewed-by: Chris Hyser --- tools/testing/selftests/sched/Makefile | 6 +- tools/testing/selftests/sched/cs_prctl_test.c | 74 ++++++++++--------- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/tools/testing/selftests/sched/Makefile b/tools/testing/selftes= ts/sched/Makefile index f491d741cb45..90c53bc1337e 100644 --- a/tools/testing/selftests/sched/Makefile +++ b/tools/testing/selftests/sched/Makefile @@ -1,9 +1,11 @@ # SPDX-License-Identifier: GPL-2.0+ TEST_GEN_PROGS :=3D cs_dlserver_test - -cs_dlserver_test: cs_dlserver_test.c common.c +TEST_GEN_PROGS +=3D cs_prctl_test =20 CFLAGS +=3D $(KHDR_INCLUDES) CFLAGS +=3D -Wall =20 include ../lib.mk + +$(OUTPUT)/cs_dlserver_test: cs_dlserver_test.c common.c +$(OUTPUT)/cs_prctl_test: cs_prctl_test.c common.c diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/= selftests/sched/cs_prctl_test.c index 7ba057154343..bb7aee703cdf 100644 --- a/tools/testing/selftests/sched/cs_prctl_test.c +++ b/tools/testing/selftests/sched/cs_prctl_test.c @@ -28,10 +28,11 @@ #include #include #include -#include #include #include =20 +#include "common.h" + #if __GLIBC_PREREQ(2, 30) =3D=3D 0 #include static pid_t gettid(void) @@ -80,7 +81,7 @@ static int _prctl(int option, unsigned long arg2, unsigne= d long arg3, unsigned l int res; =20 res =3D prctl(option, arg2, arg3, arg4, arg5); - printf("%d =3D prctl(%d, %ld, %ld, %ld, %lx)\n", res, option, (long)arg2,= (long)arg3, + ksft_print_msg("%d =3D prctl(%d, %ld, %ld, %ld, %lx)\n", res, option, (lo= ng)arg2, (long)arg3, (long)arg4, arg5); return res; } @@ -91,21 +92,20 @@ static int _prctl(int option, unsigned long arg2, unsig= ned long arg3, unsigned l static void __handle_error(char *fn, int ln, char *msg) { int pidx; - printf("(%s:%d) - ", fn, ln); + ksft_print_msg("(%s:%d) - ", fn, ln); perror(msg); if (need_cleanup) { for (pidx =3D 0; pidx < num_processes; ++pidx) kill(procs[pidx].cpid, 15); need_cleanup =3D 0; } - exit(EXIT_FAILURE); + ksft_exit_fail(); } =20 static void handle_usage(int rc, char *msg) { - puts(USAGE); - puts(msg); - putchar('\n'); + ksft_print_msg("%s\n", USAGE); + ksft_print_msg("%s\n\n", msg); exit(rc); } =20 @@ -117,7 +117,7 @@ static unsigned long get_cs_cookie(int pid) ret =3D prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, pid, PIDTYPE_PID, (unsigned long)&cookie); if (ret) { - printf("Not a core sched system\n"); + ksft_print_msg("Not a core sched system\n"); return -1UL; } =20 @@ -160,7 +160,7 @@ static int child_func_process(void *arg) =20 ret =3D write(ca->pfd[1], &ca->thr_tids, sizeof(int) * ca->num_threads); if (ret =3D=3D -1) - printf("write failed on pfd[%d] - error (%s)\n", + ksft_print_msg("write failed on pfd[%d] - error (%s)\n", ca->pfd[1], strerror(errno)); =20 close(ca->pfd[1]); @@ -192,7 +192,7 @@ void create_processes(int num_processes, int num_thread= s, struct child_args proc for (i =3D 0; i < num_processes; ++i) { ret =3D read(proc[i].pfd[0], &proc[i].thr_tids, sizeof(int) * proc[i].nu= m_threads); if (ret =3D=3D -1) - printf("read failed on proc[%d].pfd[0] error (%s)\n", + ksft_print_msg("read failed on proc[%d].pfd[0] error (%s)\n", i, strerror(errno)); close(proc[i].pfd[0]); } @@ -202,30 +202,29 @@ void disp_processes(int num_processes, struct child_a= rgs proc[]) { int i, j; =20 - printf("tid=3D%d, / tgid=3D%d / pgid=3D%d: %lx\n", gettid(), getpid(), ge= tpgid(0), + ksft_print_msg("tid=3D%d, / tgid=3D%d / pgid=3D%d: %lx\n", gettid(), getp= id(), getpgid(0), get_cs_cookie(getpid())); =20 for (i =3D 0; i < num_processes; ++i) { - printf(" tid=3D%d, / tgid=3D%d / pgid=3D%d: %lx\n", proc[i].cpid, pro= c[i].cpid, + ksft_print_msg(" tid=3D%d, / tgid=3D%d / pgid=3D%d: %lx\n", proc[i].c= pid, proc[i].cpid, getpgid(proc[i].cpid), get_cs_cookie(proc[i].cpid)); for (j =3D 0; j < proc[i].num_threads; ++j) { - printf(" tid=3D%d, / tgid=3D%d / pgid=3D%d: %lx\n", proc[i].thr_= tids[j], + ksft_print_msg(" tid=3D%d, / tgid=3D%d / pgid=3D%d: %lx\n", proc= [i].thr_tids[j], proc[i].cpid, getpgid(0), get_cs_cookie(proc[i].thr_tids[j])); } } puts("\n"); } =20 -static int errors; - #define validate(v) _validate(__LINE__, v, #v) void _validate(int line, int val, char *msg) { if (!val) { - ++errors; - printf("(%d) FAILED: %s\n", line, msg); + ksft_print_msg("(%d) FAILED: %s\n", line, msg); + ksft_inc_fail_cnt(); } else { - printf("(%d) PASSED: %s\n", line, msg); + ksft_print_msg("(%d) PASSED: %s\n", line, msg); + ksft_inc_pass_cnt(); } } =20 @@ -254,13 +253,17 @@ int main(int argc, char *argv[]) keypress =3D 1; break; case 'h': - printf(USAGE); + ksft_print_msg(USAGE); exit(EXIT_SUCCESS); default: handle_usage(20, "unknown option"); } } =20 + if (!hyperthreading_enabled()) { + ksft_exit_skip("This test requires hyperthreading to be enabled\n"); + } + if (num_processes < 1 || num_processes > MAX_PROCESSES) handle_usage(1, "Bad processes value"); =20 @@ -272,17 +275,22 @@ int main(int argc, char *argv[]) =20 srand(time(NULL)); =20 - /* put into separate process group */ + /* Put into separate process group */ if (setpgid(0, 0) !=3D 0) handle_error("process group"); =20 - printf("\n## Create a thread/process/process group hiearchy\n"); + ksft_print_header(); + + /* Increase the count if adding more validate() statements. */ + ksft_set_plan(17); + + ksft_print_msg("\n## Create a thread/process/process group hiearchy\n"); create_processes(num_processes, num_threads, procs); need_cleanup =3D 1; disp_processes(num_processes, procs); validate(get_cs_cookie(0) =3D=3D 0); =20 - printf("\n## Set a cookie on entire process group\n"); + ksft_print_msg("\n## Set a cookie on entire process group\n"); if (_prctl(PR_SCHED_CORE, PR_SCHED_CORE_CREATE, 0, PIDTYPE_PGID, 0) < 0) handle_error("core_sched create failed -- PGID"); disp_processes(num_processes, procs); @@ -296,7 +304,7 @@ int main(int argc, char *argv[]) validate(get_cs_cookie(0) =3D=3D get_cs_cookie(pid)); validate(get_cs_cookie(0) =3D=3D get_cs_cookie(procs[pidx].thr_tids[0])); =20 - printf("\n## Set a new cookie on entire process/TGID [%d]\n", pid); + ksft_print_msg("\n## Set a new cookie on entire process/TGID [%d]\n", pid= ); if (_prctl(PR_SCHED_CORE, PR_SCHED_CORE_CREATE, pid, PIDTYPE_TGID, 0) < 0) handle_error("core_sched create failed -- TGID"); disp_processes(num_processes, procs); @@ -305,7 +313,7 @@ int main(int argc, char *argv[]) validate(get_cs_cookie(pid) !=3D 0); validate(get_cs_cookie(pid) =3D=3D get_cs_cookie(procs[pidx].thr_tids[0])= ); =20 - printf("\n## Copy the cookie of current/PGID[%d], to pid [%d] as PIDTYPE_= PID\n", + ksft_print_msg("\n## Copy the cookie of current/PGID[%d], to pid [%d] as = PIDTYPE_PID\n", getpid(), pid); if (_prctl(PR_SCHED_CORE, PR_SCHED_CORE_SHARE_TO, pid, PIDTYPE_PID, 0) < = 0) handle_error("core_sched share to itself failed -- PID"); @@ -315,7 +323,7 @@ int main(int argc, char *argv[]) validate(get_cs_cookie(pid) !=3D 0); validate(get_cs_cookie(pid) !=3D get_cs_cookie(procs[pidx].thr_tids[0])); =20 - printf("\n## Copy cookie from a thread [%d] to current/PGID [%d] as PIDTY= PE_PID\n", + ksft_print_msg("\n## Copy cookie from a thread [%d] to current/PGID [%d] = as PIDTYPE_PID\n", procs[pidx].thr_tids[0], getpid()); if (_prctl(PR_SCHED_CORE, PR_SCHED_CORE_SHARE_FROM, procs[pidx].thr_tids[= 0], PIDTYPE_PID, 0) < 0) @@ -325,7 +333,7 @@ int main(int argc, char *argv[]) validate(get_cs_cookie(0) =3D=3D get_cs_cookie(procs[pidx].thr_tids[0])); validate(get_cs_cookie(pid) !=3D get_cs_cookie(procs[pidx].thr_tids[0])); =20 - printf("\n## Copy cookie from current [%d] to current as pidtype PGID\n",= getpid()); + ksft_print_msg("\n## Copy cookie from current [%d] to current as pidtype = PGID\n", getpid()); if (_prctl(PR_SCHED_CORE, PR_SCHED_CORE_SHARE_TO, 0, PIDTYPE_PGID, 0) < 0) handle_error("core_sched share to self failed -- PGID"); disp_processes(num_processes, procs); @@ -340,20 +348,16 @@ int main(int argc, char *argv[]) validate(_prctl(PR_SCHED_CORE, PR_SCHED_CORE_SHARE_TO, 0, PIDTYPE_PGID, 1= ) < 0 && errno =3D=3D EINVAL); =20 - if (errors) { - printf("TESTS FAILED. errors: %d\n", errors); - res =3D 10; - } else { - printf("SUCCESS !!!\n"); - } - - if (keypress) + if (keypress) { + ksft_print_msg("Waiting for keypress to exit\n"); getchar(); - else + } else { sleep(delay); + } =20 for (pidx =3D 0; pidx < num_processes; ++pidx) kill(procs[pidx].cpid, 15); =20 + ksft_finished(); return res; } --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) (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 C984CBE5A for ; Wed, 13 Mar 2024 01:25:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293126; cv=none; b=LakwxtzQqtq4aP2iD76WPJ1Rz1HD+XUMQqbDZAJQ6D2ScInj9kwabZttcKAacLu0UrzHj5K9FTFN/WnhOi5C6AVnoJSTE3MCYgpLdkxVZEVRD020DxUkoBEljzROFqbaHMgYtHSjHrSznUH4GNGyl1e5w+rwVhcyLD/BILvaiRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293126; c=relaxed/simple; bh=cu3MMzOHuWJKImjKqYJ4/NXYAdw+8BhcKEGy95D0Imk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kcBOFGI2QOEsPwx0Nxc22JyxEnCGiVWB8mpoeVoqlUL9x6woQl4JlapgrhGt/kQAZH96jxPLCaa6M2WyYCEIoCho8nq1GWG1K4euPPdYnP8oMt53wsVjYrwp1Nc1Lm7MJOOZwpQXMwZe0jlHPSIOcwJcgoAp2pB8qQjfkYDvVzM= 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=Rqssngnl; arc=none smtp.client-ip=209.85.219.54 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="Rqssngnl" Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-68f41af71ebso4405436d6.1 for ; Tue, 12 Mar 2024 18:25:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293123; x=1710897923; 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=+jDrn7wgy/ve0lPoR/xKtbF/cZLSIaETTt3wbkL2858=; b=RqssngnlyfPfkO1M7NSQ7hg3w1o+3ugwNj8VifSkFo1gE1VncEZG/qRGwEVRuwk5dR /Q+q98uVy6tOx2QCuE1fpom5WUFBjIhgylb2lQOzjzRdLS6sJVxiBy5mUS4YPmZZPn/4 i8CkPjqp+1KWYqvNEOhxS2kbqfgX4IsZwjc7g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293123; x=1710897923; 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=+jDrn7wgy/ve0lPoR/xKtbF/cZLSIaETTt3wbkL2858=; b=DdkM5kMYFqEx63wnpciUP7UwGr5AXYnH3Q2BsNeJs66payhbMw8Oq+xEwj+3cZRRua 2XqC/mRry0/bU6dLE+j3DsRUPDir63XitraVn3smTkVoIfZTzYlt5boxkaWxMpeZQ3RZ zUeDVhlWH7sKlnP8kLVB4adXBCqaGKGJ2uYVBMSv2TKxz4JE29qStZHMjcK8JY/gyT7h ZqAJBtgUkp/KDUDGj3rQmx18qO6MehgOgCwLLKdYUYfLkZ5epQTg/aNSd6cyLfsAttd9 qkgmxrUsqZIe6WQK2iJ3fPO56dkdnB8ufoRKToCB+4bhvu0VDskRR3dmwQ1/Sw66INCI Zr4w== X-Gm-Message-State: AOJu0YzpIrfLuz2FlgpQE2dmic7aQxs0HrqLvUsmFb1osyiLma8F5S5R dx/TUM17EB4aebhCvv/eW6JskXnVL7q2jRrA50ts6kVUti9YDMsv4mcF/qxFJwrvtg28nxkySiT E X-Google-Smtp-Source: AGHT+IEbJtuWeR15hakVbXEMMZTuDPev36PD/22XP5I3KXlRLbjFh9A2AyTmrw6JNT7mBOc3CUEd2A== X-Received: by 2002:a05:6214:238a:b0:691:907:f9e5 with SMTP id fw10-20020a056214238a00b006910907f9e5mr1929870qvb.12.1710293123162; Tue, 12 Mar 2024 18:25:23 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:21 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Pawan Gupta , Jonathan Corbet Cc: Suleiman Souhlal , Youssef Esmat , Steven Rostedt , David Vernet , "Paul E . McKenney" , joseph.salisbury@canonical.com, Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Luca Abeni , Tommaso Cucinotta , Vineeth Pillai , Shuah Khan , Phil Auld , "Joel Fernandes (Google)" , linux-doc@vger.kernel.org Subject: [PATCH v2 09/15] admin-guide/hw-vuln: Correct prctl() argument description Date: Tue, 12 Mar 2024 21:24:45 -0400 Message-Id: <20240313012451.1693807-10-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" Correct the description for arg4 which appears to be outdated. Signed-off-by: Joel Fernandes (Google) Reviewed-by: Chris Hyser --- Documentation/admin-guide/hw-vuln/core-scheduling.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/hw-vuln/core-scheduling.rst b/Docume= ntation/admin-guide/hw-vuln/core-scheduling.rst index cf1eeefdfc32..338d639a8127 100644 --- a/Documentation/admin-guide/hw-vuln/core-scheduling.rst +++ b/Documentation/admin-guide/hw-vuln/core-scheduling.rst @@ -62,8 +62,8 @@ arg3: =20 arg4: ``pid_type`` for which the operation applies. It is one of - ``PR_SCHED_CORE_SCOPE_``-prefixed macro constants. For example, if ar= g4 - is ``PR_SCHED_CORE_SCOPE_THREAD_GROUP``, then the operation of this co= mmand + ``PIDTIME_``-prefixed macro constants. For example, if arg4 + is ``PIDTYPE_TGID``, then the operation of this command will be performed for all tasks in the task group of ``pid``. =20 arg5: --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (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 206F4199A1 for ; Wed, 13 Mar 2024 01:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293128; cv=none; b=oRwfyUoZt4GE79BMeigOudiLRcW1UcIhCkyYl0dgLPD+01bLo8JjM8w82or/hGX5gA/Xv7v1WUlPVkhdJrShEnKG7ZjJBAUNHyP3WuhMxl8+46QyPG3fWm+4+DvgRzlwcX750xJzyDZxH6z0e1EEcIUhQims5p1VAIa0yFvJau4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293128; c=relaxed/simple; bh=o8njkdLQwpeSFKVUbv1Vgg6wMteGEmlFXV/7brtrrq4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FsARZDgrjDmSVALNG7NrK8u/+2z9Dofom+flbY+ka0rH5uhTfUOv92aq54NxbianbU9RNyWGJnlxm6+2tfvY5CJXPIpgC3hpopuRbpCVnTYeBLKDR6zZ0gEp9hZRA5bP25rGnaxuUGykup9jBqlvJsnsScgUImMg1nTx5hsD32Y= 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=YwqqQl0g; arc=none smtp.client-ip=209.85.219.49 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="YwqqQl0g" Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-690ca2d2c5bso20587396d6.2 for ; Tue, 12 Mar 2024 18:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293125; x=1710897925; 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=yHQc0zFqwpbzybw0LbQrYD8RqgFtXPcRDLH11DqCLn4=; b=YwqqQl0g5t27KgfNPbMUaY3O7HQKd5jck/EyI1BsV9maYvOlMW9xjXLe8V0kVdEvIt PvX4nPyihdHkpEtfCoTDEHS75DOvEd5ZQribsRAQi1hQM8baN2c+6l47A8mC0xlCc8j5 XWiRqmnSdazVVZ4lwY3Fsfpv7+x2jcpLv1M9s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293125; x=1710897925; 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=yHQc0zFqwpbzybw0LbQrYD8RqgFtXPcRDLH11DqCLn4=; b=jSiNxfndsbvyAEKikFl6PdqcMYURN9dRgh4AetO/iEAgtd8nUiPGvcF4ZSYHoVaUpm vHu4MC7v8oS0MQVyuGDMDsH9ghAgPpaaerJXZ+cBbIK1HmUcD1fHjDrBAskQWkDB7HLL Uw7tlscCtbVH04q8+YmjwUd6VPypIuMhRym9/KMxRtmGNU9YCbkZgaT+QpiciZVBSnLe Ij+I9G43Udgdf4hoMEVzpvXneivliEZqA9IABP4hkpo+cjqRZ5Ybm9q1MV2ZCK8GvI65 wWfqgM9QdRe5yUoxVgIyNCr+x+QZQWBrIXZpWtDFMJdnMohMw37oNH42jzcV07uUDY0O 7rVw== X-Gm-Message-State: AOJu0YzqGFwnO4Gf5zcpmdNmN748gPjQGpTh/7WweflebWF5K3U/eVB2 u2RwkQXMWzvQikmGuaQ+lcRK+dvECLaBOS78xnrqtK58FpNkF3P9gatnRbmvWU6uq3HRmF8exir z X-Google-Smtp-Source: AGHT+IFH9PpSr8f9cA/V1GrvQXnCI5vJgzMU1R4IjJUUe1gozissvxwo7WyqvGk2jTOwm5nF85t3Cw== X-Received: by 2002:a05:6214:240b:b0:690:f644:147f with SMTP id fv11-20020a056214240b00b00690f644147fmr3900286qvb.36.1710293124921; Tue, 12 Mar 2024 18:25:24 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:24 -0700 (PDT) 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 v2 10/15] sched: Fix build error in "sched/rt: Remove default bandwidth control" Date: Tue, 12 Mar 2024 21:24:46 -0400 Message-Id: <20240313012451.1693807-11-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" This fixes a build error introduced by "sched/rt: Remove default bandwidth control". The issue happens because a function is unused when !CONFIG_SMP. It could be squashed into the original patch. Signed-off-by: Joel Fernandes (Google) Reviewed-by: Chris Hyser --- kernel/sched/rt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 37bee56a70f7..d3065fe35c61 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -964,8 +964,10 @@ struct rt_rq *sched_rt_period_rt_rq(struct rt_bandwidt= h *rt_b, int cpu) return &cpu_rq(cpu)->rt; } =20 +#ifdef CONFIG_SMP static void __enable_runtime(struct rq *rq) { } static void __disable_runtime(struct rq *rq) { } +#endif =20 #endif /* CONFIG_RT_GROUP_SCHED */ =20 --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) (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 670CA1B971 for ; Wed, 13 Mar 2024 01:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293131; cv=none; b=F+0FikpRQaMkc3ZGMXM90cVSmj3UZSVn8k2sXb/nS/henNC/tLEuS8/Plnu5jg+XAkHcnQPSSMf64W66u8YNJO4PAYAoyXyxTnejesZx4/937vN/FwStqRYFA3UPHEAzmK4wHu7saLe5kFbwJXQl91wfqP8UsK384yJ7j2FwP80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293131; c=relaxed/simple; bh=jY7DsCgc8BB+eH2jvyxI0sUw6W9MrUx/z0pU0qLpZHQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f8Y4+r6TzOZsguFe+Z03eY0Km55JqZCFyVqKpgrNHZ5PU9bo9o4UfBS9ml08Kw8gtdDfvAus02z3W0Dd1jNhrEUSxiFMdB5tglxVxLAGlKO/ahJlRMEdOvt2FxN+B3pdMDDAP9EzlgKk81QeV7v5c6CwhynMXyBDzah+4uQK9hg= 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=YnbbJR/y; arc=none smtp.client-ip=209.85.219.50 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="YnbbJR/y" Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-690ddcd97dbso13295126d6.2 for ; Tue, 12 Mar 2024 18:25:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293127; x=1710897927; 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=/FazbUMp2++JK4V9me5cdA/Vo7sBxJTMKGEWaWEVy5s=; b=YnbbJR/ypd+L/vsTzyQCw6ygrYRH+IQyvyTCDb6z+XMZHUddwixix3YLDCh5nT/oFo QpOYbe5XPwMtYSIFctVrOwP8oCt23YWDs54tQX1e/0bMwsM8kBG5eVxqirP+e1QTPBgz ifL+tkvRfS/beR1J9uexS0h1lWLjbHpO8Xoxs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293127; x=1710897927; 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=/FazbUMp2++JK4V9me5cdA/Vo7sBxJTMKGEWaWEVy5s=; b=R3AQylqaJt+X9Ad6gu7KkX+o2N6/pshpeuDhv1Ya14zQ77unZ0xWm3pHFd0WoKCMFk dMjyuiT8uNZORORhfkZeM7XJVSLxF+UamF5BWVaGy6jC3k6qZrX/zkHnPpbS5fRG5HD/ Zq5zChxA+wGzDjfbi8isyBoHpWoG+xXDyrpwTCU4txnqOXOWgal2ccCBKsN0RZHVaWEC TUi1521Ksas2fdeYfn1OeYlG+7xWjP4gpMoUFUZVZIbSeT3y4tRZZc/uVPSDk/732ukO O9SOH93k7Ncw05cCzekYIbCPhpUlolqrjAA4XTrSuG8G1PwMvhlOYzeOb0r4u0TX/A1K oNIw== X-Gm-Message-State: AOJu0YxaTAfN/zVuFYjvo1wMEiwo9d/h8RoT30vG6gemCkaieGyq7KvZ ldkAsqfsI0N/u0VLN8YaEglVIzXJSnQwQwZGx7Q9TwpWYi9Pu5L+Hk09Tgwn92Y0aRsGuxqJUqd y X-Google-Smtp-Source: AGHT+IG2mA+z/pc+onmOaLaX36WFzaDUZj+ekyCHGljdpYYb/qNsdpJ9t7ZHX0Q+Xtb722TDGKdK7A== X-Received: by 2002:ad4:4e06:0:b0:690:c733:f027 with SMTP id dl6-20020ad44e06000000b00690c733f027mr2130618qvb.53.1710293127086; Tue, 12 Mar 2024 18:25:27 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:26 -0700 (PDT) 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 v2 11/15] sched/deadline: Mark DL server as unthrottled before enqueue Date: Tue, 12 Mar 2024 21:24:47 -0400 Message-Id: <20240313012451.1693807-12-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" The DL server may not have had its timer started if start_dl_timer() returns 0 (say the zero-laxity time has already passed). In such cases, mark the DL task which is about to be enqueued as not throttled and cancel any previous timers, then do the enqueue. This fixes the following crash: [ 9.263331] kernel BUG at kernel/sched/deadline.c:1765! [ 9.282382] Call Trace: [ 9.282767] [ 9.283086] ? __die_body+0x62/0xb0 [ 9.283602] ? die+0x9b/0xc0 [ 9.284036] ? do_trap+0xa3/0x170 [ 9.284528] ? enqueue_dl_entity+0x45e/0x460 [ 9.285158] ? enqueue_dl_entity+0x45e/0x460 [ 9.285791] ? handle_invalid_op+0x65/0x80 [ 9.286392] ? enqueue_dl_entity+0x45e/0x460 [ 9.287021] ? exc_invalid_op+0x2f/0x40 [ 9.287585] ? asm_exc_invalid_op+0x16/0x20 [ 9.288200] ? find_later_rq+0x120/0x120 [ 9.288775] ? fair_server_init+0x40/0x40 [ 9.289364] ? enqueue_dl_entity+0x45e/0x460 [ 9.289989] ? find_later_rq+0x120/0x120 [ 9.290564] dl_task_timer+0x1d7/0x2f0 [ 9.291120] ? find_later_rq+0x120/0x120 [ 9.291695] __run_hrtimer+0x73/0x1b0 [ 9.292238] hrtimer_interrupt+0x216/0x2c0 [ 9.292841] __sysvec_apic_timer_interrupt+0x53/0x140 [ 9.293581] sysvec_apic_timer_interrupt+0x2d/0x80 [ 9.294285] asm_sysvec_apic_timer_interrupt+0x16/0x20 The crash can easily be reproduced by adding a 100ms delay as follows: +int delay_inject_count; + static void enqueue_dl_entity(struct sched_dl_entity *dl_se, int flags) { @@ -1827,6 +1830,12 @@ enqueue_dl_entity(struct sched_dl_entity *dl_se, int= flags) setup_new_dl_entity(dl_se); } + // 100ms delay every 20 enqueues. + if (delay_inject_count++ > 20) { + mdelay(100); + delay_inject_count =3D 0; + } + /* * If we are still throttled, eg. we got replenished but are a * zero-laxity task and still got to wait, don't enqueue. Signed-off-by: Joel Fernandes (Google) --- kernel/sched/deadline.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 5adfc15803c3..1d54231fbaa6 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1949,6 +1949,18 @@ enqueue_dl_entity(struct sched_dl_entity *dl_se, int= flags) if (dl_se->dl_throttled && start_dl_timer(dl_se)) return; =20 + /* + * We're about to enqueue, make sure we're not ->dl_throttled! + * In case the timer was not started, say because the 0-lax time + * has passed, mark as not throttled and mark unarmed. + * Also cancel earlier timers, since letting those run is pointless. + */ + if (dl_se->dl_throttled) { + hrtimer_try_to_cancel(&dl_se->dl_timer); + dl_se->dl_defer_armed =3D 0; + dl_se->dl_throttled =3D 0; + } + __enqueue_dl_entity(dl_se); } =20 --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (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 ED1B61F5FA for ; Wed, 13 Mar 2024 01:25:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293133; cv=none; b=qHFSvCeX+aQ1NgwzIdAwng8s0rRX414VLPzPfIlV+jypIFMRmgAeb892upJWaHwzJXjCj/beIVuUzwWASsptxfn7C1RGwunt6k8nrK9B0JM4OZte1Ae84ZAzIVZUhRCeR085EYWvSvdLta0W7EFTD9lbK5VpxQapplEEt2GADzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293133; c=relaxed/simple; bh=QLdUMfFBHEXRelk3Gs5vH3ZclEOu/Hi8wJrg6o9Q3NE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DYYh3I0xxJMe3j+uIv0YFFe2lcjbejDWJgXhIwKb5fulI5C5k32KeXSqQQKhAxoEkdAoHhnVokJJacmLmcBstMFF8wQyRLt303i7g8QrcnCD6qIDvJY51ZJ2W0JX1f95Bc8WUoS5uTxID7b/29gQ/5pJtfO01+hUD4mgl3ahRVw= 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=BeGPxHsN; arc=none smtp.client-ip=209.85.128.181 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="BeGPxHsN" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-60a0599f647so5124657b3.1 for ; Tue, 12 Mar 2024 18:25:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293130; x=1710897930; 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=kJpm5svSk0YcjafSF+vl5lrL0xoq62Q9LU01QDuwzgU=; b=BeGPxHsNZtmVeAp2A+d/KK0dd/+9vAIzAPsZcklZlNnYTwufbxwN0BRaFiOJHccvBy ZV9AiUqi9QoyfRAwca4SL4jhbwsX3HI6OqFJsQO/VMdm5B9cmK4TSs0TKsiAcvE+FgSY Usevbt11KmIY+NKzWCVBGDL1idmQx3Iz+jzPM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293130; x=1710897930; 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=kJpm5svSk0YcjafSF+vl5lrL0xoq62Q9LU01QDuwzgU=; b=hZT8teP89eqJqi8vrEaehDMwBVet+baG1UpJ20iBVHck/va0xEqunix4MeTSa9pIMU fWqkyjrh4HxAJ8VxHo81TVK3684FvbM56VQWrH81gF5Qa8owj95hf7Wt6rAOiShzI+fP Q3KTEIGVS2e7OakJt6DB/zkHAY4hkiAcSIlBknWrKuL1gs637+6AQgRS/S94Y/tIAlMF Y6jos4eNEH6Dw7jr+R/eL/ai/pRKll1of//Aw69Cn8BKej3gA/I+phVR8AiPczf4FLYA 5whuVaSwYmdViRmZ38ftLj5ALdEU/9LxI3JYi4BWKZBBdodQyX0FRtdhKTr84fQJ+yOo 8MyQ== X-Gm-Message-State: AOJu0YwAaDEZEqw2B+zsn2Es+W8ITh8dXEj2ggX0Q20XaELCMv9RCU59 WOPnhe+7sgk5PEwXr4Ea4ltqQGeRUG7H3Rpc/oRPnLv2W4TdahKlUx53Kf1/8GmnwuFilEjMXtC v X-Google-Smtp-Source: AGHT+IFYCSAEULJTqtEn0oYnVdABZeIOJE0FPOhc7DzvWAW+8IvxOF0ETtT2R4mXtSk8pc45IKRtIQ== X-Received: by 2002:a25:6911:0:b0:dd1:21de:7454 with SMTP id e17-20020a256911000000b00dd121de7454mr1182621ybc.57.1710293129800; Tue, 12 Mar 2024 18:25:29 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:28 -0700 (PDT) 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 Subject: [PATCH v2 12/15] sched/deadline: Reverse args to dl_time_before in replenish Date: Tue, 12 Mar 2024 21:24:48 -0400 Message-Id: <20240313012451.1693807-13-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Suleiman Souhlal dl_time_before() seems to be incorrectly used, we need to check that the 0-laxity time is ahead of the rq_clock. Fix it. Signed-off-by: Joel Fernandes (Google) --- kernel/sched/deadline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 1d54231fbaa6..dbba95d364e2 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -914,7 +914,7 @@ static void replenish_dl_entity(struct sched_dl_entity = *dl_se) * is in the future, throttle the server and arm the zero laxity timer. */ if (dl_se->dl_defer && - dl_time_before(dl_se->deadline - dl_se->runtime, rq_clock(rq))) { + dl_time_before(rq_clock(rq), dl_se->deadline - dl_se->runtime)) { if (!is_dl_boosted(dl_se)) { dl_se->dl_defer_armed =3D 1; dl_se->dl_throttled =3D 1; --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) (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 44A9D210E9 for ; Wed, 13 Mar 2024 01:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293135; cv=none; b=uzlRQw+MIZg7yMB5Ppd4sD7BqeRDP2nRSH8gjHKxdyiX5orS0otE7NV+67cKmBGDf5hb3v2N62jyp4jh4qEriy3pVhpwPblKVcuOppxfxy9M8gDMjW1WFoq+uQutWLLuLKf7KYpSBJVWkIJV4RDDZ85g3CFpybNVAvTAPGAxy6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293135; c=relaxed/simple; bh=bEbpzc3o6NPBPhxbWoEkjxbQuHObKOCYacbHoAyzbQA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HwgygCLF9j4awAxjbj8GPu+ktaCWF7ZJ2Y3bn4xjM08NYbR/rTyoOWhc3bSHgUJKwIMAqngbDJJ/pVlIilzWNXr6gZIpoOkO5g1ChmyOp/V6jLa1pcnI1MkGNOFtIvftRIV5SA+fcOYlN4l67F9mWMNs7SWGlx9rDBPOQYBYB5E= 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=GjeWV7nG; arc=none smtp.client-ip=209.85.219.50 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="GjeWV7nG" Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-690e2d194f6so11214396d6.0 for ; Tue, 12 Mar 2024 18:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293132; x=1710897932; 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=6ZYANLYuUMfpIZu9pt5liLGvM3ivTsaOwqTCSKV0HFk=; b=GjeWV7nG2315toKGqMB98wMglLGQEWI8bPXLZl8V2NpxHHquRPHYwj3Y3pKKyNHhYV zy1hoDGDrUHgOdKpxzBANwXhrLkWkY69wIkCARkjxzhGMSKqs3kjsYNv5O3Fblyjh0IR H+ggZOUhDNgeE7wRdyPrHR0vgwJFcRqWbyqXs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293132; x=1710897932; 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=6ZYANLYuUMfpIZu9pt5liLGvM3ivTsaOwqTCSKV0HFk=; b=WPqYNZVIH5psfbikhT8qR0RbSyeUUhoG5L16vZ8KWWkokZTpsKqqLqgUYOv5q0tahq mtn+fNpWRvV6+6MrzVnmzuUxgrsrX9yJTDzYmeeplTL7ojlvfTcfHXxUgX2Zu34ksKRu MXJ1y9Edz4e9Cg9UMo/Efk3do+U9njXuFLJfwUCz/P9iJJjEPl6kJVxgYr9l9z4FTmfr B23JP2pnu9XooDlsV2hgDry9/pXKKrIM4xU7zJLlec+efQV92wLZosCOr3EUDlFKbMdV CrHV2ekJBMoNkhiLwuWpQSbmuOuwPbjyblo6+pv+e25PvPV4BWKzaAd/YWv+WNPIasM3 j9bg== X-Gm-Message-State: AOJu0Yxsa9dAh+Njwo24j7JZ89D+PhYOH3sCKtFO4Fh81BGVxlSwMhRk JpWphFDiuUDQh81mkvLah+tqToHeMKeUjIXZudkZLRZ/I/J5riPd4iRw8FxucvBuYRtOXL+F3y3 l X-Google-Smtp-Source: AGHT+IENf7xbFa4g7w2qrwzP0tC65M2qKSQANmudIY7CUuScaysHdsqw8e6UzYS5NHM2OVnofApjVA== X-Received: by 2002:a0c:eecb:0:b0:690:d6fc:f0e with SMTP id h11-20020a0ceecb000000b00690d6fc0f0emr5943620qvs.11.1710293131938; Tue, 12 Mar 2024 18:25:31 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:31 -0700 (PDT) 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 v2 13/15] sched/deadline: Make start_dl_timer callers more robust Date: Tue, 12 Mar 2024 21:24:49 -0400 Message-Id: <20240313012451.1693807-14-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" For whatever reason, if start_dl_timer() returned 0 during replenish (it did not start a new timer), then do not marked dl_defer_armed, because we never really armed. Further, we need to cancel any old timers, This is similar to what dl_check_constrained_dl() does. Add some guardrails for such situations. Signed-off-by: Joel Fernandes (Google) --- kernel/sched/deadline.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index dbba95d364e2..e978e299381c 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -918,7 +918,16 @@ static void replenish_dl_entity(struct sched_dl_entity= *dl_se) if (!is_dl_boosted(dl_se)) { dl_se->dl_defer_armed =3D 1; dl_se->dl_throttled =3D 1; - start_dl_timer(dl_se); + if (!start_dl_timer(dl_se)) { + /* + * If for whatever reason (delays), if a previous timer was + * queued but not serviced, cancel it. + */ + hrtimer_try_to_cancel(&dl_se->dl_timer); + dl_se->dl_defer_armed =3D 0; + dl_se->dl_throttled =3D 0; + return; + } } } } @@ -1465,7 +1474,14 @@ static void update_curr_dl_se(struct rq *rq, struct = sched_dl_entity *dl_se, s64 hrtimer_try_to_cancel(&dl_se->dl_timer); =20 replenish_dl_new_period(dl_se, dl_se->rq); - start_dl_timer(dl_se); + + /* + * Not being able to start the timer seems problematic. If it could not + * be started for whatever reason, we need to "unthrottle" the DL server + * and queue right away. Otherwise nothing might queue it. That's similar + * to what enqueue_dl_entity() does on start_dl_timer=3D=3D0. For now, j= ust warn. + */ + WARN_ON_ONCE(!start_dl_timer(dl_se)); =20 return; } --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 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 F371B22331 for ; Wed, 13 Mar 2024 01:25:35 +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=1710293137; cv=none; b=V3VYDdo2Waa/xPEURZaj3SGXQUKhMiI7lcAoMQCa1om8cUBosDw8lXXD/OK82WxhMbugAYzIvdNLqmrWTZvUAIFeIGhOkks9NsBp2InHmhiWRhFz+OwW2wqcGrOlJM5ZKRVMJwLpdZyXvjPvD9GwWfnVkD2K2JfUJlQpYsYFZB8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293137; c=relaxed/simple; bh=UK2WewGj1PIdmX5EoPv0UOW0uK+6Xcz9jOAYo7+Svic=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KYiemUW9qZEuIz5kU9IzhWTemqYK7ks6lAyHQ281vxqVnv3oChUdu4PV6MpfH4pKoWdcrcfXu75GY7SldbetllDvORuCBX8ZRMFB2kcoXUgPVPbOsAwOz8O2sqxok2HBJf2wT3/0LUdGPNNPJkDquZqJ+RaeCtgJcK5EnmcBa8U= 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=vE27EaJg; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="vE27EaJg" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-690cbf99143so17989276d6.3 for ; Tue, 12 Mar 2024 18:25:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293134; x=1710897934; 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=lBjm0Ju7uUY9PPr2QBHaZ0I3rXA0RezNA7kWYg5Bv1Y=; b=vE27EaJg5k+F+H94r0qeBiIRrBSmi/JxDIqnsrqctOl0ibJaF7envW78FjgX6GQQcZ gPv5Elxl1iqTKoL+ozxBI1pEUm1XeXzn2+QpaX6qoidgCxQqVnkPZeikD7UCZFfPq/K5 QqWEgs7vELBZwGs+hmTUp1Yqm2JYm4jMsEQu0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293134; x=1710897934; 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=lBjm0Ju7uUY9PPr2QBHaZ0I3rXA0RezNA7kWYg5Bv1Y=; b=PxwUCvDyCN9o/uq+hffkZeBtlNzTe09fjOD43ns7//3F0Q+4fyGOxQNIr7D7gwEvcH qYn2qzXND5zOlRBVY3FJ7jS95Bs8DT6mqqpN7F55ZRCv7scesJEzd7AKuvDbNTg8J0oA YbGnxiap8NfZgqbvT5YFytK4MUt6eMAqPRqNmaWFAOXjdhHycWyjQGBQ1+q8w1S0mYsf Zjx9wortcJmB9urPB7QXGrQH5MMnoiRzHaowwYz5GPMeU4QmBTMfTn+2Etmksuaztmht kl/ZCImD9xWyA6zGYc99cHtTDh1F7jZCqj2qeK8wQRd/9bhncnJErcQOQeCQwx2O8MEL Tv4Q== X-Gm-Message-State: AOJu0YwDoJxR/ZXspFtJHJEXXIkaEC1u5dmxqZbfPYcZY2ztGGPvfjCa p4knXBt4wsAxaoaGBf1f0d1WbggBeOZ/B2WeX61X5UaDYui4f0p+YdF+Z/iqLzbtfvVSherj+6j c X-Google-Smtp-Source: AGHT+IH3s9mhqMJ/yNBnTRDu/1Dct/MaUOssMa5OV0jrVWSMhXTmX6uyDS1HQiGgrasxkfPj/T/M1A== X-Received: by 2002:ad4:584d:0:b0:690:ca5c:ce9 with SMTP id de13-20020ad4584d000000b00690ca5c0ce9mr3320784qvb.58.1710293134227; Tue, 12 Mar 2024 18:25:34 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:33 -0700 (PDT) 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 v2 14/15] sched/deadline: Do not restart the DL server on replenish from timer Date: Tue, 12 Mar 2024 21:24:50 -0400 Message-Id: <20240313012451.1693807-15-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" There is no point in doing so if there are no CFS tasks to run. If there were, we would be doing ENQUEUE_REPLENISH from the dl_task_timer, instead of calling replenish_dl_entity(). Fix that. Signed-off-by: Joel Fernandes (Google) --- kernel/sched/deadline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index e978e299381c..179369d27f66 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -915,7 +915,7 @@ static void replenish_dl_entity(struct sched_dl_entity = *dl_se) */ if (dl_se->dl_defer && dl_time_before(rq_clock(rq), dl_se->deadline - dl_se->runtime)) { - if (!is_dl_boosted(dl_se)) { + if (!is_dl_boosted(dl_se) && dl_se->server_has_tasks(dl_se)) { dl_se->dl_defer_armed =3D 1; dl_se->dl_throttled =3D 1; if (!start_dl_timer(dl_se)) { --=20 2.34.1 From nobody Sun Feb 8 11:06:11 2026 Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) (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 095FE225CD for ; Wed, 13 Mar 2024 01:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293139; cv=none; b=WXpYQfw6qi5hMpUHhtq++Q9u5CqdP714gc57VYjihYkpTdlGVxPLE5lD6nRcO/puV+/7MKJWNz6WKYXISMTzKQSBMqgt/lgFC9UTdIvM7jt3O1LQcDpeD3muEcUmJsBsLEZtp57/lFmrpcOImEStT/AUuyj6fBok+i17hxXfjhg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710293139; c=relaxed/simple; bh=7fIBSHLdyRr253VoUz32d0lGxdCPuDKV5UA70PG7VVA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bIAIAHJIvechjqxBaGbTNI5p8gzjv/5P5vb9gLZJcBIAillu17FJhs1l2d+9Ih5yihhOgj3JWtzbOqGEU5bKJlsgnETuL9vM8nx/AA9fV6wZPUidREOFWzyuXALnXaRpcTUCSUEpPbSgqzRfuKW15FCRzgWBhUeHns2PRZ8Y/WE= 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=yZn9k/Hm; arc=none smtp.client-ip=209.85.222.52 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="yZn9k/Hm" Received: by mail-ua1-f52.google.com with SMTP id a1e0cc1a2514c-7dc3a92c4b8so7151241.0 for ; Tue, 12 Mar 2024 18:25:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1710293136; x=1710897936; 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=tFP3nhe5u/vPdDQ2418/fxPClwHL82o3qm5dzpjWd74=; b=yZn9k/Hm4weqkCzGR8/8pL9kq4SMqZEEEH0yeI5hQ9mqV63MDGWsyzhXvFQnz/eaD8 aLIhN2EsxklhTKIh0SJ1NCFzPLa7CH6mt8MaprvyrCwE+SYqCiURTotnGdwUY/rdhYg5 yuYmavtUg2jJ6Ra043CwPDYJEdGcW0G4PgVQ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710293136; x=1710897936; 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=tFP3nhe5u/vPdDQ2418/fxPClwHL82o3qm5dzpjWd74=; b=h3GbJXRep4T4WuX/omifU8IcDHVslZB1N4zsikGdY8lTQarHuk2gFcANTsFMyhw7No EHN0q4RhvZzisCkzU7F+s/jfuTVT7mdyjEOu/8xtlX1eVqwiXKukFSPNeYe87tiDFBx3 Mc4gtLdRar/fo3VoJnSDFBGtIB/ANzmwv+ModQc7W0P263NIjHqfCwTmJOrE1xaUFIMl p+4kTTA+o5iYRutDH2HKNbSTixdWq64FFmLLkmYRZejzTwZy83WzTWvWv058Wu/cjnna mEcEgU+ET2amyBVq1rto168EZlhWVIT4xwpHYAEwpO+CPk111e6d1JEOD+q/L5KoVYEA 39fw== X-Gm-Message-State: AOJu0YxT+SbqmJOYs7+srbUidtFA8NTsIuG8VzH5COBKcpYYGSsIWaGj w1gMJSB5+LnLL272UA+W6mhJUvB5JLw9bQaKVBL48xw0HKX0Wuxb3QC3vn1HB76NV2Yr7fjdyfE S X-Google-Smtp-Source: AGHT+IHFyfYpc9INhRrW5wM3R5KSsVt91M/yg0XSiM2yIflnqcoaTMBRvEN1d1qEZiPy/gNCwjWcjA== X-Received: by 2002:a05:6122:1dab:b0:4d3:3b1b:aa92 with SMTP id gg43-20020a0561221dab00b004d33b1baa92mr8166193vkb.11.1710293136009; Tue, 12 Mar 2024 18:25:36 -0700 (PDT) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id u9-20020a05621411a900b00690314356a4sm4162132qvv.80.2024.03.12.18.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 18:25:35 -0700 (PDT) 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 v2 15/15] sched/deadline: Always start a new period if CFS exceeded DL runtime Date: Tue, 12 Mar 2024 21:24:51 -0400 Message-Id: <20240313012451.1693807-16-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240313012451.1693807-1-joel@joelfernandes.org> References: <20240313012451.1693807-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: quoted-printable Content-Type: text/plain; charset="utf-8" We believe that this is the right thing to do. The unit test (cs_dlserver_test) also agrees. If we let the CFS run without starting a new period, while the server is regularly throttled, then the test fails because CFS does not appear to get enough bandwidth. Intuitively, this makes sense to do as well. If CFS used up all the CFS bandwidth, while the DL server was in a throttled state, it got the bandwidth it wanted and some. Now, we can start all over from scratch to guarantee it a minimum bandwidth. Signed-off-by: Joel Fernandes (Google) --- kernel/sched/deadline.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 179369d27f66..a0ea668ac1bf 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1454,23 +1454,6 @@ static void update_curr_dl_se(struct rq *rq, struct = sched_dl_entity *dl_se, s64 * starting a new period, pushing the activation to the zero-lax time. */ if (dl_se->dl_defer && dl_se->dl_throttled && dl_runtime_exceeded(dl_se))= { - s64 runtime_diff =3D dl_se->runtime + dl_se->dl_runtime; - - /* - * If this is a regular throttling case, let it run negative until - * the dl_runtime - runtime > 0. The reason being is that the next - * replenishment will result in a positive runtime one period ahead. - * - * Otherwise, the deadline will be pushed more than one period, not - * providing runtime/period anymore. - * - * If the dl_runtime - runtime < 0, then the server was able to get - * the runtime/period before the replenishment. So it is safe - * to start a new deffered period. - */ - if (!dl_se->dl_defer_armed && runtime_diff > 0) - return; - hrtimer_try_to_cancel(&dl_se->dl_timer); =20 replenish_dl_new_period(dl_se, dl_se->rq); --=20 2.34.1