Skip to contentSkip to conversation

device-mapper: use dynamic debug

PATCH In review Hannes Reinecke 3 participants 7 messages May 14, 2020 Device mapper

lore
Share & tools
lore
#0 lore raw

v2 cover device-mapper: use dynamic debug

Hi all,

here's an updated version of my earlier patch to switch to dynamic debug instead of using a compile-time option.
I've modified the initial patch as suggested by Mike, and also fixed up stray newlines which had crept in with some debugging messages in dm-zoned.

Hannes Reinecke (2):
device-mapper: use dynamic debug instead of compile-time config option
dm-zoned: remove spurious newlines from debugging messages

 drivers/md/dm-zoned-reclaim.c | 4 ++--
 drivers/md/dm-zoned-target.c  | 4 ++--
 include/linux/device-mapper.h | 5 ++---
 3 files changed, 6 insertions(+), 7 deletions(-)
Signature · 1 line
2.16.4
#1 lore raw

PATCH v2 1/2 device-mapper: use dynamic debug instead of compile-time config option

Switch to use dynamic debug to avoid having recompile the kernel just to enable debugging messages.

---
 include/linux/device-mapper.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/linux/device-mapper.h +2 -3
index af48d9da3916..4694e1bb4196 100644
@@ -557,12 +557,11 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
 #define DMINFO(fmt, ...) pr_info(DM_FMT(fmt), ##__VA_ARGS__)
 #define DMINFO_LIMIT(fmt, ...) pr_info_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
 
+#define DMDEBUG_LIMIT(fmt, ...) pr_debug_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
 #ifdef CONFIG_DM_DEBUG
 #define DMDEBUG(fmt, ...) printk(KERN_DEBUG DM_FMT(fmt), ##__VA_ARGS__)
-#define DMDEBUG_LIMIT(fmt, ...) pr_debug_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
 #else
-#define DMDEBUG(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
-#define DMDEBUG_LIMIT(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
+#define DMDEBUG(fmt, ...) pr_debug(DM_FMT(fmt), ##__VA_ARGS__)
 #endif
 
 #define DMEMIT(x...) sz += ((sz >= maxlen) ? \
Signature · 1 line
2.16.4
#5 lore raw

PATCH v2 2/2 dm-zoned: remove spurious newlines from debugging messages

In reply to Hannes Reinecke

DMDEBUG will already add a newline to the logging messages, so we shouldn't be adding it to the message itself.

---
 drivers/md/dm-zoned-reclaim.c | 4 ++--
 drivers/md/dm-zoned-target.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/md/dm-zoned-reclaim.c +2 -2
index 39ea0d5d4706..4bfa61540b9c 100644
@@ -405,7 +405,7 @@ static int dmz_do_reclaim(struct dmz_reclaim *zrc)
 
 	ret = dmz_flush_metadata(zrc->metadata);
 	if (ret) {
-		DMDEBUG("(%s): Metadata flush for zone %u failed, err %d\n",
+		DMDEBUG("(%s): Metadata flush for zone %u failed, err %d",
 			dmz_metadata_label(zmd), rzone->id, ret);
 		return ret;
 	}
@@ -493,7 +493,7 @@ static void dmz_reclaim_work(struct work_struct *work)
 
 	ret = dmz_do_reclaim(zrc);
 	if (ret) {
-		DMDEBUG("(%s): Reclaim error %d\n",
+		DMDEBUG("(%s): Reclaim error %d",
 			dmz_metadata_label(zmd), ret);
 		if (!dmz_check_dev(zmd))
 			return;
drivers/md/dm-zoned-target.c +2 -2
index ea43f6892ced..a3d572da70ad 100644
@@ -515,7 +515,7 @@ static void dmz_flush_work(struct work_struct *work)
 	/* Flush dirty metadata blocks */
 	ret = dmz_flush_metadata(dmz->metadata);
 	if (ret)
-		DMDEBUG("(%s): Metadata flush failed, rc=%d\n",
+		DMDEBUG("(%s): Metadata flush failed, rc=%d",
 			dmz_metadata_label(dmz->metadata), ret);
 
 	/* Process queued flush requests */
@@ -679,7 +679,7 @@ static int dmz_map(struct dm_target *ti, struct bio *bio)
 	/* Now ready to handle this BIO */
 	ret = dmz_queue_chunk_work(dmz, bio);
 	if (ret) {
-		DMDEBUG("(%s): BIO op %d, can't process chunk %llu, err %i\n",
+		DMDEBUG("(%s): BIO op %d, can't process chunk %llu, err %i",
 			dmz_metadata_label(zmd),
 			bio_op(bio), (u64)dmz_bio_chunk(zmd, bio),
 			ret);
Signature · 1 line
2.16.4
#2 lore raw

Re: [PATCH 1/2] device-mapper: use dynamic debug instead of compile-time config option

In reply to Hannes Reinecke
Quoted 13 lines · Hannes Reinecke

Switch to use dynamic debug to avoid having recompile the kernel just to enable debugging messages.

---
 include/linux/device-mapper.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/linux/device-mapper.h +0 -0
index af48d9da3916..4694e1bb4196 100644

include/linux/device-mapper.h void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size); · line 560

Quoted 4 lines
include/linux/device-mapper.h +1 -0
@@ -557,12 +557,11 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
 #define DMINFO(fmt, ...) pr_info(DM_FMT(fmt), ##__VA_ARGS__)
 #define DMINFO_LIMIT(fmt, ...) pr_info_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
 
+#define DMDEBUG_LIMIT(fmt, ...) pr_debug_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)

Why do you move this one out of the #ifdef CONFIG_DM_DEBUG scope ?

Quoted 11 lines
include/linux/device-mapper.h +1 -3
 #ifdef CONFIG_DM_DEBUG
 #define DMDEBUG(fmt, ...) printk(KERN_DEBUG DM_FMT(fmt), ##__VA_ARGS__)
-#define DMDEBUG_LIMIT(fmt, ...) pr_debug_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
 #else
-#define DMDEBUG(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
-#define DMDEBUG_LIMIT(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
+#define DMDEBUG(fmt, ...) pr_debug(DM_FMT(fmt), ##__VA_ARGS__)
 #endif
 
 #define DMEMIT(x...) sz += ((sz >= maxlen) ? \
Signature · 2 lines
Damien Le Moal
Western Digital Research
Reviewed-by on v2 2/2
#6 lore raw

Re: [PATCH 2/2] dm-zoned: remove spurious newlines from debugging messages

In reply to Hannes Reinecke
Quoted 46 lines · Hannes Reinecke

DMDEBUG will already add a newline to the logging messages, so we shouldn't be adding it to the message itself.

---
 drivers/md/dm-zoned-reclaim.c | 4 ++--
 drivers/md/dm-zoned-target.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/md/dm-zoned-reclaim.c +2 -2
index 39ea0d5d4706..4bfa61540b9c 100644
@@ -405,7 +405,7 @@ static int dmz_do_reclaim(struct dmz_reclaim *zrc)
 
 	ret = dmz_flush_metadata(zrc->metadata);
 	if (ret) {
-		DMDEBUG("(%s): Metadata flush for zone %u failed, err %d\n",
+		DMDEBUG("(%s): Metadata flush for zone %u failed, err %d",
 			dmz_metadata_label(zmd), rzone->id, ret);
 		return ret;
 	}
@@ -493,7 +493,7 @@ static void dmz_reclaim_work(struct work_struct *work)
 
 	ret = dmz_do_reclaim(zrc);
 	if (ret) {
-		DMDEBUG("(%s): Reclaim error %d\n",
+		DMDEBUG("(%s): Reclaim error %d",
 			dmz_metadata_label(zmd), ret);
 		if (!dmz_check_dev(zmd))
 			return;
drivers/md/dm-zoned-target.c +1 -1
index ea43f6892ced..a3d572da70ad 100644
@@ -515,7 +515,7 @@ static void dmz_flush_work(struct work_struct *work)
 	/* Flush dirty metadata blocks */
 	ret = dmz_flush_metadata(dmz->metadata);
 	if (ret)
-		DMDEBUG("(%s): Metadata flush failed, rc=%d\n",
+		DMDEBUG("(%s): Metadata flush failed, rc=%d",
 			dmz_metadata_label(dmz->metadata), ret);
 
 	/* Process queued flush requests */

drivers/md/dm-zoned-target.c static int dmz_map(struct dm_target *ti, struct bio *bio) · line 685

Quoted 8 lines
drivers/md/dm-zoned-target.c +1 -1
@@ -679,7 +679,7 @@ static int dmz_map(struct dm_target *ti, struct bio *bio)
 	/* Now ready to handle this BIO */
 	ret = dmz_queue_chunk_work(dmz, bio);
 	if (ret) {
-		DMDEBUG("(%s): BIO op %d, can't process chunk %llu, err %i\n",
+		DMDEBUG("(%s): BIO op %d, can't process chunk %llu, err %i",
 			dmz_metadata_label(zmd),
 			bio_op(bio), (u64)dmz_bio_chunk(zmd, bio),
 			ret);
Signature · 2 lines
Damien Le Moal
Western Digital Research
#3 lore raw

Re: [PATCH 1/2] device-mapper: use dynamic debug instead of compile-time config option

In reply to Damien Le Moal
Quoted 17 lines · Damien Le Moal
Quoted 16 lines · Hannes Reinecke

Switch to use dynamic debug to avoid having recompile the kernel just to enable debugging messages.

---
 include/linux/device-mapper.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/linux/device-mapper.h +0 -0
index af48d9da3916..4694e1bb4196 100644
@@ -557,12 +557,11 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
 #define DMINFO(fmt, ...) pr_info(DM_FMT(fmt), ##__VA_ARGS__)
 #define DMINFO_LIMIT(fmt, ...) pr_info_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
 
Quoted 3 lines

include/linux/device-mapper.h void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size); · line 560

Quoted 1 line
include/linux/device-mapper.h +1 -0
+#define DMDEBUG_LIMIT(fmt, ...) pr_debug_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)

Why do you move this one out of the #ifdef CONFIG_DM_DEBUG scope ?

I'd imagine because it already uses dynamic debugging and is useful even if CONFIG_DM_DEBUG isn't set. Makes sense to me. I'll add a note about it in the commit header though.

Mike

#4 lore raw

Re: [PATCH 1/2] device-mapper: use dynamic debug instead of compile-time config option

In reply to Hannes Reinecke
Quoted 4 lines · Hannes Reinecke

Switch to use dynamic debug to avoid having recompile the kernel just to enable debugging messages.

FYI, I decided to always use pr_debug* rather than preserve using printk if CONFIG_DM_DEBUG is enabled. More consistent and less surprising for a developer (to have to reason through how to enable debugging).

May cause initial surprise if debugging messages disappear despite CONFIG_DM_DEBUG being enabled... but pretty sure DM developers can cope (and/or help non-developers) as needed.

Patches were staged for 5.8, I also added an additional related cleanup:
https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/log/?h=dm-5.8

Thanks,
Mike