Re: [Intel-gfx] [PATCH v4 03/10] lib/ref_tracker: add printing to memory buffer

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

 



On 20.03.2023 00:18, Andi Shyti wrote:
Hi Andrzej,

This looks also good, just few questions.

On Mon, Mar 06, 2023 at 05:31:59PM +0100, Andrzej Hajda wrote:
In case one wants to show stats via debugfs.

shall I say it? I'll say it... you can do better with the log
here. It's not a typo fix :)

Signed-off-by: Andrzej Hajda <andrzej.hajda@xxxxxxxxx>

[...]

+void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
+			   unsigned int display_limit)
+{
+	struct ostream os = {};
+
+	__ref_tracker_dir_pr_ostream(dir, display_limit, &os);
+}
  EXPORT_SYMBOL(__ref_tracker_dir_print);
void ref_tracker_dir_print(struct ref_tracker_dir *dir,
@@ -114,6 +141,19 @@ void ref_tracker_dir_print(struct ref_tracker_dir *dir,
  }
  EXPORT_SYMBOL(ref_tracker_dir_print);
+int ref_tracker_dir_snprint(struct ref_tracker_dir *dir, char *buf, size_t size)

nit: snprintf is normally referred to its variable parameter
counterpart... I would choose a different name... how about
ref_tracker_dir_fetch_print()?


Hmm, original ref_tracker_dir_print prints the stats to dmesg,
ref_tracker_dir_snprint prints to memory buffer, like:
- stack_depot_print and stack_depot_snprint,
- stack_trace_print and stack_trace_snprint.



+{
+	struct ostream os = { .buf = buf, .size = size };
+	unsigned long flags;
+
+	spin_lock_irqsave(&dir->lock, flags);
+	__ref_tracker_dir_pr_ostream(dir, 16, &os);
+	spin_unlock_irqrestore(&dir->lock, flags);

What are you trying to protect with this spinlock? what if
the caller has already locked here? do we need a _locked()
version?

spinlock is to serialize access to dir,
at the moment _locked version is not necessary, but it can be easily added if needed.

Regards
Andrzej



Thanks,
Andi

+	return os.used;
+}
+EXPORT_SYMBOL(ref_tracker_dir_snprint);
+
  void ref_tracker_dir_exit(struct ref_tracker_dir *dir)
  {
  	struct ref_tracker *tracker, *n;

--
2.34.1




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux