Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp187026lqp; Tue, 11 Jun 2024 00:57:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX7W6V9LEbiDw3PRXwPO++97cIiuIUIGKuayjRYgNf0McqjQr9LHqTWA+TXn1ZPhT4MXYYWez47N6m5XGxCn2sYbKFc4wE/MG58p6mDoQ== X-Google-Smtp-Source: AGHT+IETBXGIRwTJS9zmg8He8t9oh4KhpFR3Prv4prVx9OXS1k9KAk4lXHItt80BeM8C7ITf0ERf X-Received: by 2002:a05:6358:280e:b0:19f:4b31:962f with SMTP id e5c5f4694b2df-19f4b319a68mr708262755d.32.1718092676158; Tue, 11 Jun 2024 00:57:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718092676; cv=pass; d=google.com; s=arc-20160816; b=G49UXo35FJsyzroUk0tfEa1KeruFH0wEYM30qphjptAcvaHGl7rfHPghE+HFTmACOz 4VVvtuEV9MH1xvn+CB0cou/sTLYtXlVJgRWfAB1VOPfi1KbbDLAdrfZLgwGvkUo1/6uf pPFjF3sBxzY9I9hrLxh5W4w38XhxgnWpA/yE53zEkdcLJ8pA3A6BWNAIhGUaJyB2RuQu e5Sy9uHLzrBSTQt8eO4a99mRow8kHBo8boPTF9Iprtd/PglJrDq9bmaH0PNc7dczzN/h yMZlyVlJUnTA/YUzAhVL3EXwsrf86xl3+Fy7XvQTcPjQd1JwZTsunj0fDLtLmV5JY9T7 Gx9g== 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:cc:to :from; bh=wBjmOGWcLk2cWqBxIrmYMQhVpZT2u0Iw6yruqlmGD1g=; fh=VfyKcNSDobqgaS21AFlwKBQLWyATUjjduix9Pxb1PTs=; b=cy96eDhzs5nWSNfa/+KuwND/VNErh4BVzfmDc2JLKMFmE2MbWUXHAzoAV/IZG58nsu MXNJ0ydySfXDVj6pnjh/EvdwjS+IPMDUFd0190UORr02tgPeMg7aFm1kpbC94cy2HtpL 9A0JLflVxRXth45gHgY5Z+yzKOKNc9Aa9lCzCNsaeqKiPJ43gC8QXC/IuXtohtHdGQ5o SdaCm0uQF7hrPquRCCLTc6QhS6qnQFO0Di5JICmpWXmZ/QA4FfrcAIvvdxA9mGdH8oAQ FHW/MzJAZNfYaeAoRpiH9L484ogqhiekp/D4okONypPj/qICgtmhvux4N+i59563kyNy H2Yw==; 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-209384-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209384-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6e383c7584dsi6938804a12.397.2024.06.11.00.57.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 00:57:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209384-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-209384-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209384-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6DDE3B20396 for ; Tue, 11 Jun 2024 07:36:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C6B817279F; Tue, 11 Jun 2024 07:36:35 +0000 (UTC) Received: from SHSQR01.spreadtrum.com (unknown [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 BF5A8172773 for ; Tue, 11 Jun 2024 07:36:30 +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=1718091394; cv=none; b=sGxwA0jzUQJKpny+fnge2HY3xM35tUHkr5+S5VIU+p0bEsKUn0aJflcrJt0/0y5jAOdECcyPdEkk8fsrHb226jOrWyfy2er1YCFZo5DWtzDETcu+KJ3WgyYaekc+l6xGj2iClLPUPnbyiFopW35G998eiR7AKYblOKTKlJu7wKM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718091394; c=relaxed/simple; bh=uJnDfuouCf0ofiaadXE2js0RA0ImI73q/IfYZIwKOkg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=l1rUNRUSbt0DYcLfnG+Qb/gDKh+3ojGSrS81fZAggvlHPK6+NhHWrSWTs6YZF+Yq73ApeerIBKyM6XHxi/4iUoDeiFLLL2msZm+UJhpBg2zaSlFSl3gOQk02fGjZ6P1jFs7RrXLnzLR8C30OYCtcSBjNxN9SdOvxOLfm+R3tSEA= 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 45B7ZQWO082600; Tue, 11 Jun 2024 15:35:26 +0800 (+08) (envelope-from Dongliang.Cui@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4Vz0hx41q6z2RdZvm; Tue, 11 Jun 2024 15:31:13 +0800 (CST) Received: from tj10379pcu.spreadtrum.com (10.5.32.15) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 11 Jun 2024 15:35:21 +0800 From: Dongliang Cui To: , , , , CC: , , , , , , , , Dongliang Cui Subject: [PATCH v4] block: Add ioprio to block_rq tracepoint Date: Tue, 11 Jun 2024 15:35:19 +0800 Message-ID: <20240611073519.323680-1-dongliang.cui@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-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL:SHSQR01.spreadtrum.com 45B7ZQWO082600 Sometimes we need to track the processing order of requests with ioprio set. So the ioprio of request can be useful information. Example: block_rq_insert: 8,0 RA 16384 () 6500840 + 32 be,0,6 [binder:815_3] block_rq_issue: 8,0 RA 16384 () 6500840 + 32 be,0,6 [binder:815_3] block_rq_complete: 8,0 RA () 6500840 + 32 be,0,6 [0] Signed-off-by: Dongliang Cui --- Changes in v4: - Use macros to split ioprio. - Print ioprio hint. - Only storage ioprio in __entry. --- --- include/trace/events/block.h | 77 +++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 27 deletions(-) diff --git a/include/trace/events/block.h b/include/trace/events/block.h index 0e128ad51460..209d54dc9dce 100644 --- a/include/trace/events/block.h +++ b/include/trace/events/block.h @@ -9,9 +9,17 @@ #include #include #include +#include #define RWBS_LEN 8 +#define IOPRIO_CLASS_STRINGS \ + { IOPRIO_CLASS_NONE, "none" }, \ + { IOPRIO_CLASS_RT, "rt" }, \ + { IOPRIO_CLASS_BE, "be" }, \ + { IOPRIO_CLASS_IDLE, "idle" }, \ + { IOPRIO_CLASS_INVALID, "invalid"} + #ifdef CONFIG_BUFFER_HEAD DECLARE_EVENT_CLASS(block_buffer, @@ -79,27 +87,32 @@ TRACE_EVENT(block_rq_requeue, TP_ARGS(rq), TP_STRUCT__entry( - __field( dev_t, dev ) - __field( sector_t, sector ) - __field( unsigned int, nr_sector ) - __array( char, rwbs, RWBS_LEN ) - __dynamic_array( char, cmd, 1 ) + __field( dev_t, dev ) + __field( sector_t, sector ) + __field( unsigned int, nr_sector ) + __field( unsigned short, ioprio ) + __array( char, rwbs, RWBS_LEN ) + __dynamic_array( char, cmd, 1 ) ), TP_fast_assign( __entry->dev = rq->q->disk ? disk_devt(rq->q->disk) : 0; __entry->sector = blk_rq_trace_sector(rq); __entry->nr_sector = blk_rq_trace_nr_sectors(rq); + __entry->ioprio = rq->ioprio; blk_fill_rwbs(__entry->rwbs, rq->cmd_flags); __get_str(cmd)[0] = '\0'; ), - TP_printk("%d,%d %s (%s) %llu + %u [%d]", + TP_printk("%d,%d %s (%s) %llu + %u %s,%u,%u [%d]", MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, __get_str(cmd), - (unsigned long long)__entry->sector, - __entry->nr_sector, 0) + (unsigned long long)__entry->sector, __entry->nr_sector, + __print_symbolic(IOPRIO_PRIO_CLASS(__entry->ioprio), + IOPRIO_CLASS_STRINGS), + IOPRIO_PRIO_HINT(__entry->ioprio), + IOPRIO_PRIO_LEVEL(__entry->ioprio), 0) ); DECLARE_EVENT_CLASS(block_rq_completion, @@ -109,12 +122,13 @@ DECLARE_EVENT_CLASS(block_rq_completion, TP_ARGS(rq, error, nr_bytes), TP_STRUCT__entry( - __field( dev_t, dev ) - __field( sector_t, sector ) - __field( unsigned int, nr_sector ) - __field( int , error ) - __array( char, rwbs, RWBS_LEN ) - __dynamic_array( char, cmd, 1 ) + __field( dev_t, dev ) + __field( sector_t, sector ) + __field( unsigned int, nr_sector ) + __field( int , error ) + __field( unsigned short, ioprio ) + __array( char, rwbs, RWBS_LEN ) + __dynamic_array( char, cmd, 1 ) ), TP_fast_assign( @@ -122,16 +136,20 @@ DECLARE_EVENT_CLASS(block_rq_completion, __entry->sector = blk_rq_pos(rq); __entry->nr_sector = nr_bytes >> 9; __entry->error = blk_status_to_errno(error); + __entry->ioprio = rq->ioprio; blk_fill_rwbs(__entry->rwbs, rq->cmd_flags); __get_str(cmd)[0] = '\0'; ), - TP_printk("%d,%d %s (%s) %llu + %u [%d]", + TP_printk("%d,%d %s (%s) %llu + %u %s,%u,%u [%d]", MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, __get_str(cmd), - (unsigned long long)__entry->sector, - __entry->nr_sector, __entry->error) + (unsigned long long)__entry->sector, __entry->nr_sector, + __print_symbolic(IOPRIO_PRIO_CLASS(__entry->ioprio), + IOPRIO_CLASS_STRINGS), + IOPRIO_PRIO_HINT(__entry->ioprio), + IOPRIO_PRIO_LEVEL(__entry->ioprio), __entry->error) ); /** @@ -176,13 +194,14 @@ DECLARE_EVENT_CLASS(block_rq, TP_ARGS(rq), TP_STRUCT__entry( - __field( dev_t, dev ) - __field( sector_t, sector ) - __field( unsigned int, nr_sector ) - __field( unsigned int, bytes ) - __array( char, rwbs, RWBS_LEN ) - __array( char, comm, TASK_COMM_LEN ) - __dynamic_array( char, cmd, 1 ) + __field( dev_t, dev ) + __field( sector_t, sector ) + __field( unsigned int, nr_sector ) + __field( unsigned int, bytes ) + __field( unsigned short, ioprio ) + __array( char, rwbs, RWBS_LEN ) + __array( char, comm, TASK_COMM_LEN ) + __dynamic_array( char, cmd, 1 ) ), TP_fast_assign( @@ -190,17 +209,21 @@ DECLARE_EVENT_CLASS(block_rq, __entry->sector = blk_rq_trace_sector(rq); __entry->nr_sector = blk_rq_trace_nr_sectors(rq); __entry->bytes = blk_rq_bytes(rq); + __entry->ioprio = rq->ioprio; blk_fill_rwbs(__entry->rwbs, rq->cmd_flags); __get_str(cmd)[0] = '\0'; memcpy(__entry->comm, current->comm, TASK_COMM_LEN); ), - TP_printk("%d,%d %s %u (%s) %llu + %u [%s]", + TP_printk("%d,%d %s %u (%s) %llu + %u %s,%u,%u [%s]", MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, __entry->bytes, __get_str(cmd), - (unsigned long long)__entry->sector, - __entry->nr_sector, __entry->comm) + (unsigned long long)__entry->sector, __entry->nr_sector, + __print_symbolic(IOPRIO_PRIO_CLASS(__entry->ioprio), + IOPRIO_CLASS_STRINGS), + IOPRIO_PRIO_HINT(__entry->ioprio), + IOPRIO_PRIO_LEVEL(__entry->ioprio), __entry->comm) ); /** -- 2.25.1