Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp147780rdb; Thu, 8 Feb 2024 01:32:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1rdrAaeIqe2UdJaY3tqzB+RAc1uAslxiiVwHygbhF0ao1cwzuhS2ggphDqiCojAIEYDcs X-Received: by 2002:a05:622a:206:b0:42c:42d7:8df with SMTP id b6-20020a05622a020600b0042c42d708dfmr4707960qtx.42.1707384771848; Thu, 08 Feb 2024 01:32:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707384771; cv=pass; d=google.com; s=arc-20160816; b=ENKd0FaZOm9Yf0rFkUkDmQFrU1ZdprB4tZRuRpDAtWsM6h/yBgz6VBwv4b8dvH17ft ONOXfR/r7gyjgm8xT9Y7LzkU/ElC/jlmpn3emBwh7ClXBSaVVq5DLiPqfWIIkaWi3/uF k2ds31nxkPTLvxIOuVsA3n5qsYnxFCmNGs4H1uA5THv9sh6LjQDQEkEy7Ah8lGddLgEY YwCNYd4OuMmcCovjzi7jmkdw8SI+Wmc7CkDrLZHUbjj9U8MAiUYq+dAUjc2w2uYcKDFo ETlR7cJHEq8WOXauZEpPY2WMyHS8FpIAO0yBIvEWdg3vr88vJZ8iEe7gQyjn2fuaItj3 qcrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from; bh=b4DmtMaTMz+O5CnlRC8UdHLQQYCn38bZOmZn4L+fdY8=; fh=K8wQQoUZBHvyTciIXHgL208d819C7B4oM3yJpKU5DNs=; b=qpkBfiSvuKlzqP3QpY53DDolBBmNX9irEGZA+PiMl+cOYFLAH/O+AOPgbRyIZGU0nJ g06qYFGquBnleUuFnoBlTB4aH0NN3MeOShHb8R+AHd4uYHsOrXIH5SEo++IzCfYckiJY Q/EwOdb+mK+1szoogGBeBuAkH+hRBW3cyIgPmpCRMjZDcjDsEsQD06yNFVcFJw3Luup0 K2xZApum1JcgHDVVSd/FWBaZbedT/Gv8uRP6ijvqnoXbBK6+FdxcKWf21625PrkVRmp6 Cb+kjTfOn+g8V97vWEli6I5cTE8bjPe9Ah4gcN/Sdtm72CmoWTNGeGKxUQ+azPtj2EEc 3ddg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-57752-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57752-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXD9DTEnYAY59Vy09m7cgsIx4z3zDSZANbOIQtCZDbb764+JVdw7//TLHY/lzehFKTIB/Ekr8K+S1PYZtp2RIeM3V/zaOVVIvWMdsdJwA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s19-20020ac85cd3000000b0042c184e12cfsi3010360qta.291.2024.02.08.01.32.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 01:32:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57752-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-57752-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57752-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 972B11C22AEB for ; Thu, 8 Feb 2024 09:32:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1285A6BB42; Thu, 8 Feb 2024 09:32:45 +0000 (UTC) Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF05E6BB2F for ; Thu, 8 Feb 2024 09:32:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=222.66.158.135 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707384764; cv=none; b=i+hR/F3bZ2fVTb5Tne9cDsJMtr2LkzFmGhDd5ATi13Bi/qaAM6yZfs8V/4OkXXylOaDvurJXIODW6i/pUvH/WdX4GqDWtdPQp6kFqeBtoBiFVTC3DiIDBTkpA3vo5vv7A9hJG3J76cukYvIjhJsAOLVVq3OLxW7wSb3D7OOTs+w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707384764; c=relaxed/simple; bh=77RDjA7vu16sLKzoTYcGU4lvILnaItQ4kSRq9AXWhwo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J3f/KijE2Gew/xbBWWfEDAJNPLW1sx70aAvG2aZEv55RY5m2m2eZP568vQH2fib14Emf9qohqFoRlOrjw500TulKanh+gcak0si9iy/NDx9k8Fiv5023VyzK+y81begq6BxvSLA4N9nCmscBM8NCdpa6DNwL7LyXE77mrcr7sxQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com; spf=pass smtp.mailfrom=unisoc.com; arc=none smtp.client-ip=222.66.158.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 4189VnjY048930; Thu, 8 Feb 2024 17:31:49 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4TVsF769WXz2K4gjP; Thu, 8 Feb 2024 17:31:39 +0800 (CST) Received: from bj03382pcu01.spreadtrum.com (10.0.73.40) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 8 Feb 2024 17:31:47 +0800 From: "zhaoyang.huang" To: Jens Axboe , Peter Zijlstra , Ingo Molnar , Juri Lelli , Vincent Guittot , Yu Zhao , , , Zhaoyang Huang , Subject: [PATCH 2/3] sched: introduce a macro for getting approximat CFS part of a timing value Date: Thu, 8 Feb 2024 17:31:35 +0800 Message-ID: <20240208093136.178797-2-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240208093136.178797-1-zhaoyang.huang@unisoc.com> References: <20240208093136.178797-1-zhaoyang.huang@unisoc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL:SHSQR01.spreadtrum.com 4189VnjY048930 From: Zhaoyang Huang A timing value within CFS task could be deemed as being composed of CFS part and RT part(preempt by RT). We would like to know the previous value in some scenarios. Introducin a macro here to get its approximate value by means of CPU utils. Signed-off-by: Zhaoyang Huang --- kernel/sched/sched.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index b0cffc9c0f0d..a6f0051d0b15 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -179,6 +179,16 @@ extern int sched_rr_timeslice; */ #define RUNTIME_INF ((u64)~0ULL) +/* + * val is a period of time which composed by CFS part and RT part from CPU's + * point of view. + * This macro provide its approximate proportion of CFS part by remove the + * preempted time by RT. + */ +#define CFS_PROPORTION(task, val) \ + (div64_ul(task_rq(task)->cfs.avg.util_avg * val, \ + task_rq(task)->cfs.avg.util_avg + task_rq(task)->avg_rt.util_avg + 1)) \ + static inline int idle_policy(int policy) { return policy == SCHED_IDLE; -- 2.25.1