Re: [PATCH 2/7] mm: shrinker: Add a .to_text() method for shrinkers

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

 



Hi Kent,

On 2023/11/24 05:24, Kent Overstreet wrote:
On Thu, Nov 23, 2023 at 11:32:59AM +0800, Qi Zheng wrote:
+	void (*to_text)(struct seq_buf *, struct shrinker *);

The "to_text" looks a little strange, how about naming it
"stat_objects"?

The convention I've been using heavily in bcachefs is
typename_to_text(), or type.to_text(), for debug reports. The

OK.

consistency is nice.

However, this is inconsistent with the name style of other
shrinker callbacks. Please use the "objects" suffix. As for
bcachefs's own callback function, you can use typename_to_text()
to ensure consistency.

Thanks,
Qi



   	long batch;	/* reclaim batch size, 0 = default */
   	int seeks;	/* seeks to recreate an obj */
@@ -110,7 +114,6 @@ struct shrinker {
   #endif
   #ifdef CONFIG_SHRINKER_DEBUG
   	int debugfs_id;
-	const char *name;

The name will only be allocated memory when the CONFIG_SHRINKER_DEBUG is
enabled, otherwise its value is NULL. So you can't move it out and use
it while CONFIG_SHRINKER_DEBUG is disabled.

Good catch

+void shrinkers_to_text(struct seq_buf *out)
+{
+	struct shrinker *shrinker;
+	struct shrinker_by_mem {
+		struct shrinker	*shrinker;
+		unsigned long	mem;

The "mem" also looks a little strange, how about naming it
"freeable"?

The type is just used in this one function, but sure.


+	} shrinkers_by_mem[10];
+	int i, nr = 0;
+
+	if (!mutex_trylock(&shrinker_mutex)) {
+		seq_buf_puts(out, "(couldn't take shrinker lock)");
+		return;
+	}

We now have lockless method (RCU + refcount) to iterate shrinker_list,
please refer to shrink_slab().

Will do!




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux