From: Can Guo <cang@codeaurora.org>
To: daejun7.park@samsung.com
Cc: asutoshd@codeaurora.org, nguyenb@codeaurora.org,
hongwus@codeaurora.org, linux-scsi@vger.kernel.org,
kernel-team@android.com, ALIM AKHTAR <alim.akhtar@samsung.com>,
Avri Altman <avri.altman@wdc.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Stanley Chu <stanley.chu@mediatek.com>,
Bean Huo <beanhuo@micron.com>, Jaegeuk Kim <jaegeuk@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Kiwoong Kim <kwmad.kim@samsung.com>,
Satya Tangirala <satyat@google.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] scsi: ufs: Introduce hba performance monitor sysfs nodes
Date: Tue, 06 Apr 2021 13:43:32 +0800 [thread overview]
Message-ID: <ef71a41a501f69a6070daa33cbddae25@codeaurora.org> (raw)
In-Reply-To: <e29c3fa0d5ecfd8eb386432008f24e8c@codeaurora.org>
On 2021-04-06 13:37, Can Guo wrote:
> Hi Daejun,
>
> On 2021-04-06 12:11, Daejun Park wrote:
>> Hi Can Guo,
>>
>>> +static ssize_t monitor_enable_store(struct device *dev,
>>> + struct device_attribute *attr,
>>> + const char *buf, size_t count)
>>> +{
>>> + struct ufs_hba *hba = dev_get_drvdata(dev);
>>> + unsigned long value, flags;
>>> +
>>> + if (kstrtoul(buf, 0, &value))
>>> + return -EINVAL;
>>> +
>>> + value = !!value;
>>> + spin_lock_irqsave(hba->host->host_lock, flags);
>>> + if (value == hba->monitor.enabled)
>>> + goto out_unlock;
>>> +
>>> + if (!value) {
>>> + memset(&hba->monitor, 0, sizeof(hba->monitor));
>>> + } else {
>>> + hba->monitor.enabled = true;
>>> + hba->monitor.enabled_ts = ktime_get();
>>
>> How about setting lat_max to and lat_min to KTIME_MAX and 0?
>
> lat_min is already 0. What is the benefit of setting lat_max to
> KTIME_MAX?
>
>> I think lat_sum should be 0 at this point.
>
> lat_sum is already 0 at this point, what is the problem?
>
>>
>>> + }
>>> +
>>> +out_unlock:
>>> + spin_unlock_irqrestore(hba->host->host_lock, flags);
>>> + return count;
>>> +}
>>
>>
>>> +static void ufshcd_update_monitor(struct ufs_hba *hba, struct
>>> ufshcd_lrb *lrbp)
>>> +{
>>> + int dir = ufshcd_monitor_opcode2dir(*lrbp->cmd->cmnd);
>>> +
>>> + if (dir >= 0 && hba->monitor.nr_queued[dir] > 0) {
>>> + struct request *req = lrbp->cmd->request;
>>> + struct ufs_hba_monitor *m = &hba->monitor;
>>> + ktime_t now, inc, lat;
>>> +
>>> + now = ktime_get();
>>
>> How about using lrbp->compl_time_stamp instead of getting new value?
>
> I am expecting "now" keeps increasing and use it to update
> m->busy_start_s,
> but if I use lrbp->compl_time_stamp to do that, below line ktime_sub()
> may
> give me an unexpected value as lrbp->compl_time_stamp may be smaller
> than
> m->busy_start_ts, because the actual requests are not completed by the
> device
> in the exact same ordering as the bits set in hba->outstanding_tasks,
> but driver
> is completing them from bit 0 to bit 31 in ascending order.
Sorry, I missunderstood your point... Yes, we can use
lrbp->compl_time_stamp.
Thanks,
Can Guo.
>
>>
>>> + inc = ktime_sub(now, m->busy_start_ts[dir]);
>>> + m->total_busy[dir] = ktime_add(m->total_busy[dir],
>>> inc);
>>> + m->nr_sec_rw[dir] += blk_rq_sectors(req);
>>> +
>>> + /* Update latencies */
>>> + m->nr_req[dir]++;
>>> + lat = ktime_sub(now, lrbp->issue_time_stamp);
>>> + m->lat_sum[dir] += lat;
>>> + if (m->lat_max[dir] < lat || !m->lat_max[dir])
>>> + m->lat_max[dir] = lat;
>>> + if (m->lat_min[dir] > lat || !m->lat_min[dir])
>>> + m->lat_min[dir] = lat;
>>
>> This if statement can be shorted, by setting lat_max / lat_min as
>> default value.
>
> I don't quite get it, can you show me the code sample?
>
> Thanks,
> Can Guo
>
>>
>>> +
>>> + m->nr_queued[dir]--;
>>> + /* Push forward the busy start of monitor */
>>> + m->busy_start_ts[dir] = now;
>>> + }
>>> +}
>>
>> Thanks,
>> Daejun
next prev parent reply other threads:[~2021-04-06 5:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 6:15 [PATCH v4 0/2] Introduce hba performance monitoring sysfs nodes Can Guo
2021-04-01 6:15 ` [PATCH 1/2] scsi: ufs: Introduce hba performance monitor " Can Guo
2021-04-06 4:11 ` Daejun Park
2021-04-06 5:37 ` Can Guo
2021-04-06 5:43 ` Can Guo [this message]
2021-04-06 5:58 ` Daejun Park
2021-04-06 6:11 ` Can Guo
2021-04-01 6:15 ` [PATCH 2/2] scsi: ufs: Add support for hba performance monitor Can Guo
-- strict thread matches above, loose matches on Subject: below --
2021-04-01 6:11 [PATCH v3 0/2] Introduce hba performance monitoring sysfs nodes Can Guo
2021-04-01 6:11 ` [PATCH 1/2] scsi: ufs: Introduce hba performance monitor " Can Guo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef71a41a501f69a6070daa33cbddae25@codeaurora.org \
--to=cang@codeaurora.org \
--cc=adrian.hunter@intel.com \
--cc=alim.akhtar@samsung.com \
--cc=asutoshd@codeaurora.org \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=daejun7.park@samsung.com \
--cc=hongwus@codeaurora.org \
--cc=jaegeuk@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=kernel-team@android.com \
--cc=kwmad.kim@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=nguyenb@codeaurora.org \
--cc=satyat@google.com \
--cc=stanley.chu@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox