From: Christoph Hellwig <hch@infradead.org>
To: Hannes Reinecke <hare@suse.de>
Cc: Christoph Hellwig <hch@infradead.org>,
James Bottomley <jbottomley@parallels.com>,
Ewan Milne <emilne@redhat.com>,
Yoshihiro Yunomae <yoshihiro.yunomae.ez@hitachi.com>,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH 14/20] scsi: use local buffer for printing CDB
Date: Sun, 7 Sep 2014 09:10:26 -0700 [thread overview]
Message-ID: <20140907161026.GA16238@infradead.org> (raw)
In-Reply-To: <1409738775-80876-15-git-send-email-hare@suse.de>
On Wed, Sep 03, 2014 at 12:06:09PM +0200, Hannes Reinecke wrote:
> The CDB needs to be printed in one line (ie with one printk
> statement) to avoid the individual bytes to be broken up
> under high load.
> As using individual printk() statements here would lead to
> unnecessary complicated code and needs the stack space to
> hold the format string we should be using a local buffer
> here. If the CDB is longer than the provided buffer
> it will be printed in several lines.
Some general comments:
- as pointed out by YUNOMAE-san we need a constant for the buffer. And
I'd also like to see a comment why exactly you're chosing 80 for it.
- I'd really like to see some worst case stack usage analysis of the
old vs the new case.
> @@ -189,6 +189,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
> {
> int errno, retries = 0, timeout, result;
> struct scsi_sense_hdr sshdr;
> + char buf[80];
>
> timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
> ? timeout_init : timeout_move;
> @@ -196,8 +197,8 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
> retry:
> errno = 0;
> if (debug) {
> - DPRINTK("command: ");
> - __scsi_print_command(cmd);
> + __scsi_print_command(cmd, buf, 80);
> + DPRINTK("command: %s", buf);
The buffer variable should be inside the "if (debug)" here.
> +/* attempt to guess cdb length if cdb_len==0 */
cdb_len == 0 is only passed in from __scsi_print_command. But as far
as I can tell all of it's caller have it easily available, so we should
just pass it in and get rid of this special case.
> +static int print_opcode_name(unsigned char * cdbp, int cdb_len,
> + char *buf, int buf_len)
This doesn't print anything now, but just formats the CDB, so it
should be called format_opcode_name. Also as a convention pass
buf and buf_len as the first two arguments similar to s*printf,
and fix up the formatting for the cdbp argument. Can you please
just run your next series through checkpatch?
> -void __scsi_print_command(unsigned char *cdb)
> +void __scsi_print_command(unsigned char *cdb, char *buf, int buf_len)
Rename this to scsi_format_command, pass buf and buf_len as first two
argument, and as mention earlier pass in the cdb length as well.
> {
> + int len, off;
>
> + off = print_opcode_name(cdb, 0, buf, buf_len);
> len = scsi_command_size(cdb);
> + /* Variable length CDBs are not supported */
Why?
next prev parent reply other threads:[~2014-09-07 16:10 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
2014-09-03 10:05 ` [PATCH 01/20] Remove scsi_cmd_print_sense_hdr() Hannes Reinecke
2014-09-03 10:05 ` [PATCH 02/20] aha152x: Debug output update and whitespace cleanup Hannes Reinecke
2014-09-06 0:02 ` Christoph Hellwig
2014-09-03 10:05 ` [PATCH 03/20] sd: Remove scsi_print_sense() in sd_done() Hannes Reinecke
2014-09-03 10:05 ` [PATCH 04/20] scsi: introduce sdev_prefix_printk() Hannes Reinecke
2014-09-06 0:03 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 05/20] scsi: Use sdev as argument for sense code printing Hannes Reinecke
2014-09-03 10:06 ` [PATCH 06/20] scsi: stop decoding if scsi_normalize_sense() fails Hannes Reinecke
2014-09-06 0:04 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 07/20] scsi: do not decode sense extras Hannes Reinecke
2014-09-06 0:04 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 08/20] scsi: use 'bool' as return value for scsi_normalize_sense() Hannes Reinecke
2014-09-05 0:51 ` Yoshihiro YUNOMAE
2014-09-05 6:07 ` Hannes Reinecke
2014-09-06 0:09 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 09/20] scsi: remove scsi_print_status() Hannes Reinecke
2014-09-06 0:10 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 10/20] Implement scsi_opcode_sa_name Hannes Reinecke
2014-09-03 10:06 ` [PATCH 11/20] scsi: Use scsi_print_command() where possible Hannes Reinecke
2014-09-06 0:11 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 12/20] scsi: merge print_opcode_name() Hannes Reinecke
2014-09-05 1:24 ` Yoshihiro YUNOMAE
2014-09-06 0:12 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 13/20] scsi: consolidate opcode lookup in scsi_opcode_sa_name() Hannes Reinecke
2014-09-06 0:46 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 14/20] scsi: use local buffer for printing CDB Hannes Reinecke
2014-09-05 2:02 ` Yoshihiro YUNOMAE
2014-09-07 16:10 ` Christoph Hellwig [this message]
2014-09-03 10:06 ` [PATCH 15/20] libata: use __scsi_print_command() Hannes Reinecke
2014-09-03 10:06 ` [PATCH 16/20] scsi: separate out scsi_retval_string() Hannes Reinecke
2014-09-05 2:04 ` Yoshihiro YUNOMAE
2014-09-05 6:14 ` Hannes Reinecke
2014-09-07 16:11 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 17/20] scsi: separate out scsi_host_hostbyte() and scsi_show_driverbyte() Hannes Reinecke
2014-09-05 4:19 ` Yoshihiro YUNOMAE
2014-09-07 16:12 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 18/20] scsi: remove scsi_show_result() Hannes Reinecke
2014-09-05 4:22 ` Yoshihiro YUNOMAE
2014-09-07 16:17 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 19/20] sd: Reduce logging output Hannes Reinecke
2014-09-07 16:17 ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 20/20] scsi_error: format abort error message Hannes Reinecke
2014-09-05 4:23 ` Yoshihiro YUNOMAE
2014-09-06 0:33 ` Christoph Hellwig
2014-09-13 1:07 ` Elliott, Robert (Server Storage)
2014-09-14 10:49 ` Hannes Reinecke
2014-09-14 16:40 ` Christoph Hellwig
2014-09-06 0:51 ` [PATCHv2 00/20] scsi logging update Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140907161026.GA16238@infradead.org \
--to=hch@infradead.org \
--cc=emilne@redhat.com \
--cc=hare@suse.de \
--cc=jbottomley@parallels.com \
--cc=linux-scsi@vger.kernel.org \
--cc=yoshihiro.yunomae.ez@hitachi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox