From patchwork Thu Feb 8 09:31:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 198254 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp47898dyd; Thu, 8 Feb 2024 01:33:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYBv1KHUzkyNPW8+U74/n62ZvZ/zwXxInZPhc09BQU1Ks12FI83djezjSupQ/J9nIkfvP9 X-Received: by 2002:aa7:c88f:0:b0:55f:961:2621 with SMTP id p15-20020aa7c88f000000b0055f09612621mr5916498eds.19.1707384789693; Thu, 08 Feb 2024 01:33:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707384789; cv=pass; d=google.com; s=arc-20160816; b=0wJc3D8LRJC/L33VDYesvukZQP3JzqYAjPmx/JZh10gac6qiNNZriaXtTdrEMBjXYz J/thjZ/OYCUpFXvYeRc+el0UPxATQiMF6vGFogfR5HfPtHhvDad77+A91v1CCfDxbwvY jl87RGFXf5gKcR5VcTw+GAUZDh0EPLwqq55dB4LUIWqS1Flhm+K70U1Z8q+8hgWf8MzS MFxdP34Xmdxv/7SiJ/oPBzi/fQF8jhd7UINetEuGO+Ut2PJVo4BPB53sq7Hi6d5kw5+y ArsIiBvo5mUABtZqTujVTihIil6jGsbGCR7nITTFroGwC8aqDizruAjzUolvX6Ei9b2Y 9hKQ== 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=6Y/u42RwtVKMdhZKH1zHSs9FnTE3hyOUrutI/xN56+c=; b=VylmKL0Y+arENsthv6mBi05AhWLRKsggqvhmZcTbapr+kQYwQMnrfqdosPqvTNmX3H iEDlmDh9J5e2g2/g8RuG6E2Pk7Aggqw8rzS0ewlr7jiiBsjQPD9S69854Gh4VP2IxkCv Cj74WAI+gy+8/pxVGEIMdBhsFFFyaHwlgEIrLqhaxtOGTrQyoPK4Mmr915Y5uk2D2tWr waOpHAz6wVeiBlmx2YhGtf2uUNyAWZXXAFGVzAULnOGLPnMuMC1YEaz6cAdS95XTTHrd fo8oWBn5G6m199Ft0xauDQx13QDJvpBlYEoCe2UXcj1uz3EHvSQ8ROWvYJjn7rYKehKe DnFg==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57752-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWYGozk8uYHmjsFNzogA27R3Kjvm4Z/6W2QGibkhswpFvYA0PY8Oqor9EDx2nTDaFhAMMoYcoCB4JlHfpv8cfwZH6kHKw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t26-20020aa7d4da000000b0055fed11ab4fsi722109edr.304.2024.02.08.01.33.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 01:33:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57752-ouuuleilei=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; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-57752-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57752-ouuuleilei=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 4E2F61F212B8 for ; Thu, 8 Feb 2024 09:33:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 226F96D1AD; Thu, 8 Feb 2024 09:32:46 +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 X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 4189VnjY048930 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790322713555099893 X-GMAIL-MSGID: 1790322713555099893 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;