Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4046567rdb; Thu, 28 Dec 2023 08:21:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHky0nLN+ssGvHZSvP7YNwwnNgdkabQmJUE5ABACvR0Rpi9a9BDpX7ZR0w7fchxejBdUHGH X-Received: by 2002:a17:907:26cd:b0:a27:7da8:aaee with SMTP id bp13-20020a17090726cd00b00a277da8aaeemr235187ejc.12.1703780506323; Thu, 28 Dec 2023 08:21:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703780506; cv=none; d=google.com; s=arc-20160816; b=fXxd879LyndRKXuDQvGkyj9LNj2qI6aCXDzf4+1B9Uyte13NSNm5MWTuXz5vNOEed+ 7MK0KXpWripuW1DDb+moF14HYOvnbc+jn27OAuHTUgbX0ghrRW9h8jC2Kt4FEtir0SVe Plh07iS2fRpmFBWD1yHpZzbut9TYGJGgXotrc0iALN1aZns6dih5mpfgIoBKQP8ljSG4 FfbQJ3u0zWH7mDLAQ2zXhgRBmLuNIxjel/ONuuR80cirzRPBRPfH9NUJGhh3tx0pfbb2 T2p/O/uDONoG870YQdbPKlnKAiUP0b5jOwRD+OjTYmoFuEEpY9OjNaBEeeXCqvJq8teU x8ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+gTBczjz6Eq5plgRjAoLyqF7xwyEX6B2BD6x+zo4UNk=; fh=DRM6plsCI8NkPTNMqW1MgJyoMdP48iOwPYu2p4IOHEs=; b=W7JPb36O2/ezHXmKt5rj5/3M8GOdNAdlpYU+7fK5hjxkB3pRG9VW/HZJnCJuAPg5SV 4e1eCxK9Gwzp6Z6Ud3GmtqO0BJFt0lpGZN3hJM2oDCrYW4OEojlH2WAxfmMProwXC/bM qGuVAHliBShGVwJ11dzYxSwSH3k24orEucsjdySehF+bx0NUoHyFEXboMvzVSfmarOVr jOZMUl+5hMCmFAnx+IjJo7YfZuWaBiqXzS7b1RxPK4umGFIfBHv8Gw3EH0kHEUlYmGle rahVP0qCkD6iwCdiZDrSRWngF4d2sxbXkQpU2bMXzmbcMRZn8/ymAWAqIEu4ybUa2+jI aO8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=YFzJOf8I; spf=pass (google.com: domain of linux-kernel+bounces-12773-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12773-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id fx16-20020a170906b75000b00a235fc5744esi7025157ejb.481.2023.12.28.08.21.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 08:21:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12773-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=YFzJOf8I; spf=pass (google.com: domain of linux-kernel+bounces-12773-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12773-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E42161F22BF8 for ; Thu, 28 Dec 2023 16:21:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46B97F9E4; Thu, 28 Dec 2023 16:21:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=layalina-io.20230601.gappssmtp.com header.i=@layalina-io.20230601.gappssmtp.com header.b="YFzJOf8I" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 46BCCF9C1 for ; Thu, 28 Dec 2023 16:21:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=layalina.io Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-40d560818b8so35502855e9.1 for ; Thu, 28 Dec 2023 08:21:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1703780494; x=1704385294; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=+gTBczjz6Eq5plgRjAoLyqF7xwyEX6B2BD6x+zo4UNk=; b=YFzJOf8IuoYIdzySXywPa28gPm9jdE6WnQrOd02Lt8fGXrnGMMho9Ic4SZUcgXx8/K yZfyxY6jxvF65sW8VXJo6AGDugHSYTDam0xgnti9v+OlmbV5y3fd1kLn0si82lH8Y520 Xn0S3M8EAPoyVIA9ySyxJnCIwRTaBaVORGChzCRcEjWz+0qAWUPAGb8EN3JNQtdrY487 T4bP6EK2E/pRh2bCxxcOJMiSQHjfhaU0QpFfVyxsEK5Y7UL93t7LJvvAkUgF05VNehfG sfwaHJId466R0h2sqveLx4WZ4ECIh9VNy5Kdt6ed7RZBpbvyV/JPW7UqA//mn/3YMjn4 TgPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703780494; x=1704385294; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+gTBczjz6Eq5plgRjAoLyqF7xwyEX6B2BD6x+zo4UNk=; b=U5N3oP8PwBtHlIERIbm8g96Uzpw9Wvofl/zQUZCF/yjeNo771ufOnfIF+gJJedcOoE /dAj8lMITnblC2/+TbfOsvS2rGbQPm0HA6ax6FTPRNeglQ0LyK1Ke6h5491N2Fb2oxtS I1khAv19zfkg4fN/oxTcTIYbPc2vLIAWk7+b6gqIAsTZUIzOuhxl6pYMvSnaBN00QDVa 79K2NqwAjtP6kIupud9Jd/e0tpuSK1JBnvhR2jgRqs4DmKsFv18cbiHCQGyLHw+Y0wVa q78TJeqxhQb7nc5rhg3ceG4YqETEC9BxkbnhgOnuCdKzMXAO53imnJzzJJaBKSe2d6tj kQCA== X-Gm-Message-State: AOJu0YzWp3+XdGXw1skYCq0gYGIgd8lW4pK32tuAu0Ii/h92FqIUlbet Eb2+Ks1V0O9mdjfRcSs6QbO2XSs1nbciug== X-Received: by 2002:a05:600c:3411:b0:40c:7103:d9c6 with SMTP id y17-20020a05600c341100b0040c7103d9c6mr5855519wmp.183.1703780494349; Thu, 28 Dec 2023 08:21:34 -0800 (PST) Received: from airbuntu (host109-154-238-212.range109-154.btcentralplus.com. [109.154.238.212]) by smtp.gmail.com with ESMTPSA id v16-20020a05600c471000b0040c4886f254sm35707904wmo.13.2023.12.28.08.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 08:21:33 -0800 (PST) Date: Thu, 28 Dec 2023 16:21:32 +0000 From: Qais Yousef To: John Stultz Cc: LKML , Peter Zijlstra , Joel Fernandes , Qais Yousef , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Ben Segall , Zimuzo Ezeozue , Youssef Esmat , Mel Gorman , Daniel Bristot de Oliveira , Will Deacon , Waiman Long , Boqun Feng , "Paul E . McKenney" , kernel-team@android.com, Mike Galbraith , Daniel Bristot de Oliveira Subject: Re: [PATCH v6 01/20] sched: Unify runtime accounting across classes Message-ID: <20231228162132.mauucgalrcatvwxn@airbuntu> References: <20231106193524.866104-1-jstultz@google.com> <20231106193524.866104-2-jstultz@google.com> <20231217161927.vewygmvxvddhxs65@airbuntu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On 12/18/23 12:23, John Stultz wrote: > On Sun, Dec 17, 2023 at 8:19 AM Qais Yousef wrote: > > On 11/06/23 19:34, John Stultz wrote: > > > From: Peter Zijlstra > > > > > > All classes use sched_entity::exec_start to track runtime and have > > > copies of the exact same code around to compute runtime. > > > > > > Collapse all that. > > > > ... > > Looks like this actually got merged into tip via the deadline server work :-) > > Oh! That's great to see! The patch has been floating around for a while. > > > Though not sure if I caught a bug here > > > > > diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c > > > index 85590599b4d6..7595494ceb6d 100644 > > > --- a/kernel/sched/stop_task.c > > > +++ b/kernel/sched/stop_task.c > > > @@ -70,18 +70,7 @@ static void yield_task_stop(struct rq *rq) > > > > > > static void put_prev_task_stop(struct rq *rq, struct task_struct *prev) > > > { > > > - struct task_struct *curr = rq->curr; > > > - u64 now, delta_exec; > > > - > > > - now = rq_clock_task(rq); > > > - delta_exec = now - curr->se.exec_start; > > > - if (unlikely((s64)delta_exec < 0)) > > > - delta_exec = 0; > > > > If negative instead of returning for stopper task; we set delta_exec to 0 > > > > > - > > > - schedstat_set(curr->stats.exec_max, > > > - max(curr->stats.exec_max, delta_exec)); > > > - > > > - update_current_exec_runtime(curr, now, delta_exec); > > > > And curry on to do time accounting > > > > > + update_curr_common(rq); > > > > But the new function will return early without doing accounting. Wouldn't this > > re-introrduce 8f6189684eb4 ("sched: Fix migration thread runtime bogosity")? > > Hrm. So first, good eye for catching this! > Looking through the code, much of the accounting logic we end up > skipping doesn't have much effect when delta_exec = 0, so it seems > mostly harmless to return early without the accounting. > > Though, there is one side-effect that does get skipped, which is the > removed update_current_exec_runtime() unconditionally sets: > curr->se.exec_start = now; > > Which basically resets the accounting window. > > From the commit, It's unclear how intentional this side-effect is for > the edge case where the interval is negative. > > I can't say I've really wrapped my head around the cases where the > se.exec_start would get ahead of the rq_clock_task(), so it's not > clear in which cases we would want to reset the accounting window vs > wait for the rq_clock_task() to catch up. But as this is getting > called from put_prev_task_stop(), it seems we're closing the > accounting window here anyway, and later set_next_task_stop() would be > called (which sets se.exec_start, resetting the accounting) to start > the accounting window again. > > So you are right that there is a practical change in behavior, but I > don't think I see it having an effect. Yes, agreed. I couldn't reproduce any problem and I can't see a terrible side effect of returning early as well compared to continuing to do the accounting. Cheers -- Qais Yousef