ufs: core: Only collect timestamps if the monitoring functionality is enabled
Subsystems (2)
Bart Van Assche
reviewerPATCH 1/1 ufs: core: Only collect timestamps if the monitoring functionality is enabled
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"; v5.14).
--- drivers/ufs/core/ufshcd.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/ufs/core/ufshcd.c +10 -6
@@ -2357,10 +2357,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);
@@ -5622,8 +5624,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)))
Hi Bart,
Quoted 19 lines
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"; v5.14).Cc Can Guo <[email protected]>Cc Bean Huo <[email protected]>Cc Daejun Park <[email protected]>Signed-off-by Bart Van Assche <[email protected]>---
drivers/ufs/core/ufshcd.c16 ++++++++++------1 file changed, 10 insertions(+), 6 deletions(-)drivers/ufs/core/ufshcd.c +0
-0
drivers/ufs/core/ufshcd.c void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag, · line 2363
Quoted 7 lines
drivers/ufs/core/ufshcd.c +0
-4@@ -2357,10 +2357,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;
How about modifying ufshcd_compl_one_cqe() to skip updating compl_time_stamp?
Thanks,
Daejun
Bart Van Assche
reviewerQuoted 1 line · Daejun Park
How about modifying
ufshcd_compl_one_cqe()to skip updatingcompl_time_stamp?
I think my patch already does that:
@@ -5622,8 +5624,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)))
Bart.
Quoted 36 lines · Bart Van Assche
drivers/ufs/core/ufshcd.c +6
-4@@ -2357,10 +2357,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);drivers/ufs/core/ufshcd.c +4
-2@@ -5622,8 +5624,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) {
Quoted 2 lines
if (
unlikely(ufshcd_should_inform_monitor(hba, lrbp)))
Hi Bart,
Should this information also be provided toufshcd_print_tr for debugging purposes?
Thanks
Peter
Bart Van Assche
reviewerQuoted 2 lines · Peter Wang (王信友)
Should this information also be provided to
ufshcd_print_trfor debugging purposes?
How about the patch below?
Thanks,
Bart.
--- drivers/ufs/core/ufshcd.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/ufs/core/ufshcd.c +16 -10
@@ -607,10 +607,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);
@@ -2357,10 +2359,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);
@@ -5622,8 +5626,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)))
Peter Wang (王信友)
Reviewed-byQuoted 5 lines · Bart Van Assche
External email : Please do not click links or open attachments until you have verified the sender or the content.
Quoted 9 lines
Quoted 2 lines · Peter Wang (王信友)
Should this information also be provided to
ufshcd_print_trfor debugging purposes?How about the patch below?
Thanks,
Bart.
Hi Bart,
Yes, that looks good to me.
Thanks.
Peter