Message ID | 20240220061542.489922-2-zhaoyang.huang@unisoc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-72396-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp218682dyc; Mon, 19 Feb 2024 22:17:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV1IyzD97u3C/KgHI3ji7jH6V7FP/7dD2dXKuSivv7IjB2tjwtrrs7JBESQ3/VMeuYvIERBGLPO6LF/lbjQHpU68noh2g== X-Google-Smtp-Source: AGHT+IE+s5W+3pFL9fWAYwKPtcW6A1Ye9O5VmYYiI9TqqrnS9e6uLPnX9jOacpCS+4kliUiLMrt3 X-Received: by 2002:a17:906:c44a:b0:a38:40fc:2bcf with SMTP id ck10-20020a170906c44a00b00a3840fc2bcfmr11542854ejb.60.1708409847721; Mon, 19 Feb 2024 22:17:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708409847; cv=pass; d=google.com; s=arc-20160816; b=1FoJ2R3eqQBd268lUCmP+2atq6fygXGJY2ZvHr81LLWM47XrNZI3xTxOqsaCKoZzRn /0dYcDug2DAnyQe+qo8eEKbVTKYIRtiMJbpAd7tslnN48OvVAvnTuh0hgHJmnukaRXA+ HQIYIFGnJy/vySkC3Nc0r30CJzia1holOpw9BGixoVwkbmsI39odV4uCOFFYSpXOCv7j x53qRsyxvekWNlJWhD/gsfoBYIXSnS5EdpHhvqSRowPJtf439p0RvHPxt6CPzsOT+Dey V+PhCQGrDvVcLaPyBoz3sYMl73k2u3apNisDTdBeE2or0FSbnIxDFybQdh4EURYNibbF QLUg== 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=Afe6DD+Hpp+Rd3++StB8dhAzALORwI2eFnViYNnEZ9Y=; fh=QtOHZtKrtQsMid7WyH7DZ+mtUaM1ZYqcizgd96ghgo4=; b=v+/CO8IZlK5gUW02SN8n6FfQCV66Pi63gpPB7c+g9c3ZLu75t1EbIcg9sLPodtjBXA DNIWdiTKYCcuhlbi8KQhwQoBdZFAxhrjMHjJjI/W1Jsyrq22BGJqtPMSZqQBPfFoZGW4 ESYDuguhmVg9JM7gzDo/LdWtH8E9eBWrkjH6WdZgI3g8zpzXAvQw2Ntm2nzR8RzTmGKD ApEVEMfg3a9Rhg/1rrsOU4oelGjQGw3BVSvljyZ/wL/QW1aoSeBprEK0c4nsw4uS2lay DzHjwwy8ub4yl+p4YNLfmSi3mfWBcl3zy9vTCqcZJwpqJUjuJsw3iX7ZNfPspXp/qtV4 Fx2Q==; 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-72396-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72396-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l20-20020a17090612d400b00a3d6382a307si3234844ejb.830.2024.02.19.22.17.27 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 22:17:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72396-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-72396-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72396-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 5AF261F252D4 for <ouuuleilei@gmail.com>; Tue, 20 Feb 2024 06:17:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DAB985916F; Tue, 20 Feb 2024 06:16:51 +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 89FC15822A for <linux-kernel@vger.kernel.org>; Tue, 20 Feb 2024 06:16:47 +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=1708409810; cv=none; b=fqVtOduWrGSyazKBt5squd+pXXbjllahusm3gO1qiDhARno6eExU9q8WD+U87/JML29hVg6mMw+CiZ+aRMts8KGjmfgUqiy/F2yS2GQwcCt4WoNe2VXP6Q8VOb9uFIL+5JqJXc21Mk8m9JMMrX1jpfn+OZIBoypwaHXVXycjNPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708409810; c=relaxed/simple; bh=6PsW9IgtA4lBHrAO4yi8iQHX3lJ8D2d1JDs9TZDmVvw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Po6ETC99lT1J7+02Tn19hQn9USxF9qqbBluSxYshoAqMl6JcJeZjqP/auogegaueeAvP1C6HWdJG2GNbx6WSDV86cBzZxlmrJnMsm1tSATEXavlN1ntx8YFn/86oUweFXeXbhVHsyCTzqypH0Th2mGeg70YESer7AN0SW/Xyz9E= 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 41K6FuVp095152; Tue, 20 Feb 2024 14:15:57 +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 4Tf8K76bmWz2K25V6; Tue, 20 Feb 2024 14:15:23 +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; Tue, 20 Feb 2024 14:15:54 +0800 From: "zhaoyang.huang" <zhaoyang.huang@unisoc.com> To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Juri Lelli <juri.lelli@redhat.com>, Vincent Guittot <vincent.guittot@linaro.org>, Jens Axboe <axboe@kernel.dk>, <linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Zhaoyang Huang <huangzhaoyang@gmail.com>, <steve.kang@unisoc.com> Subject: [PATCH 2/2] block: adjust CFS request expire time Date: Tue, 20 Feb 2024 14:15:42 +0800 Message-ID: <20240220061542.489922-2-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240220061542.489922-1-zhaoyang.huang@unisoc.com> References: <20240220061542.489922-1-zhaoyang.huang@unisoc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> 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 41K6FuVp095152 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791397564390963394 X-GMAIL-MSGID: 1791397564390963394 |
Series |
[1/2] sched: introduce helper function to calculate distribution over sched class
|
|
Commit Message
zhaoyang.huang
Feb. 20, 2024, 6:15 a.m. UTC
From: Zhaoyang Huang <zhaoyang.huang@unisoc.com> According to current policy, CFS's may suffer involuntary IO-latency by being preempted by RT/DL tasks or IRQ since they possess the privilege for both of CPU and IO scheduler. This commit introduce an approximate and light method to decrease these affection by adjusting the expire time via the CFS's proportion among the whole cpu active time. The average utilization of cpu's run queue could reflect the historical active proportion of different types of task that can be proved valid for this goal from belowing three perspective, 1. All types of sched class's load(util) are tracked and calculated in the same way(using a geometric series which known as PELT) 2. Keep the legacy policy by NOT adjusting rq's position in fifo_list but only make changes over expire_time. 3. The fixed expire time(hundreds of ms) is in the same range of cpu avg_load's account series(the utilization will be decayed to 0.5 in 32ms) TaskA sched in | | | submit_bio | | | fifo_time = jiffies + expire (insert_request) TaskB sched in | | vfs_xxx | |preempted by RT,DL,IRQ |\ | This period time is unfair to TaskB's IO request, should be adjust |/ | submit_bio | | | fifo_time = jiffies + expire * CFS_PROPORTION(rq) (insert_request) Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com> --- block/mq-deadline.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
Comments
On Tue, Feb 20, 2024 at 02:15:42PM +0800, zhaoyang.huang wrote: > From: Zhaoyang Huang <zhaoyang.huang@unisoc.com> > > According to current policy, CFS's may suffer involuntary IO-latency by > being preempted by RT/DL tasks or IRQ since they possess the privilege for > both of CPU and IO scheduler. What is 'current policy', what is CFS, what is RT/DL? What privilege is possessed? > 1. All types of sched class's load(util) are tracked and calculated in the > same way(using a geometric series which known as PELT) > 2. Keep the legacy policy by NOT adjusting rq's position in fifo_list > but only make changes over expire_time. > 3. The fixed expire time(hundreds of ms) is in the same range of cpu > avg_load's account series(the utilization will be decayed to 0.5 in 32ms) What problem does this fix, i.e. what performance number are improved or what other effects does it have? > + * The expire time is adjusted via calculating the proportion of > + * CFS's activation among whole cpu time during last several > + * dazen's ms.Whearas, this would NOT affect the rq's position in > + * fifo_list but only take effect when this rq is checked for its > + * expire time when at head. > */ Please speel check the comment and fix the formatting to have white spaces after sentences and never exceed 80 characters in block comments.
On Tue, Feb 20, 2024 at 5:42 PM Christoph Hellwig <hch@infradead.org> wrote: > > On Tue, Feb 20, 2024 at 02:15:42PM +0800, zhaoyang.huang wrote: > > From: Zhaoyang Huang <zhaoyang.huang@unisoc.com> > > > > According to current policy, CFS's may suffer involuntary IO-latency by > > being preempted by RT/DL tasks or IRQ since they possess the privilege for > > both of CPU and IO scheduler. > > What is 'current policy', what is CFS, what is RT/DL? What privilege > is possessed? CFS and RT/DL are types of sched class in which CFS has the least privilege to get CPU. IMO, ‘current policy’ refers to two perspectives: 1. the RT task in the same core with the CFS task gets privileges in both CPU and IO scheduler(deadline on duty) than CFS. Could we make the CFS requests' expire_time be earlier than it used to be now. 2. In terms of the timing of inserting the request, preempted CFS tasks lose the fairness involuntary when compared with none-preempted CFS tasks. Could we decrease this impact in some way. > > > 1. All types of sched class's load(util) are tracked and calculated in the > > same way(using a geometric series which known as PELT) > > 2. Keep the legacy policy by NOT adjusting rq's position in fifo_list > > but only make changes over expire_time. > > 3. The fixed expire time(hundreds of ms) is in the same range of cpu > > avg_load's account series(the utilization will be decayed to 0.5 in 32ms) > > What problem does this fix, i.e. what performance number are improved > or what other effects does it have? I have verified this commit via some benchmark tools like fio and Androbench. Neither regression nor improvement is found. By analysing the log below[2], where I find that CFS occupies most of the CPU for the most part. If it makes more sense in the way of [1] where CFS is over-preempted than a threshold. [1] - rq->fifo_time = jiffies + dd->fifo_expire[data_dir]; /*adjust expire time when cfs is over-preempted than 50%*/ + fifo_expire = cfs_prop_by_util(current,100) < 50 ? dd->fifo_expire[data_dir] : + cfs_prop_by_util(current, dd->fifo_expire[data_dir]); + rq->fifo_time = jiffies + fifo_expire; [2] //prop is the proportion of CFS's util which is mostly above 90(90%) during common benchmark test kworker/u16:3-73 [000] ...1. 321.140143: dd_insert_request: dir 1,cfs 513, prop 91, orig_expire 1250, expire 1149 kworker/u16:3-73 [000] ...1. 321.140414: dd_insert_request: dir 1,cfs 513, prop 91, orig_expire 1250, expire 1149 kworker/u16:3-73 [000] ...1. 321.140505: dd_insert_request: dir 1,cfs 513, prop 91, orig_expire 1250, expire 1149 kworker/u16:3-73 [000] ...1. 321.140574: dd_insert_request: dir 1,cfs 513, prop 91, orig_expire 1250, expire 1149 kworker/u16:3-73 [000] ...1. 321.140630: dd_insert_request: dir 1,cfs 513, prop 91, orig_expire 1250, expire 1149 kworker/u16:3-73 [000] ...1. 321.140682: dd_insert_request: dir 1,cfs 513, prop 91, orig_expire 1250, expire 1149 kworker/u16:3-73 [000] ...1. 321.140736: dd_insert_request: dir 1,cfs 513, prop 91, orig_expire 1250, expire 1149 dd-7296 [006] ...1. 321.143139: dd_insert_request: dir 0,cfs 610, prop 92, orig_expire 125, expire 115 dd-7296 [006] ...1. 321.143287: dd_insert_request: dir 0,cfs 610, prop 92, orig_expire 125, expire 115 dd-7296 [004] ...1. 321.156074: dd_insert_request: dir 0,cfs 691, prop 97, orig_expire 125, expire 122 dd-7296 [004] ...1. 321.156202: dd_insert_request: dir 0,cfs 691, prop 97, orig_expire 125, expire 122 > > > + * The expire time is adjusted via calculating the proportion of > > + * CFS's activation among whole cpu time during last several > > + * dazen's ms.Whearas, this would NOT affect the rq's position in > > + * fifo_list but only take effect when this rq is checked for its > > + * expire time when at head. > > */ > > Please speel check the comment and fix the formatting to have white > spaces after sentences and never exceed 80 characters in block comments. ok. >
diff --git a/block/mq-deadline.c b/block/mq-deadline.c index f958e79277b8..1e538cb2783b 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -839,8 +839,15 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, /* * set expire time and add to fifo list + * The expire time is adjusted via calculating the proportion of + * CFS's activation among whole cpu time during last several + * dazen's ms.Whearas, this would NOT affect the rq's position in + * fifo_list but only take effect when this rq is checked for its + * expire time when at head. */ - rq->fifo_time = jiffies + dd->fifo_expire[data_dir]; + rq->fifo_time = jiffies + + cfs_prop_by_util(current, dd->fifo_expire[data_dir]); + insert_before = &per_prio->fifo_list[data_dir]; #ifdef CONFIG_BLK_DEV_ZONED /*