Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp630251rdb; Sun, 18 Feb 2024 04:55:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV6YJsjXLkO1qFnP95k2Gbsiddm5KScgdIeJH6/VpdGOyUT7FfNxA8TXG/K+r/G+pf4KIHH8tyq/OHrfvlWdIZsIv3JpOxPqj47nkSfOQ== X-Google-Smtp-Source: AGHT+IFWQALfQvX/4FjiHHtrKaaewR68XCJvrxy1P+PLwmVj0uYV2PWXfwZV3vsNFIUMTaSpfHp+ X-Received: by 2002:a05:6808:10c6:b0:3c0:4816:52d0 with SMTP id s6-20020a05680810c600b003c0481652d0mr13528039ois.11.1708260949881; Sun, 18 Feb 2024 04:55:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708260949; cv=pass; d=google.com; s=arc-20160816; b=i7//31RGJojxRcTPG84VqfI/ItyxAdZZLZAtziNAAZhen5NBLe/RLF0k0TK9MoQ2R+ uUTUwEpr9QjMK/x6PqHGmxnIkVIOhWbWXjHpj5uNVUzgzykRmHP7p345OzUoyPg5AowO GT2oRk1IVYGFMm2uyrS321nJBgPU6WKZoX4kSg2/JLhOGjHp7ZbZOKbtFPBUtyVQ7E7U s4jKolgJGtdOV7Nk1wejXecoAfQtnbhFOPtM65umOO1HdVHt88sePjbRHNt7hah2Abyz fOSCcBHJX0sKqBjkApc5mhwizl7uqClSDMRQxgFd7sMCIDoZwrKgUYtzhiQ2fULdYMje Qx4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=KLvIqFTcCWTBWR0stNfnzEKTeehbvUhICSkQBNo+aow=; fh=29sKNsLqWUu1z2iIsMMHgzIiYcktup5OXWx4l+bNr/U=; b=GKWAenn6PSZs8Pi5VHtyvFTl6LeCE7fEKca+/vWHHbJDzEv/BtZichxHj6epl/Bz7D cz2CVAzf0BvYoz1IkWBCCNEmZyPyb9ZgO2Jnt8EfqEJMhWZxBSHN8OxuioEb+R5c+FCc q1nu5Mj1HyLSngdVkuT+jHZ/JiNxt7DVW2Accwd1R3d/XoR4gzMvv9JojL0sFD4HToTi 5LHdcD1kL1p8oURiI6IOccjjKZRTrMHtHrCZSZBxe23hYr2aNRcxuRUALLhUYEPyx3G6 pH7wGpzX0zmVkqjnG1RORNYX3V7vqPcZvthGWoxErHclURHHdjAm8NnWbeYOXgxx++LH bfjw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=z+luHfuv; arc=pass (i=1 spf=pass spfdomain=kernel.dk dkim=pass dkdomain=kernel-dk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-70391-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70391-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 k16-20020a6568d0000000b005dc84ba3c3asi2850892pgt.287.2024.02.18.04.55.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 04:55:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70391-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; dkim=pass header.i=@kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=z+luHfuv; arc=pass (i=1 spf=pass spfdomain=kernel.dk dkim=pass dkdomain=kernel-dk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-70391-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70391-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 87F20281902 for ; Sun, 18 Feb 2024 12:55:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B35546BB58; Sun, 18 Feb 2024 12:55:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="z+luHfuv" Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2BEA6350A for ; Sun, 18 Feb 2024 12:55:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708260942; cv=none; b=XQxTb7GNk4cPF11GIp8VJmA1SKQGENmHHgEtrxLEVkvlDg1x8MUJC1YCe4RIGJqy5Ji0ia0rx1Gn0ZgbfAJlP8NbKMx7O5x9MhIfo4AyoRlclBGDa5a6huwJXM9RJbZhI5MLnFrcz8rSqXB5AwpjZs+Aa2zukm0RcH7ka/cs5oY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708260942; c=relaxed/simple; bh=QqNtIzDTyZoN2LKeC51whUxZXhXE9Z1UlRa4PhZ3wsk=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=Ls+TUwAAniFSBVCw7Gfnjr5OMeM70D+V7oyVCXMxziRELdoo9vbgYPeCiG38uryMofdlB/R4AztXpxKwntR0Te3nZdlcj22IQbi2fDeiTp5TgeadvuxDwBnbkUTezCQngPACYn6I9XL4f3VKDmO0sYd3Z2phCX7DC1/65ciOrT4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=z+luHfuv; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6e33db9118cso89143b3a.1 for ; Sun, 18 Feb 2024 04:55:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1708260940; x=1708865740; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=KLvIqFTcCWTBWR0stNfnzEKTeehbvUhICSkQBNo+aow=; b=z+luHfuv2FEAFmHZfuyv13QMArh8LZy4nJnj54TvBAXqsgwgqq9pZwrnS/K9j5bdAA 8PJ92+jEGvvjvvm7ytOpkUgu+Kd/oR3UUX5r4ORYSo6BN7OEy8/8yCfbggGs2UWWlwFH iAP/aDIhyNxiooawU8xxH54MeylCbPaWvUypaBf1XU635KWEpeYvxK7/I/Nv/8f7FAqj xbZY0v36PcYEFCRsIHmgJwa/j1sO07N4tMDXmZVqasIyS+bb2WHY4JcIJfqOYtOtqyk9 pXmhvPxpiyAM8l39Drum66oww1+03bc1x7+KMNTpy9qsezjPYRQeA3o0/jfs8doU38c3 ZrQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708260940; x=1708865740; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KLvIqFTcCWTBWR0stNfnzEKTeehbvUhICSkQBNo+aow=; b=T51BgbvRDV3XFT1llPH6Uuy16yhlaCwxNVzFLPdzCcIQ4pkcIv+sjrBEj7kaGM/sWS 6mUOYOV0VM9mHMQIUmkK3Yk9T2xhdU31PQZosEm+OSSGZ+xysZZQ7JG4zZ9un75bCJnT I3xyDU+xs1p0WTS0GPpK26/vbWqrebVcqFoX8sae+ng7CneSgaSynKByFXkn0bUxzbbm g2AsAtXPTxSxIvPLOCh6HsFGf2064sD0JLV66RGT5C9jD7I3XMIA5Uk5x3QJiUFOYzRK 1VFG05TJQrtOItyKQkGqxMb4RX32t+pqDkmooybQd7iQwuhEuV9O2ToDEPsP3BCuI6x6 wCmg== X-Forwarded-Encrypted: i=1; AJvYcCVRAFBgz9R6BjfKRG1dMq+PS2BTfX6DnlT/7y5TrFE9/gtzTCmlJJBCaxlLAezdGaBhgY8yRU4asNJ6scYjle3G8CzhnpHDEm3ySVoj X-Gm-Message-State: AOJu0YzaAcCaQmkdfBU1qfpb0VMIlVDVZToQTFeatZ32+6nXzbjYTbb6 3fC5ZVfJRLUHdWZm2NJDkBxgPck41PA5izefR+AlIflVxWMa2sBsbrJ1xPxwCv0= X-Received: by 2002:aa7:9dd0:0:b0:6e4:5e66:6824 with SMTP id g16-20020aa79dd0000000b006e45e666824mr877683pfq.1.1708260940143; Sun, 18 Feb 2024 04:55:40 -0800 (PST) Received: from [192.168.1.150] ([198.8.77.194]) by smtp.gmail.com with ESMTPSA id ei7-20020a056a0080c700b006dd8985e7c6sm2995277pfb.1.2024.02.18.04.55.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 18 Feb 2024 04:55:39 -0800 (PST) Message-ID: Date: Sun, 18 Feb 2024 05:55:37 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8] io_uring: Statistics of the true utilization of sq threads. Content-Language: en-US From: Jens Axboe To: Xiaobing Li Cc: asml.silence@gmail.com, 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 References: <20240206023910.11307-1-xiaobing.li@samsung.com> <20240218055513.38601-1-xiaobing.li@samsung.com> <1f7fa75e-f920-47d8-ae4f-cc7595b5e732@kernel.dk> In-Reply-To: <1f7fa75e-f920-47d8-ae4f-cc7595b5e732@kernel.dk> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/18/24 5:45 AM, Jens Axboe wrote: > On 2/17/24 10:55 PM, Xiaobing Li wrote: >> On 2/6/24 10:39 AM, Xiaobing Li wrote: >>> io_uring/fdinfo.c | 8 ++++++++ >>> io_uring/sqpoll.c | 8 ++++++++ >>> io_uring/sqpoll.h | 1 + >>> 3 files changed, 17 insertions(+) >>> >>> diff --git a/io_uring/fdinfo.c b/io_uring/fdinfo.c >>> index 976e9500f651..18c6f4aa4a48 100644 >>> --- a/io_uring/fdinfo.c >>> +++ b/io_uring/fdinfo.c >>> @@ -64,6 +64,7 @@ __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *f) >>> unsigned int sq_shift = 0; >>> unsigned int sq_entries, cq_entries; >>> int sq_pid = -1, sq_cpu = -1; >>> + u64 sq_total_time = 0, sq_work_time = 0; >>> bool has_lock; >>> unsigned int i; >>> >>> @@ -147,10 +148,17 @@ __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *f) >>> >>> sq_pid = sq->task_pid; >>> sq_cpu = sq->sq_cpu; >>> + struct rusage r; >>> + >>> + getrusage(sq->thread, RUSAGE_SELF, &r); >>> + sq_total_time = r.ru_stime.tv_sec * 1000000 + r.ru_stime.tv_usec; >>> + sq_work_time = sq->work_time; >>> } >>> >>> seq_printf(m, "SqThread:\t%d\n", sq_pid); >>> seq_printf(m, "SqThreadCpu:\t%d\n", sq_cpu); >>> + seq_printf(m, "SqTotalTime:\t%llu\n", sq_total_time); >>> + seq_printf(m, "SqWorkTime:\t%llu\n", sq_work_time); >>> seq_printf(m, "UserFiles:\t%u\n", ctx->nr_user_files); >>> for (i = 0; has_lock && i < ctx->nr_user_files; i++) { >>> struct file *f = io_file_from_index(&ctx->file_table, i); >>> diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c >>> index 65b5dbe3c850..9155fc0b5eee 100644 >>> --- a/io_uring/sqpoll.c >>> +++ b/io_uring/sqpoll.c >>> @@ -251,6 +251,9 @@ static int io_sq_thread(void *data) >>> } >>> >>> cap_entries = !list_is_singular(&sqd->ctx_list); >>> + struct rusage start, end; >>> + >>> + getrusage(current, RUSAGE_SELF, &start); >>> list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) { >>> int ret = __io_sq_thread(ctx, cap_entries); >>> >>> @@ -260,6 +263,11 @@ static int io_sq_thread(void *data) >>> if (io_run_task_work()) >>> sqt_spin = true; >>> >>> + getrusage(current, RUSAGE_SELF, &end); >>> + if (sqt_spin == true) >>> + sqd->work_time += (end.ru_stime.tv_sec - start.ru_stime.tv_sec) * >>> + 1000000 + (end.ru_stime.tv_usec - start.ru_stime.tv_usec); >>> + >>> if (sqt_spin || !time_after(jiffies, timeout)) { >>> if (sqt_spin) >>> timeout = jiffies + sqd->sq_thread_idle; >>> diff --git a/io_uring/sqpoll.h b/io_uring/sqpoll.h >>> index 8df37e8c9149..e99f5423a3c3 100644 >>> --- a/io_uring/sqpoll.h >>> +++ b/io_uring/sqpoll.h >>> @@ -16,6 +16,7 @@ struct io_sq_data { >>> pid_t task_pid; >>> pid_t task_tgid; >>> >>> + u64 work_time; >>> unsigned long state; >>> struct completion exited; >>> }; >> >> Hi, Jens and Pavel >> This patch has been modified according to your previous opinions. >> Do you have any other comments? > > I don't have any further complaints on the patch, I think it looks > pretty straight forward now. I'll get it applied, thanks. I take that back, I'll reply to the patch... -- Jens Axboe