]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: ufs: core: Only collect timestamps if monitoring is enabled
authorBart Van Assche <bvanassche@acm.org>
Tue, 19 Aug 2025 15:39:50 +0000 (08:39 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 20 Aug 2025 02:21:10 +0000 (22:21 -0400)
Every ktime_get() call in the hot path has a measurable impact on IOPS.
Hence, only collect timestamps if the monitoring functionality is
enabled.

See also commit 1d8613a23f3c ("scsi: ufs: core: Introduce HBA
performance monitor sysfs nodes").

Cc: Can Guo <cang@codeaurora.org>
Cc: Bean Huo <beanhuo@micron.com>
Cc: Daejun Park <daejun7.park@samsung.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20250819153958.2255907-1-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/core/ufshcd.c

index daae452a1d25c63b7b8da3ec548e208301549a9f..ca6a0f8ccbea746d99415f56568b1b3eecc0f78c 100644 (file)
@@ -606,10 +606,12 @@ void ufshcd_print_tr(struct ufs_hba *hba, int tag, bool pr_prdt)
 
        lrbp = &hba->lrb[tag];
 
-       dev_err(hba->dev, "UPIU[%d] - issue time %lld us\n",
-                       tag, div_u64(lrbp->issue_time_stamp_local_clock, 1000));
-       dev_err(hba->dev, "UPIU[%d] - complete time %lld us\n",
-                       tag, div_u64(lrbp->compl_time_stamp_local_clock, 1000));
+       if (hba->monitor.enabled) {
+               dev_err(hba->dev, "UPIU[%d] - issue time %lld us\n", tag,
+                       div_u64(lrbp->issue_time_stamp_local_clock, 1000));
+               dev_err(hba->dev, "UPIU[%d] - complete time %lld us\n", tag,
+                       div_u64(lrbp->compl_time_stamp_local_clock, 1000));
+       }
        dev_err(hba->dev,
                "UPIU[%d] - Transfer Request Descriptor phys@0x%llx\n",
                tag, (u64)lrbp->utrd_dma_addr);
@@ -2356,10 +2358,12 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag,
        struct ufshcd_lrb *lrbp = &hba->lrb[task_tag];
        unsigned long flags;
 
-       lrbp->issue_time_stamp = ktime_get();
-       lrbp->issue_time_stamp_local_clock = local_clock();
-       lrbp->compl_time_stamp = ktime_set(0, 0);
-       lrbp->compl_time_stamp_local_clock = 0;
+       if (hba->monitor.enabled) {
+               lrbp->issue_time_stamp = ktime_get();
+               lrbp->issue_time_stamp_local_clock = local_clock();
+               lrbp->compl_time_stamp = ktime_set(0, 0);
+               lrbp->compl_time_stamp_local_clock = 0;
+       }
        ufshcd_add_command_trace(hba, task_tag, UFS_CMD_SEND);
        if (lrbp->cmd)
                ufshcd_clk_scaling_start_busy(hba);
@@ -5619,8 +5623,10 @@ void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag,
        enum utp_ocs ocs;
 
        lrbp = &hba->lrb[task_tag];
-       lrbp->compl_time_stamp = ktime_get();
-       lrbp->compl_time_stamp_local_clock = local_clock();
+       if (hba->monitor.enabled) {
+               lrbp->compl_time_stamp = ktime_get();
+               lrbp->compl_time_stamp_local_clock = local_clock();
+       }
        cmd = lrbp->cmd;
        if (cmd) {
                if (unlikely(ufshcd_should_inform_monitor(hba, lrbp)))