From nobody Mon Feb 9 00:27:18 2026 Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) (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 BD40C12FB18 for ; Fri, 16 Feb 2024 18:31:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108302; cv=none; b=CRRa83AkzCXeZS4TB5Hze0hoWJVsVrSAJ6T/lZfXjw0cqip3NWj0c2KZjph8RJg76GWrHjoB8ewNRvKDJOmyXTYrHVNyBWnXaFl0wL2hzN8KwWAeJg8V7W76mAyjSJBfq0HK0hEsDbO2FLuoUqJ7ml43EmtkkWKJJREWBngF0Ek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108302; c=relaxed/simple; bh=/tum2WF4xPzP3d2/oUJvAp904N/cyC9DIis13Mprwms=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HhhFfbGXCyGXvimt2OaVALuE1Bisilw0lodYH5/8x45glyZpKAanQ9ttBmUXYJOxg1U0Y9D2GRB+g2Hfctcv+rkH1pk49p3DTAdH78gES1whLOFy5UxA/dnZKCNngQUsAGHSGGOxtaVUxYOOwLQROP4gh6C52FbuJx4W9fqqftk= 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=jtG1w6j9; arc=none smtp.client-ip=209.85.161.53 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="jtG1w6j9" Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-59a94c0fb55so1148342eaf.0 for ; Fri, 16 Feb 2024 10:31:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1708108298; x=1708713098; 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=jtG1w6j9N5plCISXLHBSv/uwTyCu7EH8Sx8Ee3zv11t6ywmECZSmwpY0oybC7bZ5vs 3HQnp+vpaNyOiNVApl+5btIdCgtlyPizk07ugC55D8sOSb7Fu+M2dweor+2Qxok7q7wD owi1guotqKnwmb0LsKmonexOPeI+yra9+hN+4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108298; x=1708713098; 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=vzAEpyDBZ1jmtWKlJ7/pYt9oDhRAEMB7wuJLmC+sgWzG5F6S4UlWp0w6tz3Cdb/MvJ zzC6LzNZOannRnVLbLLA5X69gZFOms3Js0jIl0/xmzA3tGi7izNwQ2x/DwxUIn9Kc/AV j8lENOACWC45iAg/i1R/Dm4GoBj6g4HjA1j3ZX0xS5pa8Cp8e8dKwjerT7yVfK/nndEB aQlHibMQ06LPsUwcH0C1PYYVBHBKuNq6QD4RGLdU1lCDTYkN3tz5iHLFeAWx7BJTdDGq w4I2zIRbzpqaYLT30z2OJMHCSkGJ8x/7E4f34tKqB5Bmilscc0OlUfwLTWCzXCfnG2hq E50g== X-Gm-Message-State: AOJu0Yw8UfvwLET/uoBhZgMTxhWg/NrzQXSXgPzzwLGWFThEn/JqrCL7 2nsuVvfukAvvDJ3v3clV0sT5vIve9H825i3rE3gjI/Hd2zUFWeydBIp+UyLkYlS64FS1+Ibt1wB 7 X-Google-Smtp-Source: AGHT+IG4d+tTgEr7HVS2i1dyAW42NfNP2FA8s/3EREPMydnyHcJOKe6m7BgCYUEnEbDv0LJlWGMLLQ== X-Received: by 2002:a05:6358:3384:b0:176:d46c:e704 with SMTP id i4-20020a056358338400b00176d46ce704mr6500262rwd.16.1708108298409; Fri, 16 Feb 2024 10:31:38 -0800 (PST) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id nd13-20020a056214420d00b0068cdadb5e7esm159722qvb.31.2024.02.16.10.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:31:37 -0800 (PST) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: Suleiman Souhlal , Youssef Esmat , David Vernet , Thomas Gleixner , "Paul E . McKenney" , joseph.salisbury@canonical.com, Luca Abeni , Tommaso Cucinotta , Vineeth Pillai , Shuah Khan , Phil Auld , "Joel Fernandes (Google)" Subject: [PATCH 01/10] sched/core: Add clearing of ->dl_server in put_prev_task_balance() Date: Fri, 16 Feb 2024 13:30:59 -0500 Message-Id: <20240216183108.1564958-2-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216183108.1564958-1-joel@joelfernandes.org> References: <20240216183108.1564958-1-joel@joelfernandes.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 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 Mon Feb 9 00:27:18 2026 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (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 597E71350C8 for ; Fri, 16 Feb 2024 18:31:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108303; cv=none; b=JswvYlVhzzlhzzeghn4DjLQ+didPVce39SMJNgA4S2etN8ZgbWthI31G/SG5P4KkoJTlZg1P0lw+gXxCiNwJn693lOyR+6MX0P3Iv/6kPlViXruXDKFPHrBC/mCYUYcIQQDRZUUq6JVLfmCJrDU9MBV/sFLbBE1/SIsyRU4duNY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108303; c=relaxed/simple; bh=ZOaTdU6+mkYKcu73jBNLA/JSAJmZHt+8O8zlVTj/AiM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CpNxZGtHhm6Z01k2ZmWFu5OhKd1lN4Cfip12lKbb3nfxvEKtFV1adZcZst3FZA3SM3IQLr5NcbJTdgs2cLWuT+0CXABamg9JKF2AxHnOCOzWQfFqdRTxsq8GjbPFI+x7jMAbJWnfu5HLPCkJUJP4Kq2H6Y/tYbKQefUClpQk0RU= 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=N0SEb23L; arc=none smtp.client-ip=209.85.167.178 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="N0SEb23L" Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3c1333b0974so1781021b6e.1 for ; Fri, 16 Feb 2024 10:31:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1708108301; x=1708713101; 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=N0SEb23LelsStLT58qIHRcuxwaRuV+ph907HfptgXBYsWzkKUUA6vLZG8d8B0yWkgD 50vde9a1DrDily4MklVo7zvFUooP3m70ZqxC/tcveowBwH0YLvGbP96Sb4qMBKpLI+UX mBq2Zlphj5vn0HoEQlREACIte4xStNScB9C9c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108301; x=1708713101; 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=PBBSwq+vQfosGrsp0HRW3qII/WfkiiKcAoR7Uepz8mBAvSfC0RcqNN9KgruzAFAPqO jF5YXZ+Cy++V56W0dDCEyBeaBwej9ecgmTFp75icBp96K3ROlra2UjGJuzQTDluAoGkQ j+gwvD8nGNzgsj0tYDhhks1giLvWJt9ktziyxDHIVCO3Eqr1wkaxaihlXdT1MVhyPvNR 7EJYJXy55KQJ1kIS+7yGjGpE2bvuuhgxu3ETx5r+XH/FRViUmu2oBeVd9tOmoqv4ENJb aGJUSugikkIXEtdw5XtxkzpJLRNyz1d42ggvFztosgAzKSplWlFKdO/37F2tOlDgqF1T TWsg== X-Gm-Message-State: AOJu0Yyq2opdH4xOkPpoQgjh+/3v5EvaXcB8xhyHa8G97gOcm2AdjswK b/NEw6KqN0BlFYEGhgQjzyPq/744eISPqa9Fi4+zFLZGEsYZr11dol7uDTJYWTAgrEI1WVFUluu 1 X-Google-Smtp-Source: AGHT+IHfLlmYY2tH68nTJrzTI3LtFVSzFmMAcGztCM/IKH8k8dg4/JeX+ZCpu5PdJvYZxlHkpp3T/g== X-Received: by 2002:a05:6808:1642:b0:3c0:4d21:e62a with SMTP id az2-20020a056808164200b003c04d21e62amr6746614oib.31.1708108300676; Fri, 16 Feb 2024 10:31:40 -0800 (PST) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id nd13-20020a056214420d00b0068cdadb5e7esm159722qvb.31.2024.02.16.10.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:31:39 -0800 (PST) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: Suleiman Souhlal , Youssef Esmat , David Vernet , Thomas Gleixner , "Paul E . McKenney" , joseph.salisbury@canonical.com, Luca Abeni , Tommaso Cucinotta , Vineeth Pillai , Shuah Khan , Phil Auld , Joel Fernandes Subject: [PATCH 02/10] sched/core: Clear prev->dl_server in CFS pick fast path Date: Fri, 16 Feb 2024 13:31:00 -0500 Message-Id: <20240216183108.1564958-3-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216183108.1564958-1-joel@joelfernandes.org> References: <20240216183108.1564958-1-joel@joelfernandes.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 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 Mon Feb 9 00:27:18 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 924BE1353E5 for ; Fri, 16 Feb 2024 18:31:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108306; cv=none; b=kU62QZ2j6tKTqrOha/28zw58wx3S72sMhrKstVkXj9ghHz4A6GlD6ZU2mSb0hYvL68eFDhDsmzHi0iLTcNK3ph1ZAFIkLpWhDm8ETLOmi+GUuNhqlirjdCZs3W7xn/GsT33rS4O6jBTizfV9E/mwPQmiQUE/UgBGfk1/WqRT42c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108306; c=relaxed/simple; bh=BiiWEkX4I10hm0Y+ah7m6xE4dk8P54pifKn/ZYznW2g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OiKIgvF8AxSI+vro7C02ozjVfpp4HVmklJLcM7hQDahj73lRON2rN15k5A6UmjNYD/E1sQspIeKx25xo7EPGdHZ0qyxD8AYDcQsef1vV0LBWyG5UEOieT/mjUbnApduVVlQnvwVac0akdjH4WYaYMTA42Exxh0r7BttH9KPKWiY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org; spf=pass smtp.mailfrom=joelfernandes.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b=affI+dTq; arc=none smtp.client-ip=209.85.219.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=joelfernandes.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="affI+dTq" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6818a9fe380so13862416d6.2 for ; Fri, 16 Feb 2024 10:31:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1708108303; x=1708713103; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OS0mEpzEEFGetzR6NtkyoXN8TWiVnIyPmeWduyYdhXs=; b=affI+dTqhOv2xxiSZ+dyvFmb9JgvjzInrIzZuv5+cVOuNMWSXyYCPrRBeu5iS4mj4c e3ZZi19gmrTb9jmmBE86fqdT6OByBU8C9BGmkOSvKzc8oYoqF7jQvVD2cClauReYKhqn 45LMMyZ5Og0zZl0zp7vEoRXaxykck4RXtdQdE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108303; x=1708713103; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OS0mEpzEEFGetzR6NtkyoXN8TWiVnIyPmeWduyYdhXs=; b=diZ2AmVR7USHZIE+eyrDqc8V+zoHfghYKUqi8Ordkbri3mL0dIbEWf38Wi0bE8/E6R dRWlbaRoBF5MLq8xokYr3zEpI97SCMDsh0VQovECaYuaL2N5NxDnRdkcbKZex7kr7N8i biLLYirQmQOA0JdLPfxotrYSKJuJmcS3mZZx8WMnenvjkU9e7LoQqBMpzR60YdMxLFGk qGqccW7Np0X3pJ/5gubNYwkYsqU+9DPDUp4iwfiYeruL0E5uL1L5aeM1Pjx6reWi4yO6 qVO56/jL764PIdgRXLHYVNsd5hHKROYI8TA0fAwtoLrvDI1cBAsNaaeuxBiQ0UQXpQn2 SHmQ== X-Gm-Message-State: AOJu0YxhI8TbtyzbPLpZfyeTC+75zt2cMTuS25M1Cn57fIaPZ/MU2oi0 QFwFqhmBXdMTGcMS2w1o1MS5odrpBaABtUnxgg4rACyDIsP0RC5RZ6MMSSpjFy+17glFEynuufu L X-Google-Smtp-Source: AGHT+IHBo8ZmZGNl4vr3CeJCFDtCUPLEwDFNgk+oyNvQak4sFIggeBOWvdQftkTYFaUjbF5QR3fWwQ== X-Received: by 2002:a0c:e38e:0:b0:68f:3ecd:840b with SMTP id a14-20020a0ce38e000000b0068f3ecd840bmr1086525qvl.23.1708108302915; Fri, 16 Feb 2024 10:31:42 -0800 (PST) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id nd13-20020a056214420d00b0068cdadb5e7esm159722qvb.31.2024.02.16.10.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:31:42 -0800 (PST) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: Suleiman Souhlal , Youssef Esmat , David Vernet , Thomas Gleixner , "Paul E . McKenney" , joseph.salisbury@canonical.com, Luca Abeni , Tommaso Cucinotta , Vineeth Pillai , Shuah Khan , Phil Auld , "Joel Fernandes (Google)" Subject: [PATCH 03/10] sched/core: Fix priority checking for DL server picks Date: Fri, 16 Feb 2024 13:31:01 -0500 Message-Id: <20240216183108.1564958-4-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216183108.1564958-1-joel@joelfernandes.org> References: <20240216183108.1564958-1-joel@joelfernandes.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 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 Mon Feb 9 00:27:18 2026 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.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 83F8A135A55 for ; Fri, 16 Feb 2024 18:31:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108310; cv=none; b=b3nVVwMX2+GYVPkF5FFqXLJAlwRrLK3YUvgBTmTL9TdNe+zEIVXduqLRj8rs1iLxOw556KpXSiOldkfXNJOtOgq4U3+BPEw0aepbs9xGaRXkMzcQBBvJSeMb1x4wqTJU336EHwL8UYXCH4IdbTiVnIaW+2h+bdjMETRyQJHkgF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108310; c=relaxed/simple; bh=hNtzJxrNKpS3WmLYndaWMBO3so/VD/gQO0uqcJZ9FDc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yteq4Rl/ecr1SEt0ocOq1Gmo3iNK79YkkxxjIpHnlPSj/RmxMNkHRBrFME/p8evDCGNg1TsIwpUMvLw+TPQCS8+NLzLOIMiVTUfT3th/hn59BLH1qVHkE2WrYVJFFC6leRS1h5zmpLeiARwNVrr57EjKlSRCl9qtY+meqPWsR3E= 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=CeyE2qJQ; arc=none smtp.client-ip=209.85.160.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="CeyE2qJQ" Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-42c758f075dso28644121cf.0 for ; Fri, 16 Feb 2024 10:31:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1708108305; x=1708713105; 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=CeyE2qJQQJZ35mXekLyB86cXhkXFSbDxRT9lZ9DQpr45yQ9v082goouHNxfg1foozC 6PB0fJ680jVN+s+lLFaJCZ/bRWFow2Ny9QFEHFdwyt61xfpDQ3DCoIvnqdRLe2EUQvr5 xVb1yt0CWobqdlWkhE/97mu1Dwj9co2TipWQA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108305; x=1708713105; 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=b6l1gQsoQCB01lIoD4RwT41s611YxKpidN0rpk3BVIbKkjztVo1vB9VK7DQbt+CFvS pQF2yNpmD41AAa4c/K6mFs8h4aoHw3XJJm80jCmZsjDGcjExOstqbYIfgfyHYbBM4hWb qgMOzGmlmNT0ovV4w6VWW0CHKXDqVBSXe1GZY+JkTRrlKIXG8Xgv4p1DZHTojh2L4E9T nLQeF1p6Aq53YD6Fu05qZlkd6lS10DMzBDk6lrNxYtHJm17IjY+HRGCTrexIR3LZBW7e V0UphFHDlZ54aKTb9av74TSO5QORpDLhx+3OUmWUNV8EB59arLKiOPUOhek7IBJfs5V8 ffGQ== X-Gm-Message-State: AOJu0YxcI5fe0yGOWfrzpb40QEo/TU0iQhUyDWBRTKFzlrsvpulNE9Y9 dhemF/OoXVN1uaVVTIFgTESJsbyugTU3IZhzAxHg1JI0YYL1p4gCtTDuZLOo4EIO3KOLptLEv3t 6 X-Google-Smtp-Source: AGHT+IGtapIZSGJEWHqUvJNtGggfyhY0BnHoicBTpBbCh4J5VImko1k26gN2OiIiEvBLe0zTdUeaxA== X-Received: by 2002:a05:6214:3a8a:b0:68f:1102:680c with SMTP id nz10-20020a0562143a8a00b0068f1102680cmr11071161qvb.5.1708108305165; Fri, 16 Feb 2024 10:31:45 -0800 (PST) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id nd13-20020a056214420d00b0068cdadb5e7esm159722qvb.31.2024.02.16.10.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:31:44 -0800 (PST) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: Suleiman Souhlal , Youssef Esmat , David Vernet , Thomas Gleixner , "Paul E . McKenney" , joseph.salisbury@canonical.com, Luca Abeni , Tommaso Cucinotta , Vineeth Pillai , Shuah Khan , Phil Auld , "Joel Fernandes (Google)" Subject: [PATCH 04/10] sched/core: Fix picking of tasks for core scheduling with DL server Date: Fri, 16 Feb 2024 13:31:02 -0500 Message-Id: <20240216183108.1564958-5-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216183108.1564958-1-joel@joelfernandes.org> References: <20240216183108.1564958-1-joel@joelfernandes.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 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 Mon Feb 9 00:27:18 2026 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (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 DC7B6135A7F for ; Fri, 16 Feb 2024 18:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108310; cv=none; b=At77EbsyA+4PQQ1JAaw5YZa6hfPQvNTphInLJfu3Il+v8G88A7Um4qV2/vQf6KGxUGmYLJUGBg0Ijfbur00mYSzXZjtYBfUekMeIZoqvlcSmhHdWhDj4c9Hs+SWLal+N995qjucWLYU+b8BRjSw77n1Z+uwo2OahxT91+KwNTOg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108310; c=relaxed/simple; bh=BdbG0yYlQpcAJTV+cb1BRObS/3sDHMAKLat6xu5MQUI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ka16JsMSJnsUFTpR33OIX1S3Yss8+la4r1xVm3GpkaDezPn2WY71I9nR78GSQOPrEQ58etLWvW2KemEHE3Jeg/HxPb7ozXOv90JqJ7MgRDoLQFv1iitnjYCSSjCD/Aq74jhiN7xzAdbHXULMz/fa/JGrAC+0GErYixXnaYGOAvM= 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=bCBBuWpQ; arc=none smtp.client-ip=209.85.219.41 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="bCBBuWpQ" Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-68f429f55b7so559466d6.1 for ; Fri, 16 Feb 2024 10:31:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1708108307; x=1708713107; 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=bCBBuWpQNaNjqeDmb9JQNQd6M4Tf5qyq3qj4KuPzKpG6UNtipEGWIVqM0AWhnRJoJP j/mCSmz0i2+Av6GXBWugAl5tLOrNHQzc3QzFLw0UyoPGwZ+FVj+0y427MX1eQ+O/O+o9 5JXEjxER3QIn4nmdrGrrkTUqcYjZO+eC1y6zs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108307; x=1708713107; 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=vbCEcHvy5ga77oqRDNo6tT5LOjo7YIB7h8UEwt3nRIqE47F8zfwZY8vEGLSR78HLgb qJpZDX6mWGc/zuBNOy8ouPzPDECN7wL6Zg9h2sSeMa9DqoxqzjidRl3igI0KA2+3xgwh HMTbBpQiy7FspANSxGI6v8OsHuipzKzm2wH+jAmjxb+pwS6pQcVOJ6ztsq3E5aQW98mh IhryW3lFbZ+HbFyQ5h1BjSe9WC9pkztwVUpGQwoVx0xI0k+lXGJpBu0niXgykLJUGZkV zYntrQYZt+Z8/wp54jtCHd4ghiR5TCJa3T/kHSmMS7ARjCnUsJ6I3Trl0fPuuwdlCPpR TU4g== X-Gm-Message-State: AOJu0YxMIMgWlML+juUMIKHxBEamQ3tyS/fXdm5NItiC+kO8di/VoTQ2 Py7HqYVpvc3Zm1SCTqyiXdqwI3800+ayn5X4xWXgHnpHFlcR7HOu4xDSZu89B9cJEfNvFlbrRWa 6 X-Google-Smtp-Source: AGHT+IEgm/Rt03+CeLnQ0S8r32mOvp7WezqLoTo4VJlM/CGcCwSRr9+Ve15KD4TNaat1Fb+SopCMdg== X-Received: by 2002:a0c:f0ce:0:b0:68e:f036:f5dc with SMTP id d14-20020a0cf0ce000000b0068ef036f5dcmr5456748qvl.15.1708108307279; Fri, 16 Feb 2024 10:31:47 -0800 (PST) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id nd13-20020a056214420d00b0068cdadb5e7esm159722qvb.31.2024.02.16.10.31.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:31:46 -0800 (PST) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , 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 05/10] sched/debug: Use unsigned long for cpu variable to prevent cast errors Date: Fri, 16 Feb 2024 13:31:03 -0500 Message-Id: <20240216183108.1564958-6-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216183108.1564958-1-joel@joelfernandes.org> References: <20240216183108.1564958-1-joel@joelfernandes.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 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) --- 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 Mon Feb 9 00:27:18 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 557F11369A7 for ; Fri, 16 Feb 2024 18:31:51 +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=1708108312; cv=none; b=lB1tCzJHCRIdnRfbuugMuw0ogXOmQZgZA3eDAdOmw9ApUgoMWp+ENyYuvPGrZ1blpz3HptOFt8vppNataLoZNCTq0QS87rXWupFRHj5RUINha0sVULNoopctIZJSEFcNOo8kXlvvZ1FqCYhHKIVRjMNpJH6UyBikFCXI5/Izkkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108312; c=relaxed/simple; bh=G1fDd4qTQBCk+lDij0THy4jcCMe3hYb5TF5caIUyaxo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lCw0lztQUgbD1qbjH9R4TYO6sAaNryf7dDjLN1A/RPBiyt3BO+e+bu6ZBB90Q0TFFjSSPQR2+dvZtUr3egvPFAmTi5BDg5YXOOogK5QupyApptMV5lGhUJt2FI2TcDWxYdnaJeFi7eZm6K7KOl5E36Y6M/rQ/Fh/lMcjh0aclrg= 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=glu0DniM; 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="glu0DniM" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-68f3fdcb59aso1160786d6.3 for ; Fri, 16 Feb 2024 10:31:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1708108309; x=1708713109; 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=glu0DniM+b37P/XLwgGTJaGXenX6CGg6rvtGC/nmjfmDD3KmB/ymPgiB3AujHkbPN2 iWchfmbPBdW+m2Jq4fMtIckhxoiqE74kSFdzJap7CsyZzH3WtvTLoTRl45Grmalfr0Ue 71S50n1jDEc4dNzLFN6xTY6Uwpb5iJYVBef4o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108309; x=1708713109; 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=BJweHer2GKKudEKUDO7gyKeeUy6NnkIAj5lAvoYIzGChma85J9qdofHJXA38bDM+qU XPM5JsuPkGNnKrV6rFyR4ft5YvUhvZPZTGsSqKcLEG7FU02fSPDyYD6cu19Gy5PmQs2u 4uuJ0BqfKdndPXw1dIkaJaHulZFl/pTc3AnIbht1LIXLinpksw+P0AW0a0JDljUeQyGX FTNZRUWCgTOu755uS4U4ccBqqBdB4K2joUMRNfJ+qPsGfE3Ijk60Nv6fdF0TqI/caw5P aDvrgBPOz5d6T29zJ7K6tkcLUndlHDkkK/BvM+4HUWgIaq2F84tJ3QIfU8hM0SirNJ3b YZWw== X-Gm-Message-State: AOJu0Yzf3Y6mh5/sAGvRZrd6+2Y8A0mAbM8RtEq2+6C5YpNe6CytUCR3 GQycpH44J3aOQFTwJ5e1jQgKacrGz3YxtFOGmOZtyjibxolJ9bjDdpQmwTqXfaWU5CSRtHAdhbq h X-Google-Smtp-Source: AGHT+IGX8etptNM0tQd8HIVEAt7iS6dgP4kiS0uoQjpaIC3GY5i5pMiXKz5HRYZ7XJ+N8MEtyN98LQ== X-Received: by 2002:a0c:f38d:0:b0:68f:1e7c:5f46 with SMTP id i13-20020a0cf38d000000b0068f1e7c5f46mr4945535qvk.45.1708108309141; Fri, 16 Feb 2024 10:31:49 -0800 (PST) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id nd13-20020a056214420d00b0068cdadb5e7esm159722qvb.31.2024.02.16.10.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:31:48 -0800 (PST) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: Suleiman Souhlal , Youssef Esmat , David Vernet , Thomas Gleixner , "Paul E . McKenney" , joseph.salisbury@canonical.com, Luca Abeni , Tommaso Cucinotta , Vineeth Pillai , Shuah Khan , Phil Auld Subject: [PATCH 06/10] sched: server: Don't start hrtick for DL server tasks Date: Fri, 16 Feb 2024 13:31:04 -0500 Message-Id: <20240216183108.1564958-7-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216183108.1564958-1-joel@joelfernandes.org> References: <20240216183108.1564958-1-joel@joelfernandes.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 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 Mon Feb 9 00:27:18 2026 Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.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 DB792137C5F for ; Fri, 16 Feb 2024 18:31:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108316; cv=none; b=lPnuoPQTshDqh4yhPNKlv921wlo/K7jvZJxD3T60j0dge74PerQdfE4lPtV8bhTNmzqtBMxt9Jgk1+yA4Bj1tZJwn4DYzMFNwJ+g0j5Cm90E9wuujSiErgPUx9T2nSVRkfhKHVI4i0p7iGLvH6sURHv3lX7oOlM9EfRhsMU3+ms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108316; c=relaxed/simple; bh=OSrAg2NG3ZYsMO+/bzATjsRdKuLLDdxyzjpAKJt8kcI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QmSycv+SglgppT7zIKpLjOUir86yxsdpBpuR9SL0GKO4hjuEZ7g/8+bSmgQkVAhG4eCX1AFmz+mT5qwn/wcNKTpukMQ8ApDC4N6s9Z8xEr4edYYjEmKCGwawase3chghKBNeyZj3ULyM/x6nj9zn4Wa9s6chFjk9zNr8HDpZrYk= 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=IWLjp5kO; arc=none smtp.client-ip=209.85.167.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="IWLjp5kO" Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-3c1333b0974so1781265b6e.1 for ; Fri, 16 Feb 2024 10:31:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1708108312; x=1708713112; 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=IWLjp5kOd3hA6PD7W8g/XiIb7drzezRD/dyQvKXbO9e+voJzI6qDg+tRGwSsYNaXJM SotwRPZmBAIxnLIQKZzK1fpWs8YSv/nmO7jSvX1ovtUMs/k+TgAbuPAgm54koNAdgoVs N+fX7a53cfvDMf7h5iM/eUPP+N5ntSylj2QPQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108312; x=1708713112; 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=izAOeDaJKQ/mjAXymzgO6FEzxfLGu7Gan+RK1wySTtnltYWM+awkFyHIAgnNmoLyDE DWMrJlAeDYgOqIwZlcaeNqVceXZc/lYPCaPdbGUujKHUZSoOPxo7D7+MBM9W7EpsJLvl IP4eCfLOuUZNkd6l+xvhJqiIA1Pp3z23KLww732G6FEBtTbiJYtTAnKM0orS/KfuEv0Z Ic5DeRdONv+zLca14+fUzX3r8d1qHn0DlyAGPq+cJ50nVpx9/wzf+51cL5BpszcDw2h/ yLtf2sSeJQ3IORMyf9KlDCsmBv9bpI1bdD5+bq0J59aNMMb5cWLn2dEMKZxmKGo7AVgL vJ8w== X-Gm-Message-State: AOJu0YyugUReleA17wVYX/maCBFEL/o3x/D3kbNIUw4FgJyqaa5z2NI/ aQZyGkaVNj3PC4tjY6PjPcCiDcG2bW0Blj4igho6bScLF8WVPV+aopXkfkuMhNr14buh9bW0sI6 P X-Google-Smtp-Source: AGHT+IEE7A2/TJwSEhArltOB3UrmLoXJF/SdE7sg3qzp5oni/oYQqIESe/97hAGPhadzbXunlifSeg== X-Received: by 2002:a05:6808:1309:b0:3c1:325f:4527 with SMTP id y9-20020a056808130900b003c1325f4527mr6544337oiv.40.1708108311913; Fri, 16 Feb 2024 10:31:51 -0800 (PST) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id nd13-20020a056214420d00b0068cdadb5e7esm159722qvb.31.2024.02.16.10.31.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:31:51 -0800 (PST) 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 07/10] selftests/sched: Add a test to verify that DL server works with core scheduling Date: Fri, 16 Feb 2024 13:31:05 -0500 Message-Id: <20240216183108.1564958-8-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216183108.1564958-1-joel@joelfernandes.org> References: <20240216183108.1564958-1-joel@joelfernandes.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 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 Mon Feb 9 00:27:18 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 1ECFB134CCE for ; Fri, 16 Feb 2024 18:31:55 +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=1708108319; cv=none; b=m35VZ1lFWRBhaEtmLG7oMsQl9LdRpRRKvaB18PsVFnxq3k+y2rqDImRc9b5bqP8KUTwDm8IXIVPwwQkVC+6TFyC0WoKC4LIb6hu/3lrSIjpwSwW9FJXbAacgAMtttmOiCZPl1MXBYgOpTGQGXoq9d96C75jRhsmEP65a6P98WVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108319; c=relaxed/simple; bh=mZ2gOIXcUxYPUWs6+iWh+plbgTcX3Uoy+H9V33hkCIo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QkXXf+iTroUwqpWgtgTcwzpeVQmzY8fwEDEd+QO11aqc1tpXe25QC74HSzz1zDu+vslG5ecW8DRubooIJ8+R6n14MOU8c1yLibMmhFSPn4PFD3NccxzJFAJ6yWoUTth0GyuChJu1OY4jxdpue5au4vYr4UO8dPEn93epnf1wVX4= 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=T1FQqQW9; 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="T1FQqQW9" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-686a92a8661so11902706d6.0 for ; Fri, 16 Feb 2024 10:31:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1708108314; x=1708713114; 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=T1FQqQW9TyHh7HgT+F67Khdj1PilhW3VPjsjqYihnfFaIn7pw8ggciDJAkQGDTSSBI iqoTmDz6YS4G1PF1+7y7A17Uu3oZhNRu0a1tRPTOqV+6v3KDzJ2nGLwkEIUejXwMqCkv bEyROjqgxfZs9uHnGSFc68A/67hVrl3WKckNk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108314; x=1708713114; 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=lI3ISlLeHh3kPa+wHgN3Ii5S+WxW5iHf78G/gZDmtEkA+OaYDlAwjdbqXsXwUW4pji Y0atdckzYXe5M4Gn654kAzRRsPsuZcg1fQ6SyvI5BZK74pY258lKOGdSGPyZ67Gz5zlm vUkrr2s51tp3+fDCM8aNde8pIeWo+SYiSvV8cb8Yw+OEZUA4y8vAH7DlLxouJjVF7Qct yVDnR7x6IDWqpf4LUJqW+CPMlof2GhKsYJ4zg/S4ltRFqYmYqN75NgBFp6oolrzHME8+ slxky6gvzSCzxtu2fof+m12UipATb072nLchOLKsFGgpo6EQ+egLAVTONybV28kmOMMG 7EBQ== X-Gm-Message-State: AOJu0YyR721HDtnq1q6diSwu93X/KZ89iTEW4wBgRSoPVrcNo1/z9/FN +Qgs5QXYC7w2eNCyO7nR5aHmi+1nPIoOGKP6I5V0L/3ECOg8HIh+7OyIDO1yuXmz1zdACo2DdVq n X-Google-Smtp-Source: AGHT+IGhLeBZCvEV3RiqOD8Gk2JJl2wSyxA9sXMztIfDCRh/Q2EdnLcbUU8EEBlGLC3HNXEpawOwhw== X-Received: by 2002:a05:6214:5904:b0:68c:668b:c610 with SMTP id qo4-20020a056214590400b0068c668bc610mr7398414qvb.2.1708108314017; Fri, 16 Feb 2024 10:31:54 -0800 (PST) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id nd13-20020a056214420d00b0068cdadb5e7esm159722qvb.31.2024.02.16.10.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:31:53 -0800 (PST) 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 08/10] selftests/sched: Migrate cs_prctl_test to kselfttest Date: Fri, 16 Feb 2024 13:31:06 -0500 Message-Id: <20240216183108.1564958-9-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216183108.1564958-1-joel@joelfernandes.org> References: <20240216183108.1564958-1-joel@joelfernandes.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 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) Acked-by: Shuah Khan 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 Mon Feb 9 00:27:18 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 42DDE1350D2 for ; Fri, 16 Feb 2024 18:31:57 +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=1708108319; cv=none; b=J5Lj/P+yfAsOqpKQ/U02wu2+oW44FH4nP99PCMWO9IjsJhB12B5n1kcUnPjo+syaCtmBsVv16EWS0Z9aZCdMEI02tlj37uHcZrAzIV9KW4luqlv4VSSEdxlWtzGsTRzGhle+BRsXkAwXezWTYG9mu2yAPEc6z3fIwOn9Ir8ibGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108319; c=relaxed/simple; bh=cu3MMzOHuWJKImjKqYJ4/NXYAdw+8BhcKEGy95D0Imk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YVEgxKwXQuy5HhsAqPP4G4PjDxHU1FUrRSVrqAPZD4ZBZ/4FR1UjI89uKZxmz/8Kqzw8ly1jQMBXaSksQsjpydtR2Cm8VxzROqWFCb3v2czKDT6uOdCC65SPAmdqnq5jgdixo/MzCBbL2KlgmTMmvevLBy5spIlk0fsxkekgAZg= 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=g5RWjmtE; 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="g5RWjmtE" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-6818aa07d81so15849196d6.0 for ; Fri, 16 Feb 2024 10:31:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1708108316; x=1708713116; 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=g5RWjmtE4GeWFZAaV/uIOkmk7lxOE7p7YrGvVJmAcKzXvTzNblJIjIzroSJ1DZOx8s 10g4s5s2oVoLfPMsw/ZdSlJcCRY/0V6duVc/nPqY+7wYUNTvLMH+bgC1ZNqZWi3hLG1Y Yg244tgwGgsbBZ1rcW/qjluZ+b7u7d335ytdM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108316; x=1708713116; 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=WAIQu2v4gTMzLeSE93OM23AF12QpTKC2BO8Gl/awIoRkI2bVmQATw5UhqnZ14vVdxy D5C7SBR94dGqEGwZVBKOqM2uN3MfguDVFz6Ic1KZ3/3YA9QY0J8mLRmy9+6EJgvKKz7H +X45+zHTeTt7TNoMkB6vVuYnxMWJ6+lKb1TgbOO9ro2CJ9BGybK0nY0E6e/SVkgIeBXX Omx/XmkYgLwmdSS5Fep6hTyebL8+fbm13Dpp8U1uWSZ7WBih7RDtkifH2xE4rq3lS0NY W2f1cdugKnj0pN+2gZLL29Xm6kBwl9qhSBTZ5HVi0dx8Hi/e+ApzpJ2J+bmwGytgJCaV NYSA== X-Gm-Message-State: AOJu0YzspS2xvuJnMoAkk1Dr+aVfnqS03PZl/iaX262nm9Xkz7mDygNa N03HPQSYGPzhNeoL8EaJJwrFTiE/2RKhP3zLncWe3lYreeIANRvIvpHnWhGIt0kUHd9zJyImtci w X-Google-Smtp-Source: AGHT+IEMG/tv2++C9Upd1PzGPby/mwewGK3XuvH9GyHJN5ozTK/AseozSEHuW8OieKt6MmugUwdvUQ== X-Received: by 2002:a0c:ca0f:0:b0:68f:144f:4c4 with SMTP id c15-20020a0cca0f000000b0068f144f04c4mr6750511qvk.37.1708108316068; Fri, 16 Feb 2024 10:31:56 -0800 (PST) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id nd13-20020a056214420d00b0068cdadb5e7esm159722qvb.31.2024.02.16.10.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:31:55 -0800 (PST) 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 09/10] admin-guide/hw-vuln: Correct prctl() argument description Date: Fri, 16 Feb 2024 13:31:07 -0500 Message-Id: <20240216183108.1564958-10-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216183108.1564958-1-joel@joelfernandes.org> References: <20240216183108.1564958-1-joel@joelfernandes.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 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) --- 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 Mon Feb 9 00:27:18 2026 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (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 AC92013A88C for ; Fri, 16 Feb 2024 18:31:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108321; cv=none; b=XdayfiBthx4Jh1CX2fcq8kcw8TrCWcTyvfmb2or0Os8xhQJzPaR08CAudiapJ1tpZ3GENSxHTbVPOoKsFLZ90+F9ncnVbgtD4Znw5x2CAOTuahdtwQh+/VQAoOzzAm+/weV6MgC4HpmCWjTuI3kb+JnF28YlbVhgplzmm6yh2q8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108321; c=relaxed/simple; bh=o8njkdLQwpeSFKVUbv1Vgg6wMteGEmlFXV/7brtrrq4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mb9xhuBtoiClZH7c0H6DOQk/Zdld1n59kCl8z+DfpiNRnRJxpvOCOcqAXUBJbiEhjW+GLhnJm5Tev1k5AnfCnre99Uyq5GzGZFk0mNws3wbi3EyI630Tpl1ziWGMjxSKBAiMg1bykk01Nb7AdlXcRmTAvsi9Pk/d2PeUUjAHeVw= 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=RTI3IZt0; arc=none smtp.client-ip=209.85.222.172 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="RTI3IZt0" Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-7872ade6f0aso55512985a.1 for ; Fri, 16 Feb 2024 10:31:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1708108318; x=1708713118; 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=RTI3IZt0wq+6/wGYTtp0kX1KgE7ZTrBGCvNgfzdabuTMLsiY9itQArhMd4Cikoz1ez ceKRROrCAzSjh0xtzAFtiQ7821XRu97ZZulp+iJ0U4Ykm0QMomY+SUG5ezJ692/NMXXI frFVKtK/uZgvnfi0rW0z2hyVfaZ40NXxwsKs0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108318; x=1708713118; 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=cn4iOX+rB2Dk+aQ2iDPqQZWA+OJLC+FEbgRDplIo370kP2Oy6AI4tnYVxez46bpYYs UIB+IG0vak3ZBN/bbQuWw7QTtFaSONOxcN++/d1c9gaacNCvHpd/APsa0iJV+oaPcZU3 hKC2i4iNgM+ZOAYRT0WcjO5FDuOcsq74ljOUfDumkSHQbhdewnQV26SnH8q3BHj2HdQs Udacy6ytLWO6zkfrQENa5/n2XzLs1Nqbl64RiwmxxlY/IXwOHZQRx0Q/RLuJaAqvEMet /N+djVGq43hC4MUyoVCSdtjLDJYgTSdGoqwxJvYsTAQpzCiPCJTjAaND67v2/lcNKRf4 fQtQ== X-Gm-Message-State: AOJu0YwYWkpLVP4r8s2kai0dg/zXh3PTOTbry8FCZbMdtbFA3L4sD24v iq33UAMx1zTexibELaI7rknMteKaQXbSmtdgPWP8jYCUhj4aPMy8Ht4tDPUJzSsYDHZtzhcx7MX n X-Google-Smtp-Source: AGHT+IFBKuy553o0SxY+baIXFsZYeaJKSoNLM3xELgWqh57AsVbOsnUirYjkQQVzjewQhFJtyM+wkw== X-Received: by 2002:a0c:f38d:0:b0:68f:1e7c:5f46 with SMTP id i13-20020a0cf38d000000b0068f1e7c5f46mr4946028qvk.45.1708108317858; Fri, 16 Feb 2024 10:31:57 -0800 (PST) Received: from joelbox2.. (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id nd13-20020a056214420d00b0068cdadb5e7esm159722qvb.31.2024.02.16.10.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:31:57 -0800 (PST) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: Suleiman Souhlal , Youssef Esmat , David Vernet , Thomas Gleixner , "Paul E . McKenney" , joseph.salisbury@canonical.com, Luca Abeni , Tommaso Cucinotta , Vineeth Pillai , Shuah Khan , Phil Auld , "Joel Fernandes (Google)" Subject: [PATCH 10/10] sched: Fix build error in "sched/rt: Remove default bandwidth control" Date: Fri, 16 Feb 2024 13:31:08 -0500 Message-Id: <20240216183108.1564958-11-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216183108.1564958-1-joel@joelfernandes.org> References: <20240216183108.1564958-1-joel@joelfernandes.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 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) --- 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