Skip to contentSkip to conversation

printk: implement printk_header() and merging printk, take #3

PATCH In review Tejun Heo 3 participants 17 messages Feb 13, 2008 – Feb 16, 2008

Subsystems (2)
lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 printk: implement printk_header() and merging printk, take #3

Hello, all.

This is the third take of implement-printk_header-and-mprintk patchset.

Changes from the last take[L] are...

* Now header is printed on every line of a multiline message. If the header ends with ':' followed by spaces. The colon is replaced with space from the second line.

* s/mprintk/mprintk_flush/ and s/mprintk_add/mprintk/ as suggested.

* mprintk_init_alloc() and mprintk_free() added to ease malloc'd buffer handling. No need to specify buffer size. Sizing is left to mprintk.

This patchset aims to make printing multiline messages and assembling message piece-by-piece easier.

In a nutshell, printk_header() lets you do the following atomically (against other messages).

code:
printk(KERN_INFO "ata1.00: ", "line0\nline1\nline2\n");

output:
<6>ata1.00: line0
<6>ata1.00 line1
<6>ata1.00 line2

And mprintk the following.

code:
DEFINE_MPRINTK(mp, 2 * 80);

  mprintk_set_header(&mp, KERN_INFO "ata%u.%2u: ", 1, 0);
  mprintk_push(&mp, "ATA %d", 7);
  mprintk_push(&mp, ", %u sectors\n", 1024);
  mprintk(&mp, "everything seems dandy\n");

output:
<6>ata1.00: ATA 7, 1024 sectors
<6>ata1.00 everything seems dandy

For more info, please read Documentation/printk.txt which is created by the fourth patch.

This patchset is on top of

linux-2.6#master (96b5a46e2a72dc1829370c87053e0cd558d58bc0)
+ printk-fix-possible-printk-buffer-overrun [1]
+ printk-implement-printk_buf-overflow-warning [2]

and contains the following patches.

0001-printk-keep-log-level-on-multiline-messages.patch 0002-printk-implement-v-printk_header.patch 0003-printk-implement-merging-printk.patch 0004-printk-add-Documentation-printk.txt.patch 0005-libata-make-libata-use-printk_header-and-mprintk.patch

 Documentation/00-INDEX      |    2 
 Documentation/printk.txt    |  724 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/ata/libata-core.c   |  204 +++++++-----
 drivers/ata/libata-eh.c     |  182 +++++------
 drivers/ata/libata-pmp.c    |    5 
 drivers/ata/libata-scsi.c   |    6 
 drivers/ata/sata_inic162x.c |    2 
 drivers/ata/sata_nv.c       |    4 
 include/linux/kernel.h      |   85 +++++
 include/linux/libata.h      |   35 +-
 kernel/printk.c             |  435 ++++++++++++++++++++++++--
 11 files changed, 1453 insertions(+), 231 deletions(-)

If this gets acked, I think it's best to push it through libata-dev as libata is the first user.

Thanks.

--
tejun

[L] http://thread.gmane.org/gmane.linux.ide/27317
[1] http://article.gmane.org/gmane.linux.kernel/639018
[2] http://article.gmane.org/gmane.linux.kernel/639029

author
#1 lore raw

PATCH 1/5 printk: keep log level on multiline messages

When printing multiline messages, printk() resets log level to default_message_loglevel after the first line. This changes log level unexpectedly when printing multiline messages.

For example, libata error messages are printed like the following.

<3>ata8.00: cmd 60/01:00:e0:71:02/00:00:00:00:00/40 tag 0 ncq 512 in
<4> res 40/00:34:de:71:02/00:00:00:00:00/40 Emask 0x10 (ATA bus error)

This patch makes printk use the log level of the last line if the current line doesn't specify log level explicitly.

While at it, separate out is_loglevel() test. This will be used by later changes.

---
 kernel/printk.c |   50 +++++++++++++++++++++++---------------------------
 1 files changed, 23 insertions(+), 27 deletions(-)
kernel/printk.c +23 -27
index 419cd47..2317ec8 100644
@@ -614,6 +614,11 @@ asmlinkage int printk(const char *fmt, ...)
 	return r;
 }
 
+static int is_loglevel(const char *p)
+{
+	return p[0] == '<' && p[1] >= '0' && p[1] <= '7' && p[2] == '>';
+}
+
 asmlinkage int vprintk(const char *fmt, va_list args)
 {
 	/* cpu currently holding logbuf_lock */
@@ -625,10 +630,11 @@ asmlinkage int vprintk(const char *fmt, va_list args)
 	static int log_level_unknown = 1;
 	static char printk_buf[PRINTK_BUF_LEN + sizeof(overflow_tag) - 1];
 
+	int last_lv = default_message_loglevel;
 	unsigned long flags;
 	int printed_len = 0;
 	int this_cpu;
-	char *p;
+	const char *p;
 
 	boot_delay_msec();
 
@@ -682,47 +688,37 @@ asmlinkage int vprintk(const char *fmt, va_list args)
 	for (p = printk_buf; *p; p++) {
 		if (log_level_unknown) {
                         /* log_level_unknown signals the start of a new line */
+			int lv = last_lv;
+
+			if (is_loglevel(p)) {
+				lv = p[1] - '0';
+				p += 3;
+				printed_len -= 3;
+			}
+
+			emit_log_char('<');
+			emit_log_char(lv + '0');
+			emit_log_char('>');
+			printed_len += 3;
+
 			if (printk_time) {
-				int loglev_char;
 				char tbuf[50], *tp;
 				unsigned tlen;
 				unsigned long long t;
 				unsigned long nanosec_rem;
 
-				/*
-				 * force the log level token to be
-				 * before the time output.
-				 */
-				if (p[0] == '<' && p[1] >='0' &&
-				   p[1] <= '7' && p[2] == '>') {
-					loglev_char = p[1];
-					p += 3;
-					printed_len -= 3;
-				} else {
-					loglev_char = default_message_loglevel
-						+ '0';
-				}
 				t = cpu_clock(printk_cpu);
 				nanosec_rem = do_div(t, 1000000000);
-				tlen = sprintf(tbuf,
-						"<%c>[%5lu.%06lu] ",
-						loglev_char,
+				tlen = sprintf(tbuf, "[%5lu.%06lu] ",
 						(unsigned long)t,
 						nanosec_rem/1000);
 
 				for (tp = tbuf; tp < tbuf + tlen; tp++)
 					emit_log_char(*tp);
 				printed_len += tlen;
-			} else {
-				if (p[0] != '<' || p[1] < '0' ||
-				   p[1] > '7' || p[2] != '>') {
-					emit_log_char('<');
-					emit_log_char(default_message_loglevel
-						+ '0');
-					emit_log_char('>');
-					printed_len += 3;
-				}
 			}
+
+			last_lv = lv;
 			log_level_unknown = 0;
 			if (!*p)
 				break;
Signature · 1 line
1.5.2.4
author
#2 lore raw

PATCH 2/5 printk: implement [v]printk_header()

In reply to Tejun Heo

Implement [v]printk_header() which takes @header argument and automatically prints header in front of or indents multiline messages. For example, if @header is "<7>ata1.00: " and the formatted message is "<6>line0\nline1\n", the following gets written to the console.

<6>ata1.00: line0
<6>ata1.00 line1

As seen above if header ends with ':' followed by any number of spaces, the colon is replaced with space from the second line. This helps to distinguish where a multiline message begins when messages of similar pattern repeats, for example...

ata8.00: cmd 60/80:20:e1:71:02/00:00:00:00:00/40 tag 4 ncq 65536 in ata8.00 res 40/00:34:de:71:02/00:00:00:00:00/40 Emask 0x10 (ATA bus error) ata8.00 status: { DRDY }
ata8.00: cmd 60/0e:28:d0:71:02/00:00:00:00:00/40 tag 5 ncq 7168 in ata8.00 res 40/00:34:de:71:02/00:00:00:00:00/40 Emask 0x10 (ATA bus error) ata8.00 status: { DRDY }
ata8.00: cmd 60/7f:38:61:72:02/00:00:00:00:00/40 tag 7 ncq 65024 in ata8.00 res 40/00:34:de:71:02/00:00:00:00:00/40 Emask 0x10 (ATA bus error) ata8.00 status: { DRDY }

---
 include/linux/kernel.h |   12 ++++++
 kernel/printk.c        |   95 +++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 102 insertions(+), 5 deletions(-)
include/linux/kernel.h +12 -0
index 2df44e7..d885208 100644
@@ -177,6 +177,10 @@ struct pid;
 extern struct pid *session_of_pgrp(struct pid *pgrp);
 
 #ifdef CONFIG_PRINTK
+asmlinkage int vprintk_header(const char *header, const char *fmt, va_list args)
+	__attribute__ ((format (printf, 2, 0)));
+asmlinkage int printk_header(const char *header, const char * fmt, ...)
+	__attribute__ ((format (printf, 2, 3))) __cold;
 asmlinkage int vprintk(const char *fmt, va_list args)
 	__attribute__ ((format (printf, 1, 0)));
 asmlinkage int printk(const char * fmt, ...)
@@ -192,6 +196,14 @@ extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
 extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
 				   unsigned int interval_msec);
 #else
+static inline int vprintk_header(const char *header, const char *s, va_list args)
+	__attribute__ ((format (printf, 2, 0)));
+static inline int vprintk_header(const char *header, const char *s, va_list args)
+{ return 0; }
+static inline int printk_header(const char *header, const char *s, ...)
+	__attribute__ ((format (printf, 2, 3)));
+static inline int __cold printk_header(const char *header, const char *s, ...)
+{ return 0; }
 static inline int vprintk(const char *s, va_list args)
 	__attribute__ ((format (printf, 1, 0)));
 static inline int vprintk(const char *s, va_list args) { return 0; }
kernel/printk.c +90 -5

135 lines not on this page · raw message

Signature · 1 line
1.5.2.4
author
#3 lore raw

PATCH 3/5 printk: implement merging printk

In reply to Tejun Heo

There often are times printk messages need to be assembled piece by piece and it's usually done using one of the following methods.

* Calling printk() on partial message segments. This used to be quite common but has a problem - the message can break up if someone else prints something in the middle.

* Prepping a temp buffer and build message piece-by-piece using snprintf(). This is the most generic solution but corner case handling can be tedious and on overflow messages can be lost and such overflows would go unnoticed if overflow detection isn't properly done.

* Collect all the partial data and perform printk() once with all the parameters. This is often combined with the second. This usually works but printing messages can become non-trivial programming problem and can get quite tedious if the message format varies depending on data.

None of the above is quite satisfactory. This patch implement merging printk - mprintk to deal with this problem. It's basically a helper to construct message piece-by-piece into the specified buffer. The caller still has to care about buffer size and how the buffer is allocated but mprintk makes it easier.

* DEFINE_MPRINTK() macro makes it easy to define a mprintk instance with on-stack buffer. Malloc'd buffer can also be used.

* Message is never lost. On buffer overflow, all queued and to be queued messages are printed followed by warning message and stack dump. The warning message and stack dump are printed only once per mprintk instance. The caller also doesn't have to handle buffer malloc failure. If buffer is initialized to NULL, mprintk simply bypasses the messages to printk().

* Has good support for multiline messages. A mprintk instance can have header associated with it and the header can have log level. Header log level is used if a partial message doesn't specify log level explicitly. When log level is specified explicitly in a partial message, the log level is applied to the partial message only.

A simple example.

  DEFINE_MPRINTK(mp, 2 * 80);

  mprintk_set_header(&mp, KERN_DEBUG "ata%u.%2u: ", 1, 0);
  mprintk_push(&mp, "ATA %d", 7);
  mprintk_push(&mp, ", %u sectors\n", 1024);
  mprintk(&mp, "everything seems dandy\n");

Which will be printed like the following as a single message.

<7>ata1.00: ATA 7, 1024 sectors
<7>ata1.00 everything seems dandy

---
 include/linux/kernel.h |   73 ++++++++++++
 kernel/printk.c        |  300 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 370 insertions(+), 3 deletions(-)
include/linux/kernel.h +73 -0
index d885208..a9cbda8 100644
@@ -177,6 +177,27 @@ struct pid;
 extern struct pid *session_of_pgrp(struct pid *pgrp);
 
 #ifdef CONFIG_PRINTK
+struct mprintk {
+	char		*buf;
+	char		*body;
+	char		*cur;
+	char		*end;
+	unsigned int	flags;
+};
+
+#define MPRINTK_INITIALIZER(_buf, _size)				\
+	{								\
+		.buf		= _buf,					\
+		.body		= _buf,					\
+		.cur		= _buf,					\
+		.end		= _buf + _size,				\
+		.flags		= 0					\
+	}
+
+#define DEFINE_MPRINTK(name, size)					\
+	char __##name##_buf[size];					\
+	struct mprintk name = MPRINTK_INITIALIZER(__##name##_buf, size)
+
 asmlinkage int vprintk_header(const char *header, const char *fmt, va_list args)
 	__attribute__ ((format (printf, 2, 0)));
 asmlinkage int printk_header(const char *header, const char * fmt, ...)
@@ -185,6 +206,26 @@ asmlinkage int vprintk(const char *fmt, va_list args)
 	__attribute__ ((format (printf, 1, 0)));
 asmlinkage int printk(const char * fmt, ...)
 	__attribute__ ((format (printf, 1, 2))) __cold;
+
+static inline void mprintk_init(struct mprintk *mp, char *buf, size_t size)
+{
+	*mp = (struct mprintk)MPRINTK_INITIALIZER(buf, size);
+}
+extern void mprintk_init_alloc(struct mprintk *mp, gfp_t gfp);
+extern void mprintk_free(struct mprintk *mp);
+extern int vmprintk(struct mprintk *mp, const char *fmt, va_list args)
+	__attribute__ ((format (printf, 2, 0)));
+extern int vmprintk_set_header(struct mprintk *mp, const char *fmt, va_list args)
+	__attribute__ ((format (printf, 2, 0)));
+extern int vmprintk_flush(struct mprintk *mp, const char *fmt, va_list args)
+	__attribute__ ((format (printf, 2, 0)));
+extern int mprintk(struct mprintk *mp, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
+extern int mprintk_set_header(struct mprintk *mp, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
+extern int mprintk_flush(struct mprintk *mp, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
+
 extern int log_buf_get_len(void);
 extern int log_buf_read(int idx);
 extern int log_buf_copy(char *dest, int idx, int len);
@@ -196,6 +237,11 @@ extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
 extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
 				   unsigned int interval_msec);
 #else
+struct mprintk { };
+#define MPRINTK_INITIALIZER(_buf, _size)	{ }
+#define DEFINE_MPRINTK(name, size)		\
+	struct mprintk name = __MPRINTK_INITIALIZER(NULL, size)
+
 static inline int vprintk_header(const char *header, const char *s, va_list args)
 	__attribute__ ((format (printf, 2, 0)));
 static inline int vprintk_header(const char *header, const char *s, va_list args)
@@ -210,6 +256,33 @@ static inline int vprintk(const char *s, va_list args) { return 0; }
 static inline int printk(const char *s, ...)
 	__attribute__ ((format (printf, 1, 2)));
 static inline int __cold printk(const char *s, ...) { return 0; }
+static inline void mprintk_init(struct mprintk *mp, char *buf, size_t size) { }
+static inline void mprintk_init_alloc(struct mprintk *mp, gfp_t gfp) { }
+static inline void mprintk_free(struct mprintk *mp) { }
+static inline int vmprintk(struct mprintk *mp, const char *fmt, va_list args)
+	__attribute__ ((format (printf, 2, 0)));
+static inline int vmprintk(struct mprintk *mp, const char *fmt, va_list args)
+{ return 0; }
+static inline int vmprintk_set_header(struct mprintk *mp, const char *fmt, va_list args)
+	__attribute__ ((format (printf, 2, 0)));
+static inline int vmprintk_set_header(struct mprintk *mp, const char *fmt, va_list args)
+{ return 0; }
+static inline int vmprintk_flush(struct mprintk *mp, const char *fmt, va_list args)
+	__attribute__ ((format (printf, 2, 0)));
+static inline int vmprintk_flush(struct mprintk *mp, const char *fmt, va_list args)
+{ return 0; }
+static inline int mprintk(struct mprintk *mp, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
+static inline int mprintk(struct mprintk *mp, const char *fmt, ...)
+{ return 0; }
+static inline int mprintk_set_header(struct mprintk *mp, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
+static inline int mprintk_set_header(struct mprintk *mp, const char *fmt, ...)
+{ return 0; }
+static inline int mprintk_flush(struct mprintk *mp, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
+static inline int mprintk_flush(struct mprintk *mp, const char *fmt, ...)
+{ return 0; }
 static inline int log_buf_get_len(void) { return 0; }
 static inline int log_buf_read(int idx) { return 0; }
 static inline int log_buf_copy(char *dest, int idx, int len) { return 0; }
kernel/printk.c +297 -3

330 lines not on this page · raw message

Signature · 1 line
1.5.2.4
author
#4 lore raw

PATCH 4/5 printk: add Documentation/printk.txt

In reply to Tejun Heo

Add Documentation/printk.txt which explains printk, mprintk and their friends.

---
 Documentation/00-INDEX   |    2 +
 Documentation/printk.txt |  724 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 726 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/printk.txt
Documentation/00-INDEX +2 -0
index 8d55670..e4c2862 100644
@@ -313,6 +313,8 @@ powerpc/
 	- directory with info on using Linux with the PowerPC.
 preempt-locking.txt
 	- info on locking under a preemptive kernel.
+printk.txt
+	- info on printk and mprintk.
 prio_tree.txt
 	- info on radix-priority-search-tree use for indexing vmas.
 ramdisk.txt
Documentation/printk.txt new file +724 -0

724 lines not on this page · raw message

Signature · 1 line
1.5.2.4
author
#5 lore raw

PATCH 5/5 libata: make libata use printk_header() and mprintk

In reply to Tejun Heo

Reimplement libata printk helpers using printk_header, implement helpers to initialize mprintk and use mprintk during device configuration and EH reporting.

This fixes various formatting related problems of libata messages such as misaligned multiline messages, decoded register lines with leading headers making them difficult to tell to which error they belong to, awkward manual indents and complex message printing logics. More importantly, by making message assembly flexible, this patch makes future changes to device configuration and EH reporting easier.

---
 drivers/ata/libata-core.c   |  204 +++++++++++++++++++++++++++----------------
 drivers/ata/libata-eh.c     |  182 ++++++++++++++++++--------------------
 drivers/ata/libata-pmp.c    |    5 +-
 drivers/ata/libata-scsi.c   |    6 +-
 drivers/ata/sata_inic162x.c |    2 +-
 drivers/ata/sata_nv.c       |    4 +-
 include/linux/libata.h      |   35 ++++----
 7 files changed, 237 insertions(+), 201 deletions(-)
drivers/ata/libata-core.c +127 -77
index 004dae4..da670c0 100644
@@ -129,6 +129,79 @@ MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
 
 
+int ata_port_printk(struct ata_port *ap, const char *lv, const char *fmt, ...)
+{
+	va_list args;
+	char hbuf[16];
+	int ret;
+
+	snprintf(hbuf, sizeof(hbuf), "%sata%u: ", lv, ap->print_id);
+
+	va_start(args, fmt);
+	ret = vprintk_header(hbuf, fmt, args);
+	va_end(args);
+
+	return ret;
+}
+
+int ata_link_printk(struct ata_link *link, const char *lv, const char *fmt, ...)
+{
+	va_list args;
+	char hbuf[16];
+	int ret;
+
+	if (link->ap->nr_pmp_links)
+		snprintf(hbuf, sizeof(hbuf), "%sata%u.%02u: ",
+			 lv, link->ap->print_id, link->pmp);
+	else
+		snprintf(hbuf, sizeof(hbuf), "%sata%u: ",
+			 lv, link->ap->print_id);
+
+	va_start(args, fmt);
+	ret = vprintk_header(hbuf, fmt, args);
+	va_end(args);
+
+	return ret;
+}
+
+int ata_dev_printk(struct ata_device *dev, const char *lv, const char *fmt, ...)
+{
+	va_list args;
+	char hbuf[16];
+	int ret;
+
+	snprintf(hbuf, sizeof(hbuf), "%sata%u.%02u: ",
+		 lv, dev->link->ap->print_id, dev->link->pmp + dev->devno);
+
+	va_start(args, fmt);
+	ret = vprintk_header(hbuf, fmt, args);
+	va_end(args);
+
+	return ret;
+}
+
+void ata_port_mp_header(struct ata_port *ap, const char *lv, struct mprintk *mp)
+{
+	mprintk_set_header(mp, "%sata%u: ", lv, ap->print_id);
+}
+
+void ata_link_mp_header(struct ata_link *link, const char *lv,
+			struct mprintk *mp)
+{
+	if (link->ap->nr_pmp_links)
+		mprintk_set_header(mp, "%sata%u.%02u: ",
+				   lv, link->ap->print_id, link->pmp);
+	else
+		mprintk_set_header(mp, "%sata%u: ", lv, link->ap->print_id);
+}
+
+void ata_dev_mp_header(struct ata_device *dev, const char *lv,
+		       struct mprintk *mp)
+{
+	mprintk_set_header(mp, "%sata%u.%02u: ", lv, dev->link->ap->print_id,
+			   dev->link->pmp + dev->devno);
+}
+
 /**
  *	ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure
  *	@tf: Taskfile to convert
@@ -2006,18 +2079,16 @@ static inline u8 ata_dev_knobble(struct ata_device *dev)
 	return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id)));
 }
 
-static void ata_dev_config_ncq(struct ata_device *dev,
-			       char *desc, size_t desc_sz)
+static void ata_dev_config_ncq(struct ata_device *dev, struct mprintk *mp)
 {
 	struct ata_port *ap = dev->link->ap;
 	int hdepth = 0, ddepth = ata_id_queue_depth(dev->id);
 
-	if (!ata_id_has_ncq(dev->id)) {
-		desc[0] = '\0';
+	if (!ata_id_has_ncq(dev->id))
 		return;
-	}
+
 	if (dev->horkage & ATA_HORKAGE_NONCQ) {
-		snprintf(desc, desc_sz, "NCQ (not used)");
+		mprintk(mp, ", NCQ (not used)");
 		return;
 	}
 	if (ap->flags & ATA_FLAG_NCQ) {
@@ -2026,9 +2097,9 @@ static void ata_dev_config_ncq(struct ata_device *dev,
 	}
 
 	if (hdepth >= ddepth)
-		snprintf(desc, desc_sz, "NCQ (depth %d)", ddepth);
+		mprintk(mp, ", NCQ (depth %d)", ddepth);
 	else
-		snprintf(desc, desc_sz, "NCQ (depth %d/%d)", hdepth, ddepth);
+		mprintk(mp, ", NCQ (depth %d/%d)", hdepth, ddepth);
 }
 
 /**
@@ -2050,8 +2121,8 @@ int ata_dev_configure(struct ata_device *dev)
 	struct ata_eh_context *ehc = &dev->link->eh_context;
 	int print_info = ehc->i.flags & ATA_EHI_PRINTINFO;
 	const u16 *id = dev->id;
+	struct mprintk mp = MPRINTK_INITIALIZER(ap->sector_buf, ATA_SECT_SIZE);
 	unsigned long xfer_mask;
-	char revbuf[7];		/* XYZ-99\0 */
 	char fwrevbuf[ATA_ID_FW_REV_LEN+1];
 	char modelbuf[ATA_ID_PROD_LEN+1];
 	int rc;
@@ -2065,6 +2136,8 @@ int ata_dev_configure(struct ata_device *dev)
 	if (ata_msg_probe(ap))
 		ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__);
 
+	ata_dev_mp_header(dev, KERN_INFO, &mp);
+
 	/* set horkage */
 	dev->horkage |= ata_dev_blacklisted(dev);
 
@@ -2113,57 +2186,49 @@ int ata_dev_configure(struct ata_device *dev)
 	ata_id_c_string(dev->id, modelbuf, ATA_ID_PROD,
 			sizeof(modelbuf));
 
-	/* ATA-specific feature tests */
 	if (dev->class == ATA_DEV_ATA) {
+		/* ATA-specific feature tests */
 		if (ata_id_is_cfa(id)) {
-			if (id[162] & 1) /* CPRM may make this media unusable */
+			/* CPRM may make this media unusable */
+			if ((id[162] & 1) && print_info)
 				ata_dev_printk(dev, KERN_WARNING,
 					       "supports DRM functions and may "
 					       "not be fully accessable.\n");
-			snprintf(revbuf, 7, "CFA");
+			mprintk(&mp, "CFA: ");
 		} else {
-			snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id));
+			mprintk(&mp, "ATA-%d: ", ata_id_major_version(id));
 			/* Warn the user if the device has TPM extensions */
-			if (ata_id_has_tpm(id))
+			if (ata_id_has_tpm(id) && print_info)
 				ata_dev_printk(dev, KERN_WARNING,
 					       "supports DRM functions and may "
 					       "not be fully accessable.\n");
 		}
 
+		mprintk(&mp, "%s, %s, max %s\n",
+			modelbuf, fwrevbuf, ata_mode_string(xfer_mask));
+
 		dev->n_sectors = ata_id_n_sectors(id);
+		mprintk(&mp, "%Lu sectors", (unsigned long long)dev->n_sectors);
 
-		if (dev->id[59] & 0x100)
+		if (dev->id[59] & 0x100) {
 			dev->multi_count = dev->id[59] & 0xff;
+			mprintk(&mp, ", multi %u", dev->multi_count);
+		}
 
 		if (ata_id_has_lba(id)) {
-			const char *lba_desc;
-			char ncq_desc[20];
-
-			lba_desc = "LBA";
 			dev->flags |= ATA_DFLAG_LBA;
+			mprintk(&mp, ", LBA");
+
 			if (ata_id_has_lba48(id)) {
 				dev->flags |= ATA_DFLAG_LBA48;
-				lba_desc = "LBA48";
-
+				mprintk(&mp, "48");
 				if (dev->n_sectors >= (1UL << 28) &&
 				    ata_id_has_flush_ext(id))
 					dev->flags |= ATA_DFLAG_FLUSH_EXT;
 			}
 
 			/* config NCQ */
-			ata_dev_config_ncq(dev, ncq_desc, sizeof(ncq_desc));
-
-			/* print device info to dmesg */
-			if (ata_msg_drv(ap) && print_info) {
-				ata_dev_printk(dev, KERN_INFO,
-					"%s: %s, %s, max %s\n",
-					revbuf, modelbuf, fwrevbuf,
-					ata_mode_string(xfer_mask));
-				ata_dev_printk(dev, KERN_INFO,
-					"%Lu sectors, multi %u: %s %s\n",
-					(unsigned long long)dev->n_sectors,
-					dev->multi_count, lba_desc, ncq_desc);
-			}
+			ata_dev_config_ncq(dev, &mp);
 		} else {
 			/* CHS */
 
@@ -2179,27 +2244,13 @@ int ata_dev_configure(struct ata_device *dev)
 				dev->sectors   = id[56];
 			}
 
-			/* print device info to dmesg */
-			if (ata_msg_drv(ap) && print_info) {
-				ata_dev_printk(dev, KERN_INFO,
-					"%s: %s, %s, max %s\n",
-					revbuf,	modelbuf, fwrevbuf,
-					ata_mode_string(xfer_mask));
-				ata_dev_printk(dev, KERN_INFO,
-					"%Lu sectors, multi %u, CHS %u/%u/%u\n",
-					(unsigned long long)dev->n_sectors,
-					dev->multi_count, dev->cylinders,
-					dev->heads, dev->sectors);
-			}
+			mprintk(&mp, ", CHS %u/%u/%u",
+				dev->cylinders, dev->heads, dev->sectors);
 		}
 
 		dev->cdb_len = 16;
-	}
-
-	/* ATAPI-specific feature tests */
-	else if (dev->class == ATA_DEV_ATAPI) {
-		const char *cdb_intr_string = "";
-		const char *atapi_an_string = "";
+	} else if (dev->class == ATA_DEV_ATAPI) {
+		/* ATAPI-specific feature tests */
 		u32 sntf;
 
 		rc = atapi_cdb_len(id);
@@ -2212,6 +2263,14 @@ int ata_dev_configure(struct ata_device *dev)
 		}
 		dev->cdb_len = (unsigned int) rc;
 
+		mprintk(&mp, "ATAPI: %s, %s, max %s", modelbuf, fwrevbuf,
+			ata_mode_string(xfer_mask));
+
+		if (ata_id_cdb_intr(dev->id)) {
+			dev->flags |= ATA_DFLAG_CDB_INTR;
+			mprintk(&mp, ", CDB intr");
+		}
+
 		/* Enable ATAPI AN if both the host and device have
 		 * the support.  If PMP is attached, SNTF is required
 		 * to enable ATAPI AN to discern between PHY status
@@ -2231,22 +2290,9 @@ int ata_dev_configure(struct ata_device *dev)
 					"(err_mask=0x%x)\n", err_mask);
 			else {
 				dev->flags |= ATA_DFLAG_AN;
-				atapi_an_string = ", ATAPI AN";
+				mprintk(&mp, ", ATAPI AN");
 			}
 		}
-
-		if (ata_id_cdb_intr(dev->id)) {
-			dev->flags |= ATA_DFLAG_CDB_INTR;
-			cdb_intr_string = ", CDB intr";
-		}
-
-		/* print device info to dmesg */
-		if (ata_msg_drv(ap) && print_info)
-			ata_dev_printk(dev, KERN_INFO,
-				       "ATAPI: %s, %s, max %s%s%s\n",
-				       modelbuf, fwrevbuf,
-				       ata_mode_string(xfer_mask),
-				       cdb_intr_string, atapi_an_string);
 	}
 
 	/* determine max_sectors */
@@ -2264,9 +2310,7 @@ int ata_dev_configure(struct ata_device *dev)
 	/* Limit PATA drive on SATA cable bridge transfers to udma5,
 	   200 sectors */
 	if (ata_dev_knobble(dev)) {
-		if (ata_msg_drv(ap) && print_info)
-			ata_dev_printk(dev, KERN_INFO,
-				       "applying bridge limits\n");
+		mprintk(&mp, ", applying bridge limits");
 		dev->udma_mask &= ATA_UDMA5;
 		dev->max_sectors = ATA_MAX_SECTORS;
 	}
@@ -2291,21 +2335,21 @@ int ata_dev_configure(struct ata_device *dev)
 	if (ap->ops->dev_config)
 		ap->ops->dev_config(dev);
 
-	if (dev->horkage & ATA_HORKAGE_DIAGNOSTIC) {
+	if ((dev->horkage & ATA_HORKAGE_DIAGNOSTIC) && print_info) {
 		/* Let the user know. We don't want to disallow opens for
 		   rescue purposes, or in case the vendor is just a blithering
 		   idiot. Do this after the dev_config call as some controllers
 		   with buggy firmware may want to avoid reporting false device
 		   bugs */
-
-		if (print_info) {
-			ata_dev_printk(dev, KERN_WARNING,
-"Drive reports diagnostics failure. This may indicate a drive\n");
-			ata_dev_printk(dev, KERN_WARNING,
-"fault or invalid emulation. Contact drive vendor for information.\n");
-		}
+		ata_dev_printk(dev, KERN_WARNING,
+		  "Drive reports diagnostics failure. This may indicate a drive\n"
+		  "fault or invalid emulation. Contact drive vendor for information.\n");
 	}
 
+	/* print device info to dmesg */
+	if (ata_msg_drv(ap) && print_info)
+		mprintk_flush(&mp, "\n");
+
 	if (ata_msg_probe(ap))
 		ata_dev_printk(dev, KERN_DEBUG, "%s: EXIT, drv_stat = 0x%x\n",
 			__FUNCTION__, ata_chk_status(ap));
@@ -7544,6 +7588,12 @@ EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug);
 EXPORT_SYMBOL_GPL(sata_deb_timing_long);
 EXPORT_SYMBOL_GPL(ata_dummy_port_ops);
 EXPORT_SYMBOL_GPL(ata_dummy_port_info);
+EXPORT_SYMBOL_GPL(ata_port_printk);
+EXPORT_SYMBOL_GPL(ata_link_printk);
+EXPORT_SYMBOL_GPL(ata_dev_printk);
+EXPORT_SYMBOL_GPL(ata_port_mp_header);
+EXPORT_SYMBOL_GPL(ata_link_mp_header);
+EXPORT_SYMBOL_GPL(ata_dev_mp_header);
 EXPORT_SYMBOL_GPL(ata_std_bios_param);
 EXPORT_SYMBOL_GPL(ata_std_ports);
 EXPORT_SYMBOL_GPL(ata_host_init);
drivers/ata/libata-eh.c +85 -97

229 lines not on this page · raw message

drivers/ata/libata-pmp.c +2 -3
index caef2bb..cc6e4ca 100644
@@ -408,9 +408,8 @@ static int sata_pmp_configure(struct ata_device *dev, int print_info)
 
 		if (!(dev->flags & ATA_DFLAG_AN))
 			ata_dev_printk(dev, KERN_INFO,
-				"Asynchronous notification not supported, "
-				"hotplug won't\n         work on fan-out "
-				"ports. Use warm-plug instead.\n");
+			  "Asynchronous notification not supported, hotplug won't\n"
+			  "work on fan-out ports. Use warm-plug instead.\n");
 	}
 
 	return 0;
drivers/ata/libata-scsi.c +3 -3
index c02c490..bcf0a3d 100644
@@ -3234,9 +3234,9 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
 			goto repeat;
 		}
 
-		ata_port_printk(ap, KERN_ERR, "WARNING: synchronous SCSI scan "
-				"failed without making any progress,\n"
-				"                  switching to async\n");
+		ata_port_printk(ap, KERN_ERR,
+		  "WARNING: synchronous SCSI scan failed without making any \n"
+		  "         progress, switching to async\n");
 	}
 
 	queue_delayed_work(ata_aux_wq, &ap->hotplug_task,
drivers/ata/sata_inic162x.c +1 -1
index 59e65ed..4ba8534 100644
@@ -491,7 +491,7 @@ static void inic_dev_config(struct ata_device *dev)
 	if (dev->n_sectors >= 1 << 28) {
 		ata_dev_printk(dev, KERN_ERR,
 	"ERROR: This driver doesn't support LBA48 yet and may cause\n"
-	"                data corruption on such devices.  Disabling.\n");
+	"       data corruption on such devices.  Disabling.\n");
 		ata_dev_disable(dev);
 	}
 }
drivers/ata/sata_nv.c +2 -2
index ed5473b..85bcfca 100644
@@ -1849,8 +1849,8 @@ static void nv_swncq_ncq_stop(struct ata_port *ap)
 			"EH in SWNCQ mode,QC:qc_active 0x%X sactive 0x%X\n",
 			ap->qc_active, ap->link.sactive);
 	ata_port_printk(ap, KERN_ERR,
-		"SWNCQ:qc_active 0x%X defer_bits 0x%X last_issue_tag 0x%x\n  "
-		"dhfis 0x%X dmafis 0x%X sdbfis 0x%X\n",
+		"SWNCQ: qc_active 0x%X defer_bits 0x%X last_issue_tag 0x%x\n"
+		"       dhfis 0x%X dmafis 0x%X sdbfis 0x%X\n",
 		pp->qc_active, pp->defer_queue.defer_bits, pp->last_issue_tag,
 		pp->dhfis_bits, pp->dmafis_bits, pp->sdbfis_bits);
 
include/linux/libata.h +17 -18
index bc5a8d0..168170c 100644
@@ -787,6 +787,23 @@ static inline int ata_port_is_dummy(struct ata_port *ap)
 	return ap->ops == &ata_dummy_port_ops;
 }
 
+extern int ata_port_printk(struct ata_port *ap, const char *lv,
+			   const char *fmt, ...)
+	__attribute__ ((format (printf, 3, 4)));
+extern int ata_link_printk(struct ata_link *link, const char *lv,
+			   const char *fmt, ...)
+	__attribute__ ((format (printf, 3, 4)));
+extern int ata_dev_printk(struct ata_device *dev, const char *lv,
+			  const char *fmt, ...)
+	__attribute__ ((format (printf, 3, 4)));
+
+extern void ata_port_mp_header(struct ata_port *ap, const char *lv,
+			       struct mprintk *mp);
+extern void ata_link_mp_header(struct ata_link *link, const char *lv,
+			       struct mprintk *mp);
+extern void ata_dev_mp_header(struct ata_device *dev, const char *lv,
+			      struct mprintk *mp);
+
 extern void sata_print_link_status(struct ata_link *link);
 extern void ata_port_probe(struct ata_port *);
 extern void ata_bus_reset(struct ata_port *ap);
@@ -1074,24 +1091,6 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
 		      ata_postreset_fn_t postreset);
 
 /*
- * printk helpers
- */
-#define ata_port_printk(ap, lv, fmt, args...) \
-	printk("%sata%u: "fmt, lv, (ap)->print_id , ##args)
-
-#define ata_link_printk(link, lv, fmt, args...) do { \
-	if ((link)->ap->nr_pmp_links) \
-		printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id,	\
-		       (link)->pmp , ##args); \
-	else \
-		printk("%sata%u: "fmt, lv, (link)->ap->print_id , ##args); \
-	} while(0)
-
-#define ata_dev_printk(dev, lv, fmt, args...) \
-	printk("%sata%u.%02u: "fmt, lv, (dev)->link->ap->print_id,	\
-	       (dev)->link->pmp + (dev)->devno , ##args)
-
-/*
  * ata_eh_info helpers
  */
 extern void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...)
Signature · 1 line
1.5.2.4
#6 lore raw
In reply to Tejun Heo
Quoted 21 lines · On Wed, 13 Feb 2008 18:09:28 +0900 Tejun Heo <[email protected]> wrote:

This is the third take of implement-printk_header-and-mprintk patchset.

Changes from the last take[L] are...

* Now header is printed on every line of a multiline message. If the header ends with ':' followed by spaces. The colon is replaced with space from the second line.

* s/mprintk/mprintk_flush/ and s/mprintk_add/mprintk/ as suggested.

* mprintk_init_alloc() and mprintk_free() added to ease malloc'd buffer handling. No need to specify buffer size. Sizing is left to mprintk.

This patchset aims to make printing multiline messages and assembling message piece-by-piece easier.

In a nutshell, printk_header() lets you do the following atomically (against other messages).

Quoted 7 lines

code:
printk(KERN_INFO "ata1.00: ", "line0\nline1\nline2\n");

output:
<6>ata1.00: line0
<6>ata1.00 line1
<6>ata1.00 line2

That seems sensible.

Quoted 5 lines

And mprintk the following.

code:
DEFINE_MPRINTK(mp, 2 * 80);

Quoted 9 lines
  mprintk_set_header(&mp, KERN_INFO "ata%u.%2u: ", 1, 0);
  mprintk_push(&mp, "ATA %d", 7);
  mprintk_push(&mp, ", %u sectors\n", 1024);
  mprintk(&mp, "everything seems dandy\n");

output:
<6>ata1.00: ATA 7, 1024 sectors
<6>ata1.00 everything seems dandy

And that looks like an awful lot of fuss. Is it really worth doing?

author
#7 lore raw
Quoted 10 lines · Andrew Morton
Quoted 10 lines

And mprintk the following.

code:
DEFINE_MPRINTK(mp, 2 * 80);

  mprintk_set_header(&mp, KERN_INFO "ata%u.%2u: ", 1, 0);
  mprintk_push(&mp, "ATA %d", 7);
  mprintk_push(&mp, ", %u sectors\n", 1024);
  mprintk(&mp, "everything seems dandy\n");
Quoted 5 lines
Quoted 3 lines

output:
<6>ata1.00: ATA 7, 1024 sectors
<6>ata1.00 everything seems dandy

And that looks like an awful lot of fuss. Is it really worth doing?

In the above example, s/mprintk(/mprintk_flush(/ and s/mprintk_push(/mprintk(/

Can you please take a look at ata_eh_link_report() in drivers/ata/libata-eh.c? Currently, it has some problems.

* All that it wants to do is printing some messages but it's awfully complex with temp bufs and super-long printk calls containing optional %s's.

* status / error decode print outs are printed separately from cmd/res making it difficult to tell how they are grouped. Putting them together would require allocating another temp buf(s) and adding extra %s's to cmd/res printout.

* For timeouts, result TF isn't available and thus res printout is misleading. res shouldn't be printed after timeouts. This would require allocating yest another temp buf and separating out res printing into separate snprintf.

I was trying to do this and got fed up with all the tricks in the function. The only sane way out is to build messages piece-by-piece into a buffer and print it at once. The eh message is gigantic and I needed to allocate the buffer elsewhere than stack. ata_eh_link_report() fortunately has fixed place for that - ap->sector_buf - but let's assume there was no such buffer for the discussion. I'm still not too sure whether it's wise to use sector_buf for message building anyway.

The only way is to malloc the buffer. Once the buffer is available, building message using snprintf is a bit cumbersome but is okay. The problem is that malloc can fail. To handle that case, we basically need to do

  if (buf)
     printed += snprintf(buf + printed, len - printed, ...);
  else
     printk(...);

which is very cumbersome, so we need a wrapper around the above. As the wrapper needs to control when the message goes out, a flush function is necessary too. Combine those with overflow handling - mprintk.

Similar problem exists for ata_dev_configure() in drivers/ata/libata-core.c although it's a bit better there. Please take a look at the fifth patch. It doesn't remove a lot of lines but it streamlines both functions significantly. For ata_dev_configure(), message reporting becomes what the function does secondarily while configuring the device, not something it's structured around.

Thanks.

Signature · 1 line
tejun
#8 lore raw
Quoted 2 lines · On Thu, 14 Feb 2008 09:40:51 +0900 Tejun Heo <[email protected]> wrote:

Can you please take a look at ata_eh_link_report() in drivers/ata/libata-eh.c?

I did. Punishment?

Quoted 1 line

Currently, it has some problems.

Yes, and the patches do clean that up.

ho hum. What tends to happen with this sort of thing is that fi we merge it, it ends up getting used more often than one expected...

If you stand back and squint at it, there are quite a few places where we do this sort of thing: allocate a buffer, squirt characters into it, reallocating and/or flushing as we proceed. All sysfs and procfs read-side code, for a start...

author
#9 lore raw

Hello,

Quoted 7 lines · Andrew Morton
Quoted 2 lines · On Thu, 14 Feb 2008 09:40:51 +0900 Tejun Heo <[email protected]> wrote:

Can you please take a look at ata_eh_link_report() in drivers/ata/libata-eh.c?

I did. Punishment?

Heh.. :-)

Quoted 3 lines
Quoted 1 line

Currently, it has some problems.

Yes, and the patches do clean that up.

Yeap, it does.

Quoted 2 lines

ho hum. What tends to happen with this sort of thing is that fi we merge it, it ends up getting used more often than one expected...

Hmmm... Okay. mprintk being printk, I'm not too sure how it can go over usual expectations but well, yeah, that actually is my expectation.

Quoted 4 lines

If you stand back and squint at it, there are quite a few places where we do this sort of thing: allocate a buffer, squirt characters into it, reallocating and/or flushing as we proceed. All sysfs and procfs read-side code, for a start...

printk is a special case, I think. It's the primary logging/debugging method which can't fail and as it's mostly interpreted by human beings (and developers in problematic cases), it has different maneuvering room on errors - ie. it's far better to print messages w/o header or proper log level than failing to print, which is quite different requirements from other components.

Thanks.

Signature · 1 line
tejun
#16 lore raw
In reply to Tejun Heo
Quoted 5 lines · Tejun Heo

..
* For timeouts, result TF isn't available and thus res printout is misleading. res shouldn't be printed after timeouts. This would require allocating yest another temp buf and separating out res printing into separate snprintf.

..

And snprintf() is buggy, by the way. It does not always seem to return the correct character fill counts. I've given up trying to use it here for anything in kernelspace that *must* work.

Someday I'll go back and try to figure out where it's screwing up. I think it is doing so in the cases where it runs out of space in the buffer.

-ml

author
#10 lore raw
In reply to Tejun Heo
Quoted 28 lines · Tejun Heo

Hello,

Quoted 6 lines · Andrew Morton
Quoted 2 lines · On Thu, 14 Feb 2008 09:40:51 +0900 Tejun Heo <[email protected]> wrote:

Can you please take a look at ata_eh_link_report() in drivers/ata/libata-eh.c?

I did. Punishment?

Heh.. :-)

Quoted 2 lines
Quoted 1 line

Currently, it has some problems.

Yes, and the patches do clean that up.

Yeap, it does.

Quoted 2 lines

ho hum. What tends to happen with this sort of thing is that fi we merge it, it ends up getting used more often than one expected...

Hmmm... Okay. mprintk being printk, I'm not too sure how it can go over usual expectations but well, yeah, that actually is my expectation.

Quoted 4 lines

If you stand back and squint at it, there are quite a few places where we do this sort of thing: allocate a buffer, squirt characters into it, reallocating and/or flushing as we proceed. All sysfs and procfs read-side code, for a start...

Quoted 6 lines

printk is a special case, I think. It's the primary logging/debugging method which can't fail and as it's mostly interpreted by human beings (and developers in problematic cases), it has different maneuvering room on errors - ie. it's far better to print messages w/o header or proper log level than failing to print, which is quite different requirements from other components.

Andrew, any more comments or suggestions on how to proceed on this? One way or the other, I think this is a problem worth solving.

Thanks.

Signature · 1 line
tejun
#11 lore raw
Quoted 8 lines · On Fri, 15 Feb 2008 10:49:31 +0900 Tejun Heo <[email protected]> wrote:
Quoted 6 lines

printk is a special case, I think. It's the primary logging/debugging method which can't fail and as it's mostly interpreted by human beings (and developers in problematic cases), it has different maneuvering room on errors - ie. it's far better to print messages w/o header or proper log level than failing to print, which is quite different requirements from other components.

Andrew, any more comments or suggestions on how to proceed on this?

Nope.

Quoted 2 lines

One
way or the other, I think this is a problem worth solving.

There are a lot of such problems ;)

author
#12 lore raw
Quoted 6 lines · Andrew Morton
Quoted 6 lines
Quoted 6 lines

printk is a special case, I think. It's the primary logging/debugging method which can't fail and as it's mostly interpreted by human beings (and developers in problematic cases), it has different maneuvering room on errors - ie. it's far better to print messages w/o header or proper log level than failing to print, which is quite different requirements from other components.

Quoted 8 lines
Quoted 1 line

Andrew, any more comments or suggestions on how to proceed on this?

Nope.

Quoted 2 lines

One
way or the other, I think this is a problem worth solving.

There are a lot of such problems ;)

So, I guess it's NACK w/o suggested alternatives, right?

Signature · 1 line
tejun
#13 lore raw
Quoted 9 lines · On Fri, 15 Feb 2008 11:36:12 +0900 Tejun Heo <[email protected]> wrote:
Quoted 8 lines · Andrew Morton
Quoted 7 lines
Quoted 6 lines

printk is a special case, I think. It's the primary logging/debugging method which can't fail and as it's mostly interpreted by human beings (and developers in problematic cases), it has different maneuvering room on errors - ie. it's far better to print messages w/o header or proper log level than failing to print, which is quite different requirements from other components.

Andrew, any more comments or suggestions on how to proceed on this?

Quoted 9 lines
Quoted 6 lines

Nope.

Quoted 2 lines

One
way or the other, I think this is a problem worth solving.

There are a lot of such problems ;)

So, I guess it's NACK w/o suggested alternatives, right?

I wouldn't nack without good reasons, and I have none here. I don't have very strong opinions either way.

As a seat-of-the-pants thing, it does seem to be a lot of core code to solve a fairly minor problem in (afaik) one remote place. But I haven't looked - perhaps there are other places which could be improved if such facilities were available.

author
#14 lore raw
Quoted 4 lines · Andrew Morton
Quoted 1 line

So, I guess it's NACK w/o suggested alternatives, right?

I wouldn't nack without good reasons, and I have none here. I don't have very strong opinions either way.

I was just wondering whether I should just go with snprintf dancing in eh_link_report, which does make sense if not many need merging printk.

Quoted 4 lines

As a seat-of-the-pants thing, it does seem to be a lot of core code to solve a fairly minor problem in (afaik) one remote place. But I haven't looked - perhaps there are other places which could be improved if such facilities were available.

Okay, I see. I'll look around and see whether there are other places which can use it. I can think of a few in SCSI. Let's see.

Thanks.

Signature · 1 line
tejun
#15 lore raw
Quoted 7 lines · Tejun Heo
Quoted 3 lines · Andrew Morton
Quoted 1 line

So, I guess it's NACK w/o suggested alternatives, right?

I wouldn't nack without good reasons, and I have none here. I don't have very strong opinions either way.

I was just wondering whether I should just go with snprintf dancing in eh_link_report, which does make sense if not many need merging printk.

..

Any chance you could poke through snprintf() and look for the off-by-one bug on the return result? (I think it happens when "n" is exceeded).

:)