Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1392628ybn; Wed, 25 Sep 2019 17:39:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqx20nCvkqQumh1yWVz7YkoYxpMP7L0MH382GOKHzfcXt8Mtx5bD4yF3C2TXi6jLOAJyLJjC X-Received: by 2002:a17:907:2118:: with SMTP id qn24mr814667ejb.81.1569458387637; Wed, 25 Sep 2019 17:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569458387; cv=none; d=google.com; s=arc-20160816; b=lKosFUI+LnDQBny1AAZJVH0gRLO+JvN6BUjbCnpMG5f40lQRir8LAgnQkmooe/9/qi vWregOC8Ag2h7arvAWxrGrWr6Mg9jvpEgTzBRc+C8eB+EtyldR/AQnBleDKtmUUsudhi 4VUPcM22/gk610AD1dGidOtJos8MqDjhSNVd2A3J/JZki9jkJA5kOnLKot1HZBfxHNDF u2FF6XOhjngHkOg1xE01LFUIdlz2XcdqXa4sseZBNhrFZjdtb7GLC7uDKznwvtaEds0p +j46fnQn79U/2wchR+ek0yzemyBmiCN9bfsyPWg0MClK0ii9614SZROCiWXdnsFynBD5 gFVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=A84y+WaMfod08XwwUGCuyrOL9UDA0HOwJx6UH2T1Ki4=; b=cfwM9hsZve6X0Oaq1Hu/OUkkCyIMlRi1THS5wN6CdYmaVgJzVBrpJm56/G597Scj6w u37woMXkVRH2C4aktU0ePrKgi8yYs7dmiT5ERvBpd0PzQTIyE9LSiIycZPp61J+LBt7n 9dUGYuYf2G1hGgVEO+qbSiiS14/reKhLBDr2yILVgLc6I4JPAgE63nUvATYo+clkM30/ KEJfa2KN25F87GszyEZfJOKFYK6SKFI2Zu1J0lXmd4V9h9f3T7gj/AhQ08EBv/Tt6Q1f BR/F8lCusYFxIgyxpi0aSFDufyoZJtpzU6KjD2H5t0dTivglPUKo0dUU8dhSBIkgAjD9 SmLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ca7si227116ejb.319.2019.09.25.17.39.22; Wed, 25 Sep 2019 17:39:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408725AbfIXFOE (ORCPT + 99 others); Tue, 24 Sep 2019 01:14:04 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:43293 "EHLO out30-54.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404357AbfIXFOE (ORCPT ); Tue, 24 Sep 2019 01:14:04 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R881e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07417;MF=xiaoguang.wang@linux.alibaba.com;NM=1;PH=DS;RN=2;SR=0;TI=SMTPD_---0TdGsAAP_1569302037; Received: from localhost(mailfrom:xiaoguang.wang@linux.alibaba.com fp:SMTPD_---0TdGsAAP_1569302037) by smtp.aliyun-inc.com(127.0.0.1); Tue, 24 Sep 2019 13:13:58 +0800 From: Xiaoguang Wang To: linux-ext4@vger.kernel.org Cc: Xiaoguang Wang Subject: [PATCH 1/3] jbd2: add new tracepoint jbd2_wait_on_shadow Date: Tue, 24 Sep 2019 13:13:48 +0800 Message-Id: <20190924051350.1740-1-xiaoguang.wang@linux.alibaba.com> X-Mailer: git-send-email 2.17.2 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Sometimes process will be stalled in "wait_on_bit_io(&bh->b_state, BH_Shadow, TASK_UNINTERRUPTIBLE)" for a while, and in order to analyse app's latency thoroughly, add a new tracepoint to track this delay. Trace info likes below: kworker/u32:1-100 [004] .... 690.217690: jbd2_wait_on_shadow: dev 254,17 latency(us) 3363 fsstress-2139 [013] .... 690.217830: jbd2_wait_on_shadow: dev 254,17 latency(us) 2403 fsstress-2130 [005] .... 690.218241: jbd2_wait_on_shadow: dev 254,17 latency(us) 3589 fsstress-2131 [009] .... 690.230933: jbd2_wait_on_shadow: dev 254,17 latency(us) 11799 fsstress-2132 [007] .... 690.230961: jbd2_wait_on_shadow: dev 254,17 latency(us) 11540 fsstress-2130 [005] .... 690.230965: jbd2_wait_on_shadow: dev 254,17 latency(us) 3577 fsstress-2139 [005] .... 690.230979: jbd2_wait_on_shadow: dev 254,17 latency(us) 11716 fsstress-2137 [003] .... 690.230980: jbd2_wait_on_shadow: dev 254,17 latency(us) 836 fsstress-2133 [015] .... 690.230981: jbd2_wait_on_shadow: dev 254,17 latency(us) 11341 fsstress-2130 [005] .... 690.230988: jbd2_wait_on_shadow: dev 254,17 latency(us) 21 Signed-off-by: Xiaoguang Wang --- fs/jbd2/transaction.c | 4 ++++ include/trace/events/jbd2.h | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index afc06daee5bb..5d7a96e10133 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -864,6 +864,7 @@ do_get_write_access(handle_t *handle, struct journal_head *jh, int error; char *frozen_buffer = NULL; unsigned long start_lock, time_lock; + s64 start_us; if (is_handle_aborted(handle)) return -EROFS; @@ -994,7 +995,10 @@ do_get_write_access(handle_t *handle, struct journal_head *jh, if (buffer_shadow(bh)) { JBUFFER_TRACE(jh, "on shadow: sleep"); jbd_unlock_bh_state(bh); + start_us = ktime_to_us(ktime_get()); wait_on_bit_io(&bh->b_state, BH_Shadow, TASK_UNINTERRUPTIBLE); + trace_jbd2_wait_on_shadow(bh->b_bdev->bd_dev, + ktime_to_us(ktime_get()) - start_us); goto repeat; } diff --git a/include/trace/events/jbd2.h b/include/trace/events/jbd2.h index 2310b259329f..e42072c74ce9 100644 --- a/include/trace/events/jbd2.h +++ b/include/trace/events/jbd2.h @@ -380,6 +380,27 @@ TRACE_EVENT(jbd2_lock_buffer_stall, __entry->stall_ms) ); +TRACE_EVENT(jbd2_wait_on_shadow, + + TP_PROTO(dev_t dev, unsigned long wait_us), + + TP_ARGS(dev, wait_us), + + TP_STRUCT__entry( + __field( dev_t, dev ) + __field(unsigned long, wait_us ) + ), + + TP_fast_assign( + __entry->dev = dev; + __entry->wait_us = wait_us; + ), + + TP_printk("dev %d,%d latency(us) %lu", + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->wait_us) +); + #endif /* _TRACE_JBD2_H */ /* This part must be outside protection */ -- 2.17.2