Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1673976rdb; Tue, 20 Feb 2024 03:46:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXsMWtUFLmqV62k0PZ2BSYo1oJuyt2JZQ9ig9ZPfKzi4PJwMhgToOEBVu5kuRhFVrfQ3vRTTuAw4kGElfYAaqVZaKhVEMgjXayQyDm82g== X-Google-Smtp-Source: AGHT+IESTlmZERrxYPLEd2udYvAsqMU0e6aYurgPE9yeuF7n51+Ilq8WAK5cXVufvbYvL4gLqAoE X-Received: by 2002:a17:903:8ce:b0:1db:c6ff:664a with SMTP id lk14-20020a17090308ce00b001dbc6ff664amr9032920plb.53.1708429609296; Tue, 20 Feb 2024 03:46:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708429609; cv=pass; d=google.com; s=arc-20160816; b=bylWBn4XIP+IxRKQRouOlCCe01taC0XVjGYFSHca610OL8yhUhlwfCba50sAImQhqi BeYOto6M0PlKoSxJiAPGBxz6CjNhpBzV5dakT9VPs424lHCaIOnzQWNO/z0HFCoK85lN 4aeXs8Z/WVXMPa03VUYKekACbQhBSG864CUevwP1xz16vFkjCAMeWDf6XwcDKU2OwZWQ GOiGUHWHx/Aq0VzysBilpbfMBx2hJb9JLBU/6gFycnR7p0RBa9Z3RN3K0tvG1goc2kGw RmZGNTz3jaK5+vNap3ADHVMHVVwSTXRW7HmAzpXYPZlu4n2ctnPx/cS/0Hmi5JksvznW EBkg== 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:message-id:date:subject:to:from; bh=VZgoJryqSDmhKvwEdASc2YM+gel0mIau79W22kHQdM8=; fh=QtOHZtKrtQsMid7WyH7DZ+mtUaM1ZYqcizgd96ghgo4=; b=StICUmxcI161SBBUSLlSQHXBsm9rjDhI30Jod1LR9nvoBIZ1x8b+0jSQPh7Y69xvZt EPA4XdNAy/GeeJDE4fg6+M38JNnWsZPe669mnFuSyKt7m8xMUB7bxtnejKeS6ASJTQZt 7qAFGB+b4BDFDrVSeC615hXjLSZATgaFfPkWAA0BOarKX4duVkAvDjQyiLXKpGNv5PN1 2TOtaQ3P2R+8cMjlFVj3wnFnvvDQavmIGwnOkJj6KEhsZY11rAFHn8afW1PVZM+6d4r/ arK+JvXAsmEe3YfV4Yi3DXEdRxitOjdJaZwZ4lis3ZeWZVFnrjawpG3+iKH32sM1CFJu 0xFg==; 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-72936-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72936-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u6-20020a17090282c600b001da105d6a6esi5944336plz.523.2024.02.20.03.46.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 03:46:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72936-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-72936-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72936-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 06FBF2850D7 for ; Tue, 20 Feb 2024 11:46:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B53B7679E4; Tue, 20 Feb 2024 11:46:42 +0000 (UTC) Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [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 6632F67756 for ; Tue, 20 Feb 2024 11:46:36 +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=1708429602; cv=none; b=qyUiJSZSSJteQJDNQofAtAaUs715t8Q0Osa5jjoHZDYrHTbOJ0rXfoTLyEJLM/Yb4AQs2FNyVFl+GavTJCjVaZJ3u+/uze9+ZM02jkiXZBl5j+xskzMEy4YW3muLeCOmbdDSo3N9x+tQbZb9NRwzJw42Ow19rCl7TPZzO2g623o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708429602; c=relaxed/simple; bh=vNZkqBTjlTdoeDozES2fdOqPQvfg/df6N1nv+ImGzOk=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=D0LR96KYGj6T4v1qhxL7fv2GietTxqt4/WtoZ/a2Bwc9dUbXhBweQJHjUqnYXMhjmq+t1Na0dezuqYFXI9einHkWJ269mNi6+l3GHX2u479jmePX1Bt3XiVE9uj6FUdt1JYteUolHS/fTdRNNRV3TJQ1+Kqr9y7PcByU0KHC8oM= 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 41KBjlSv037342; Tue, 20 Feb 2024 19:45:47 +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 4TfHdk5cQxz2KGMyM; Tue, 20 Feb 2024 19:45:14 +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 19:45:46 +0800 From: "zhaoyang.huang" To: Peter Zijlstra , Ingo Molnar , Juri Lelli , Vincent Guittot , Jens Axboe , , , Zhaoyang Huang , Subject: [PATCHv2 2/2] block: adjust CFS request expire time Date: Tue, 20 Feb 2024 19:45:36 +0800 Message-ID: <20240220114536.513494-1-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 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 41KBjlSv037342 From: Zhaoyang Huang 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 --- change of v2: introduce direction and threshold to make the hack working as a guard for CFS's over-preempted. --- --- block/mq-deadline.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/block/mq-deadline.c b/block/mq-deadline.c index f958e79277b8..b5aa544d69a3 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -54,6 +54,7 @@ enum dd_prio { enum { DD_PRIO_COUNT = 3 }; +#define CFS_PROP_THRESHOLD 60 /* * I/O statistics per I/O priority. It is fine if these counters overflow. * What matters is that these counters are at least as wide as @@ -802,6 +803,7 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, u8 ioprio_class = IOPRIO_PRIO_CLASS(ioprio); struct dd_per_prio *per_prio; enum dd_prio prio; + int fifo_expire; lockdep_assert_held(&dd->lock); @@ -839,8 +841,20 @@ 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 when current CFS task is + * over-preempted by RT/DL/IRQ which is calculated by the + * proportion of CFS's activation among whole cpu time during + * last several dozen'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]; + fifo_expire = dd->fifo_expire[data_dir]; + if (data_dir == DD_READ && + (cfs_prop_by_util(current, 100) < CFS_PROP_THRESHOLD)) + fifo_expire = cfs_prop_by_util(current, dd->fifo_expire[data_dir]); + + rq->fifo_time = jiffies + fifo_expire; + insert_before = &per_prio->fifo_list[data_dir]; #ifdef CONFIG_BLK_DEV_ZONED /* -- 2.25.1