From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (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 EF484653 for ; Mon, 19 Feb 2024 07:22:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708327328; cv=none; b=km/sdlcjFVIVIdFaMrHrJc/RIRVDvxUaU/8WX9sK5PZ0O4oIxHOSSW2K569suaBW0W+dphpyJ0X2IFZUWi565y8LH9dAEYip9dGHW7zH4g9amWTvPFfwPuj58CyCFZ8mwGDKwZVpg8a2d4LKxECLaD6Nxf3tYZ3jegWA4kW7W6A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708327328; c=relaxed/simple; bh=z5gEp1g+Cx86Qj4hb2iV/fY7GbbVaIldH4c4QsjgZLg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=V0JmJwdPzXIfcabju+Xtf82MPLp4Oe6+EZrCWWMElPonZsGIui2oPHSOnbZUFuoHrkGptE3spdDmgpVzOIRjqNxUfScdJlEdGrRTga1N95T1rQfAHb9vyyeem7TyAotgafVFrHGUwW9OKPdGGNx2G78qau76XqSt1rDze35KYnE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=fyUkx5KR; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="fyUkx5KR" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240219072202epoutp0249a0fd1e53dfd9219e52c50e305fd188~1MqYDUahP2990729907epoutp02A for ; Mon, 19 Feb 2024 07:22:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240219072202epoutp0249a0fd1e53dfd9219e52c50e305fd188~1MqYDUahP2990729907epoutp02A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1708327322; bh=t26mQRhskGWreQ+iBAEauW8i+bpFYE4AzVGSadA654I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fyUkx5KRH8DAdigMCft6bN5zXONj8YwzDBQyAEv37ZtqitMiF4V/11YcHFJFJFkX2 gZBnf6CC1xyjgOorLr8HXHjSf2g1W5oEQQejfs/hCU1HvJIOLpsYoIbWppI/mk9yRj Zw8oej/RosobbUZj/56B4EbCSP+t+JKfNsGJ+2kY= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240219072201epcas5p41fbb970f2902d04565d8dbe3888cdb98~1MqXSaSGS1847418474epcas5p4W; Mon, 19 Feb 2024 07:22:01 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.183]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4TdYrR6rp0z4x9Pw; Mon, 19 Feb 2024 07:21:59 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id A5.80.10009.79103D56; Mon, 19 Feb 2024 16:21:59 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240219031238epcas5p3aa330855093314a2c5768cf83971599c~1JQnjg2i31795817958epcas5p32; Mon, 19 Feb 2024 03:12:38 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240219031238epsmtrp25ad73a7782742174d219c1a1ae1d2925~1JQnisthy1454914549epsmtrp2W; Mon, 19 Feb 2024 03:12:38 +0000 (GMT) X-AuditID: b6c32a4a-261fd70000002719-92-65d30197bd09 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id EA.6A.08817.527C2D56; Mon, 19 Feb 2024 12:12:37 +0900 (KST) Received: from testpc118124.samsungds.net (unknown [109.105.118.124]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240219031236epsmtip193194b00f806aa26e158495b77512ae7~1JQmQ4xjl2613326133epsmtip1T; Mon, 19 Feb 2024 03:12:36 +0000 (GMT) From: Xiaobing Li To: axboe@kernel.dk 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, xiaobing.li@samsung.com Subject: Re: Re: [PATCH] liburing: add script for statistics sqpoll running time. Date: Mon, 19 Feb 2024 11:12:32 +0800 Message-Id: <20240219031232.203025-1-xiaobing.li@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <522c03d9-a8ba-459d-9f7c-dfbf461dcf6b@kernel.dk> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrEJsWRmVeSWpSXmKPExsWy7bCmuu50xsupBi1fTCzmrNrGaLH6bj+b xbvWcywWR/+/ZbP41X2X0WLrl6+sFpd3zWGzeLaX0+LL4e/sFmcnfGC1mLplB5NFR8tlRgce j52z7rJ7XD5b6tG3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5768cf83971599c 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: 20240219031238epcas5p3aa330855093314a2c5768cf83971599c References: <522c03d9-a8ba-459d-9f7c-dfbf461dcf6b@kernel.dk> On 2/18/24 06:00 AM, Jens Axboe wrote: >And since your Signed-off-by is here, it also does not go into the >commit message, which it must. > >> 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; > >Here, and in one other spot, you're mixing variable declarations and >code. Don't do that, they need to be top of that scope and before any >code. > >> 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); > >Ditto, move the variables to the top of the scope. > >> 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); >> + > >and this should go in a helper instead. It's trivial code, but the way >too long lines makes it hard to read. Compare the above to eg: > >static void io_sq_update_worktime(struct io_sq_data *sqd, struct rusage *start) >{ > struct rusage end; > > getrusage(current, RUSAGE_SELF, &end); > end.ru_stime.tv_sec -= start->ru_stime.tv_sec; > end_ru_stime.tv_usec -= start->ru_stime.tv_usec; > > sqd->work_time += end.ru_stime.tv_usec + end.ru_stime.tv_sec * 1000000; >} > >which is so much nicer to look at. > >We're already doing an sqt_spin == true check right below, here: > >> if (sqt_spin || !time_after(jiffies, timeout)) { >> if (sqt_spin) >> timeout = jiffies + sqd->sq_thread_idle; > >why not just put io_sq_update_worktime(sqd, &start); inside this check? > ok, I got it, I will send out a v9. -- Xiaobing Li