Re: [PATCH] scsi: ufs: core: sysfs: Prevent div by zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Bart,

On 11/22/2024 4:24 AM, Bart Van Assche wrote:
On 11/19/24 10:25 PM, Gwendal Grignou wrote:
Prevent a division by 0 when monitoring is not enabled.

Fixes: 1d8613a23f3c ("scsi: ufs: core: Introduce HBA performance monitor sysfs nodes")

Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Gwendal Grignou <gwendal@xxxxxxxxxxxx>
---
  drivers/ufs/core/ufs-sysfs.c | 6 ++++++
  1 file changed, 6 insertions(+)

diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c
index c95906443d5f9..3692b39b35e78 100644
--- a/drivers/ufs/core/ufs-sysfs.c
+++ b/drivers/ufs/core/ufs-sysfs.c
@@ -485,6 +485,9 @@ static ssize_t read_req_latency_avg_show(struct device *dev,
      struct ufs_hba *hba = dev_get_drvdata(dev);
      struct ufs_hba_monitor *m = &hba->monitor;
  +    if (!m->nr_req[READ])
+        return sysfs_emit(buf, "0\n");
+
      return sysfs_emit(buf, "%llu\n", div_u64(ktime_to_us(m->lat_sum[READ]),
                           m->nr_req[READ]));
  }
@@ -552,6 +555,9 @@ static ssize_t write_req_latency_avg_show(struct device *dev,
      struct ufs_hba *hba = dev_get_drvdata(dev);
      struct ufs_hba_monitor *m = &hba->monitor;
  +    if (!m->nr_req[WRITE])
+        return sysfs_emit(buf, "0\n");
+
      return sysfs_emit(buf, "%llu\n", div_u64(ktime_to_us(m->lat_sum[WRITE]),
                           m->nr_req[WRITE]));
  }

Is anyone using the UFS monitor infrastructure or can it perhaps be
removed?

We are the user of the UFS monitor. And we are about to integrate UFS queue depth monitoring in it.


Thanks,

Can Guo.


Thanks,

Bart.




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux