From patchwork Thu Feb 8 09:31:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 13549513 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 476A8171B4 for ; Thu, 8 Feb 2024 09:31:59 +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=1707384725; cv=none; b=SILlF5xE+o1XJ0a4w/cm2YKLLzRbjoE+Vkzvu8yKfXE0QLWkBDqjWT04Xk4k8cXpDvKHdenw0fJicdmCNQqbbbzoMLyCNI74jfnriZoZLXx12Emqfzp0IL+GxQA8JDqGZOFaHzeCfoVBpe2YDQ+SSqJcNKZv3A258UnE1wV6h/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707384725; c=relaxed/simple; bh=krq/hS9/1j9KLRxH0FYt963iK2ab66gutwWA8nIZph0=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Y6/0mmvFYqPiOWfMHLzjiNRJiWCpthz6q2Gbt9OxyCMYTqkYk7s7Oszh1TlVrQn7+1yS5aKqgN+40aOSAhCGSn4kyNyMKrzIeJ5Z3dnXOkXTf1/qAfK+ne2RjROwrprWlhUT4/Xcx+e2sDkcVoI5Fo+Pdy3lKhcOwHGNz1DY5Us= 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 4189VjUp048928; Thu, 8 Feb 2024 17:31:45 +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 4TVsF36KYhz2K4gjP; Thu, 8 Feb 2024 17:31:35 +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:43 +0800 From: "zhaoyang.huang" To: Jens Axboe , Peter Zijlstra , Ingo Molnar , Juri Lelli , Vincent Guittot , Yu Zhao , , , Zhaoyang Huang , Subject: [PATCH 1/3] sched: fix compiling error on kernel/sched/sched.h Date: Thu, 8 Feb 2024 17:31:34 +0800 Message-ID: <20240208093136.178797-1-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-block@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 4189VjUp048928 From: Zhaoyang Huang Below compiling error reported. fix it. block/../kernel/sched/sched.h: In function ‘update_current_exec_runtime’: block/../kernel/sched/sched.h:3287:2: error: implicit declaration of function ‘account_group_exec_runtime’; did you mean ‘sched_group_rt_runtime’? [-Werror=implicit-function-declaration] account_group_exec_runtime(curr, delta_exec); Signed-off-by: Zhaoyang Huang --- kernel/sched/sched.h | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 04846272409c..b0cffc9c0f0d 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include 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: 13549514 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 D9BCE69300 for ; Thu, 8 Feb 2024 09:32:03 +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=1707384726; cv=none; b=apla1IzfZ9ca546UyKcJLwZZWLBbRSx31q1Q680tjs8YrPs+mteTg0wmhntGjwu4uJQbGFyCSDdqTE31a5QVUFjseiPyYWQLVWt6XqQR8SkZFiMi94JZZKMXVXXPgMH3atESb7oWVRx5o8BwGGzBO5VmvCK7Is0OQr4sdV8AHYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707384726; c=relaxed/simple; bh=77RDjA7vu16sLKzoTYcGU4lvILnaItQ4kSRq9AXWhwo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QLnU3db+uGp+O/GWEuTxETern7SXHyxpk4yeuVQVgkvx/Ah2xrV8pztt0YXYBut6XYme+M+NrPkeO6UdhP3lxtksKVYzQq+Ap6bUrvVBnk+oiKJHperyj9MizfOAy+BoegseDE6fi1B2yMpcTfoeQbbCcfqw7gkz/JFk9ca/DII= 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-block@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 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; From patchwork Thu Feb 8 09:31:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 13549515 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 842F46BB2F for ; Thu, 8 Feb 2024 09:32:03 +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=1707384727; cv=none; b=KOSH3Wm0E9vJJDloKSe8lKVt/125OUrD1LTnaD4wP726tzz3KoDdOgCKOHmqVEGTSjmBL70vGIowfKgUhUr7u+9b9++xIC1RUIc9jeSKEzVm+RWgVmVZhGpvtwA8lP3rw82QzMsF9ndYBn1EQjTLwZrXTDQfVE1s9zSzRv22VKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707384727; c=relaxed/simple; bh=Z43mwuX48ZWWYGQscTT9lPoGr9fJEhXO9dvSyk7+URw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=j2zG0lRej+TSqyMxbx1QQCWT5ojZYe3UeCweLpY6nRa/qFeJUbQSEnmcxFVaxmDpLjyI9rbH96N0bjNHB2K0hemwNEatU29Fhgnxy5lj5+d1iFFrk5JPJsfL+SDzkOTJemoVA+T7HxRBCdPfoBGz5taNKjPbQGHzK0JaoCW0Xf8= 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 4189VqAL048943; Thu, 8 Feb 2024 17:31:52 +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 4TVsFB4n1fz2K4gjP; Thu, 8 Feb 2024 17:31:42 +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:49 +0800 From: "zhaoyang.huang" To: Jens Axboe , Peter Zijlstra , Ingo Molnar , Juri Lelli , Vincent Guittot , Yu Zhao , , , Zhaoyang Huang , Subject: [PATCH 3/3] block: introducing a bias over deadline's fifo_time Date: Thu, 8 Feb 2024 17:31:36 +0800 Message-ID: <20240208093136.178797-3-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-block@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 4189VqAL048943 From: Zhaoyang Huang According to current policy, RT tasks possess the privilege for both of CPU and IO scheduler which could have the preempted CFS tasks suffer big IO-latency unfairly. This commit introduce an approximate method to deduct the preempt affection. TaskA sched in | | | submit_bio | | | fifo_time = jiffies + expire (insert_request) TaskB sched in | | preempted by RT task |\ | 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 --- block/mq-deadline.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/mq-deadline.c b/block/mq-deadline.c index f958e79277b8..43c08c3d6f18 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -15,6 +15,7 @@ #include #include #include +#include "../kernel/sched/sched.h" #include @@ -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); @@ -840,7 +842,9 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, /* * set expire time and add to fifo list */ - rq->fifo_time = jiffies + dd->fifo_expire[data_dir]; + fifo_expire = task_is_realtime(current) ? dd->fifo_expire[data_dir] : + CFS_PROPORTION(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 /*