Message ID | 20231106074055.1248629-1-xiaobing.li@samsung.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2500796vqu; Sun, 5 Nov 2023 23:56:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKqXZ6hwW3mVV7k551XiaMLC+vwVL/cIQMlzwxC83v9AEqTooHrcXOpvD5DfmI7McKJkCp X-Received: by 2002:a25:d0d0:0:b0:da0:2757:eb0 with SMTP id h199-20020a25d0d0000000b00da027570eb0mr27503783ybg.44.1699257366517; Sun, 05 Nov 2023 23:56:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699257366; cv=none; d=google.com; s=arc-20160816; b=1CTRsouOf3u6PmhZEc9YigWlrsA6Wa5s4fiHJUdJnOyKliye008wikRgmCsoZlHbM0 808DWFwgT5y5Y5k8I7r83IKH9xZqQdK6FBhh1KZEI/qe3VD2dEIjpfKPjyNiyu1O73Xd wa9UkEYD859da8if6eTC5+SLC00VNgRUZcJT2pcM3qa6lWCPbAjKdZyUiUeEIKhMI/I2 LEkaM57UR5j3O3OZ7e+ml4FIiqMBrR6Mt374RfmumPEaXvwEvfdUS3JpgXJ1bmL0UmNa Q6ykwO3Z/tS1EYraXLJtfTqwct3suQEy7F1VjzzAb8mDgqtzSZ/K0ABBvRI1eJB+0gch SC6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature:dkim-filter; bh=6NYx99oCWyMXAuJQC3OusH2vT6lJSfTjX8zw5hfAzvE=; fh=IHLCUkI0smA/KkEh3ghm8DmX2p5E3xbVcV7ILYZjlzw=; b=fWp00jCzAjHuPWfV2yTYVxZO4oCMs35rP0SkbRrc2lC1vmuqy/jMC8MzpOOXBum1gv iFgS8mg0JOGGhg+hQL2IMUoZtRTrftmCC1QdEOVzLQVX5R724Ph5HimvN4gtypF2/w21 Ecm4PCXu9L5DqvFVPJGICJwmaA+dUiQzPoGX30lWnWhTqCgOJkPTs/O6LdsKQoOvc/k1 NY+xTTmhY7pDL2XAHDM+l7DT5O9yd0nLB5sulf6OVn55K9HFM9TR2m68u5IeUzueI2hi /vOlvb6TTlnXfz98jhYa/Fjh4Seak2Smv4XvossgV/waYokt6vUwA/jRW9KeLssudxBM okqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=MZvj4vrY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id s36-20020a635264000000b00578af609d05si7228016pgl.244.2023.11.05.23.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 23:56:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=MZvj4vrY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2E9EA804C676; Sun, 5 Nov 2023 23:56:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230321AbjKFHzs (ORCPT <rfc822;lhua1029@gmail.com> + 35 others); Mon, 6 Nov 2023 02:55:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbjKFHzr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 6 Nov 2023 02:55:47 -0500 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E751DB3 for <linux-kernel@vger.kernel.org>; Sun, 5 Nov 2023 23:55:41 -0800 (PST) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20231106075539epoutp0183eea43b3cd34e6cf0cabe6c40f29fee~U_YwyPM4K2757527575epoutp01d for <linux-kernel@vger.kernel.org>; Mon, 6 Nov 2023 07:55:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20231106075539epoutp0183eea43b3cd34e6cf0cabe6c40f29fee~U_YwyPM4K2757527575epoutp01d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1699257339; bh=6NYx99oCWyMXAuJQC3OusH2vT6lJSfTjX8zw5hfAzvE=; h=From:To:Cc:Subject:Date:References:From; b=MZvj4vrYJaJDHxSB/4lg3rCf56rZuQ94fJdIuOW/7hzLCpUD2sf7NQlq81YQJ5Uj1 S5kCxauinNACzNIu4sthRMGPJFjoVCWs/5iN1MCJg3N+/TFOlfd5zJFuvuVDl7Uopo OMmE35zKoCW784VFy5ypfu2ZM+pVRFY/CeHb5tt0= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20231106075539epcas5p3b7b48b19d7968bacebe62918775115b4~U_YwY_dFe2090520905epcas5p3h; Mon, 6 Nov 2023 07:55:39 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.182]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4SP3Yk1zLXz4x9Q9; Mon, 6 Nov 2023 07:55:38 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 67.CB.19369.AFB98456; Mon, 6 Nov 2023 16:55:38 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20231106074844epcas5p252beb2aa7925de34aea33d5c64d1d72e~U_StddITd2058820588epcas5p2n; Mon, 6 Nov 2023 07:48:44 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231106074844epsmtrp20f47fa419814ea03c209a3b9c4d9dc19~U_StctKF91829318293epsmtrp2c; Mon, 6 Nov 2023 07:48:44 +0000 (GMT) X-AuditID: b6c32a50-9e1ff70000004ba9-ea-65489bfaa706 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 7E.6E.07368.B5A98456; Mon, 6 Nov 2023 16:48:43 +0900 (KST) Received: from AHRE124.. (unknown [109.105.118.124]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231106074842epsmtip29fbba4a4dd6ccb175ec68b965e03fa4b~U_SsQtdsB1909319093epsmtip2Z; Mon, 6 Nov 2023 07:48:42 +0000 (GMT) From: Xiaobing Li <xiaobing.li@samsung.com> To: axboe@kernel.dk, asml.silence@gmail.com Cc: linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, kun.dou@samsung.com, peiwei.li@samsung.com, joshi.k@samsung.com, kundan.kumar@samsung.com, wenwen.chen@samsung.com, ruyi.zhang@samsung.com, Xiaobing Li <xiaobing.li@samsung.com> Subject: [PATCH] IO_URING: Statistics of the true utilization of sq threads. Date: Mon, 6 Nov 2023 15:40:55 +0800 Message-Id: <20231106074055.1248629-1-xiaobing.li@samsung.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEJsWRmVeSWpSXmKPExsWy7bCmlu6v2R6pBt0dXBZzVm1jtFh9t5/N 4l3rORaLo//fsln86r7LaLH1y1dWi8u75rBZPNvLafHl8Hd2i6lbdjBZdLRcZnTg9tg56y67 x+WzpR59W1YxenzeJBfAEpVtk5GamJJapJCal5yfkpmXbqvkHRzvHG9qZmCoa2hpYa6kkJeY m2qr5OIToOuWmQN0k5JCWWJOKVAoILG4WEnfzqYov7QkVSEjv7jEVim1ICWnwKRArzgxt7g0 L10vL7XEytDAwMgUqDAhO2PN2mOsBS2CFR+7VzM2MB7l7WLk5JAQMJGYf30eSxcjF4eQwB5G iTMHN7FDOJ8YJdZ0r2GCcL4xSqz+38sK0/L9UgNU1V5GiW9HXjFDOC8ZJXYsO8oCUsUmoC1x fV0XWIcIkP368VSwJcwCn4Hm3v4GViQs4CNxb/k3dhCbRUBVYv2PfWwgNq+AnUT/lBmMEOvk JfYfPMsMEReUODnzCVgvM1C8eetsZoial+wSz3/JQtguEj+btjJB2MISr45vYYewpSQ+v9vL BmEXSxzp+c4KcpCEQAOjxPTbV6GKrCX+XdkDtIADaIGmxPpd+hBhWYmpp9YxQezlk+j9/QRq Pq/EjnkwtqrE6ksPWSBsaYnXDb+h4h4S5y7sYAYZKSQQK7Hibf0ERvlZSL6ZheSbWQiLFzAy r2KUSi0ozk1PTTYtMNTNSy2HR21yfu4mRnDi1ArYwbh6w1+9Q4xMHIyHGCU4mJVEeP/ae6QK 8aYkVlalFuXHF5XmpBYfYjQFhvFEZinR5Hxg6s4riTc0sTQwMTMzM7E0NjNUEud93To3RUgg PbEkNTs1tSC1CKaPiYNTqoFJtvdu/6XbRgHZd5XEXp52v3LQffefleKc9wsydq2VmXB7xZZD ot9fGv75slXX2qluvb/vhx8cMnOV/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9N/1X67zqXvv6+xl555rmdN+zr4zMXxPns/2q6 dO+qZ7FLSxVnsqoxp/MxnPn1cFaJyBzVSzcmleoLJN7JuJtbyMYVpCmacfNl/ZOlgdZnP1ww nvtqa6pgtOfWascEZ2XGCK+ZpidMjs8KLVr9xOXAlhLt6+uUWIozEg21mIuKEwGi1af/zgIA AA== X-CMS-MailID: 20231106074844epcas5p252beb2aa7925de34aea33d5c64d1d72e X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20231106074844epcas5p252beb2aa7925de34aea33d5c64d1d72e References: <CGME20231106074844epcas5p252beb2aa7925de34aea33d5c64d1d72e@epcas5p2.samsung.com> X-Spam-Status: No, score=-1.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 05 Nov 2023 23:56:04 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781800492287928603 X-GMAIL-MSGID: 1781800492287928603 |
Series |
IO_URING: Statistics of the true utilization of sq threads.
|
|
Commit Message
Xiaobing Li
Nov. 6, 2023, 7:40 a.m. UTC
Since the sq thread has a while(1) structure, during this process, there
may be a lot of time that is not processing IO but does not exceed the
timeout period, therefore, the sqpoll thread will keep running and will
keep occupying the CPU. Obviously, the CPU is wasted at this time;Our
goal is to count the part of the time that the sqpoll thread actually
processes IO, so as to reflect the part of the CPU it uses to process
IO, which can be used to help improve the actual utilization of the CPU
in the future.
Signed-off-by: Xiaobing Li <xiaobing.li@samsung.com>
---
io_uring/sqpoll.c | 8 ++++++++
io_uring/sqpoll.h | 2 ++
2 files changed, 10 insertions(+)
Comments
On 11/6/23 12:40 AM, Xiaobing Li wrote: > Since the sq thread has a while(1) structure, during this process, there > may be a lot of time that is not processing IO but does not exceed the > timeout period, therefore, the sqpoll thread will keep running and will > keep occupying the CPU. Obviously, the CPU is wasted at this time;Our > goal is to count the part of the time that the sqpoll thread actually > processes IO, so as to reflect the part of the CPU it uses to process > IO, which can be used to help improve the actual utilization of the CPU > in the future. > > Signed-off-by: Xiaobing Li <xiaobing.li@samsung.com> > --- > io_uring/sqpoll.c | 8 ++++++++ > io_uring/sqpoll.h | 2 ++ > 2 files changed, 10 insertions(+) > > diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c > index bd6c2c7959a5..27b01ad42678 100644 > --- a/io_uring/sqpoll.c > +++ b/io_uring/sqpoll.c > @@ -224,6 +224,7 @@ static int io_sq_thread(void *data) > struct io_ring_ctx *ctx; > unsigned long timeout = 0; > char buf[TASK_COMM_LEN]; > + unsigned long long start, begin, end; > DEFINE_WAIT(wait); These can just be unsigned long, that's the size of jiffies on any platform. Ditto for struct io_sq_data. And while this looks fine, nothing is using this accounting. For this to be an acceptable patch, surely the value needs to be used somehow or at least you should be able to query it?
diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c index bd6c2c7959a5..27b01ad42678 100644 --- a/io_uring/sqpoll.c +++ b/io_uring/sqpoll.c @@ -224,6 +224,7 @@ static int io_sq_thread(void *data) struct io_ring_ctx *ctx; unsigned long timeout = 0; char buf[TASK_COMM_LEN]; + unsigned long long start, begin, end; DEFINE_WAIT(wait); snprintf(buf, sizeof(buf), "iou-sqp-%d", sqd->task_pid); @@ -235,6 +236,7 @@ static int io_sq_thread(void *data) set_cpus_allowed_ptr(current, cpu_online_mask); mutex_lock(&sqd->lock); + start = jiffies; while (1) { bool cap_entries, sqt_spin = false; @@ -245,12 +247,18 @@ static int io_sq_thread(void *data) } cap_entries = !list_is_singular(&sqd->ctx_list); + begin = jiffies; list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) { int ret = __io_sq_thread(ctx, cap_entries); if (!sqt_spin && (ret > 0 || !wq_list_empty(&ctx->iopoll_list))) sqt_spin = true; } + end = jiffies; + sqd->total = end - start; + if (sqt_spin == true) + sqd->work += end - begin; + if (io_run_task_work()) sqt_spin = true; diff --git a/io_uring/sqpoll.h b/io_uring/sqpoll.h index 8df37e8c9149..c6b2ecb654fd 100644 --- a/io_uring/sqpoll.h +++ b/io_uring/sqpoll.h @@ -16,6 +16,8 @@ struct io_sq_data { pid_t task_pid; pid_t task_tgid; + unsigned long long work; + unsigned long long total; unsigned long state; struct completion exited; };