Re: Re: [RFC PATCH 07/10] scsi/trace: Use scsi_show_result trace point instead of printk
Hi Christoph, Sorry for the late reply. (2014/08/29 9:50), Christoph Hellwig wrote: I'm not sure this is the correct way. Currently we have quite some code duplication in scsi_trace.c and constants.c, correct. So I definitely would like to see them both merged. But constants.c is influenced by CONFIG_SCSI_CONSTANTS, whereas scsi_trace isn't, and the functions in constants.c are used throughout the scsi stack. So I'd rather see to have scsi_trace to be updated to use the functions from constants.c, and remove the duplicate code in scsi_trace. The tracepoints need to use the magic print_flags & co helpers so that output works properly if using the binary tracebuffer and user space tools that decoded it (e.g. trace-cmd or perf), so using a kernel function for decoding is not an option. Ah, I see. The "format" files in SCSI traceevents output decoders, so we don't need to implement own decoders in userland. I think the current problem is duplicated decoders, so we'll consolidate those. If we use decoders in constants.c, the decoders are not output in format file, so user tools cannot decode the binary. On the other hand, if we use decoders in scsi_trace.c, the output format of command names is changed and there are unsupported command names. We would use decoders in scsi_trace.c and add new command names to decoders in scsi_trace.c, I think. How do you think about this? Hannes? As another topic, we found that we cannot decode SCSI traceevents by using current decoder in format files. For example, format file of scsi_dispatch_cmd_timeout outputs prot_op as follows: __print_symbolic(REC->prot_op, { SCSI_PROT_NORMAL, "SCSI_PROT_NORMAL" }, { SCSI_PROT_READ_INSERT, "SCSI_PROT_READ_INSERT" }, { SCSI_PROT_WRITE_STRIP, "SCSI_PROT_WRITE_STRIP" }, { SCSI_PROT_READ_STRIP, "SCSI_PROT_READ_STRIP" }, { SCSI_PROT_WRITE_INSERT, "SCSI_PROT_WRITE_INSERT" }, { SCSI_PROT_READ_PASS, "SCSI_PROT_READ_PASS" }, { SCSI_PROT_WRITE_PASS, "SCSI_PROT_WRITE_PASS" }) Decoding will fail to do macro expansion here, so we need to fix this. (We don't use enum for traceevents.) Thanks, Yoshihiro YUNOMAE But we can make these tracepoints dependent on CONFIG_SCSI_CONSTANTS to still allow building lighter kernels if we really care about it. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Re: [PATCH 1/3] scsi/trace: Use macros for getting driver byte, host byte, msg byte, and status byte
(2014/09/02 0:15), Christoph Hellwig wrote: On Mon, Sep 01, 2014 at 12:33:28PM +, Yoshihiro YUNOMAE wrote: For getting driver byte, host byte, msg byte, and status byte, macros are implemented in scsi/scsi.h, so we use it. As mentioned about three times in various previous scsi logging discussions this is entirely wrong and breaks decoding binary trace buffers. No, this patch uses just macros, so this does not change decoders. However, other patches change decoders in format files, so we need to consider about these decoders more, as you say. We'll discuss on https://lkml.org/lkml/2014/8/28/657. Thanks, Yoshihiro YUNOMAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Re: [PATCH 1/3] scsi/trace: Use macros for getting driver byte, host byte, msg byte, and status byte
(2014/09/02 0:15), Christoph Hellwig wrote: On Mon, Sep 01, 2014 at 12:33:28PM +, Yoshihiro YUNOMAE wrote: For getting driver byte, host byte, msg byte, and status byte, macros are implemented in scsi/scsi.h, so we use it. As mentioned about three times in various previous scsi logging discussions this is entirely wrong and breaks decoding binary trace buffers. No, this patch uses just macros, so this does not change decoders. However, other patches change decoders in format files, so we need to consider about these decoders more, as you say. We'll discuss on https://lkml.org/lkml/2014/8/28/657. Thanks, Yoshihiro YUNOMAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Re: [RFC PATCH 07/10] scsi/trace: Use scsi_show_result trace point instead of printk
Hi Christoph, Sorry for the late reply. (2014/08/29 9:50), Christoph Hellwig wrote: I'm not sure this is the correct way. Currently we have quite some code duplication in scsi_trace.c and constants.c, correct. So I definitely would like to see them both merged. But constants.c is influenced by CONFIG_SCSI_CONSTANTS, whereas scsi_trace isn't, and the functions in constants.c are used throughout the scsi stack. So I'd rather see to have scsi_trace to be updated to use the functions from constants.c, and remove the duplicate code in scsi_trace. The tracepoints need to use the magic print_flags co helpers so that output works properly if using the binary tracebuffer and user space tools that decoded it (e.g. trace-cmd or perf), so using a kernel function for decoding is not an option. Ah, I see. The format files in SCSI traceevents output decoders, so we don't need to implement own decoders in userland. I think the current problem is duplicated decoders, so we'll consolidate those. If we use decoders in constants.c, the decoders are not output in format file, so user tools cannot decode the binary. On the other hand, if we use decoders in scsi_trace.c, the output format of command names is changed and there are unsupported command names. We would use decoders in scsi_trace.c and add new command names to decoders in scsi_trace.c, I think. How do you think about this? Hannes? As another topic, we found that we cannot decode SCSI traceevents by using current decoder in format files. For example, format file of scsi_dispatch_cmd_timeout outputs prot_op as follows: __print_symbolic(REC-prot_op, { SCSI_PROT_NORMAL, SCSI_PROT_NORMAL }, { SCSI_PROT_READ_INSERT, SCSI_PROT_READ_INSERT }, { SCSI_PROT_WRITE_STRIP, SCSI_PROT_WRITE_STRIP }, { SCSI_PROT_READ_STRIP, SCSI_PROT_READ_STRIP }, { SCSI_PROT_WRITE_INSERT, SCSI_PROT_WRITE_INSERT }, { SCSI_PROT_READ_PASS, SCSI_PROT_READ_PASS }, { SCSI_PROT_WRITE_PASS, SCSI_PROT_WRITE_PASS }) Decoding will fail to do macro expansion here, so we need to fix this. (We don't use enum for traceevents.) Thanks, Yoshihiro YUNOMAE But we can make these tracepoints dependent on CONFIG_SCSI_CONSTANTS to still allow building lighter kernels if we really care about it. -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/3] scsi/trace: Delete a duplicated decoder of SCSI command
There is a decoder of SCSI command in constants.c, so this patch deletes it in SCSI traveevents. A decoder in traceevents uses macros, so the command name is output as "XXX_YYY_ZZZ". On the other hand, a decoder in constants uses strings, so the command name is output as "Xxx Yyy Zzz" including space. We use a decoder in constants, so this patch adds double quotes for the name. Note: - If CONFIG_SCSI_CONSTANTS is disabled, command names are not shown. - Add command names for 0x07 and 0x2b. Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Robert Elliott Cc: Ewan D. Milne Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c| 13 +++- include/scsi/scsi.h |1 include/trace/events/scsi.h | 130 +-- 3 files changed, 37 insertions(+), 107 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 8c1f7ac..50e08c8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -36,7 +36,7 @@ static const char * cdb_byte0_names[] = { /* 00-03 */ "Test Unit Ready", "Rezero Unit/Rewind", NULL, "Request Sense", /* 04-07 */ "Format Unit/Medium", "Read Block Limits", NULL, - "Reassign Blocks", + "Reassign Blocks/Initialize Element Status", /* 08-0d */ "Read(6)", NULL, "Write(6)", "Seek(6)", NULL, NULL, /* 0e-12 */ NULL, "Read Reverse", "Write Filemarks", "Space", "Inquiry", /* 13-16 */ "Verify(6)", "Recover Buffered Data", "Mode Select(6)", @@ -47,8 +47,8 @@ static const char * cdb_byte0_names[] = { /* 20-22 */ NULL, NULL, NULL, /* 23-28 */ "Read Format Capacities", "Set Window", "Read Capacity(10)", NULL, NULL, "Read(10)", -/* 29-2d */ "Read Generation", "Write(10)", "Seek(10)", "Erase(10)", -"Read updated block", +/* 29-2d */ "Read Generation", "Write(10)", "Seek(10)/Position To Element", + "Erase(10)", "Read updated block", /* 2e-31 */ "Write Verify(10)", "Verify(10)", "Search High", "Search Equal", /* 32-34 */ "Search Low", "Set Limits", "Prefetch/Read Position", /* 35-37 */ "Synchronize Cache(10)", "Lock/Unlock Cache(10)", @@ -103,6 +103,11 @@ static const char * cdb_byte0_names[] = { "Volume set (out), Send DVD structure", }; +inline const char *show_opcode_name(int cdb0) +{ + return cdb_byte0_names[cdb0]; +} + struct value_name_pair { int value; const char * name; @@ -365,7 +370,7 @@ static void print_opcode_name(struct scsi_device *sdev, const char *prefix, if (cdb0 < 0xc0) { cdb_classifier = NULL; #ifdef CONFIG_SCSI_CONSTANTS - cdb_name = cdb_byte0_names[cdb0]; + cdb_name = show_opcode_name(cdb0); if (!cdb_name) cdb_classifier = " (reserved)"; #endif diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 6d6b3ef..59fedff 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -587,6 +587,7 @@ static inline __u32 scsi_to_u32(__u8 *ptr) } #ifdef CONFIG_SCSI_CONSTANTS +inline const char *show_opcode_name(int cdb0); inline const char *show_hostbyte_name(int hb); inline const char *show_driverbyte_name(int db); #endif diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index 67be592..5695ad7 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -9,102 +9,6 @@ #include #include -#define scsi_opcode_name(opcode) { opcode, #opcode } -#define show_opcode_name(val) \ - __print_symbolic(val, \ - scsi_opcode_name(TEST_UNIT_READY), \ - scsi_opcode_name(REZERO_UNIT), \ - scsi_opcode_name(REQUEST_SENSE),\ - scsi_opcode_name(FORMAT_UNIT), \ - scsi_opcode_name(READ_BLOCK_LIMITS),\ - scsi_opcode_name(REASSIGN_BLOCKS), \ - scsi_opcode_name(INITIALIZE_ELEMENT_STATUS),\ - scsi_opcode_name(READ_6), \ - scsi_opcode_name(WRITE_6), \ - scsi_opcode_name(SEEK_6), \ - scsi_opcode_name(READ_REVERSE), \ - scsi_opcode_name(WRITE_FILEMARKS), \ - scsi_opcode_name(SPACE),
[PATCH 1/3] scsi/trace: Use macros for getting driver byte, host byte, msg byte, and status byte
For getting driver byte, host byte, msg byte, and status byte, macros are implemented in scsi/scsi.h, so we use it. Signed-off-by: Yoshihiro YUNOMAE Reviewed-by: Ewan D. Milne Reviewed-by: Hannes Reinecke Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Robert Elliott Cc: Ewan D. Milne Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- include/trace/events/scsi.h |8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index db6c935..8aecdc2 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -328,10 +328,10 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template, show_opcode_name(__entry->opcode), __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len), - show_driverbyte_name(((__entry->result) >> 24) & 0xff), - show_hostbyte_name(((__entry->result) >> 16) & 0xff), - show_msgbyte_name(((__entry->result) >> 8) & 0xff), - show_statusbyte_name(__entry->result & 0xff)) + show_driverbyte_name(driver_byte(__entry->result)), + show_hostbyte_name(host_byte(__entry->result)), + show_msgbyte_name(msg_byte(__entry->result)), + show_statusbyte_name(status_byte(__entry->result))) ); DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_done, -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[ PATCH -logging 0/3] scsi/trace: Delete duplicated decoders
Hi All, This patchset deletes duplicated decoders in scsi_trace.c. Almost decoders are implemented in constants.c, so we should use them. This patchset deletes following decoders in scsi_trace.c: - hostbyte in patch [2/3] - driverbyte in patch [2/3] - SCSI command in patch [3/3] This patchset is based on Hannes' logging branch: http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging Thanks, Yoshihiro YUNOMAE --- Yoshihiro YUNOMAE (3): scsi/trace: Use macros for getting driver byte, host byte, msg byte, and status byte scsi/trace: Delete duplicated decoders of hostbyte and driverbyte scsi/trace: Delete a duplicated decoder of SCSI command drivers/scsi/constants.c| 34 +--- include/scsi/scsi.h |6 + include/trace/events/scsi.h | 179 ++- 3 files changed, 68 insertions(+), 151 deletions(-) -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/3] scsi/trace: Delete duplicated decoders of hostbyte and driverbyte
There are decoders of hostbyte and driverbyte in constants.c, so this patch deletes those in SCSI traveevents. Note: If CONFIG_SCSI_CONSTANTS is disabled, hostbyte, driverbyte, msgbyte, and statusbyte are output as raw format from this patch. Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Robert Elliott Cc: Ewan D. Milne Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c| 21 ++- include/scsi/scsi.h |5 + include/trace/events/scsi.h | 47 +-- 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index c6a7a4a..8c1f7ac 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1505,21 +1505,22 @@ static const char * const driverbyte_table[]={ "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; #define NUM_DRIVERBYTE_STRS ARRAY_SIZE(driverbyte_table) -void scsi_show_result(struct scsi_device *sdev, const char *name, int result) +inline const char *show_hostbyte_name(int hb) { - int hb = host_byte(result); - int db = driver_byte(result); - const char *hb_string; - const char *db_string; - - hb_string = (hb < NUM_HOSTBYTE_STRS) ? hostbyte_table[hb] : "invalid"; - db_string = (db < NUM_DRIVERBYTE_STRS) ? - driverbyte_table[db] : "invalid"; + return (hb < NUM_HOSTBYTE_STRS) ? hostbyte_table[hb] : "invalid"; +} +inline const char *show_driverbyte_name(int db) +{ + return (db < NUM_DRIVERBYTE_STRS) ? driverbyte_table[db] : "invalid"; +} +void scsi_show_result(struct scsi_device *sdev, const char *name, int result) +{ sdev_printk(KERN_INFO, sdev, "[%s] Result: hostbyte=%s driverbyte=%s\n", - name, hb_string, db_string); + name, show_hostbyte_name(host_byte(result)), + show_driverbyte_name(driver_byte(result))); } #else diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 54ebf54..6d6b3ef 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -586,4 +586,9 @@ static inline __u32 scsi_to_u32(__u8 *ptr) return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3]; } +#ifdef CONFIG_SCSI_CONSTANTS +inline const char *show_hostbyte_name(int hb); +inline const char *show_driverbyte_name(int db); +#endif + #endif /* _SCSI_SCSI_H */ diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index 8aecdc2..67be592 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -105,39 +105,6 @@ scsi_opcode_name(ATA_16), \ scsi_opcode_name(ATA_12)) -#define scsi_hostbyte_name(result) { result, #result } -#define show_hostbyte_name(val)\ - __print_symbolic(val, \ - scsi_hostbyte_name(DID_OK), \ - scsi_hostbyte_name(DID_NO_CONNECT), \ - scsi_hostbyte_name(DID_BUS_BUSY), \ - scsi_hostbyte_name(DID_TIME_OUT), \ - scsi_hostbyte_name(DID_BAD_TARGET), \ - scsi_hostbyte_name(DID_ABORT), \ - scsi_hostbyte_name(DID_PARITY), \ - scsi_hostbyte_name(DID_ERROR), \ - scsi_hostbyte_name(DID_RESET), \ - scsi_hostbyte_name(DID_BAD_INTR), \ - scsi_hostbyte_name(DID_PASSTHROUGH),\ - scsi_hostbyte_name(DID_SOFT_ERROR), \ - scsi_hostbyte_name(DID_IMM_RETRY), \ - scsi_hostbyte_name(DID_REQUEUE),\ - scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED),\ - scsi_hostbyte_name(DID_TRANSPORT_FAILFAST)) - -#define scsi_driverbyte_name(result) { result, #result } -#define show_driverbyte_name(val) \ - __print_symbolic(val, \ - scsi_driverbyte_name(DRIVER_OK),\ - scsi_driverbyte_name(DRIVER_BUSY), \ - scsi_driverbyte_name(DRIVER_SOFT), \ - scsi_driverbyte_name(DRIVER_MEDIA), \ - scsi_driverbyte_name(DRIVER_ERROR), \ - scsi_driverbyte_name(DRIVER_INVALID), \ - scsi_driverbyte_name(DRIVER_TIMEOUT), \ - scsi_driverbyte_name(DRIVER_HARD), \ -
Re: [RFC PATCH 10/10] scsi/trace: Use scsi_print_command trace point instead of printk
Hi Hannes, Sorry for the late reply. (2014/08/28 21:15), Hannes Reinecke wrote: On 08/28/2014 08:19 AM, Yoshihiro YUNOMAE wrote: Hi Hannes, I tried to remove duplicated decoder of SCSI command, but the output format of it in constants.c is different from it in traceevents. I have two questions for it. (Ex1) traceevents: TEST_UNIT_READY constants: Test Unit Ready => Which of "XXX_YYY_ZZZ" and "Xxx Yyy Zzz" should the kernel output strings? This difference comes from difference of implementation. The decoder in traceevents are using macro. So, it cannot define separated words. On the other hand, the decoder in constants are using constant string array table. So, it can define separated words. I would go with the wording in constants.c, but set in double quotes like "Test Unit Ready" to avoid parsing errors later on. OK, we use constants' format and add double quotes for each sense code. (Ex2) traceevents: (nothing) constants: Set limits(12) => Should we merge those decoder? Yes, I would prefer this. Again, we should be setting the strings in double quotes irrespective if there are spaces in the resulting string or not. Sure. I understand we use the decoder of constants, but we need to solve these problems. Would you give me your comments? As mentioned previously, my aim is to convert the logging system in several steps: a) convert all lone 'printk' statements into dev_printk() variants and ensure everything is printed in one statement to avoid linebreaks in the resulting logging message. This will eliminate the immediate problem we're having, namely that debugging is near to impossible under high load. The patchset is nearing completion, and I will be posting it later this week. b) Convert scsi_trace to use the functions from constants.c to avoid code duplication and update scsi_trace to log sense codes. c) Remove all logging functions in the hot path (ie SCSI_LOG_MLQUEUE and SCSI_LOG_MLCOMPLETE) and replace them with trace events. b) is what you're working on, right? Right. For 'c)' the problem is that we should retain the existing functionality with scsi_logging_level here, at least initially. So we cannot just replace it, as this would leave SCSI_LOG_ML a dummy without any real functionality. I tried to change printk messages to new tracevents, but I'll stop it until we solve the problem. I'll submit the patch set removing duplicated decoder first. Thanks, Yoshihiro YUNOMAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH 10/10] scsi/trace: Use scsi_print_command trace point instead of printk
Hi Hannes, Sorry for the late reply. (2014/08/28 21:15), Hannes Reinecke wrote: On 08/28/2014 08:19 AM, Yoshihiro YUNOMAE wrote: Hi Hannes, I tried to remove duplicated decoder of SCSI command, but the output format of it in constants.c is different from it in traceevents. I have two questions for it. (Ex1) traceevents: TEST_UNIT_READY constants: Test Unit Ready = Which of XXX_YYY_ZZZ and Xxx Yyy Zzz should the kernel output strings? This difference comes from difference of implementation. The decoder in traceevents are using macro. So, it cannot define separated words. On the other hand, the decoder in constants are using constant string array table. So, it can define separated words. I would go with the wording in constants.c, but set in double quotes like Test Unit Ready to avoid parsing errors later on. OK, we use constants' format and add double quotes for each sense code. (Ex2) traceevents: (nothing) constants: Set limits(12) = Should we merge those decoder? Yes, I would prefer this. Again, we should be setting the strings in double quotes irrespective if there are spaces in the resulting string or not. Sure. I understand we use the decoder of constants, but we need to solve these problems. Would you give me your comments? As mentioned previously, my aim is to convert the logging system in several steps: a) convert all lone 'printk' statements into dev_printk() variants and ensure everything is printed in one statement to avoid linebreaks in the resulting logging message. This will eliminate the immediate problem we're having, namely that debugging is near to impossible under high load. The patchset is nearing completion, and I will be posting it later this week. b) Convert scsi_trace to use the functions from constants.c to avoid code duplication and update scsi_trace to log sense codes. c) Remove all logging functions in the hot path (ie SCSI_LOG_MLQUEUE and SCSI_LOG_MLCOMPLETE) and replace them with trace events. b) is what you're working on, right? Right. For 'c)' the problem is that we should retain the existing functionality with scsi_logging_level here, at least initially. So we cannot just replace it, as this would leave SCSI_LOG_ML a dummy without any real functionality. I tried to change printk messages to new tracevents, but I'll stop it until we solve the problem. I'll submit the patch set removing duplicated decoder first. Thanks, Yoshihiro YUNOMAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[ PATCH -logging 0/3] scsi/trace: Delete duplicated decoders
Hi All, This patchset deletes duplicated decoders in scsi_trace.c. Almost decoders are implemented in constants.c, so we should use them. This patchset deletes following decoders in scsi_trace.c: - hostbyte in patch [2/3] - driverbyte in patch [2/3] - SCSI command in patch [3/3] This patchset is based on Hannes' logging branch: http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging Thanks, Yoshihiro YUNOMAE --- Yoshihiro YUNOMAE (3): scsi/trace: Use macros for getting driver byte, host byte, msg byte, and status byte scsi/trace: Delete duplicated decoders of hostbyte and driverbyte scsi/trace: Delete a duplicated decoder of SCSI command drivers/scsi/constants.c| 34 +--- include/scsi/scsi.h |6 + include/trace/events/scsi.h | 179 ++- 3 files changed, 68 insertions(+), 151 deletions(-) -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/3] scsi/trace: Delete duplicated decoders of hostbyte and driverbyte
There are decoders of hostbyte and driverbyte in constants.c, so this patch deletes those in SCSI traveevents. Note: If CONFIG_SCSI_CONSTANTS is disabled, hostbyte, driverbyte, msgbyte, and statusbyte are output as raw format from this patch. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Robert Elliott elli...@hp.com Cc: Ewan D. Milne emi...@redhat.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c| 21 ++- include/scsi/scsi.h |5 + include/trace/events/scsi.h | 47 +-- 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index c6a7a4a..8c1f7ac 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1505,21 +1505,22 @@ static const char * const driverbyte_table[]={ DRIVER_INVALID, DRIVER_TIMEOUT, DRIVER_HARD, DRIVER_SENSE}; #define NUM_DRIVERBYTE_STRS ARRAY_SIZE(driverbyte_table) -void scsi_show_result(struct scsi_device *sdev, const char *name, int result) +inline const char *show_hostbyte_name(int hb) { - int hb = host_byte(result); - int db = driver_byte(result); - const char *hb_string; - const char *db_string; - - hb_string = (hb NUM_HOSTBYTE_STRS) ? hostbyte_table[hb] : invalid; - db_string = (db NUM_DRIVERBYTE_STRS) ? - driverbyte_table[db] : invalid; + return (hb NUM_HOSTBYTE_STRS) ? hostbyte_table[hb] : invalid; +} +inline const char *show_driverbyte_name(int db) +{ + return (db NUM_DRIVERBYTE_STRS) ? driverbyte_table[db] : invalid; +} +void scsi_show_result(struct scsi_device *sdev, const char *name, int result) +{ sdev_printk(KERN_INFO, sdev, [%s] Result: hostbyte=%s driverbyte=%s\n, - name, hb_string, db_string); + name, show_hostbyte_name(host_byte(result)), + show_driverbyte_name(driver_byte(result))); } #else diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 54ebf54..6d6b3ef 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -586,4 +586,9 @@ static inline __u32 scsi_to_u32(__u8 *ptr) return (ptr[0]24) + (ptr[1]16) + (ptr[2]8) + ptr[3]; } +#ifdef CONFIG_SCSI_CONSTANTS +inline const char *show_hostbyte_name(int hb); +inline const char *show_driverbyte_name(int db); +#endif + #endif /* _SCSI_SCSI_H */ diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index 8aecdc2..67be592 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -105,39 +105,6 @@ scsi_opcode_name(ATA_16), \ scsi_opcode_name(ATA_12)) -#define scsi_hostbyte_name(result) { result, #result } -#define show_hostbyte_name(val)\ - __print_symbolic(val, \ - scsi_hostbyte_name(DID_OK), \ - scsi_hostbyte_name(DID_NO_CONNECT), \ - scsi_hostbyte_name(DID_BUS_BUSY), \ - scsi_hostbyte_name(DID_TIME_OUT), \ - scsi_hostbyte_name(DID_BAD_TARGET), \ - scsi_hostbyte_name(DID_ABORT), \ - scsi_hostbyte_name(DID_PARITY), \ - scsi_hostbyte_name(DID_ERROR), \ - scsi_hostbyte_name(DID_RESET), \ - scsi_hostbyte_name(DID_BAD_INTR), \ - scsi_hostbyte_name(DID_PASSTHROUGH),\ - scsi_hostbyte_name(DID_SOFT_ERROR), \ - scsi_hostbyte_name(DID_IMM_RETRY), \ - scsi_hostbyte_name(DID_REQUEUE),\ - scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED),\ - scsi_hostbyte_name(DID_TRANSPORT_FAILFAST)) - -#define scsi_driverbyte_name(result) { result, #result } -#define show_driverbyte_name(val) \ - __print_symbolic(val, \ - scsi_driverbyte_name(DRIVER_OK),\ - scsi_driverbyte_name(DRIVER_BUSY), \ - scsi_driverbyte_name(DRIVER_SOFT), \ - scsi_driverbyte_name(DRIVER_MEDIA), \ - scsi_driverbyte_name(DRIVER_ERROR), \ - scsi_driverbyte_name(DRIVER_INVALID), \ - scsi_driverbyte_name(DRIVER_TIMEOUT), \ - scsi_driverbyte_name(DRIVER_HARD
[PATCH 1/3] scsi/trace: Use macros for getting driver byte, host byte, msg byte, and status byte
For getting driver byte, host byte, msg byte, and status byte, macros are implemented in scsi/scsi.h, so we use it. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Reviewed-by: Ewan D. Milne emi...@redhat.com Reviewed-by: Hannes Reinecke h...@suse.de Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Robert Elliott elli...@hp.com Cc: Ewan D. Milne emi...@redhat.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- include/trace/events/scsi.h |8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index db6c935..8aecdc2 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -328,10 +328,10 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template, show_opcode_name(__entry-opcode), __parse_cdb(__get_dynamic_array(cmnd), __entry-cmd_len), __print_hex(__get_dynamic_array(cmnd), __entry-cmd_len), - show_driverbyte_name(((__entry-result) 24) 0xff), - show_hostbyte_name(((__entry-result) 16) 0xff), - show_msgbyte_name(((__entry-result) 8) 0xff), - show_statusbyte_name(__entry-result 0xff)) + show_driverbyte_name(driver_byte(__entry-result)), + show_hostbyte_name(host_byte(__entry-result)), + show_msgbyte_name(msg_byte(__entry-result)), + show_statusbyte_name(status_byte(__entry-result))) ); DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_done, -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/3] scsi/trace: Delete a duplicated decoder of SCSI command
There is a decoder of SCSI command in constants.c, so this patch deletes it in SCSI traveevents. A decoder in traceevents uses macros, so the command name is output as XXX_YYY_ZZZ. On the other hand, a decoder in constants uses strings, so the command name is output as Xxx Yyy Zzz including space. We use a decoder in constants, so this patch adds double quotes for the name. Note: - If CONFIG_SCSI_CONSTANTS is disabled, command names are not shown. - Add command names for 0x07 and 0x2b. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Robert Elliott elli...@hp.com Cc: Ewan D. Milne emi...@redhat.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c| 13 +++- include/scsi/scsi.h |1 include/trace/events/scsi.h | 130 +-- 3 files changed, 37 insertions(+), 107 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 8c1f7ac..50e08c8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -36,7 +36,7 @@ static const char * cdb_byte0_names[] = { /* 00-03 */ Test Unit Ready, Rezero Unit/Rewind, NULL, Request Sense, /* 04-07 */ Format Unit/Medium, Read Block Limits, NULL, - Reassign Blocks, + Reassign Blocks/Initialize Element Status, /* 08-0d */ Read(6), NULL, Write(6), Seek(6), NULL, NULL, /* 0e-12 */ NULL, Read Reverse, Write Filemarks, Space, Inquiry, /* 13-16 */ Verify(6), Recover Buffered Data, Mode Select(6), @@ -47,8 +47,8 @@ static const char * cdb_byte0_names[] = { /* 20-22 */ NULL, NULL, NULL, /* 23-28 */ Read Format Capacities, Set Window, Read Capacity(10), NULL, NULL, Read(10), -/* 29-2d */ Read Generation, Write(10), Seek(10), Erase(10), -Read updated block, +/* 29-2d */ Read Generation, Write(10), Seek(10)/Position To Element, + Erase(10), Read updated block, /* 2e-31 */ Write Verify(10), Verify(10), Search High, Search Equal, /* 32-34 */ Search Low, Set Limits, Prefetch/Read Position, /* 35-37 */ Synchronize Cache(10), Lock/Unlock Cache(10), @@ -103,6 +103,11 @@ static const char * cdb_byte0_names[] = { Volume set (out), Send DVD structure, }; +inline const char *show_opcode_name(int cdb0) +{ + return cdb_byte0_names[cdb0]; +} + struct value_name_pair { int value; const char * name; @@ -365,7 +370,7 @@ static void print_opcode_name(struct scsi_device *sdev, const char *prefix, if (cdb0 0xc0) { cdb_classifier = NULL; #ifdef CONFIG_SCSI_CONSTANTS - cdb_name = cdb_byte0_names[cdb0]; + cdb_name = show_opcode_name(cdb0); if (!cdb_name) cdb_classifier = (reserved); #endif diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 6d6b3ef..59fedff 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -587,6 +587,7 @@ static inline __u32 scsi_to_u32(__u8 *ptr) } #ifdef CONFIG_SCSI_CONSTANTS +inline const char *show_opcode_name(int cdb0); inline const char *show_hostbyte_name(int hb); inline const char *show_driverbyte_name(int db); #endif diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index 67be592..5695ad7 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -9,102 +9,6 @@ #include linux/tracepoint.h #include linux/trace_seq.h -#define scsi_opcode_name(opcode) { opcode, #opcode } -#define show_opcode_name(val) \ - __print_symbolic(val, \ - scsi_opcode_name(TEST_UNIT_READY), \ - scsi_opcode_name(REZERO_UNIT), \ - scsi_opcode_name(REQUEST_SENSE),\ - scsi_opcode_name(FORMAT_UNIT), \ - scsi_opcode_name(READ_BLOCK_LIMITS),\ - scsi_opcode_name(REASSIGN_BLOCKS), \ - scsi_opcode_name(INITIALIZE_ELEMENT_STATUS),\ - scsi_opcode_name(READ_6), \ - scsi_opcode_name(WRITE_6), \ - scsi_opcode_name(SEEK_6), \ - scsi_opcode_name(READ_REVERSE), \ - scsi_opcode_name(WRITE_FILEMARKS), \ - scsi_opcode_name(SPACE),\ - scsi_opcode_name(INQUIRY), \ - scsi_opcode_name(RECOVER_BUFFERED_DATA),\ - scsi_opcode_name(MODE_SELECT), \ - scsi_opcode_name(RESERVE
Re: Re: Re: [RFC PATCH 10/10] scsi/trace: Use scsi_print_command trace point instead of printk
Hi Hannes, I tried to remove duplicated decoder of SCSI command, but the output format of it in constants.c is different from it in traceevents. I have two questions for it. (Ex1) traceevents: TEST_UNIT_READY constants: Test Unit Ready => Which of "XXX_YYY_ZZZ" and "Xxx Yyy Zzz" should the kernel output strings? This difference comes from difference of implementation. The decoder in traceevents are using macro. So, it cannot define separated words. On the other hand, the decoder in constants are using constant string array table. So, it can define separated words. (Ex2) traceevents: (nothing) constants: Set limits(12) => Should we merge those decoder? I understand we use the decoder of constants, but we need to solve these problems. Would you give me your comments? Thanks, Yoshihiro YUNOMAE (2014/08/28 10:40), Yoshihiro YUNOMAE wrote: (2014/08/27 23:16), Hannes Reinecke wrote: On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: Previous printk messages of SCSI command can be mixed into other printk messages because multiple printk messages are output for it. To avoid the problem, patch 4e64bb8d6 in Hannes' branch(*1) introduced a local buffer. But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. Note: We don't need constans.c any more. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples (printk) sd 2:0:0:0: [sda] CDB: Read(10) scsi_print_command: host_no=2 channel=0 id=0 lun=0 [sda] CDB (Read(10)) Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/Makefile |2 drivers/scsi/constants.c| 425 --- drivers/scsi/scsi_trace.c | 408 + include/scsi/scsi.h |8 + include/trace/events/scsi.h | 45 + 5 files changed, 461 insertions(+), 427 deletions(-) delete mode 100644 drivers/scsi/constants.c diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 5f0d299..c56f692 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -158,7 +158,7 @@ obj-$(CONFIG_SCSI_OSD_INITIATOR) += osd/ # This goes last, so that "real" scsi devices probe earlier obj-$(CONFIG_SCSI_DEBUG)+= scsi_debug.o -scsi_mod-y+= scsi.o hosts.o scsi_ioctl.o constants.o \ +scsi_mod-y+= scsi.o hosts.o scsi_ioctl.o \ scsicam.o scsi_error.o scsi_lib.o scsi_mod-$(CONFIG_SCSI_DMA)+= scsi_lib_dma.o scsi_mod-y+= scsi_scan.o scsi_sysfs.o scsi_devinfo.o diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c deleted file mode 100644 index ce9ceb8..000 --- a/drivers/scsi/constants.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - * ASCII values for a number of symbolic constants, printing functions, - * etc. - * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422) - * Additions for SCSI 3+ (SPC-3 T10/1416-D Rev 07 3 May 2002) - * by D. Gilbert and aeb (20020609) - * Updated to SPC-4 T10/1713-D Rev 36g, D. Gilbert 20130701 - */ - -#include -#include -#include -#include - -#include -#include - -/* Commands with service actions that change the command name */ -#define SERVICE_ACTION_IN_12 0xab -#define SERVICE_ACTION_OUT_12 0xa9 -#define SERVICE_ACTION_BIDIRECTIONAL 0x9d -#define SERVICE_ACTION_IN_16 0x9e -#define SERVICE_ACTION_OUT_16 0x9f -#define THIRD_PARTY_COPY_OUT 0x83 -#define THIRD_PARTY_COPY_IN 0x84 - - - -#ifdef CONFIG_SCSI_CONSTANTS -static const char * cdb_byte0_names[] = { -/* 00-03 */ "Test Unit Ready", "Rezero Unit/Rewind", NULL, "Request Sense", -/* 04-07 */ "Format Unit/Medium", "Read Block Limits", NULL, -"Reassign Blocks", -/* 08-0d */ "Read(6)", NULL, "Write(6)", "Seek(6)", NULL, NULL, -/* 0e-12 */ NULL, "Read Reverse", "Write Filemarks", "Space", "Inquiry", -/* 13-16 */ "Verify(6)", "Recover Buffered Data", "Mode Select(6)", -"Reserve(6)", -/* 17-1a */ "Release(6)", "Copy", "Erase", "Mode Sense(6)", -/* 1b-1d */ "Start/Stop Unit", "Receive Diagnostic", "Send Diagnostic", -/* 1e-1f */ "Prevent/Allow Medium Removal", NULL, -/* 20-22 */ NULL, NULL, NULL, -/* 23-28 */ "Read Format Capacities", "Set Window", -"Read Capacity(10)", NULL, NULL, "Read(10)", -/* 29-2d */ "Read Generation", "Write(10)", "Seek(10)", "Erase(10)", -"Read updated block", -/
Re: Re: Re: [RFC PATCH 10/10] scsi/trace: Use scsi_print_command trace point instead of printk
Hi Hannes, I tried to remove duplicated decoder of SCSI command, but the output format of it in constants.c is different from it in traceevents. I have two questions for it. (Ex1) traceevents: TEST_UNIT_READY constants: Test Unit Ready = Which of XXX_YYY_ZZZ and Xxx Yyy Zzz should the kernel output strings? This difference comes from difference of implementation. The decoder in traceevents are using macro. So, it cannot define separated words. On the other hand, the decoder in constants are using constant string array table. So, it can define separated words. (Ex2) traceevents: (nothing) constants: Set limits(12) = Should we merge those decoder? I understand we use the decoder of constants, but we need to solve these problems. Would you give me your comments? Thanks, Yoshihiro YUNOMAE (2014/08/28 10:40), Yoshihiro YUNOMAE wrote: (2014/08/27 23:16), Hannes Reinecke wrote: On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: Previous printk messages of SCSI command can be mixed into other printk messages because multiple printk messages are output for it. To avoid the problem, patch 4e64bb8d6 in Hannes' branch(*1) introduced a local buffer. But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. Note: We don't need constans.c any more. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples Before (printk) sd 2:0:0:0: [sda] CDB: Read(10) After scsi_print_command: host_no=2 channel=0 id=0 lun=0 [sda] CDB (Read(10)) Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/Makefile |2 drivers/scsi/constants.c| 425 --- drivers/scsi/scsi_trace.c | 408 + include/scsi/scsi.h |8 + include/trace/events/scsi.h | 45 + 5 files changed, 461 insertions(+), 427 deletions(-) delete mode 100644 drivers/scsi/constants.c diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 5f0d299..c56f692 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -158,7 +158,7 @@ obj-$(CONFIG_SCSI_OSD_INITIATOR) += osd/ # This goes last, so that real scsi devices probe earlier obj-$(CONFIG_SCSI_DEBUG)+= scsi_debug.o -scsi_mod-y+= scsi.o hosts.o scsi_ioctl.o constants.o \ +scsi_mod-y+= scsi.o hosts.o scsi_ioctl.o \ scsicam.o scsi_error.o scsi_lib.o scsi_mod-$(CONFIG_SCSI_DMA)+= scsi_lib_dma.o scsi_mod-y+= scsi_scan.o scsi_sysfs.o scsi_devinfo.o diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c deleted file mode 100644 index ce9ceb8..000 --- a/drivers/scsi/constants.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - * ASCII values for a number of symbolic constants, printing functions, - * etc. - * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422) - * Additions for SCSI 3+ (SPC-3 T10/1416-D Rev 07 3 May 2002) - * by D. Gilbert and aeb (20020609) - * Updated to SPC-4 T10/1713-D Rev 36g, D. Gilbert 20130701 - */ - -#include linux/blkdev.h -#include linux/module.h -#include linux/kernel.h -#include asm/unaligned.h - -#include scsi/scsi.h -#include scsi/scsi_cmnd.h - -/* Commands with service actions that change the command name */ -#define SERVICE_ACTION_IN_12 0xab -#define SERVICE_ACTION_OUT_12 0xa9 -#define SERVICE_ACTION_BIDIRECTIONAL 0x9d -#define SERVICE_ACTION_IN_16 0x9e -#define SERVICE_ACTION_OUT_16 0x9f -#define THIRD_PARTY_COPY_OUT 0x83 -#define THIRD_PARTY_COPY_IN 0x84 - - - -#ifdef CONFIG_SCSI_CONSTANTS -static const char * cdb_byte0_names[] = { -/* 00-03 */ Test Unit Ready, Rezero Unit/Rewind, NULL, Request Sense, -/* 04-07 */ Format Unit/Medium, Read Block Limits, NULL, -Reassign Blocks, -/* 08-0d */ Read(6), NULL, Write(6), Seek(6), NULL, NULL, -/* 0e-12 */ NULL, Read Reverse, Write Filemarks, Space, Inquiry, -/* 13-16 */ Verify(6), Recover Buffered Data, Mode Select(6), -Reserve(6), -/* 17-1a */ Release(6), Copy, Erase, Mode Sense(6), -/* 1b-1d */ Start/Stop Unit, Receive Diagnostic, Send Diagnostic, -/* 1e-1f */ Prevent/Allow Medium Removal, NULL, -/* 20-22 */ NULL, NULL, NULL, -/* 23-28 */ Read Format Capacities, Set Window, -Read Capacity(10), NULL, NULL, Read(10), -/* 29-2d */ Read Generation, Write(10), Seek(10), Erase(10), -Read updated block, -/* 2e-31 */ Write Verify(10), Verify(10), Search High, Search Equal, -/* 32-34 */ Search Low, Set Limits, Prefetch/Read Position, -/* 35-37 */ Synchronize Cache(10), Lock/Unlock Cache
Re: Re: [RFC PATCH 10/10] scsi/trace: Use scsi_print_command trace point instead of printk
(2014/08/27 23:16), Hannes Reinecke wrote: On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: Previous printk messages of SCSI command can be mixed into other printk messages because multiple printk messages are output for it. To avoid the problem, patch 4e64bb8d6 in Hannes' branch(*1) introduced a local buffer. But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. Note: We don't need constans.c any more. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples (printk) sd 2:0:0:0: [sda] CDB: Read(10) scsi_print_command: host_no=2 channel=0 id=0 lun=0 [sda] CDB (Read(10)) Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/Makefile |2 drivers/scsi/constants.c| 425 --- drivers/scsi/scsi_trace.c | 408 + include/scsi/scsi.h |8 + include/trace/events/scsi.h | 45 + 5 files changed, 461 insertions(+), 427 deletions(-) delete mode 100644 drivers/scsi/constants.c diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 5f0d299..c56f692 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -158,7 +158,7 @@ obj-$(CONFIG_SCSI_OSD_INITIATOR) += osd/ # This goes last, so that "real" scsi devices probe earlier obj-$(CONFIG_SCSI_DEBUG)+= scsi_debug.o -scsi_mod-y+= scsi.o hosts.o scsi_ioctl.o constants.o \ +scsi_mod-y+= scsi.o hosts.o scsi_ioctl.o \ scsicam.o scsi_error.o scsi_lib.o scsi_mod-$(CONFIG_SCSI_DMA)+= scsi_lib_dma.o scsi_mod-y+= scsi_scan.o scsi_sysfs.o scsi_devinfo.o diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c deleted file mode 100644 index ce9ceb8..000 --- a/drivers/scsi/constants.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - * ASCII values for a number of symbolic constants, printing functions, - * etc. - * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422) - * Additions for SCSI 3+ (SPC-3 T10/1416-D Rev 07 3 May 2002) - * by D. Gilbert and aeb (20020609) - * Updated to SPC-4 T10/1713-D Rev 36g, D. Gilbert 20130701 - */ - -#include -#include -#include -#include - -#include -#include - -/* Commands with service actions that change the command name */ -#define SERVICE_ACTION_IN_12 0xab -#define SERVICE_ACTION_OUT_12 0xa9 -#define SERVICE_ACTION_BIDIRECTIONAL 0x9d -#define SERVICE_ACTION_IN_16 0x9e -#define SERVICE_ACTION_OUT_16 0x9f -#define THIRD_PARTY_COPY_OUT 0x83 -#define THIRD_PARTY_COPY_IN 0x84 - - - -#ifdef CONFIG_SCSI_CONSTANTS -static const char * cdb_byte0_names[] = { -/* 00-03 */ "Test Unit Ready", "Rezero Unit/Rewind", NULL, "Request Sense", -/* 04-07 */ "Format Unit/Medium", "Read Block Limits", NULL, -"Reassign Blocks", -/* 08-0d */ "Read(6)", NULL, "Write(6)", "Seek(6)", NULL, NULL, -/* 0e-12 */ NULL, "Read Reverse", "Write Filemarks", "Space", "Inquiry", -/* 13-16 */ "Verify(6)", "Recover Buffered Data", "Mode Select(6)", -"Reserve(6)", -/* 17-1a */ "Release(6)", "Copy", "Erase", "Mode Sense(6)", -/* 1b-1d */ "Start/Stop Unit", "Receive Diagnostic", "Send Diagnostic", -/* 1e-1f */ "Prevent/Allow Medium Removal", NULL, -/* 20-22 */ NULL, NULL, NULL, -/* 23-28 */ "Read Format Capacities", "Set Window", -"Read Capacity(10)", NULL, NULL, "Read(10)", -/* 29-2d */ "Read Generation", "Write(10)", "Seek(10)", "Erase(10)", -"Read updated block", -/* 2e-31 */ "Write Verify(10)", "Verify(10)", "Search High", "Search Equal", -/* 32-34 */ "Search Low", "Set Limits", "Prefetch/Read Position", -/* 35-37 */ "Synchronize Cache(10)", "Lock/Unlock Cache(10)", -"Read Defect Data(10)", -/* 38-3c */ "Medium Scan", "Compare", "Copy Verify", "Write Buffer", -"Read Buffer", -/* 3d-3f */ "Update Block", "Read Long(10)", "Write Long(10)", -/* 40-41 */ "Change Definition", "Write Same(10)", -/* 42-48 */ "Unmap/Read sub-channel", "Read TOC/PMA/ATIP", -"Read density support", "Play audio(10)", "Get configuration", -"Play audio msf", "Sanit
Re: Re: [RFC PATCH 09/10] scsi/trace: Add additional sense code and additional sense code qualifier to scsi_print_sense trace point
(2014/08/27 23:16), Hannes Reinecke wrote: On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: There are no mean that additional sense code and additional sense code qualifier are output as different messages of sense key, so those information are added. Note: scsi_show_extd_sense() is changed from export symbol to non-export symbol. - Result examples (printk) sd 2:0:0:0: [sda] Add. Sense: Unrecovered read error (ftrace, merged into scsi_print_sense traceevent) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Add. Sense (Unrecovered read error) Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c| 932 --- drivers/scsi/scsi_trace.c | 920 ++ include/scsi/scsi_dbg.h |2 include/trace/events/scsi.h | 10 4 files changed, 928 insertions(+), 936 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 85b75c8..ce9ceb8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -14,12 +14,6 @@ #include #include -#include -#include -#include -#include - -#include /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -429,929 +423,3 @@ void scsi_print_command(struct scsi_cmnd *cmd) print_opcode_name(cmd->device, devname, cmd->cmnd, cmd->cmd_len); } EXPORT_SYMBOL(scsi_print_command); - -#ifdef CONFIG_SCSI_CONSTANTS - -struct error_info { -unsigned short code12;/* 0x0302 looks better than 0x03,0x02 */ -const char * text; -}; - -/* - * The canonical list of T10 Additional Sense Codes is available at: - * http://www.t10.org/lists/asc-num.txt [most recent: 20130605] - */ - -static const struct error_info additional[] = -{ -{0x, "No additional sense information"}, -{0x0001, "Filemark detected"}, -{0x0002, "End-of-partition/medium detected"}, -{0x0003, "Setmark detected"}, -{0x0004, "Beginning-of-partition/medium detected"}, -{0x0005, "End-of-data detected"}, -{0x0006, "I/O process terminated"}, -{0x0007, "Programmable early warning detected"}, -{0x0011, "Audio play operation in progress"}, -{0x0012, "Audio play operation paused"}, -{0x0013, "Audio play operation successfully completed"}, -{0x0014, "Audio play operation stopped due to error"}, -{0x0015, "No current audio status to return"}, -{0x0016, "Operation in progress"}, -{0x0017, "Cleaning requested"}, -{0x0018, "Erase operation in progress"}, -{0x0019, "Locate operation in progress"}, -{0x001A, "Rewind operation in progress"}, -{0x001B, "Set capacity operation in progress"}, -{0x001C, "Verify operation in progress"}, -{0x001D, "ATA pass through information available"}, -{0x001E, "Conflicting SA creation request"}, -{0x001F, "Logical unit transitioning to another power condition"}, -{0x0020, "Extended copy information available"}, - -{0x0100, "No index/sector signal"}, - -{0x0200, "No seek complete"}, - -{0x0300, "Peripheral device write fault"}, -{0x0301, "No write current"}, -{0x0302, "Excessive write errors"}, - -{0x0400, "Logical unit not ready, cause not reportable"}, -{0x0401, "Logical unit is in process of becoming ready"}, -{0x0402, "Logical unit not ready, initializing command required"}, -{0x0403, "Logical unit not ready, manual intervention required"}, -{0x0404, "Logical unit not ready, format in progress"}, -{0x0405, "Logical unit not ready, rebuild in progress"}, -{0x0406, "Logical unit not ready, recalculation in progress"}, -{0x0407, "Logical unit not ready, operation in progress"}, -{0x0408, "Logical unit not ready, long write in progress"}, -{0x0409, "Logical unit not ready, self-test in progress"}, -{0x040A, "Logical unit not accessible, asymmetric access state " - "transition"}, -{0x040B, "Logical unit not accessible, target port in standby state"}, -{0x040C, "Logical unit not accessible, target port in unavailable " - "state"}, -{0x040D, "Logical unit not ready, structure check required"}, -{0x0410, "Logical unit not ready, auxiliary memory not accessible"}, -{0x0411, "Logical unit not ready, notify (enable spinup) required"}, -
Re: Re: [RFC PATCH 08/10] scsi/trace: Use scsi_print_sense trace point instead of printk
(2014/08/27 23:15), Hannes Reinecke wrote: On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: Previous sense messages can be mixed into other sense messages, because continuous printk (KERN_CONT) was used. To avoid the problem, patch d87f3a6f51 introduced a local buffer in Hannes's baranch (*1). But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples (printk) sd 2:0:0:0: [sda] Sense Key : Medium Error [current] (ftrace) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c| 145 ++- drivers/scsi/scsi_trace.c | 140 -- include/scsi/scsi_eh.h |7 ++ include/trace/events/scsi.h | 48 ++ 4 files changed, 195 insertions(+), 145 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index f7b7f32..85b75c8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -19,7 +19,7 @@ #include #include - +#include /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -1267,58 +1267,8 @@ static const struct error_info2 additional2[] = {0x70, 0x00, 0xff, "Decompression exception short algorithm id of %x"}, {0, 0, 0, NULL} }; - -/* description of the sense key values */ -static const char * const snstext[] = { -"No Sense",/* 0: There is no sense information */ -"Recovered Error", /* 1: The last command completed successfully - but used error correction */ -"Not Ready",/* 2: The addressed target is not ready */ -"Medium Error",/* 3: Data error detected on the medium */ -"Hardware Error", /* 4: Controller or device failure */ -"Illegal Request", /* 5: Error in request */ -"Unit Attention", /* 6: Removable medium was changed, or - the target has been reset, or ... */ -"Data Protect",/* 7: Access to the data is blocked */ -"Blank Check",/* 8: Reached unexpected written or unwritten - region of the medium */ -"Vendor Specific(9)", -"Copy Aborted",/* A: COPY or COMPARE was aborted */ -"Aborted Command", /* B: The target aborted the command */ -"Equal",/* C: A SEARCH DATA command found data equal, - reserved in SPC-4 rev 36 */ -"Volume Overflow", /* D: Medium full with still data to be written */ -"Miscompare",/* E: Source data and data on the medium - do not agree */ -"Completed",/* F: command completed sense data reported, - may occur for successful command */ -}; -#else -static const char * const snstext[] = { -"0x0", "0x1", "0x2", "0x3", "0x4", "0x5", "0x6", "0x7", -"0x8", "0x9", "0xa", "0xb", "0xc", "0xd", "0xe", "0xf", -}; #endif -/* Get sense key string or NULL if not available */ -const char * -scsi_sense_key_string(unsigned char key) { -return snstext[key & 0xf]; -} -EXPORT_SYMBOL(scsi_sense_key_string); - -const char * -scsi_sense_type_string(struct scsi_sense_hdr *sshdr) -{ -return scsi_sense_is_deferred(sshdr) ? "[deferred]" : "[current]"; -} - -const char * -scsi_sense_format_string(struct scsi_sense_hdr *sshdr) -{ -return sshdr->response_code >= 0x72 ? "[descriptor]" : ""; -} - /* * Get additional sense code string or NULL if not available. * This string may contain a "%x" and should be printed with ascq as arg. @@ -1375,105 +1325,22 @@ void scsi_print_sense_hdr(struct scsi_device *sdev, const char *name, struct scsi_sense_hdr *sshdr) { -sdev_printk(KERN_INFO, sdev, "[%s] Sense Key : %s %s%s\n", name, -scsi_sense_key_string(sshdr->sense_key), -scsi_sense_type_string(sshdr), -scsi_sense_format_string(sshdr)); +trace_scsi_print_sense(sdev, name, sshdr, NULL, 0, 0); scsi_show_extd_sense(sdev, name, sshdr->asc, sshdr->ascq); } EXPORT_SYMBOL(scsi_print_sense_hdr); -static void -scsi_dump_sense_buffer(struct scsi_device *sdev, const char *pre
Re: Re: [RFC PATCH 07/10] scsi/trace: Use scsi_show_result trace point instead of printk
(2014/08/27 23:12), Hannes Reinecke wrote: On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: Current SCSI trace has hostbyte table and driverbyte table, so we don't need to have the same table in scsi/constants.c. - Result examples (printk) sd 2:0:0:0: [sda] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE (ftrace) scsi_show_result: host_no=2 channel=0 id=0 lun=0 [sda] result=(driver=DRIVER_SENSE host=DID_OK) Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c| 52 --- drivers/scsi/scsi_trace.c | 16 + include/trace/events/scsi.h | 38 +++ 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 6fad6b4..f7b7f32 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1488,55 +1488,3 @@ void scsi_print_sense(struct scsi_cmnd *cmd) SCSI_SENSE_BUFFERSIZE); } EXPORT_SYMBOL(scsi_print_sense); - -#ifdef CONFIG_SCSI_CONSTANTS - -static const char * const hostbyte_table[]={ -"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", -"DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR", -"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY", "DID_REQUEUE", -"DID_TRANSPORT_DISRUPTED", "DID_TRANSPORT_FAILFAST", "DID_TARGET_FAILURE", -"DID_NEXUS_FAILURE" }; -#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table) - -static const char * const driverbyte_table[]={ -"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", -"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; -#define NUM_DRIVERBYTE_STRS ARRAY_SIZE(driverbyte_table) - -void scsi_show_result(struct scsi_device *sdev, const char *name, int result) -{ -int hb = host_byte(result); -int db = driver_byte(result); -const char *hb_string; -const char *db_string; - -hb_string = (hb < NUM_HOSTBYTE_STRS) ? hostbyte_table[hb] : "invalid"; -db_string = (db < NUM_DRIVERBYTE_STRS) ? -driverbyte_table[db] : "invalid"; - - -sdev_printk(KERN_INFO, sdev, -"[%s] Result: hostbyte=%s driverbyte=%s\n", -name, hb_string, db_string); -} - -#else - -void scsi_show_result(struct scsi_device *sdev, const char *name, int result) -{ -sdev_printk(KERN_INFO, sdev, -"[%s] Result: hostbyte=0x%02x driverbyte=0x%02x\n", -name, host_byte(result), driver_byte(result)); -} - -#endif -EXPORT_SYMBOL(scsi_show_result); - -void scsi_print_result(struct scsi_cmnd *cmd) -{ -const char *devname = cmd->request->rq_disk ? -cmd->request->rq_disk->disk_name : "scsi"; -scsi_show_result(cmd->device, devname, cmd->result); -} -EXPORT_SYMBOL(scsi_print_result); diff --git a/drivers/scsi/scsi_trace.c b/drivers/scsi/scsi_trace.c index 2bea4f0..6ffbc40 100644 --- a/drivers/scsi/scsi_trace.c +++ b/drivers/scsi/scsi_trace.c @@ -19,6 +19,8 @@ #include #include +#include + #define SERVICE_ACTION16(cdb) (cdb[1] & 0x1f) #define SERVICE_ACTION32(cdb) ((cdb[8] << 8) | cdb[9]) @@ -286,3 +288,17 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len) return scsi_trace_misc(p, cdb, len); } } + +void scsi_show_result(struct scsi_device *sdev, const char *name, int result) +{ +trace_scsi_show_result(sdev, name, result); +} +EXPORT_SYMBOL(scsi_show_result); + +void scsi_print_result(struct scsi_cmnd *cmd) +{ +const char *devname = cmd->request->rq_disk ? +cmd->request->rq_disk->disk_name : "scsi"; +scsi_show_result(cmd->device, devname, cmd->result); +} +EXPORT_SYMBOL(scsi_print_result); diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index 8aecdc2..0675195 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -123,7 +123,11 @@ scsi_hostbyte_name(DID_IMM_RETRY),\ scsi_hostbyte_name(DID_REQUEUE),\ scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED),\ -scsi_hostbyte_name(DID_TRANSPORT_FAILFAST)) +scsi_hostbyte_name(DID_TRANSPORT_FAILFAST),\ +scsi_hostbyte_name(DID_TARGET_FAILURE),\ +scsi_hostbyte_name(DID_NEXUS_FAILURE),\ +scsi_hostbyte_name(DID_ALLOC_FAILURE),\ +scsi_hostbyte_name(DID_MEDIUM_ERROR)) #define scsi_driverbyte_name(result){ result, #result } #defi
Re: Re: [RFC PATCH 07/10] scsi/trace: Use scsi_show_result trace point instead of printk
(2014/08/27 23:12), Hannes Reinecke wrote: On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: Current SCSI trace has hostbyte table and driverbyte table, so we don't need to have the same table in scsi/constants.c. - Result examples Before (printk) sd 2:0:0:0: [sda] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE After (ftrace) scsi_show_result: host_no=2 channel=0 id=0 lun=0 [sda] result=(driver=DRIVER_SENSE host=DID_OK) Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c| 52 --- drivers/scsi/scsi_trace.c | 16 + include/trace/events/scsi.h | 38 +++ 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 6fad6b4..f7b7f32 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1488,55 +1488,3 @@ void scsi_print_sense(struct scsi_cmnd *cmd) SCSI_SENSE_BUFFERSIZE); } EXPORT_SYMBOL(scsi_print_sense); - -#ifdef CONFIG_SCSI_CONSTANTS - -static const char * const hostbyte_table[]={ -DID_OK, DID_NO_CONNECT, DID_BUS_BUSY, DID_TIME_OUT, DID_BAD_TARGET, -DID_ABORT, DID_PARITY, DID_ERROR, DID_RESET, DID_BAD_INTR, -DID_PASSTHROUGH, DID_SOFT_ERROR, DID_IMM_RETRY, DID_REQUEUE, -DID_TRANSPORT_DISRUPTED, DID_TRANSPORT_FAILFAST, DID_TARGET_FAILURE, -DID_NEXUS_FAILURE }; -#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table) - -static const char * const driverbyte_table[]={ -DRIVER_OK, DRIVER_BUSY, DRIVER_SOFT, DRIVER_MEDIA, DRIVER_ERROR, -DRIVER_INVALID, DRIVER_TIMEOUT, DRIVER_HARD, DRIVER_SENSE}; -#define NUM_DRIVERBYTE_STRS ARRAY_SIZE(driverbyte_table) - -void scsi_show_result(struct scsi_device *sdev, const char *name, int result) -{ -int hb = host_byte(result); -int db = driver_byte(result); -const char *hb_string; -const char *db_string; - -hb_string = (hb NUM_HOSTBYTE_STRS) ? hostbyte_table[hb] : invalid; -db_string = (db NUM_DRIVERBYTE_STRS) ? -driverbyte_table[db] : invalid; - - -sdev_printk(KERN_INFO, sdev, -[%s] Result: hostbyte=%s driverbyte=%s\n, -name, hb_string, db_string); -} - -#else - -void scsi_show_result(struct scsi_device *sdev, const char *name, int result) -{ -sdev_printk(KERN_INFO, sdev, -[%s] Result: hostbyte=0x%02x driverbyte=0x%02x\n, -name, host_byte(result), driver_byte(result)); -} - -#endif -EXPORT_SYMBOL(scsi_show_result); - -void scsi_print_result(struct scsi_cmnd *cmd) -{ -const char *devname = cmd-request-rq_disk ? -cmd-request-rq_disk-disk_name : scsi; -scsi_show_result(cmd-device, devname, cmd-result); -} -EXPORT_SYMBOL(scsi_print_result); diff --git a/drivers/scsi/scsi_trace.c b/drivers/scsi/scsi_trace.c index 2bea4f0..6ffbc40 100644 --- a/drivers/scsi/scsi_trace.c +++ b/drivers/scsi/scsi_trace.c @@ -19,6 +19,8 @@ #include linux/trace_seq.h #include trace/events/scsi.h +#include scsi/scsi_dbg.h + #define SERVICE_ACTION16(cdb) (cdb[1] 0x1f) #define SERVICE_ACTION32(cdb) ((cdb[8] 8) | cdb[9]) @@ -286,3 +288,17 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len) return scsi_trace_misc(p, cdb, len); } } + +void scsi_show_result(struct scsi_device *sdev, const char *name, int result) +{ +trace_scsi_show_result(sdev, name, result); +} +EXPORT_SYMBOL(scsi_show_result); + +void scsi_print_result(struct scsi_cmnd *cmd) +{ +const char *devname = cmd-request-rq_disk ? +cmd-request-rq_disk-disk_name : scsi; +scsi_show_result(cmd-device, devname, cmd-result); +} +EXPORT_SYMBOL(scsi_print_result); diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index 8aecdc2..0675195 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -123,7 +123,11 @@ scsi_hostbyte_name(DID_IMM_RETRY),\ scsi_hostbyte_name(DID_REQUEUE),\ scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED),\ -scsi_hostbyte_name(DID_TRANSPORT_FAILFAST)) +scsi_hostbyte_name(DID_TRANSPORT_FAILFAST),\ +scsi_hostbyte_name(DID_TARGET_FAILURE),\ +scsi_hostbyte_name(DID_NEXUS_FAILURE),\ +scsi_hostbyte_name(DID_ALLOC_FAILURE),\ +scsi_hostbyte_name(DID_MEDIUM_ERROR)) #define scsi_driverbyte_name(result){ result, #result } #define show_driverbyte_name(val)\ @@ -359,6 +363,38 @@ TRACE_EVENT(scsi_eh_wakeup, TP_printk(host_no=%u, __entry-host_no) ); +TRACE_EVENT(scsi_show_result, + +TP_PROTO(struct scsi_device *sdev, const char *devname
Re: Re: [RFC PATCH 08/10] scsi/trace: Use scsi_print_sense trace point instead of printk
(2014/08/27 23:15), Hannes Reinecke wrote: On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: Previous sense messages can be mixed into other sense messages, because continuous printk (KERN_CONT) was used. To avoid the problem, patch d87f3a6f51 introduced a local buffer in Hannes's baranch (*1). But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples Before (printk) sd 2:0:0:0: [sda] Sense Key : Medium Error [current] After (ftrace) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c| 145 ++- drivers/scsi/scsi_trace.c | 140 -- include/scsi/scsi_eh.h |7 ++ include/trace/events/scsi.h | 48 ++ 4 files changed, 195 insertions(+), 145 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index f7b7f32..85b75c8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -19,7 +19,7 @@ #include scsi/scsi_eh.h #include scsi/scsi_dbg.h - +#include trace/events/scsi.h /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -1267,58 +1267,8 @@ static const struct error_info2 additional2[] = {0x70, 0x00, 0xff, Decompression exception short algorithm id of %x}, {0, 0, 0, NULL} }; - -/* description of the sense key values */ -static const char * const snstext[] = { -No Sense,/* 0: There is no sense information */ -Recovered Error, /* 1: The last command completed successfully - but used error correction */ -Not Ready,/* 2: The addressed target is not ready */ -Medium Error,/* 3: Data error detected on the medium */ -Hardware Error, /* 4: Controller or device failure */ -Illegal Request, /* 5: Error in request */ -Unit Attention, /* 6: Removable medium was changed, or - the target has been reset, or ... */ -Data Protect,/* 7: Access to the data is blocked */ -Blank Check,/* 8: Reached unexpected written or unwritten - region of the medium */ -Vendor Specific(9), -Copy Aborted,/* A: COPY or COMPARE was aborted */ -Aborted Command, /* B: The target aborted the command */ -Equal,/* C: A SEARCH DATA command found data equal, - reserved in SPC-4 rev 36 */ -Volume Overflow, /* D: Medium full with still data to be written */ -Miscompare,/* E: Source data and data on the medium - do not agree */ -Completed,/* F: command completed sense data reported, - may occur for successful command */ -}; -#else -static const char * const snstext[] = { -0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, -0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, -}; #endif -/* Get sense key string or NULL if not available */ -const char * -scsi_sense_key_string(unsigned char key) { -return snstext[key 0xf]; -} -EXPORT_SYMBOL(scsi_sense_key_string); - -const char * -scsi_sense_type_string(struct scsi_sense_hdr *sshdr) -{ -return scsi_sense_is_deferred(sshdr) ? [deferred] : [current]; -} - -const char * -scsi_sense_format_string(struct scsi_sense_hdr *sshdr) -{ -return sshdr-response_code = 0x72 ? [descriptor] : ; -} - /* * Get additional sense code string or NULL if not available. * This string may contain a %x and should be printed with ascq as arg. @@ -1375,105 +1325,22 @@ void scsi_print_sense_hdr(struct scsi_device *sdev, const char *name, struct scsi_sense_hdr *sshdr) { -sdev_printk(KERN_INFO, sdev, [%s] Sense Key : %s %s%s\n, name, -scsi_sense_key_string(sshdr-sense_key), -scsi_sense_type_string(sshdr), -scsi_sense_format_string(sshdr)); +trace_scsi_print_sense(sdev, name, sshdr, NULL, 0, 0); scsi_show_extd_sense(sdev, name, sshdr-asc, sshdr-ascq); } EXPORT_SYMBOL(scsi_print_sense_hdr); -static void -scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, - const unsigned char *sense_buffer, int sense_len) -{ -char linebuf[128]; -int i, linelen, remaining; - -if (sense_len 32) -sense_len = 32; - -remaining = sense_len; -for (i = 0; i sense_len; i += 16
Re: Re: [RFC PATCH 09/10] scsi/trace: Add additional sense code and additional sense code qualifier to scsi_print_sense trace point
(2014/08/27 23:16), Hannes Reinecke wrote: On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: There are no mean that additional sense code and additional sense code qualifier are output as different messages of sense key, so those information are added. Note: scsi_show_extd_sense() is changed from export symbol to non-export symbol. - Result examples Before (printk) sd 2:0:0:0: [sda] Add. Sense: Unrecovered read error After (ftrace, merged into scsi_print_sense traceevent) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Add. Sense (Unrecovered read error) Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c| 932 --- drivers/scsi/scsi_trace.c | 920 ++ include/scsi/scsi_dbg.h |2 include/trace/events/scsi.h | 10 4 files changed, 928 insertions(+), 936 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 85b75c8..ce9ceb8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -14,12 +14,6 @@ #include scsi/scsi.h #include scsi/scsi_cmnd.h -#include scsi/scsi_device.h -#include scsi/scsi_host.h -#include scsi/scsi_eh.h -#include scsi/scsi_dbg.h - -#include trace/events/scsi.h /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -429,929 +423,3 @@ void scsi_print_command(struct scsi_cmnd *cmd) print_opcode_name(cmd-device, devname, cmd-cmnd, cmd-cmd_len); } EXPORT_SYMBOL(scsi_print_command); - -#ifdef CONFIG_SCSI_CONSTANTS - -struct error_info { -unsigned short code12;/* 0x0302 looks better than 0x03,0x02 */ -const char * text; -}; - -/* - * The canonical list of T10 Additional Sense Codes is available at: - * http://www.t10.org/lists/asc-num.txt [most recent: 20130605] - */ - -static const struct error_info additional[] = -{ -{0x, No additional sense information}, -{0x0001, Filemark detected}, -{0x0002, End-of-partition/medium detected}, -{0x0003, Setmark detected}, -{0x0004, Beginning-of-partition/medium detected}, -{0x0005, End-of-data detected}, -{0x0006, I/O process terminated}, -{0x0007, Programmable early warning detected}, -{0x0011, Audio play operation in progress}, -{0x0012, Audio play operation paused}, -{0x0013, Audio play operation successfully completed}, -{0x0014, Audio play operation stopped due to error}, -{0x0015, No current audio status to return}, -{0x0016, Operation in progress}, -{0x0017, Cleaning requested}, -{0x0018, Erase operation in progress}, -{0x0019, Locate operation in progress}, -{0x001A, Rewind operation in progress}, -{0x001B, Set capacity operation in progress}, -{0x001C, Verify operation in progress}, -{0x001D, ATA pass through information available}, -{0x001E, Conflicting SA creation request}, -{0x001F, Logical unit transitioning to another power condition}, -{0x0020, Extended copy information available}, - -{0x0100, No index/sector signal}, - -{0x0200, No seek complete}, - -{0x0300, Peripheral device write fault}, -{0x0301, No write current}, -{0x0302, Excessive write errors}, - -{0x0400, Logical unit not ready, cause not reportable}, -{0x0401, Logical unit is in process of becoming ready}, -{0x0402, Logical unit not ready, initializing command required}, -{0x0403, Logical unit not ready, manual intervention required}, -{0x0404, Logical unit not ready, format in progress}, -{0x0405, Logical unit not ready, rebuild in progress}, -{0x0406, Logical unit not ready, recalculation in progress}, -{0x0407, Logical unit not ready, operation in progress}, -{0x0408, Logical unit not ready, long write in progress}, -{0x0409, Logical unit not ready, self-test in progress}, -{0x040A, Logical unit not accessible, asymmetric access state - transition}, -{0x040B, Logical unit not accessible, target port in standby state}, -{0x040C, Logical unit not accessible, target port in unavailable - state}, -{0x040D, Logical unit not ready, structure check required}, -{0x0410, Logical unit not ready, auxiliary memory not accessible}, -{0x0411, Logical unit not ready, notify (enable spinup) required}, -{0x0412, Logical unit not ready, offline}, -{0x0413, Logical unit not ready, SA creation in progress}, -{0x0414, Logical unit not ready, space allocation in progress}, -{0x0415, Logical unit not ready, robotics disabled}, -{0x0416, Logical unit not ready, configuration
Re: Re: [RFC PATCH 10/10] scsi/trace: Use scsi_print_command trace point instead of printk
(2014/08/27 23:16), Hannes Reinecke wrote: On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: Previous printk messages of SCSI command can be mixed into other printk messages because multiple printk messages are output for it. To avoid the problem, patch 4e64bb8d6 in Hannes' branch(*1) introduced a local buffer. But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. Note: We don't need constans.c any more. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples Before (printk) sd 2:0:0:0: [sda] CDB: Read(10) After scsi_print_command: host_no=2 channel=0 id=0 lun=0 [sda] CDB (Read(10)) Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/Makefile |2 drivers/scsi/constants.c| 425 --- drivers/scsi/scsi_trace.c | 408 + include/scsi/scsi.h |8 + include/trace/events/scsi.h | 45 + 5 files changed, 461 insertions(+), 427 deletions(-) delete mode 100644 drivers/scsi/constants.c diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 5f0d299..c56f692 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -158,7 +158,7 @@ obj-$(CONFIG_SCSI_OSD_INITIATOR) += osd/ # This goes last, so that real scsi devices probe earlier obj-$(CONFIG_SCSI_DEBUG)+= scsi_debug.o -scsi_mod-y+= scsi.o hosts.o scsi_ioctl.o constants.o \ +scsi_mod-y+= scsi.o hosts.o scsi_ioctl.o \ scsicam.o scsi_error.o scsi_lib.o scsi_mod-$(CONFIG_SCSI_DMA)+= scsi_lib_dma.o scsi_mod-y+= scsi_scan.o scsi_sysfs.o scsi_devinfo.o diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c deleted file mode 100644 index ce9ceb8..000 --- a/drivers/scsi/constants.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - * ASCII values for a number of symbolic constants, printing functions, - * etc. - * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422) - * Additions for SCSI 3+ (SPC-3 T10/1416-D Rev 07 3 May 2002) - * by D. Gilbert and aeb (20020609) - * Updated to SPC-4 T10/1713-D Rev 36g, D. Gilbert 20130701 - */ - -#include linux/blkdev.h -#include linux/module.h -#include linux/kernel.h -#include asm/unaligned.h - -#include scsi/scsi.h -#include scsi/scsi_cmnd.h - -/* Commands with service actions that change the command name */ -#define SERVICE_ACTION_IN_12 0xab -#define SERVICE_ACTION_OUT_12 0xa9 -#define SERVICE_ACTION_BIDIRECTIONAL 0x9d -#define SERVICE_ACTION_IN_16 0x9e -#define SERVICE_ACTION_OUT_16 0x9f -#define THIRD_PARTY_COPY_OUT 0x83 -#define THIRD_PARTY_COPY_IN 0x84 - - - -#ifdef CONFIG_SCSI_CONSTANTS -static const char * cdb_byte0_names[] = { -/* 00-03 */ Test Unit Ready, Rezero Unit/Rewind, NULL, Request Sense, -/* 04-07 */ Format Unit/Medium, Read Block Limits, NULL, -Reassign Blocks, -/* 08-0d */ Read(6), NULL, Write(6), Seek(6), NULL, NULL, -/* 0e-12 */ NULL, Read Reverse, Write Filemarks, Space, Inquiry, -/* 13-16 */ Verify(6), Recover Buffered Data, Mode Select(6), -Reserve(6), -/* 17-1a */ Release(6), Copy, Erase, Mode Sense(6), -/* 1b-1d */ Start/Stop Unit, Receive Diagnostic, Send Diagnostic, -/* 1e-1f */ Prevent/Allow Medium Removal, NULL, -/* 20-22 */ NULL, NULL, NULL, -/* 23-28 */ Read Format Capacities, Set Window, -Read Capacity(10), NULL, NULL, Read(10), -/* 29-2d */ Read Generation, Write(10), Seek(10), Erase(10), -Read updated block, -/* 2e-31 */ Write Verify(10), Verify(10), Search High, Search Equal, -/* 32-34 */ Search Low, Set Limits, Prefetch/Read Position, -/* 35-37 */ Synchronize Cache(10), Lock/Unlock Cache(10), -Read Defect Data(10), -/* 38-3c */ Medium Scan, Compare, Copy Verify, Write Buffer, -Read Buffer, -/* 3d-3f */ Update Block, Read Long(10), Write Long(10), -/* 40-41 */ Change Definition, Write Same(10), -/* 42-48 */ Unmap/Read sub-channel, Read TOC/PMA/ATIP, -Read density support, Play audio(10), Get configuration, -Play audio msf, Sanitize/Play audio track/index, -/* 49-4f */ Play track relative(10), Get event status notification, -Pause/resume, Log Select, Log Sense, Stop play/scan, -NULL, -/* 50-55 */ Xdwrite, Xpwrite, Read disk info, Xdread, Read track info, -Reserve track, Send OPC info, Mode Select(10), -/* 56-5b */ Reserve(10), Release(10), Repair track, Read master cue, -Mode Sense(10), Close track/session, -/* 5c-5f */ Read buffer capacity
Re: Re: [RFC PATCH 04/10] scsi/constants: Cleanup printk message in scsi_dump_sense_buffer()
(2014/08/16 0:08), Ewan Milne wrote: On Fri, 2014-08-08 at 11:50 +, Yoshihiro YUNOMAE wrote: Unrecognized sense data should be output after linebuf is filled because "[%s] Unrecognized sense data (in hex): %s" message is output many times in loop. Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 5956d4d..6fad6b4 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1385,16 +1385,13 @@ EXPORT_SYMBOL(scsi_print_sense_hdr); static void scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, - const unsigned char *sense_buffer, int sense_len, - struct scsi_sense_hdr *sshdr) + const unsigned char *sense_buffer, int sense_len) { char linebuf[128]; int i, linelen, remaining; if (sense_len < 32) sense_len = 32; - sdev_printk(KERN_INFO, sdev, - "[%s] Unrecognized sense data (in hex):", prefix); remaining = sense_len; for (i = 0; i < sense_len; i += 16) { @@ -1403,9 +1400,10 @@ scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, hex_dump_to_buffer(sense_buffer + i, linelen, 16, 1, linebuf, sizeof(linebuf), false); - sdev_printk(KERN_INFO, sdev, "[%s] Sense: %s\n", - prefix, linebuf); } + sdev_printk(KERN_INFO, sdev, + "[%s] Unrecognized sense data (in hex): %s", + prefix, linebuf); } See my earlier comment regarding PATCH 03/10. This doesn't look right -- In Hannes' tree what the code is doing is printing out a separate line for each 16 bytes of the sense data. Your change will cause only the last (partial?) 16 bytes to be printed. That's true. We should not apply this as well. The removal of the unused sshdr argument is fine, though. Thanks! Yoshihiro YUNOMAE -Ewan static void @@ -1467,8 +1465,7 @@ void __scsi_print_sense(struct scsi_device *sdev, const char *name, if (!scsi_normalize_sense(sense_buffer, sense_len, )) { /* this may be SCSI-1 sense data */ - scsi_dump_sense_buffer(sdev, name, sense_buffer, - sense_len, ); + scsi_dump_sense_buffer(sdev, name, sense_buffer, sense_len); return; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH 03/10] scsi/constants: Cleanup printk message in __scsi_print_command()
Hi Ewan, Thank you for your review. (2014/08/16 0:05), Ewan Milne wrote: On Fri, 2014-08-08 at 11:50 +, Yoshihiro YUNOMAE wrote: All bytes in CDB should be output after linebuf is filled because "[%s] CDB: %s\n" message is output many times in loop. Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 9c38b8d..5956d4d 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -413,9 +413,8 @@ void __scsi_print_command(struct scsi_device *sdev, const char *prefix, hex_dump_to_buffer(cdb + i, linelen, 16, 1, linebuf, sizeof(linebuf), false); - sdev_printk(KERN_INFO, sdev, "[%s] CDB: %s\n", - prefix, linebuf); } + sdev_printk(KERN_INFO, sdev, "[%s] CDB: %s\n", prefix, linebuf); } EXPORT_SYMBOL(__scsi_print_command); This doesn't look right -- In Hannes' tree what the code is doing is printing out a separate line for each 16 bytes of the CDB. You change will cause only the last (partial?) 16 bytes to be printed. Ah, that's true. We should not apply this patch. Thanks, Yoshihiro YUNOMAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH 03/10] scsi/constants: Cleanup printk message in __scsi_print_command()
Hi Ewan, Thank you for your review. (2014/08/16 0:05), Ewan Milne wrote: On Fri, 2014-08-08 at 11:50 +, Yoshihiro YUNOMAE wrote: All bytes in CDB should be output after linebuf is filled because [%s] CDB: %s\n message is output many times in loop. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 9c38b8d..5956d4d 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -413,9 +413,8 @@ void __scsi_print_command(struct scsi_device *sdev, const char *prefix, hex_dump_to_buffer(cdb + i, linelen, 16, 1, linebuf, sizeof(linebuf), false); - sdev_printk(KERN_INFO, sdev, [%s] CDB: %s\n, - prefix, linebuf); } + sdev_printk(KERN_INFO, sdev, [%s] CDB: %s\n, prefix, linebuf); } EXPORT_SYMBOL(__scsi_print_command); This doesn't look right -- In Hannes' tree what the code is doing is printing out a separate line for each 16 bytes of the CDB. You change will cause only the last (partial?) 16 bytes to be printed. Ah, that's true. We should not apply this patch. Thanks, Yoshihiro YUNOMAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Re: [RFC PATCH 04/10] scsi/constants: Cleanup printk message in scsi_dump_sense_buffer()
(2014/08/16 0:08), Ewan Milne wrote: On Fri, 2014-08-08 at 11:50 +, Yoshihiro YUNOMAE wrote: Unrecognized sense data should be output after linebuf is filled because [%s] Unrecognized sense data (in hex): %s message is output many times in loop. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 5956d4d..6fad6b4 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1385,16 +1385,13 @@ EXPORT_SYMBOL(scsi_print_sense_hdr); static void scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, - const unsigned char *sense_buffer, int sense_len, - struct scsi_sense_hdr *sshdr) + const unsigned char *sense_buffer, int sense_len) { char linebuf[128]; int i, linelen, remaining; if (sense_len 32) sense_len = 32; - sdev_printk(KERN_INFO, sdev, - [%s] Unrecognized sense data (in hex):, prefix); remaining = sense_len; for (i = 0; i sense_len; i += 16) { @@ -1403,9 +1400,10 @@ scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, hex_dump_to_buffer(sense_buffer + i, linelen, 16, 1, linebuf, sizeof(linebuf), false); - sdev_printk(KERN_INFO, sdev, [%s] Sense: %s\n, - prefix, linebuf); } + sdev_printk(KERN_INFO, sdev, + [%s] Unrecognized sense data (in hex): %s, + prefix, linebuf); } See my earlier comment regarding PATCH 03/10. This doesn't look right -- In Hannes' tree what the code is doing is printing out a separate line for each 16 bytes of the sense data. Your change will cause only the last (partial?) 16 bytes to be printed. That's true. We should not apply this as well. The removal of the unused sshdr argument is fine, though. Thanks! Yoshihiro YUNOMAE -Ewan static void @@ -1467,8 +1465,7 @@ void __scsi_print_sense(struct scsi_device *sdev, const char *name, if (!scsi_normalize_sense(sense_buffer, sense_len, sshdr)) { /* this may be SCSI-1 sense data */ - scsi_dump_sense_buffer(sdev, name, sense_buffer, - sense_len, sshdr); + scsi_dump_sense_buffer(sdev, name, sense_buffer, sense_len); return; } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH 01/10] scsi/constants: Cleanup printk message in __scsi_print_sense()
Hi Elliot, Thank you for your comment. (2014/08/12 23:51), Elliott, Robert (Server Storage) wrote: -Original Message- From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi- ow...@vger.kernel.org] On Behalf Of Yoshihiro YUNOMAE Sent: Friday, 08 August, 2014 6:50 AM ... Subject: [RFC PATCH 01/10] scsi/constants: Cleanup printk message in __scsi_print_sense() A device name is output like "sda: Sense Key : Medium Error [current]" in __scsi_print_sense(), but it should be "[sda] Sense Key : Medium Error [current]" because other printk messages output a device name like "[sda] foo." ... diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index c6a7a4a..a0e8159 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1470,7 +1470,7 @@ void __scsi_print_sense(struct scsi_device *sdev, const char *name, return; } - sdev_printk(KERN_INFO, sdev, "%s: Sense Key : %s %s%s\n", name, + sdev_printk(KERN_INFO, sdev, "[%s] Sense Key : %s %s%s\n", name, scsi_sense_key_string(sshdr.sense_key), scsi_sense_type_string(), scsi_sense_format_string()); The callers of __scsi_print_sense do not always pass in a name like "sda". In fact, sd.c doesn't even call that function; its sd_print_sense_hdr calls sd_printk (which prints name as "[%s]") and scsi_show_sense_hdr. OK, I understood. Current Linux kernel also outputs ":" in __scsi_print_sense(), so we should not change this. Thanks, Yoshihiro YUNOMOAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Re: [RFC PATCH -logging 00/10] scsi/constants: Output continuous error messages on trace
Hi Douglas, Thank you for your comment. (2014/08/08 22:07), Douglas Gilbert wrote: On 14-08-08 01:50 PM, Yoshihiro YUNOMAE wrote: Hi All, This patch set introduces new traceevents in order to output continuous error messages. Current SCSI printk messages in upstream kernel can be divided by and mixed with other messages. Even if each error message has its device id, sometimes we can easily be lost in mixed logs because the message's device id is separated from it's body. To avoid it, I'd like to use traceevents to store error messages into the ftrace or perf buuffer, because traceevents are atomically commited to the buffer. In this patch set, all printk messages are removed based on a local discussion with Hannes, but I think printk messages should be kept because all users don't enable traceevents and rsyslog can store as files. However, if printk of logging branch is kept, the messages are duplicate and it can induce stack overflow by using local buffer(*1). (*1) https://lkml.org/lkml/2014/5/20/742 So, my suggestion is follows: 1) printk Keeps current implemntation of upstream kernel. The messages are divided and can be mixed, but all users can check the error messages without any settings. 2) traceevents To get the complete messages, we can use ftrace or perf (or something on them). Users can always understand correct messages, but they need to set up the tracers. This patch set is based on Hannes' logging branch: http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging [1/10] ~ [6/10]: just cleanup for logging branch [7/10] ~ [10/10]: introduce new traceevents Any comments are welcome! In sg3_utils there are now string yielding equivalents to the sense buffer "print" functions. They take a form like this: char * get_sense_str(const unsigned char * sense_buffer, int sb_len, int blen, char * b); So this just does the hard work of decoding the sense buffer (or saying it is invalid) the result of which it places in buffer 'b'. And 'b' is returned (so this function can be in the arguments of a driver's printing function). Adding such string functions would give other parts of the SCSI subsystem the capability of tailoring their own messages that include sense data information. Existing sense buffer "print" function could be kept and implemented using the newer "_str" variants. Would that be worth the trouble? I have already sent the idea using local buffer on this February, but it was rejected by James (*1). By using stack region for local buffer, stack overflow can occur. So, I implemented this feature to atomically output an error message with device information. (*1) https://lkml.org/lkml/2014/5/20/742 Thanks, Yoshihiro YUNOMAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Re: [RFC PATCH -logging 00/10] scsi/constants: Output continuous error messages on trace
Hi Douglas, Thank you for your comment. (2014/08/08 22:07), Douglas Gilbert wrote: On 14-08-08 01:50 PM, Yoshihiro YUNOMAE wrote: Hi All, This patch set introduces new traceevents in order to output continuous error messages. Current SCSI printk messages in upstream kernel can be divided by and mixed with other messages. Even if each error message has its device id, sometimes we can easily be lost in mixed logs because the message's device id is separated from it's body. To avoid it, I'd like to use traceevents to store error messages into the ftrace or perf buuffer, because traceevents are atomically commited to the buffer. In this patch set, all printk messages are removed based on a local discussion with Hannes, but I think printk messages should be kept because all users don't enable traceevents and rsyslog can store as files. However, if printk of logging branch is kept, the messages are duplicate and it can induce stack overflow by using local buffer(*1). (*1) https://lkml.org/lkml/2014/5/20/742 So, my suggestion is follows: 1) printk Keeps current implemntation of upstream kernel. The messages are divided and can be mixed, but all users can check the error messages without any settings. 2) traceevents To get the complete messages, we can use ftrace or perf (or something on them). Users can always understand correct messages, but they need to set up the tracers. This patch set is based on Hannes' logging branch: http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging [1/10] ~ [6/10]: just cleanup for logging branch [7/10] ~ [10/10]: introduce new traceevents Any comments are welcome! In sg3_utils there are now string yielding equivalents to the sense buffer print functions. They take a form like this: char * get_sense_str(const unsigned char * sense_buffer, int sb_len, int blen, char * b); So this just does the hard work of decoding the sense buffer (or saying it is invalid) the result of which it places in buffer 'b'. And 'b' is returned (so this function can be in the arguments of a driver's printing function). Adding such string functions would give other parts of the SCSI subsystem the capability of tailoring their own messages that include sense data information. Existing sense buffer print function could be kept and implemented using the newer _str variants. Would that be worth the trouble? I have already sent the idea using local buffer on this February, but it was rejected by James (*1). By using stack region for local buffer, stack overflow can occur. So, I implemented this feature to atomically output an error message with device information. (*1) https://lkml.org/lkml/2014/5/20/742 Thanks, Yoshihiro YUNOMAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH 01/10] scsi/constants: Cleanup printk message in __scsi_print_sense()
Hi Elliot, Thank you for your comment. (2014/08/12 23:51), Elliott, Robert (Server Storage) wrote: -Original Message- From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi- ow...@vger.kernel.org] On Behalf Of Yoshihiro YUNOMAE Sent: Friday, 08 August, 2014 6:50 AM ... Subject: [RFC PATCH 01/10] scsi/constants: Cleanup printk message in __scsi_print_sense() A device name is output like sda: Sense Key : Medium Error [current] in __scsi_print_sense(), but it should be [sda] Sense Key : Medium Error [current] because other printk messages output a device name like [sda] foo. ... diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index c6a7a4a..a0e8159 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1470,7 +1470,7 @@ void __scsi_print_sense(struct scsi_device *sdev, const char *name, return; } - sdev_printk(KERN_INFO, sdev, %s: Sense Key : %s %s%s\n, name, + sdev_printk(KERN_INFO, sdev, [%s] Sense Key : %s %s%s\n, name, scsi_sense_key_string(sshdr.sense_key), scsi_sense_type_string(sshdr), scsi_sense_format_string(sshdr)); The callers of __scsi_print_sense do not always pass in a name like sda. In fact, sd.c doesn't even call that function; its sd_print_sense_hdr calls sd_printk (which prints name as [%s]) and scsi_show_sense_hdr. OK, I understood. Current Linux kernel also outputs name: in __scsi_print_sense(), so we should not change this. Thanks, Yoshihiro YUNOMOAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 09/10] scsi/trace: Add additional sense code and additional sense code qualifier to scsi_print_sense trace point
There are no mean that additional sense code and additional sense code qualifier are output as different messages of sense key, so those information are added. Note: scsi_show_extd_sense() is changed from export symbol to non-export symbol. - Result examples (printk) sd 2:0:0:0: [sda] Add. Sense: Unrecovered read error (ftrace, merged into scsi_print_sense traceevent) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Add. Sense (Unrecovered read error) Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c| 932 --- drivers/scsi/scsi_trace.c | 920 ++ include/scsi/scsi_dbg.h |2 include/trace/events/scsi.h | 10 4 files changed, 928 insertions(+), 936 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 85b75c8..ce9ceb8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -14,12 +14,6 @@ #include #include -#include -#include -#include -#include - -#include /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -429,929 +423,3 @@ void scsi_print_command(struct scsi_cmnd *cmd) print_opcode_name(cmd->device, devname, cmd->cmnd, cmd->cmd_len); } EXPORT_SYMBOL(scsi_print_command); - -#ifdef CONFIG_SCSI_CONSTANTS - -struct error_info { - unsigned short code12; /* 0x0302 looks better than 0x03,0x02 */ - const char * text; -}; - -/* - * The canonical list of T10 Additional Sense Codes is available at: - * http://www.t10.org/lists/asc-num.txt [most recent: 20130605] - */ - -static const struct error_info additional[] = -{ - {0x, "No additional sense information"}, - {0x0001, "Filemark detected"}, - {0x0002, "End-of-partition/medium detected"}, - {0x0003, "Setmark detected"}, - {0x0004, "Beginning-of-partition/medium detected"}, - {0x0005, "End-of-data detected"}, - {0x0006, "I/O process terminated"}, - {0x0007, "Programmable early warning detected"}, - {0x0011, "Audio play operation in progress"}, - {0x0012, "Audio play operation paused"}, - {0x0013, "Audio play operation successfully completed"}, - {0x0014, "Audio play operation stopped due to error"}, - {0x0015, "No current audio status to return"}, - {0x0016, "Operation in progress"}, - {0x0017, "Cleaning requested"}, - {0x0018, "Erase operation in progress"}, - {0x0019, "Locate operation in progress"}, - {0x001A, "Rewind operation in progress"}, - {0x001B, "Set capacity operation in progress"}, - {0x001C, "Verify operation in progress"}, - {0x001D, "ATA pass through information available"}, - {0x001E, "Conflicting SA creation request"}, - {0x001F, "Logical unit transitioning to another power condition"}, - {0x0020, "Extended copy information available"}, - - {0x0100, "No index/sector signal"}, - - {0x0200, "No seek complete"}, - - {0x0300, "Peripheral device write fault"}, - {0x0301, "No write current"}, - {0x0302, "Excessive write errors"}, - - {0x0400, "Logical unit not ready, cause not reportable"}, - {0x0401, "Logical unit is in process of becoming ready"}, - {0x0402, "Logical unit not ready, initializing command required"}, - {0x0403, "Logical unit not ready, manual intervention required"}, - {0x0404, "Logical unit not ready, format in progress"}, - {0x0405, "Logical unit not ready, rebuild in progress"}, - {0x0406, "Logical unit not ready, recalculation in progress"}, - {0x0407, "Logical unit not ready, operation in progress"}, - {0x0408, "Logical unit not ready, long write in progress"}, - {0x0409, "Logical unit not ready, self-test in progress"}, - {0x040A, "Logical unit not accessible, asymmetric access state " -"transition"}, - {0x040B, "Logical unit not accessible, target port in standby state"}, - {0x040C, "Logical unit not accessible, target port in unavailable " -"state"}, - {0x040D, "Logical unit not ready, structure check required"}, - {0x0410, "Logical unit not ready, auxiliary memory not accessible"}, - {0x0411, "Logical unit not ready,
[RFC PATCH 04/10] scsi/constants: Cleanup printk message in scsi_dump_sense_buffer()
Unrecognized sense data should be output after linebuf is filled because "[%s] Unrecognized sense data (in hex): %s" message is output many times in loop. Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 5956d4d..6fad6b4 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1385,16 +1385,13 @@ EXPORT_SYMBOL(scsi_print_sense_hdr); static void scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, - const unsigned char *sense_buffer, int sense_len, - struct scsi_sense_hdr *sshdr) + const unsigned char *sense_buffer, int sense_len) { char linebuf[128]; int i, linelen, remaining; if (sense_len < 32) sense_len = 32; - sdev_printk(KERN_INFO, sdev, - "[%s] Unrecognized sense data (in hex):", prefix); remaining = sense_len; for (i = 0; i < sense_len; i += 16) { @@ -1403,9 +1400,10 @@ scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, hex_dump_to_buffer(sense_buffer + i, linelen, 16, 1, linebuf, sizeof(linebuf), false); - sdev_printk(KERN_INFO, sdev, "[%s] Sense: %s\n", - prefix, linebuf); } + sdev_printk(KERN_INFO, sdev, + "[%s] Unrecognized sense data (in hex): %s", + prefix, linebuf); } static void @@ -1467,8 +1465,7 @@ void __scsi_print_sense(struct scsi_device *sdev, const char *name, if (!scsi_normalize_sense(sense_buffer, sense_len, )) { /* this may be SCSI-1 sense data */ - scsi_dump_sense_buffer(sdev, name, sense_buffer, - sense_len, ); + scsi_dump_sense_buffer(sdev, name, sense_buffer, sense_len); return; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 03/10] scsi/constants: Cleanup printk message in __scsi_print_command()
All bytes in CDB should be output after linebuf is filled because "[%s] CDB: %s\n" message is output many times in loop. Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 9c38b8d..5956d4d 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -413,9 +413,8 @@ void __scsi_print_command(struct scsi_device *sdev, const char *prefix, hex_dump_to_buffer(cdb + i, linelen, 16, 1, linebuf, sizeof(linebuf), false); - sdev_printk(KERN_INFO, sdev, "[%s] CDB: %s\n", - prefix, linebuf); } + sdev_printk(KERN_INFO, sdev, "[%s] CDB: %s\n", prefix, linebuf); } EXPORT_SYMBOL(__scsi_print_command); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 05/10] scsi/trace: Use macros for getting driver byte, host byte, msg byte, and status byte
For getting driver byte, host byte, msg byte, and status byte, macros are implemented in scsi/scsi.h, so we use it. Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- include/trace/events/scsi.h |8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index db6c935..8aecdc2 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -328,10 +328,10 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template, show_opcode_name(__entry->opcode), __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len), - show_driverbyte_name(((__entry->result) >> 24) & 0xff), - show_hostbyte_name(((__entry->result) >> 16) & 0xff), - show_msgbyte_name(((__entry->result) >> 8) & 0xff), - show_statusbyte_name(__entry->result & 0xff)) + show_driverbyte_name(driver_byte(__entry->result)), + show_hostbyte_name(host_byte(__entry->result)), + show_msgbyte_name(msg_byte(__entry->result)), + show_statusbyte_name(status_byte(__entry->result))) ); DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_done, -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 02/10] scsi/constants: Cleanup printk message in scsi_decode_sense_extras()
If sense_flags and fixed_valid are zero, the kernel does not need to output a printk message. So, if those conditions are met, it just returns. Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index a0e8159..9c38b8d 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1438,6 +1438,9 @@ scsi_decode_sense_extras(struct scsi_device *sdev, const char *name, sense_flags |= ucp[3] & 0xe0; } + if (!sense_flags && !fixed_valid) + return; + res = 0; memset(buff, 0, sizeof(buff)); blen = sizeof(buff) - 1; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 10/10] scsi/trace: Use scsi_print_command trace point instead of printk
Previous printk messages of SCSI command can be mixed into other printk messages because multiple printk messages are output for it. To avoid the problem, patch 4e64bb8d6 in Hannes' branch(*1) introduced a local buffer. But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. Note: We don't need constans.c any more. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples (printk) sd 2:0:0:0: [sda] CDB: Read(10) scsi_print_command: host_no=2 channel=0 id=0 lun=0 [sda] CDB (Read(10)) Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/Makefile |2 drivers/scsi/constants.c| 425 --- drivers/scsi/scsi_trace.c | 408 + include/scsi/scsi.h |8 + include/trace/events/scsi.h | 45 + 5 files changed, 461 insertions(+), 427 deletions(-) delete mode 100644 drivers/scsi/constants.c diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 5f0d299..c56f692 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -158,7 +158,7 @@ obj-$(CONFIG_SCSI_OSD_INITIATOR) += osd/ # This goes last, so that "real" scsi devices probe earlier obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o -scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ +scsi_mod-y += scsi.o hosts.o scsi_ioctl.o \ scsicam.o scsi_error.o scsi_lib.o scsi_mod-$(CONFIG_SCSI_DMA)+= scsi_lib_dma.o scsi_mod-y += scsi_scan.o scsi_sysfs.o scsi_devinfo.o diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c deleted file mode 100644 index ce9ceb8..000 --- a/drivers/scsi/constants.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - * ASCII values for a number of symbolic constants, printing functions, - * etc. - * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422) - * Additions for SCSI 3+ (SPC-3 T10/1416-D Rev 07 3 May 2002) - * by D. Gilbert and aeb (20020609) - * Updated to SPC-4 T10/1713-D Rev 36g, D. Gilbert 20130701 - */ - -#include -#include -#include -#include - -#include -#include - -/* Commands with service actions that change the command name */ -#define SERVICE_ACTION_IN_12 0xab -#define SERVICE_ACTION_OUT_12 0xa9 -#define SERVICE_ACTION_BIDIRECTIONAL 0x9d -#define SERVICE_ACTION_IN_16 0x9e -#define SERVICE_ACTION_OUT_16 0x9f -#define THIRD_PARTY_COPY_OUT 0x83 -#define THIRD_PARTY_COPY_IN 0x84 - - - -#ifdef CONFIG_SCSI_CONSTANTS -static const char * cdb_byte0_names[] = { -/* 00-03 */ "Test Unit Ready", "Rezero Unit/Rewind", NULL, "Request Sense", -/* 04-07 */ "Format Unit/Medium", "Read Block Limits", NULL, - "Reassign Blocks", -/* 08-0d */ "Read(6)", NULL, "Write(6)", "Seek(6)", NULL, NULL, -/* 0e-12 */ NULL, "Read Reverse", "Write Filemarks", "Space", "Inquiry", -/* 13-16 */ "Verify(6)", "Recover Buffered Data", "Mode Select(6)", - "Reserve(6)", -/* 17-1a */ "Release(6)", "Copy", "Erase", "Mode Sense(6)", -/* 1b-1d */ "Start/Stop Unit", "Receive Diagnostic", "Send Diagnostic", -/* 1e-1f */ "Prevent/Allow Medium Removal", NULL, -/* 20-22 */ NULL, NULL, NULL, -/* 23-28 */ "Read Format Capacities", "Set Window", - "Read Capacity(10)", NULL, NULL, "Read(10)", -/* 29-2d */ "Read Generation", "Write(10)", "Seek(10)", "Erase(10)", -"Read updated block", -/* 2e-31 */ "Write Verify(10)", "Verify(10)", "Search High", "Search Equal", -/* 32-34 */ "Search Low", "Set Limits", "Prefetch/Read Position", -/* 35-37 */ "Synchronize Cache(10)", "Lock/Unlock Cache(10)", - "Read Defect Data(10)", -/* 38-3c */ "Medium Scan", "Compare", "Copy Verify", "Write Buffer", - "Read Buffer", -/* 3d-3f */ "Update Block", "Read Long(10)", "Write Long(10)", -/* 40-41 */ "Change Definition", "Write Same(10)", -/* 42-48 */ "Unmap/Read sub-channel", "Read TOC/PMA/ATIP", - "Read density support", "Play audio(10)", "Get configuration", - "Play audio msf", "Sanitize/Play audio track/index", -/* 49-4f
[RFC PATCH 08/10] scsi/trace: Use scsi_print_sense trace point instead of printk
Previous sense messages can be mixed into other sense messages, because continuous printk (KERN_CONT) was used. To avoid the problem, patch d87f3a6f51 introduced a local buffer in Hannes's baranch (*1). But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples (printk) sd 2:0:0:0: [sda] Sense Key : Medium Error [current] (ftrace) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c| 145 ++- drivers/scsi/scsi_trace.c | 140 -- include/scsi/scsi_eh.h |7 ++ include/trace/events/scsi.h | 48 ++ 4 files changed, 195 insertions(+), 145 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index f7b7f32..85b75c8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -19,7 +19,7 @@ #include #include - +#include /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -1267,58 +1267,8 @@ static const struct error_info2 additional2[] = {0x70, 0x00, 0xff, "Decompression exception short algorithm id of %x"}, {0, 0, 0, NULL} }; - -/* description of the sense key values */ -static const char * const snstext[] = { - "No Sense", /* 0: There is no sense information */ - "Recovered Error", /* 1: The last command completed successfully - but used error correction */ - "Not Ready",/* 2: The addressed target is not ready */ - "Medium Error", /* 3: Data error detected on the medium */ - "Hardware Error", /* 4: Controller or device failure */ - "Illegal Request", /* 5: Error in request */ - "Unit Attention", /* 6: Removable medium was changed, or - the target has been reset, or ... */ - "Data Protect", /* 7: Access to the data is blocked */ - "Blank Check", /* 8: Reached unexpected written or unwritten - region of the medium */ - "Vendor Specific(9)", - "Copy Aborted", /* A: COPY or COMPARE was aborted */ - "Aborted Command", /* B: The target aborted the command */ - "Equal",/* C: A SEARCH DATA command found data equal, - reserved in SPC-4 rev 36 */ - "Volume Overflow", /* D: Medium full with still data to be written */ - "Miscompare", /* E: Source data and data on the medium - do not agree */ - "Completed",/* F: command completed sense data reported, - may occur for successful command */ -}; -#else -static const char * const snstext[] = { - "0x0", "0x1", "0x2", "0x3", "0x4", "0x5", "0x6", "0x7", - "0x8", "0x9", "0xa", "0xb", "0xc", "0xd", "0xe", "0xf", -}; #endif -/* Get sense key string or NULL if not available */ -const char * -scsi_sense_key_string(unsigned char key) { - return snstext[key & 0xf]; -} -EXPORT_SYMBOL(scsi_sense_key_string); - -const char * -scsi_sense_type_string(struct scsi_sense_hdr *sshdr) -{ - return scsi_sense_is_deferred(sshdr) ? "[deferred]" : "[current]"; -} - -const char * -scsi_sense_format_string(struct scsi_sense_hdr *sshdr) -{ - return sshdr->response_code >= 0x72 ? "[descriptor]" : ""; -} - /* * Get additional sense code string or NULL if not available. * This string may contain a "%x" and should be printed with ascq as arg. @@ -1375,105 +1325,22 @@ void scsi_print_sense_hdr(struct scsi_device *sdev, const char *name, struct scsi_sense_hdr *sshdr) { - sdev_printk(KERN_INFO, sdev, "[%s] Sense Key : %s %s%s\n", name, - scsi_sense_key_string(sshdr->sense_key), - scsi_sense_type_string(sshdr), - scsi_sense_format_string(sshdr)); + trace_scsi_print_sense(sdev, name, sshdr, NULL, 0, 0); scsi_show_extd_sense(sdev, name, sshdr->asc, sshdr->ascq); } EXPORT_SYMBOL(scsi_print_
[RFC PATCH 01/10] scsi/constants: Cleanup printk message in __scsi_print_sense()
A device name is output like "sda: Sense Key : Medium Error [current]" in __scsi_print_sense(), but it should be "[sda] Sense Key : Medium Error [current]" because other printk messages output a device name like "[sda] foo." Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index c6a7a4a..a0e8159 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1470,7 +1470,7 @@ void __scsi_print_sense(struct scsi_device *sdev, const char *name, return; } - sdev_printk(KERN_INFO, sdev, "%s: Sense Key : %s %s%s\n", name, + sdev_printk(KERN_INFO, sdev, "[%s] Sense Key : %s %s%s\n", name, scsi_sense_key_string(sshdr.sense_key), scsi_sense_type_string(), scsi_sense_format_string()); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 06/10] scsi/sd: Delete extra scsi_show_extd_sense() in sd_print_sense_hdr()
sd_print_sense_hdr() calls scsi_show_extd_sense(), but scsi_print_sense_hdr() also calls scsi_show_extd_sense(). We can get same result, so we delete it. Note: Calling scsi_show_extd_sense() is introduced in fdd8b297. Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/sd.c |2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 8d7204a..22dd214 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3286,8 +3286,6 @@ static void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) { scsi_print_sense_hdr(sdkp->device, sdkp->disk->disk_name, sshdr); - scsi_show_extd_sense(sdkp->device, sdkp->disk->disk_name, -sshdr->asc, sshdr->ascq); } static void sd_print_result(struct scsi_disk *sdkp, int result) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 07/10] scsi/trace: Use scsi_show_result trace point instead of printk
Current SCSI trace has hostbyte table and driverbyte table, so we don't need to have the same table in scsi/constants.c. - Result examples (printk) sd 2:0:0:0: [sda] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE (ftrace) scsi_show_result: host_no=2 channel=0 id=0 lun=0 [sda] result=(driver=DRIVER_SENSE host=DID_OK) Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c| 52 --- drivers/scsi/scsi_trace.c | 16 + include/trace/events/scsi.h | 38 +++ 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 6fad6b4..f7b7f32 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1488,55 +1488,3 @@ void scsi_print_sense(struct scsi_cmnd *cmd) SCSI_SENSE_BUFFERSIZE); } EXPORT_SYMBOL(scsi_print_sense); - -#ifdef CONFIG_SCSI_CONSTANTS - -static const char * const hostbyte_table[]={ -"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", -"DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR", -"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY", "DID_REQUEUE", -"DID_TRANSPORT_DISRUPTED", "DID_TRANSPORT_FAILFAST", "DID_TARGET_FAILURE", -"DID_NEXUS_FAILURE" }; -#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table) - -static const char * const driverbyte_table[]={ -"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", -"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; -#define NUM_DRIVERBYTE_STRS ARRAY_SIZE(driverbyte_table) - -void scsi_show_result(struct scsi_device *sdev, const char *name, int result) -{ - int hb = host_byte(result); - int db = driver_byte(result); - const char *hb_string; - const char *db_string; - - hb_string = (hb < NUM_HOSTBYTE_STRS) ? hostbyte_table[hb] : "invalid"; - db_string = (db < NUM_DRIVERBYTE_STRS) ? - driverbyte_table[db] : "invalid"; - - - sdev_printk(KERN_INFO, sdev, - "[%s] Result: hostbyte=%s driverbyte=%s\n", - name, hb_string, db_string); -} - -#else - -void scsi_show_result(struct scsi_device *sdev, const char *name, int result) -{ - sdev_printk(KERN_INFO, sdev, - "[%s] Result: hostbyte=0x%02x driverbyte=0x%02x\n", - name, host_byte(result), driver_byte(result)); -} - -#endif -EXPORT_SYMBOL(scsi_show_result); - -void scsi_print_result(struct scsi_cmnd *cmd) -{ - const char *devname = cmd->request->rq_disk ? - cmd->request->rq_disk->disk_name : "scsi"; - scsi_show_result(cmd->device, devname, cmd->result); -} -EXPORT_SYMBOL(scsi_print_result); diff --git a/drivers/scsi/scsi_trace.c b/drivers/scsi/scsi_trace.c index 2bea4f0..6ffbc40 100644 --- a/drivers/scsi/scsi_trace.c +++ b/drivers/scsi/scsi_trace.c @@ -19,6 +19,8 @@ #include #include +#include + #define SERVICE_ACTION16(cdb) (cdb[1] & 0x1f) #define SERVICE_ACTION32(cdb) ((cdb[8] << 8) | cdb[9]) @@ -286,3 +288,17 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len) return scsi_trace_misc(p, cdb, len); } } + +void scsi_show_result(struct scsi_device *sdev, const char *name, int result) +{ + trace_scsi_show_result(sdev, name, result); +} +EXPORT_SYMBOL(scsi_show_result); + +void scsi_print_result(struct scsi_cmnd *cmd) +{ + const char *devname = cmd->request->rq_disk ? + cmd->request->rq_disk->disk_name : "scsi"; + scsi_show_result(cmd->device, devname, cmd->result); +} +EXPORT_SYMBOL(scsi_print_result); diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index 8aecdc2..0675195 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -123,7 +123,11 @@ scsi_hostbyte_name(DID_IMM_RETRY), \ scsi_hostbyte_name(DID_REQUEUE),\ scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED),\ - scsi_hostbyte_name(DID_TRANSPORT_FAILFAST)) + scsi_hostbyte_name(DID_TRANSPORT_FAILFAST), \ + scsi_hostbyte_name(DID_TARGET_FAILURE), \ + scsi_hostbyte_name(DID_NEXUS_FAILURE), \ + scsi_hostbyte_name(DID_ALLOC_FAILURE), \ + scsi_hostbyte_name(DID
[RFC PATCH -logging 00/10] scsi/constants: Output continuous error messages on trace
Hi All, This patch set introduces new traceevents in order to output continuous error messages. Current SCSI printk messages in upstream kernel can be divided by and mixed with other messages. Even if each error message has its device id, sometimes we can easily be lost in mixed logs because the message's device id is separated from it's body. To avoid it, I'd like to use traceevents to store error messages into the ftrace or perf buuffer, because traceevents are atomically commited to the buffer. In this patch set, all printk messages are removed based on a local discussion with Hannes, but I think printk messages should be kept because all users don't enable traceevents and rsyslog can store as files. However, if printk of logging branch is kept, the messages are duplicate and it can induce stack overflow by using local buffer(*1). (*1) https://lkml.org/lkml/2014/5/20/742 So, my suggestion is follows: 1) printk Keeps current implemntation of upstream kernel. The messages are divided and can be mixed, but all users can check the error messages without any settings. 2) traceevents To get the complete messages, we can use ftrace or perf (or something on them). Users can always understand correct messages, but they need to set up the tracers. This patch set is based on Hannes' logging branch: http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging [1/10] ~ [6/10]: just cleanup for logging branch [7/10] ~ [10/10]: introduce new traceevents Any comments are welcome! Thanks, Yoshihiro YUNOMAE --- Yoshihiro YUNOMAE (10): scsi/constants: Cleanup printk message in __scsi_print_sense() scsi/constants: Cleanup printk message in scsi_decode_sense_extras() scsi/constants: Cleanup printk message in __scsi_print_command() scsi/constants: Cleanup printk message in scsi_dump_sense_buffer() scsi/trace: Use macros for getting driver byte, host byte, msg byte, and status byte scsi/sd: Delete extra scsi_show_extd_sense() in sd_print_sense_hdr() scsi/trace: Use scsi_show_result trace point instead of printk scsi/trace: Use scsi_print_sense trace point instead of printk scsi/trace: Add additional sense code and additional sense code qualifier to scsi_print_sense trace point scsi/trace: Use scsi_print_command trace point instead of printk drivers/scsi/Makefile |2 drivers/scsi/constants.c| 1543 --- drivers/scsi/scsi_trace.c | 1484 + drivers/scsi/sd.c |2 include/scsi/scsi.h |8 include/scsi/scsi_dbg.h |2 include/scsi/scsi_eh.h |7 include/trace/events/scsi.h | 145 8 files changed, 1633 insertions(+), 1560 deletions(-) delete mode 100644 drivers/scsi/constants.c -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH -logging 00/10] scsi/constants: Output continuous error messages on trace
Hi All, This patch set introduces new traceevents in order to output continuous error messages. Current SCSI printk messages in upstream kernel can be divided by and mixed with other messages. Even if each error message has its device id, sometimes we can easily be lost in mixed logs because the message's device id is separated from it's body. To avoid it, I'd like to use traceevents to store error messages into the ftrace or perf buuffer, because traceevents are atomically commited to the buffer. In this patch set, all printk messages are removed based on a local discussion with Hannes, but I think printk messages should be kept because all users don't enable traceevents and rsyslog can store as files. However, if printk of logging branch is kept, the messages are duplicate and it can induce stack overflow by using local buffer(*1). (*1) https://lkml.org/lkml/2014/5/20/742 So, my suggestion is follows: 1) printk Keeps current implemntation of upstream kernel. The messages are divided and can be mixed, but all users can check the error messages without any settings. 2) traceevents To get the complete messages, we can use ftrace or perf (or something on them). Users can always understand correct messages, but they need to set up the tracers. This patch set is based on Hannes' logging branch: http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging [1/10] ~ [6/10]: just cleanup for logging branch [7/10] ~ [10/10]: introduce new traceevents Any comments are welcome! Thanks, Yoshihiro YUNOMAE --- Yoshihiro YUNOMAE (10): scsi/constants: Cleanup printk message in __scsi_print_sense() scsi/constants: Cleanup printk message in scsi_decode_sense_extras() scsi/constants: Cleanup printk message in __scsi_print_command() scsi/constants: Cleanup printk message in scsi_dump_sense_buffer() scsi/trace: Use macros for getting driver byte, host byte, msg byte, and status byte scsi/sd: Delete extra scsi_show_extd_sense() in sd_print_sense_hdr() scsi/trace: Use scsi_show_result trace point instead of printk scsi/trace: Use scsi_print_sense trace point instead of printk scsi/trace: Add additional sense code and additional sense code qualifier to scsi_print_sense trace point scsi/trace: Use scsi_print_command trace point instead of printk drivers/scsi/Makefile |2 drivers/scsi/constants.c| 1543 --- drivers/scsi/scsi_trace.c | 1484 + drivers/scsi/sd.c |2 include/scsi/scsi.h |8 include/scsi/scsi_dbg.h |2 include/scsi/scsi_eh.h |7 include/trace/events/scsi.h | 145 8 files changed, 1633 insertions(+), 1560 deletions(-) delete mode 100644 drivers/scsi/constants.c -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 06/10] scsi/sd: Delete extra scsi_show_extd_sense() in sd_print_sense_hdr()
sd_print_sense_hdr() calls scsi_show_extd_sense(), but scsi_print_sense_hdr() also calls scsi_show_extd_sense(). We can get same result, so we delete it. Note: Calling scsi_show_extd_sense() is introduced in fdd8b297. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/sd.c |2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 8d7204a..22dd214 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3286,8 +3286,6 @@ static void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) { scsi_print_sense_hdr(sdkp-device, sdkp-disk-disk_name, sshdr); - scsi_show_extd_sense(sdkp-device, sdkp-disk-disk_name, -sshdr-asc, sshdr-ascq); } static void sd_print_result(struct scsi_disk *sdkp, int result) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 07/10] scsi/trace: Use scsi_show_result trace point instead of printk
Current SCSI trace has hostbyte table and driverbyte table, so we don't need to have the same table in scsi/constants.c. - Result examples Before (printk) sd 2:0:0:0: [sda] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE After (ftrace) scsi_show_result: host_no=2 channel=0 id=0 lun=0 [sda] result=(driver=DRIVER_SENSE host=DID_OK) Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c| 52 --- drivers/scsi/scsi_trace.c | 16 + include/trace/events/scsi.h | 38 +++ 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 6fad6b4..f7b7f32 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1488,55 +1488,3 @@ void scsi_print_sense(struct scsi_cmnd *cmd) SCSI_SENSE_BUFFERSIZE); } EXPORT_SYMBOL(scsi_print_sense); - -#ifdef CONFIG_SCSI_CONSTANTS - -static const char * const hostbyte_table[]={ -DID_OK, DID_NO_CONNECT, DID_BUS_BUSY, DID_TIME_OUT, DID_BAD_TARGET, -DID_ABORT, DID_PARITY, DID_ERROR, DID_RESET, DID_BAD_INTR, -DID_PASSTHROUGH, DID_SOFT_ERROR, DID_IMM_RETRY, DID_REQUEUE, -DID_TRANSPORT_DISRUPTED, DID_TRANSPORT_FAILFAST, DID_TARGET_FAILURE, -DID_NEXUS_FAILURE }; -#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table) - -static const char * const driverbyte_table[]={ -DRIVER_OK, DRIVER_BUSY, DRIVER_SOFT, DRIVER_MEDIA, DRIVER_ERROR, -DRIVER_INVALID, DRIVER_TIMEOUT, DRIVER_HARD, DRIVER_SENSE}; -#define NUM_DRIVERBYTE_STRS ARRAY_SIZE(driverbyte_table) - -void scsi_show_result(struct scsi_device *sdev, const char *name, int result) -{ - int hb = host_byte(result); - int db = driver_byte(result); - const char *hb_string; - const char *db_string; - - hb_string = (hb NUM_HOSTBYTE_STRS) ? hostbyte_table[hb] : invalid; - db_string = (db NUM_DRIVERBYTE_STRS) ? - driverbyte_table[db] : invalid; - - - sdev_printk(KERN_INFO, sdev, - [%s] Result: hostbyte=%s driverbyte=%s\n, - name, hb_string, db_string); -} - -#else - -void scsi_show_result(struct scsi_device *sdev, const char *name, int result) -{ - sdev_printk(KERN_INFO, sdev, - [%s] Result: hostbyte=0x%02x driverbyte=0x%02x\n, - name, host_byte(result), driver_byte(result)); -} - -#endif -EXPORT_SYMBOL(scsi_show_result); - -void scsi_print_result(struct scsi_cmnd *cmd) -{ - const char *devname = cmd-request-rq_disk ? - cmd-request-rq_disk-disk_name : scsi; - scsi_show_result(cmd-device, devname, cmd-result); -} -EXPORT_SYMBOL(scsi_print_result); diff --git a/drivers/scsi/scsi_trace.c b/drivers/scsi/scsi_trace.c index 2bea4f0..6ffbc40 100644 --- a/drivers/scsi/scsi_trace.c +++ b/drivers/scsi/scsi_trace.c @@ -19,6 +19,8 @@ #include linux/trace_seq.h #include trace/events/scsi.h +#include scsi/scsi_dbg.h + #define SERVICE_ACTION16(cdb) (cdb[1] 0x1f) #define SERVICE_ACTION32(cdb) ((cdb[8] 8) | cdb[9]) @@ -286,3 +288,17 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len) return scsi_trace_misc(p, cdb, len); } } + +void scsi_show_result(struct scsi_device *sdev, const char *name, int result) +{ + trace_scsi_show_result(sdev, name, result); +} +EXPORT_SYMBOL(scsi_show_result); + +void scsi_print_result(struct scsi_cmnd *cmd) +{ + const char *devname = cmd-request-rq_disk ? + cmd-request-rq_disk-disk_name : scsi; + scsi_show_result(cmd-device, devname, cmd-result); +} +EXPORT_SYMBOL(scsi_print_result); diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index 8aecdc2..0675195 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -123,7 +123,11 @@ scsi_hostbyte_name(DID_IMM_RETRY), \ scsi_hostbyte_name(DID_REQUEUE),\ scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED),\ - scsi_hostbyte_name(DID_TRANSPORT_FAILFAST)) + scsi_hostbyte_name(DID_TRANSPORT_FAILFAST), \ + scsi_hostbyte_name(DID_TARGET_FAILURE), \ + scsi_hostbyte_name(DID_NEXUS_FAILURE), \ + scsi_hostbyte_name(DID_ALLOC_FAILURE), \ + scsi_hostbyte_name(DID_MEDIUM_ERROR)) #define scsi_driverbyte_name(result) { result, #result } #define show_driverbyte_name(val) \ @@ -359,6 +363,38 @@ TRACE_EVENT(scsi_eh_wakeup, TP_printk(host_no=%u, __entry-host_no
[RFC PATCH 08/10] scsi/trace: Use scsi_print_sense trace point instead of printk
Previous sense messages can be mixed into other sense messages, because continuous printk (KERN_CONT) was used. To avoid the problem, patch d87f3a6f51 introduced a local buffer in Hannes's baranch (*1). But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples Before (printk) sd 2:0:0:0: [sda] Sense Key : Medium Error [current] After (ftrace) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c| 145 ++- drivers/scsi/scsi_trace.c | 140 -- include/scsi/scsi_eh.h |7 ++ include/trace/events/scsi.h | 48 ++ 4 files changed, 195 insertions(+), 145 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index f7b7f32..85b75c8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -19,7 +19,7 @@ #include scsi/scsi_eh.h #include scsi/scsi_dbg.h - +#include trace/events/scsi.h /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -1267,58 +1267,8 @@ static const struct error_info2 additional2[] = {0x70, 0x00, 0xff, Decompression exception short algorithm id of %x}, {0, 0, 0, NULL} }; - -/* description of the sense key values */ -static const char * const snstext[] = { - No Sense, /* 0: There is no sense information */ - Recovered Error, /* 1: The last command completed successfully - but used error correction */ - Not Ready,/* 2: The addressed target is not ready */ - Medium Error, /* 3: Data error detected on the medium */ - Hardware Error, /* 4: Controller or device failure */ - Illegal Request, /* 5: Error in request */ - Unit Attention, /* 6: Removable medium was changed, or - the target has been reset, or ... */ - Data Protect, /* 7: Access to the data is blocked */ - Blank Check, /* 8: Reached unexpected written or unwritten - region of the medium */ - Vendor Specific(9), - Copy Aborted, /* A: COPY or COMPARE was aborted */ - Aborted Command, /* B: The target aborted the command */ - Equal,/* C: A SEARCH DATA command found data equal, - reserved in SPC-4 rev 36 */ - Volume Overflow, /* D: Medium full with still data to be written */ - Miscompare, /* E: Source data and data on the medium - do not agree */ - Completed,/* F: command completed sense data reported, - may occur for successful command */ -}; -#else -static const char * const snstext[] = { - 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, - 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, -}; #endif -/* Get sense key string or NULL if not available */ -const char * -scsi_sense_key_string(unsigned char key) { - return snstext[key 0xf]; -} -EXPORT_SYMBOL(scsi_sense_key_string); - -const char * -scsi_sense_type_string(struct scsi_sense_hdr *sshdr) -{ - return scsi_sense_is_deferred(sshdr) ? [deferred] : [current]; -} - -const char * -scsi_sense_format_string(struct scsi_sense_hdr *sshdr) -{ - return sshdr-response_code = 0x72 ? [descriptor] : ; -} - /* * Get additional sense code string or NULL if not available. * This string may contain a %x and should be printed with ascq as arg. @@ -1375,105 +1325,22 @@ void scsi_print_sense_hdr(struct scsi_device *sdev, const char *name, struct scsi_sense_hdr *sshdr) { - sdev_printk(KERN_INFO, sdev, [%s] Sense Key : %s %s%s\n, name, - scsi_sense_key_string(sshdr-sense_key), - scsi_sense_type_string(sshdr), - scsi_sense_format_string(sshdr)); + trace_scsi_print_sense(sdev, name, sshdr, NULL, 0, 0); scsi_show_extd_sense(sdev, name, sshdr-asc, sshdr-ascq); } EXPORT_SYMBOL(scsi_print_sense_hdr); -static void -scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, - const unsigned char *sense_buffer, int sense_len) -{ - char linebuf[128]; - int i, linelen, remaining; - - if (sense_len 32
[RFC PATCH 01/10] scsi/constants: Cleanup printk message in __scsi_print_sense()
A device name is output like sda: Sense Key : Medium Error [current] in __scsi_print_sense(), but it should be [sda] Sense Key : Medium Error [current] because other printk messages output a device name like [sda] foo. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index c6a7a4a..a0e8159 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1470,7 +1470,7 @@ void __scsi_print_sense(struct scsi_device *sdev, const char *name, return; } - sdev_printk(KERN_INFO, sdev, %s: Sense Key : %s %s%s\n, name, + sdev_printk(KERN_INFO, sdev, [%s] Sense Key : %s %s%s\n, name, scsi_sense_key_string(sshdr.sense_key), scsi_sense_type_string(sshdr), scsi_sense_format_string(sshdr)); -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 05/10] scsi/trace: Use macros for getting driver byte, host byte, msg byte, and status byte
For getting driver byte, host byte, msg byte, and status byte, macros are implemented in scsi/scsi.h, so we use it. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- include/trace/events/scsi.h |8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index db6c935..8aecdc2 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -328,10 +328,10 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template, show_opcode_name(__entry-opcode), __parse_cdb(__get_dynamic_array(cmnd), __entry-cmd_len), __print_hex(__get_dynamic_array(cmnd), __entry-cmd_len), - show_driverbyte_name(((__entry-result) 24) 0xff), - show_hostbyte_name(((__entry-result) 16) 0xff), - show_msgbyte_name(((__entry-result) 8) 0xff), - show_statusbyte_name(__entry-result 0xff)) + show_driverbyte_name(driver_byte(__entry-result)), + show_hostbyte_name(host_byte(__entry-result)), + show_msgbyte_name(msg_byte(__entry-result)), + show_statusbyte_name(status_byte(__entry-result))) ); DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_done, -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 02/10] scsi/constants: Cleanup printk message in scsi_decode_sense_extras()
If sense_flags and fixed_valid are zero, the kernel does not need to output a printk message. So, if those conditions are met, it just returns. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index a0e8159..9c38b8d 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1438,6 +1438,9 @@ scsi_decode_sense_extras(struct scsi_device *sdev, const char *name, sense_flags |= ucp[3] 0xe0; } + if (!sense_flags !fixed_valid) + return; + res = 0; memset(buff, 0, sizeof(buff)); blen = sizeof(buff) - 1; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 10/10] scsi/trace: Use scsi_print_command trace point instead of printk
Previous printk messages of SCSI command can be mixed into other printk messages because multiple printk messages are output for it. To avoid the problem, patch 4e64bb8d6 in Hannes' branch(*1) introduced a local buffer. But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. Note: We don't need constans.c any more. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples Before (printk) sd 2:0:0:0: [sda] CDB: Read(10) After scsi_print_command: host_no=2 channel=0 id=0 lun=0 [sda] CDB (Read(10)) Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/Makefile |2 drivers/scsi/constants.c| 425 --- drivers/scsi/scsi_trace.c | 408 + include/scsi/scsi.h |8 + include/trace/events/scsi.h | 45 + 5 files changed, 461 insertions(+), 427 deletions(-) delete mode 100644 drivers/scsi/constants.c diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 5f0d299..c56f692 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -158,7 +158,7 @@ obj-$(CONFIG_SCSI_OSD_INITIATOR) += osd/ # This goes last, so that real scsi devices probe earlier obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o -scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ +scsi_mod-y += scsi.o hosts.o scsi_ioctl.o \ scsicam.o scsi_error.o scsi_lib.o scsi_mod-$(CONFIG_SCSI_DMA)+= scsi_lib_dma.o scsi_mod-y += scsi_scan.o scsi_sysfs.o scsi_devinfo.o diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c deleted file mode 100644 index ce9ceb8..000 --- a/drivers/scsi/constants.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - * ASCII values for a number of symbolic constants, printing functions, - * etc. - * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422) - * Additions for SCSI 3+ (SPC-3 T10/1416-D Rev 07 3 May 2002) - * by D. Gilbert and aeb (20020609) - * Updated to SPC-4 T10/1713-D Rev 36g, D. Gilbert 20130701 - */ - -#include linux/blkdev.h -#include linux/module.h -#include linux/kernel.h -#include asm/unaligned.h - -#include scsi/scsi.h -#include scsi/scsi_cmnd.h - -/* Commands with service actions that change the command name */ -#define SERVICE_ACTION_IN_12 0xab -#define SERVICE_ACTION_OUT_12 0xa9 -#define SERVICE_ACTION_BIDIRECTIONAL 0x9d -#define SERVICE_ACTION_IN_16 0x9e -#define SERVICE_ACTION_OUT_16 0x9f -#define THIRD_PARTY_COPY_OUT 0x83 -#define THIRD_PARTY_COPY_IN 0x84 - - - -#ifdef CONFIG_SCSI_CONSTANTS -static const char * cdb_byte0_names[] = { -/* 00-03 */ Test Unit Ready, Rezero Unit/Rewind, NULL, Request Sense, -/* 04-07 */ Format Unit/Medium, Read Block Limits, NULL, - Reassign Blocks, -/* 08-0d */ Read(6), NULL, Write(6), Seek(6), NULL, NULL, -/* 0e-12 */ NULL, Read Reverse, Write Filemarks, Space, Inquiry, -/* 13-16 */ Verify(6), Recover Buffered Data, Mode Select(6), - Reserve(6), -/* 17-1a */ Release(6), Copy, Erase, Mode Sense(6), -/* 1b-1d */ Start/Stop Unit, Receive Diagnostic, Send Diagnostic, -/* 1e-1f */ Prevent/Allow Medium Removal, NULL, -/* 20-22 */ NULL, NULL, NULL, -/* 23-28 */ Read Format Capacities, Set Window, - Read Capacity(10), NULL, NULL, Read(10), -/* 29-2d */ Read Generation, Write(10), Seek(10), Erase(10), -Read updated block, -/* 2e-31 */ Write Verify(10), Verify(10), Search High, Search Equal, -/* 32-34 */ Search Low, Set Limits, Prefetch/Read Position, -/* 35-37 */ Synchronize Cache(10), Lock/Unlock Cache(10), - Read Defect Data(10), -/* 38-3c */ Medium Scan, Compare, Copy Verify, Write Buffer, - Read Buffer, -/* 3d-3f */ Update Block, Read Long(10), Write Long(10), -/* 40-41 */ Change Definition, Write Same(10), -/* 42-48 */ Unmap/Read sub-channel, Read TOC/PMA/ATIP, - Read density support, Play audio(10), Get configuration, - Play audio msf, Sanitize/Play audio track/index, -/* 49-4f */ Play track relative(10), Get event status notification, -Pause/resume, Log Select, Log Sense, Stop play/scan, -NULL, -/* 50-55 */ Xdwrite, Xpwrite, Read disk info, Xdread, Read track info, -Reserve track, Send OPC info, Mode Select(10), -/* 56-5b */ Reserve(10), Release(10), Repair track, Read master cue, -Mode Sense(10), Close track/session, -/* 5c-5f */ Read buffer capacity, Send cue sheet, Persistent reserve
[RFC PATCH 03/10] scsi/constants: Cleanup printk message in __scsi_print_command()
All bytes in CDB should be output after linebuf is filled because [%s] CDB: %s\n message is output many times in loop. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 9c38b8d..5956d4d 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -413,9 +413,8 @@ void __scsi_print_command(struct scsi_device *sdev, const char *prefix, hex_dump_to_buffer(cdb + i, linelen, 16, 1, linebuf, sizeof(linebuf), false); - sdev_printk(KERN_INFO, sdev, [%s] CDB: %s\n, - prefix, linebuf); } + sdev_printk(KERN_INFO, sdev, [%s] CDB: %s\n, prefix, linebuf); } EXPORT_SYMBOL(__scsi_print_command); -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 04/10] scsi/constants: Cleanup printk message in scsi_dump_sense_buffer()
Unrecognized sense data should be output after linebuf is filled because [%s] Unrecognized sense data (in hex): %s message is output many times in loop. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 5956d4d..6fad6b4 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1385,16 +1385,13 @@ EXPORT_SYMBOL(scsi_print_sense_hdr); static void scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, - const unsigned char *sense_buffer, int sense_len, - struct scsi_sense_hdr *sshdr) + const unsigned char *sense_buffer, int sense_len) { char linebuf[128]; int i, linelen, remaining; if (sense_len 32) sense_len = 32; - sdev_printk(KERN_INFO, sdev, - [%s] Unrecognized sense data (in hex):, prefix); remaining = sense_len; for (i = 0; i sense_len; i += 16) { @@ -1403,9 +1400,10 @@ scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, hex_dump_to_buffer(sense_buffer + i, linelen, 16, 1, linebuf, sizeof(linebuf), false); - sdev_printk(KERN_INFO, sdev, [%s] Sense: %s\n, - prefix, linebuf); } + sdev_printk(KERN_INFO, sdev, + [%s] Unrecognized sense data (in hex): %s, + prefix, linebuf); } static void @@ -1467,8 +1465,7 @@ void __scsi_print_sense(struct scsi_device *sdev, const char *name, if (!scsi_normalize_sense(sense_buffer, sense_len, sshdr)) { /* this may be SCSI-1 sense data */ - scsi_dump_sense_buffer(sdev, name, sense_buffer, - sense_len, sshdr); + scsi_dump_sense_buffer(sdev, name, sense_buffer, sense_len); return; } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 09/10] scsi/trace: Add additional sense code and additional sense code qualifier to scsi_print_sense trace point
There are no mean that additional sense code and additional sense code qualifier are output as different messages of sense key, so those information are added. Note: scsi_show_extd_sense() is changed from export symbol to non-export symbol. - Result examples Before (printk) sd 2:0:0:0: [sda] Add. Sense: Unrecovered read error After (ftrace, merged into scsi_print_sense traceevent) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Add. Sense (Unrecovered read error) Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c| 932 --- drivers/scsi/scsi_trace.c | 920 ++ include/scsi/scsi_dbg.h |2 include/trace/events/scsi.h | 10 4 files changed, 928 insertions(+), 936 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 85b75c8..ce9ceb8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -14,12 +14,6 @@ #include scsi/scsi.h #include scsi/scsi_cmnd.h -#include scsi/scsi_device.h -#include scsi/scsi_host.h -#include scsi/scsi_eh.h -#include scsi/scsi_dbg.h - -#include trace/events/scsi.h /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -429,929 +423,3 @@ void scsi_print_command(struct scsi_cmnd *cmd) print_opcode_name(cmd-device, devname, cmd-cmnd, cmd-cmd_len); } EXPORT_SYMBOL(scsi_print_command); - -#ifdef CONFIG_SCSI_CONSTANTS - -struct error_info { - unsigned short code12; /* 0x0302 looks better than 0x03,0x02 */ - const char * text; -}; - -/* - * The canonical list of T10 Additional Sense Codes is available at: - * http://www.t10.org/lists/asc-num.txt [most recent: 20130605] - */ - -static const struct error_info additional[] = -{ - {0x, No additional sense information}, - {0x0001, Filemark detected}, - {0x0002, End-of-partition/medium detected}, - {0x0003, Setmark detected}, - {0x0004, Beginning-of-partition/medium detected}, - {0x0005, End-of-data detected}, - {0x0006, I/O process terminated}, - {0x0007, Programmable early warning detected}, - {0x0011, Audio play operation in progress}, - {0x0012, Audio play operation paused}, - {0x0013, Audio play operation successfully completed}, - {0x0014, Audio play operation stopped due to error}, - {0x0015, No current audio status to return}, - {0x0016, Operation in progress}, - {0x0017, Cleaning requested}, - {0x0018, Erase operation in progress}, - {0x0019, Locate operation in progress}, - {0x001A, Rewind operation in progress}, - {0x001B, Set capacity operation in progress}, - {0x001C, Verify operation in progress}, - {0x001D, ATA pass through information available}, - {0x001E, Conflicting SA creation request}, - {0x001F, Logical unit transitioning to another power condition}, - {0x0020, Extended copy information available}, - - {0x0100, No index/sector signal}, - - {0x0200, No seek complete}, - - {0x0300, Peripheral device write fault}, - {0x0301, No write current}, - {0x0302, Excessive write errors}, - - {0x0400, Logical unit not ready, cause not reportable}, - {0x0401, Logical unit is in process of becoming ready}, - {0x0402, Logical unit not ready, initializing command required}, - {0x0403, Logical unit not ready, manual intervention required}, - {0x0404, Logical unit not ready, format in progress}, - {0x0405, Logical unit not ready, rebuild in progress}, - {0x0406, Logical unit not ready, recalculation in progress}, - {0x0407, Logical unit not ready, operation in progress}, - {0x0408, Logical unit not ready, long write in progress}, - {0x0409, Logical unit not ready, self-test in progress}, - {0x040A, Logical unit not accessible, asymmetric access state -transition}, - {0x040B, Logical unit not accessible, target port in standby state}, - {0x040C, Logical unit not accessible, target port in unavailable -state}, - {0x040D, Logical unit not ready, structure check required}, - {0x0410, Logical unit not ready, auxiliary memory not accessible}, - {0x0411, Logical unit not ready, notify (enable spinup) required}, - {0x0412, Logical unit not ready, offline}, - {0x0413, Logical unit not ready, SA creation in progress}, - {0x0414, Logical unit not ready, space allocation in progress}, - {0x0415, Logical unit not ready, robotics
Re: Re: [PATCH V4 1/5] trace-cmd/listen: Apply the trace-msg protocol for communication between a server and clients
Hi Steven, Thank you for your review. (2014/07/23 0:04), Steven Rostedt wrote: Sorry for taking so long to reply, I've been hacking on the kernel a bit and that takes precedence over user tools :-/ On Fri, 11 Jul 2014 00:58:26 + Yoshihiro YUNOMAE wrote: Apply trace-msg protocol for communication between a server and clients. Currently, trace-listen(server) and trace-record -N(client) operate as follows: listen to socket fd connect to socket fd accept the client send "tracecmd" +> receive "tracecmd" check "tracecmd" send cpus receive cpus <+ print "cpus=XXX" send pagesize | receive pagesize <+ print "pagesize=XXX" send option | receive option <--+ understand option send port_array +> receive port_array understand port_array send meta data receive meta data <---+ record meta data (snip) read block --- start sending trace data on child processes --- --- When client finishes sending trace data --- close(socket fd) read size = 0 close(socket fd) All messages are unstructured character strings, so server(client) using the protocol must parse the unstructured messages. Since it is hard to add complex contents in the protocol, structured binary message trace-msg is introduced as the communication protocol. By applying this patch, server and client operate as follows: listen to socket fd connect to socket fd accept the client send "tracecmd" +> receive "tracecmd" check "tracecmd" send "V2\0\00" as the v2 protocol Lets change this to "-1V2\0\00" The -1 will cause an old server to exit as it will not accept a -1 for CPU count. Then you can check if the return of the next read is -1, as the client would have disconnected. Sure. The reason I ask this, is because once you send a valid CPU count (and unfortunately, 0 happens to be valid :-p, the server side creates a file. When you close it, that file stays around as zero length. By sending -1, the old server will error out and never create a file. Yes, I also thought this should be fixed. I'll submit fixed patch. Thank you, Yoshihiro YUNOMAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] serial/core: Fix too big allocation for attribute member
Current code allocates too much data for tty_groups member of uart_port struct, so fix it. Signed-off-by: Yoshihiro YUNOMAE CC: Greg Kroah-Hartman CC: Dan Carpenter --- drivers/tty/serial/serial_core.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 4af764c..8ded213 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2617,7 +2617,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport) if (uport->attr_group) num_groups++; - uport->tty_groups = kcalloc(num_groups, sizeof(**uport->tty_groups), + uport->tty_groups = kcalloc(num_groups, sizeof(*uport->tty_groups), GFP_KERNEL); if (!uport->tty_groups) { ret = -ENOMEM; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] serial/core: Fix too big allocation for attribute member
Current code allocates too much data for tty_groups member of uart_port struct, so fix it. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com CC: Greg Kroah-Hartman gre...@linuxfoundation.org CC: Dan Carpenter dan.carpen...@oracle.com --- drivers/tty/serial/serial_core.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 4af764c..8ded213 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2617,7 +2617,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport) if (uport-attr_group) num_groups++; - uport-tty_groups = kcalloc(num_groups, sizeof(**uport-tty_groups), + uport-tty_groups = kcalloc(num_groups, sizeof(*uport-tty_groups), GFP_KERNEL); if (!uport-tty_groups) { ret = -ENOMEM; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Re: [PATCH V4 1/5] trace-cmd/listen: Apply the trace-msg protocol for communication between a server and clients
Hi Steven, Thank you for your review. (2014/07/23 0:04), Steven Rostedt wrote: Sorry for taking so long to reply, I've been hacking on the kernel a bit and that takes precedence over user tools :-/ On Fri, 11 Jul 2014 00:58:26 + Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com wrote: Apply trace-msg protocol for communication between a server and clients. Currently, trace-listen(server) and trace-record -N(client) operate as follows: server client listen to socket fd connect to socket fd accept the client send tracecmd + receive tracecmd check tracecmd send cpus receive cpus + print cpus=XXX send pagesize | receive pagesize + print pagesize=XXX send option | receive option --+ understand option send port_array + receive port_array understand port_array send meta data receive meta data ---+ record meta data (snip) read block --- start sending trace data on child processes --- --- When client finishes sending trace data --- close(socket fd) read size = 0 close(socket fd) All messages are unstructured character strings, so server(client) using the protocol must parse the unstructured messages. Since it is hard to add complex contents in the protocol, structured binary message trace-msg is introduced as the communication protocol. By applying this patch, server and client operate as follows: server client listen to socket fd connect to socket fd accept the client send tracecmd + receive tracecmd check tracecmd send V2\0MAGIC_NUMBER\00 as the v2 protocol Lets change this to -1V2\0MAGIC_NUMBER\00 The -1 will cause an old server to exit as it will not accept a -1 for CPU count. Then you can check if the return of the next read is -1, as the client would have disconnected. Sure. The reason I ask this, is because once you send a valid CPU count (and unfortunately, 0 happens to be valid :-p, the server side creates a file. When you close it, that file stays around as zero length. By sending -1, the old server will error out and never create a file. Yes, I also thought this should be fixed. I'll submit fixed patch. Thank you, Yoshihiro YUNOMAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V9 1/2] Serial: allow port drivers to have a default attribute group
From: Greg Kroah-Hartman Some serial drivers (like 8250), want to add sysfs files. We need to do so in a race-free way, so allow any port to be able to specify an attribute group that should be added at device creation time. Signed-off-by: Greg Kroah-Hartman Signed-off-by: Yoshihiro YUNOMAE --- drivers/tty/serial/serial_core.c | 24 +--- include/linux/serial_core.h |2 ++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index fbf6c5a..4af764c 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2563,12 +2563,6 @@ static const struct attribute_group tty_dev_attr_group = { .attrs = tty_dev_attrs, }; -static const struct attribute_group *tty_dev_attr_groups[] = { - _dev_attr_group, - NULL - }; - - /** * uart_add_one_port - attach a driver-defined port structure * @drv: pointer to the uart low level driver structure for this port @@ -2585,6 +2579,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport) struct tty_port *port; int ret = 0; struct device *tty_dev; + int num_groups; BUG_ON(in_interrupt()); @@ -2618,12 +2613,26 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport) uart_configure_port(drv, state, uport); + num_groups = 2; + if (uport->attr_group) + num_groups++; + + uport->tty_groups = kcalloc(num_groups, sizeof(**uport->tty_groups), + GFP_KERNEL); + if (!uport->tty_groups) { + ret = -ENOMEM; + goto out; + } + uport->tty_groups[0] = _dev_attr_group; + if (uport->attr_group) + uport->tty_groups[1] = uport->attr_group; + /* * Register the port whether it's detected or not. This allows * setserial to be used to alter this port's parameters. */ tty_dev = tty_port_register_device_attr(port, drv->tty_driver, - uport->line, uport->dev, port, tty_dev_attr_groups); + uport->line, uport->dev, port, uport->tty_groups); if (likely(!IS_ERR(tty_dev))) { device_set_wakeup_capable(tty_dev, 1); } else { @@ -2702,6 +2711,7 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *uport) */ if (uport->type != PORT_UNKNOWN) uport->ops->release_port(uport); + kfree(uport->tty_groups); /* * Indicate that there isn't a port here anymore. diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 5bbb809..cf3a1e7 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -199,6 +199,8 @@ struct uart_port { unsigned char suspended; unsigned char irq_wake; unsigned char unused[2]; + struct attribute_group *attr_group;/* port specific attributes */ + const struct attribute_group **tty_groups; /* all attributes (serial core use only) */ void*private_data; /* generic platform data pointer */ }; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V9 2/2] serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers
Add tunable RX interrupt trigger I/F of FIFO buffers. Serial devices are used as not only message communication devices but control or sending communication devices. For the latter uses, normally small data will be exchanged, so user applications want to receive data unit as soon as possible for real-time tendency. If we have a sensor which sends a 1 byte data each time and must control a device based on the sensor feedback, the RX interrupt should be triggered for each data. According to HW specification of serial UART devices, RX interrupt trigger can be changed, but the trigger is hard-coded. For example, RX interrupt trigger in 16550A can be set to 1, 4, 8, or 14 bytes for HW, but current driver sets the trigger to only 8bytes. This patch makes some devices change RX interrupt trigger from userland. - Read current setting # cat /sys/class/tty/ttyS0/rx_trig_bytes 8 - Write user setting # echo 1 > /sys/class/tty/ttyS0/rx_trig_bytes # cat /sys/class/tty/ttyS0/rx_trig_bytes 1 - 16550A and Tegra (1, 4, 8, or 14 bytes) - 16650V2 (8, 16, 24, or 28 bytes) - 16654 (8, 16, 56, or 60 bytes) - 16750 (1, 16, 32, or 56 bytes) Changes in V9: - Use attr_group instead of dev_spec_attr_group of uart_port structure Changes in V8: - Divide this patch from V7's patch based on Greg's comment Changes in V7: - Add Documentation - Change I/F name from rx_int_trig to rx_trig_bytes because the name rx_int_trig is hard to understand how users specify the value Changes in V6: - Move FCR_RX_TRIG_* definition in 8250.h to include/uapi/linux/serial_reg.h, rename those to UART_FCR_R_TRIG_*, and use UART_FCR_TRIGGER_MASK to UART_FCR_R_TRIG_BITS() - Change following function names: convert_fcr2val() => fcr_get_rxtrig_bytes() convert_val2rxtrig() => bytes_to_fcr_rxtrig() - Fix typo in serial8250_do_set_termios() - Delete the verbose error message pr_info() in bytes_to_fcr_rxtrig() - Rename *rx_int_trig/rx_trig* to *rxtrig* for several functions or variables (but UI remains rx_int_trig) - Change the meaningless variable name 'val' to 'bytes' following functions: fcr_get_rxtrig_bytes(), bytes_to_fcr_rxtrig(), do_set_rxtrig(), do_serial8250_set_rxtrig(), and serial8250_set_attr_rxtrig() - Use up->fcr in order to get rxtrig_bytes instead of rx_trig_raw in fcr_get_rxtrig_bytes() - Use conf_type->rxtrig_bytes[0] instead of switch statement for support check in register_dev_spec_attr_grp() - Delete the checking whether a user changed FCR or not when minimum buffer is needed in serial8250_do_set_termios() Changes in V5.1: - Fix FCR_RX_TRIG_MAX_STATE definition Changes in V5: - Support Tegra, 16650V2, 16654, and 16750 - Store default FCR value to up->fcr when the port is first created - Add rx_trig_byte[] in uart_config[] for each device and use rx_trig_byte[] in convert_fcr2val() and convert_val2rxtrig() Changes in V4: - Introduce fifo_bug flag in uart_8250_port structure This is enabled only when parity is enabled and UART_BUG_PARITY is enabled for up->bugs. If this flag is enabled, user cannot set RX trigger. - Return -EOPNOTSUPP when it does not support device at convert_fcr2val() and at convert_val2rxtrig() - Set the nearest lower RX trigger when users input a meaningless value at convert_val2rxtrig() - Check whether p->fcr is existing at serial8250_clear_and_reinit_fifos() - Set fcr = up->fcr in the begging of serial8250_do_set_termios() Changes in V3: - Change I/F from ioctl(2) to sysfs(rx_int_trig) Changed in V2: - Use _IOW for TIOCSFIFORTRIG definition - Pass the interrupt trigger value itself Signed-off-by: Yoshihiro YUNOMAE --- Documentation/ABI/testing/sysfs-tty | 16 +++ drivers/tty/serial/8250/8250.h |2 drivers/tty/serial/8250/8250_core.c | 173 --- include/linux/serial_8250.h |2 include/uapi/linux/serial_reg.h |5 + 5 files changed, 183 insertions(+), 15 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-tty b/Documentation/ABI/testing/sysfs-tty index ad22fb0..9eb3c2b 100644 --- a/Documentation/ABI/testing/sysfs-tty +++ b/Documentation/ABI/testing/sysfs-tty @@ -138,3 +138,19 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. + +What: /sys/class/tty/ttyS0/rx_trig_bytes +Date: May 2014 +Contact: Yoshihiro YUNOMAE +Description: +Shows current RX interrupt trigger bytes or sets the +user specified value to change it for the FIFO buffer. +Users can show or set this value regardless of opening the +serial device file or not. + +The RX trigger can be set one of four kinds of values for UART +serials. When users input a meaning less value to this I/F, +the RX trigger is changed to the nearest lower value for
[ PATCH V9 0/2] serial/uart/8250: Introduce tunable RX trigger I/F
Hi Greg, This patch set introduces tunable RX interrupt trigger I/F for 8250 serials. I used Greg's patch(*1) as 1st patch in this version, and applied 2nd patch of previous version. Would you review this patch set? Thanks! Note: I cleaned up Greg's patch as follows: - Delete extra line break - Use kcalloc instead of kmalloc - sizeof(struct attribute_group *) => sizeof(**uport->tty_groups) *1: https://lkml.org/lkml/2014/7/12/177 Changes in V9: [2/2] - Use attr_group instead of dev_spec_attr_group of uart_port structure Changes in V8: - Split V7's patch up into 2 patches Changes in V7: - Add Documentation - Change I/F name from rx_int_trig to rx_trig_bytes because the name rx_int_trig is hard to understand how users specify the value Changes in V6: - Move FCR_RX_TRIG_* definition in 8250.h to include/uapi/linux/serial_reg.h, rename those to UART_FCR_R_TRIG_*, and use UART_FCR_TRIGGER_MASK to UART_FCR_R_TRIG_BITS() - Change following function names: convert_fcr2val() => fcr_get_rxtrig_bytes() convert_val2rxtrig() => bytes_to_fcr_rxtrig() - Fix typo in serial8250_do_set_termios() - Delete the verbose error message pr_info() in bytes_to_fcr_rxtrig() - Rename *rx_int_trig/rx_trig* to *rxtrig* for several functions or variables (but UI remains rx_int_trig) - Change the meaningless variable name 'val' to 'bytes' following functions: fcr_get_rxtrig_bytes(), bytes_to_fcr_rxtrig(), do_set_rxtrig(), do_serial8250_set_rxtrig(), and serial8250_set_attr_rxtrig() - Use up->fcr in order to get rxtrig_bytes instead of rx_trig_raw in fcr_get_rxtrig_bytes() - Use conf_type->rxtrig_bytes[0] instead of switch statement for support check in register_dev_spec_attr_grp() - Delete the checking whether a user changed FCR or not when minimum buffer is needed in serial8250_do_set_termios() Changes in V5.1: - Fix FCR_RX_TRIG_MAX_STATE definition Changes in V5: - Support Tegra, 16650V2, 16654, and 16750 - Store default FCR value to up->fcr when the port is first created - Add rx_trig_byte[] in uart_config[] for each device and use rx_trig_byte[] in convert_fcr2val() and convert_val2rxtrig() Changes in V4: - Introduce fifo_bug flag in uart_8250_port structure This is enabled only when parity is enabled and UART_BUG_PARITY is enabled for up->bugs. If this flag is enabled, user cannot set RX trigger. - Return -EOPNOTSUPP when it does not support device at convert_fcr2val() and at convert_val2rxtrig() - Set the nearest lower RX trigger when users input a meaningless value at convert_val2rxtrig() - Check whether p->fcr is existing at serial8250_clear_and_reinit_fifos() - Set fcr = up->fcr in the begging of serial8250_do_set_termios() Changes in V3: - Change I/F from ioctl(2) to sysfs(rx_int_trig) Changed in V2: - Use _IOW for TIOCSFIFORTRIG definition - Pass the interrupt trigger value itself --- Greg Kroah-Hartman (1): Serial: allow port drivers to have a default attribute group Yoshihiro YUNOMAE (1): serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers Documentation/ABI/testing/sysfs-tty | 16 +++ drivers/tty/serial/8250/8250.h |2 drivers/tty/serial/8250/8250_core.c | 173 --- drivers/tty/serial/serial_core.c| 24 +++-- include/linux/serial_8250.h |2 include/linux/serial_core.h |2 include/uapi/linux/serial_reg.h |5 + 7 files changed, 202 insertions(+), 22 deletions(-) -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V9 2/2] serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers
Add tunable RX interrupt trigger I/F of FIFO buffers. Serial devices are used as not only message communication devices but control or sending communication devices. For the latter uses, normally small data will be exchanged, so user applications want to receive data unit as soon as possible for real-time tendency. If we have a sensor which sends a 1 byte data each time and must control a device based on the sensor feedback, the RX interrupt should be triggered for each data. According to HW specification of serial UART devices, RX interrupt trigger can be changed, but the trigger is hard-coded. For example, RX interrupt trigger in 16550A can be set to 1, 4, 8, or 14 bytes for HW, but current driver sets the trigger to only 8bytes. This patch makes some devices change RX interrupt trigger from userland. How to use - Read current setting # cat /sys/class/tty/ttyS0/rx_trig_bytes 8 - Write user setting # echo 1 /sys/class/tty/ttyS0/rx_trig_bytes # cat /sys/class/tty/ttyS0/rx_trig_bytes 1 Support uart devices - 16550A and Tegra (1, 4, 8, or 14 bytes) - 16650V2 (8, 16, 24, or 28 bytes) - 16654 (8, 16, 56, or 60 bytes) - 16750 (1, 16, 32, or 56 bytes) Change log Changes in V9: - Use attr_group instead of dev_spec_attr_group of uart_port structure Changes in V8: - Divide this patch from V7's patch based on Greg's comment Changes in V7: - Add Documentation - Change I/F name from rx_int_trig to rx_trig_bytes because the name rx_int_trig is hard to understand how users specify the value Changes in V6: - Move FCR_RX_TRIG_* definition in 8250.h to include/uapi/linux/serial_reg.h, rename those to UART_FCR_R_TRIG_*, and use UART_FCR_TRIGGER_MASK to UART_FCR_R_TRIG_BITS() - Change following function names: convert_fcr2val() = fcr_get_rxtrig_bytes() convert_val2rxtrig() = bytes_to_fcr_rxtrig() - Fix typo in serial8250_do_set_termios() - Delete the verbose error message pr_info() in bytes_to_fcr_rxtrig() - Rename *rx_int_trig/rx_trig* to *rxtrig* for several functions or variables (but UI remains rx_int_trig) - Change the meaningless variable name 'val' to 'bytes' following functions: fcr_get_rxtrig_bytes(), bytes_to_fcr_rxtrig(), do_set_rxtrig(), do_serial8250_set_rxtrig(), and serial8250_set_attr_rxtrig() - Use up-fcr in order to get rxtrig_bytes instead of rx_trig_raw in fcr_get_rxtrig_bytes() - Use conf_type-rxtrig_bytes[0] instead of switch statement for support check in register_dev_spec_attr_grp() - Delete the checking whether a user changed FCR or not when minimum buffer is needed in serial8250_do_set_termios() Changes in V5.1: - Fix FCR_RX_TRIG_MAX_STATE definition Changes in V5: - Support Tegra, 16650V2, 16654, and 16750 - Store default FCR value to up-fcr when the port is first created - Add rx_trig_byte[] in uart_config[] for each device and use rx_trig_byte[] in convert_fcr2val() and convert_val2rxtrig() Changes in V4: - Introduce fifo_bug flag in uart_8250_port structure This is enabled only when parity is enabled and UART_BUG_PARITY is enabled for up-bugs. If this flag is enabled, user cannot set RX trigger. - Return -EOPNOTSUPP when it does not support device at convert_fcr2val() and at convert_val2rxtrig() - Set the nearest lower RX trigger when users input a meaningless value at convert_val2rxtrig() - Check whether p-fcr is existing at serial8250_clear_and_reinit_fifos() - Set fcr = up-fcr in the begging of serial8250_do_set_termios() Changes in V3: - Change I/F from ioctl(2) to sysfs(rx_int_trig) Changed in V2: - Use _IOW for TIOCSFIFORTRIG definition - Pass the interrupt trigger value itself Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com --- Documentation/ABI/testing/sysfs-tty | 16 +++ drivers/tty/serial/8250/8250.h |2 drivers/tty/serial/8250/8250_core.c | 173 --- include/linux/serial_8250.h |2 include/uapi/linux/serial_reg.h |5 + 5 files changed, 183 insertions(+), 15 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-tty b/Documentation/ABI/testing/sysfs-tty index ad22fb0..9eb3c2b 100644 --- a/Documentation/ABI/testing/sysfs-tty +++ b/Documentation/ABI/testing/sysfs-tty @@ -138,3 +138,19 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. + +What: /sys/class/tty/ttyS0/rx_trig_bytes +Date: May 2014 +Contact: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com +Description: +Shows current RX interrupt trigger bytes or sets the +user specified value to change it for the FIFO buffer. +Users can show or set this value regardless of opening the +serial device file or not. + +The RX trigger can be set one of four kinds of values for UART +serials. When users input a meaning less value to this I/F
[ PATCH V9 0/2] serial/uart/8250: Introduce tunable RX trigger I/F
Hi Greg, This patch set introduces tunable RX interrupt trigger I/F for 8250 serials. I used Greg's patch(*1) as 1st patch in this version, and applied 2nd patch of previous version. Would you review this patch set? Thanks! Note: I cleaned up Greg's patch as follows: - Delete extra line break - Use kcalloc instead of kmalloc - sizeof(struct attribute_group *) = sizeof(**uport-tty_groups) *1: https://lkml.org/lkml/2014/7/12/177 Change log Changes in V9: [2/2] - Use attr_group instead of dev_spec_attr_group of uart_port structure Changes in V8: - Split V7's patch up into 2 patches Changes in V7: - Add Documentation - Change I/F name from rx_int_trig to rx_trig_bytes because the name rx_int_trig is hard to understand how users specify the value Changes in V6: - Move FCR_RX_TRIG_* definition in 8250.h to include/uapi/linux/serial_reg.h, rename those to UART_FCR_R_TRIG_*, and use UART_FCR_TRIGGER_MASK to UART_FCR_R_TRIG_BITS() - Change following function names: convert_fcr2val() = fcr_get_rxtrig_bytes() convert_val2rxtrig() = bytes_to_fcr_rxtrig() - Fix typo in serial8250_do_set_termios() - Delete the verbose error message pr_info() in bytes_to_fcr_rxtrig() - Rename *rx_int_trig/rx_trig* to *rxtrig* for several functions or variables (but UI remains rx_int_trig) - Change the meaningless variable name 'val' to 'bytes' following functions: fcr_get_rxtrig_bytes(), bytes_to_fcr_rxtrig(), do_set_rxtrig(), do_serial8250_set_rxtrig(), and serial8250_set_attr_rxtrig() - Use up-fcr in order to get rxtrig_bytes instead of rx_trig_raw in fcr_get_rxtrig_bytes() - Use conf_type-rxtrig_bytes[0] instead of switch statement for support check in register_dev_spec_attr_grp() - Delete the checking whether a user changed FCR or not when minimum buffer is needed in serial8250_do_set_termios() Changes in V5.1: - Fix FCR_RX_TRIG_MAX_STATE definition Changes in V5: - Support Tegra, 16650V2, 16654, and 16750 - Store default FCR value to up-fcr when the port is first created - Add rx_trig_byte[] in uart_config[] for each device and use rx_trig_byte[] in convert_fcr2val() and convert_val2rxtrig() Changes in V4: - Introduce fifo_bug flag in uart_8250_port structure This is enabled only when parity is enabled and UART_BUG_PARITY is enabled for up-bugs. If this flag is enabled, user cannot set RX trigger. - Return -EOPNOTSUPP when it does not support device at convert_fcr2val() and at convert_val2rxtrig() - Set the nearest lower RX trigger when users input a meaningless value at convert_val2rxtrig() - Check whether p-fcr is existing at serial8250_clear_and_reinit_fifos() - Set fcr = up-fcr in the begging of serial8250_do_set_termios() Changes in V3: - Change I/F from ioctl(2) to sysfs(rx_int_trig) Changed in V2: - Use _IOW for TIOCSFIFORTRIG definition - Pass the interrupt trigger value itself --- Greg Kroah-Hartman (1): Serial: allow port drivers to have a default attribute group Yoshihiro YUNOMAE (1): serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers Documentation/ABI/testing/sysfs-tty | 16 +++ drivers/tty/serial/8250/8250.h |2 drivers/tty/serial/8250/8250_core.c | 173 --- drivers/tty/serial/serial_core.c| 24 +++-- include/linux/serial_8250.h |2 include/linux/serial_core.h |2 include/uapi/linux/serial_reg.h |5 + 7 files changed, 202 insertions(+), 22 deletions(-) -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V9 1/2] Serial: allow port drivers to have a default attribute group
From: Greg Kroah-Hartman gre...@linuxfoundation.org Some serial drivers (like 8250), want to add sysfs files. We need to do so in a race-free way, so allow any port to be able to specify an attribute group that should be added at device creation time. Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com --- drivers/tty/serial/serial_core.c | 24 +--- include/linux/serial_core.h |2 ++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index fbf6c5a..4af764c 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2563,12 +2563,6 @@ static const struct attribute_group tty_dev_attr_group = { .attrs = tty_dev_attrs, }; -static const struct attribute_group *tty_dev_attr_groups[] = { - tty_dev_attr_group, - NULL - }; - - /** * uart_add_one_port - attach a driver-defined port structure * @drv: pointer to the uart low level driver structure for this port @@ -2585,6 +2579,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport) struct tty_port *port; int ret = 0; struct device *tty_dev; + int num_groups; BUG_ON(in_interrupt()); @@ -2618,12 +2613,26 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport) uart_configure_port(drv, state, uport); + num_groups = 2; + if (uport-attr_group) + num_groups++; + + uport-tty_groups = kcalloc(num_groups, sizeof(**uport-tty_groups), + GFP_KERNEL); + if (!uport-tty_groups) { + ret = -ENOMEM; + goto out; + } + uport-tty_groups[0] = tty_dev_attr_group; + if (uport-attr_group) + uport-tty_groups[1] = uport-attr_group; + /* * Register the port whether it's detected or not. This allows * setserial to be used to alter this port's parameters. */ tty_dev = tty_port_register_device_attr(port, drv-tty_driver, - uport-line, uport-dev, port, tty_dev_attr_groups); + uport-line, uport-dev, port, uport-tty_groups); if (likely(!IS_ERR(tty_dev))) { device_set_wakeup_capable(tty_dev, 1); } else { @@ -2702,6 +2711,7 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *uport) */ if (uport-type != PORT_UNKNOWN) uport-ops-release_port(uport); + kfree(uport-tty_groups); /* * Indicate that there isn't a port here anymore. diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 5bbb809..cf3a1e7 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -199,6 +199,8 @@ struct uart_port { unsigned char suspended; unsigned char irq_wake; unsigned char unused[2]; + struct attribute_group *attr_group;/* port specific attributes */ + const struct attribute_group **tty_groups; /* all attributes (serial core use only) */ void*private_data; /* generic platform data pointer */ }; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Re: [PATCH V8 2/2] serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers
(2014/07/13 6:22), Greg KH wrote: On Thu, Jul 10, 2014 at 04:16:37PM -0700, Greg Kroah-Hartman wrote: On Thu, Jul 10, 2014 at 03:31:57PM +0100, One Thousand Gnomes wrote: I really don't like the way that the tty core has been changed to handle multiple attribute groups, as I feel tty drivers shouldn't be creating "special" sysfs files, depending on what driver is bound to them. The intent isn't that it is "special" but that it can be propogated to others as and when they wish to provide it. Usually we have handled this using tools like 'stty' and ioctls, right? Surely there is an ioctl to control the interrupt level, right? Hasn't this been covered before somehow? No, and the direction when this started was to use sysfs as we have also been moving all the other attributes towards sysfs and has been since 2012. TTY devices do have lots of strange attributes and right now many of them are only programmable by using device tree and rebooting. Ok. Hm, there has to be a better way to do the group sysfs file handling... Let me work on this tomorrow and see what I can come up with. We should be able to use the is_visable() attribute to create/notcreate the attribute where needed... Ok, how about this patch instead of your first one? It creates a new port attribute, attr_group, which you should be able to set in the 8250 driver if you device needs it. Then the serial core will handle the dynamic group creation, without relying on a "magic" number of groups. Very close to your patch, but now it's dynamic, and no fixed array, and no crazy casting in the tty_port_register_device_attr() call. Thank you very much for your patch. I'll use it as 1st patch in next version. I have not tested this, only test built the code. OK, I'll test it. If it works for you, can you redo your second patch, and then send both of these back to me so that I can apply them? Sure. Thank you, Yoshihiro YUNOMAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Re: [PATCH V8 2/2] serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers
(2014/07/13 6:22), Greg KH wrote: On Thu, Jul 10, 2014 at 04:16:37PM -0700, Greg Kroah-Hartman wrote: On Thu, Jul 10, 2014 at 03:31:57PM +0100, One Thousand Gnomes wrote: I really don't like the way that the tty core has been changed to handle multiple attribute groups, as I feel tty drivers shouldn't be creating special sysfs files, depending on what driver is bound to them. The intent isn't that it is special but that it can be propogated to others as and when they wish to provide it. Usually we have handled this using tools like 'stty' and ioctls, right? Surely there is an ioctl to control the interrupt level, right? Hasn't this been covered before somehow? No, and the direction when this started was to use sysfs as we have also been moving all the other attributes towards sysfs and has been since 2012. TTY devices do have lots of strange attributes and right now many of them are only programmable by using device tree and rebooting. Ok. Hm, there has to be a better way to do the group sysfs file handling... Let me work on this tomorrow and see what I can come up with. We should be able to use the is_visable() attribute to create/notcreate the attribute where needed... Ok, how about this patch instead of your first one? It creates a new port attribute, attr_group, which you should be able to set in the 8250 driver if you device needs it. Then the serial core will handle the dynamic group creation, without relying on a magic number of groups. Very close to your patch, but now it's dynamic, and no fixed array, and no crazy casting in the tty_port_register_device_attr() call. Thank you very much for your patch. I'll use it as 1st patch in next version. I have not tested this, only test built the code. OK, I'll test it. If it works for you, can you redo your second patch, and then send both of these back to me so that I can apply them? Sure. Thank you, Yoshihiro YUNOMAE -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V4 2/5] trace-cmd/msg: Use poll(2) to wait for a message
Use poll(2) to wait for a message. If a client/server cannot send a message for any reasons, the current server/client will wait in a blocking read operation. So, we use poll(2) for avoiding remaining in a blocking state. Changes in V4: Change the argument of tracecmd_msg_recv_wait() Fix some typos Signed-off-by: Yoshihiro YUNOMAE --- trace-msg.c | 42 -- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/trace-msg.c b/trace-msg.c index 08fa2a6..db48365 100644 --- a/trace-msg.c +++ b/trace-msg.c @@ -395,6 +395,27 @@ error: return -ENOMSG; } +#define MSG_WAIT_MSEC 5000 + +/* + * A return value of 0 indicates time-out + */ +static int tracecmd_msg_recv_wait(int fd, struct tracecmd_msg *msg) +{ + struct pollfd pfd; + int ret; + + pfd.fd = fd; + pfd.events = POLLIN; + ret = poll(, 1, MSG_WAIT_MSEC); + if (ret < 0) + return -errno; + else if (ret == 0) + return -ETIMEDOUT; + + return tracecmd_msg_recv(fd, msg); +} + static void *tracecmd_msg_buf_access(struct tracecmd_msg *msg, int offset) { return (void *)msg + offset; @@ -405,9 +426,12 @@ static int tracecmd_msg_wait_for_msg(int fd, struct tracecmd_msg *msg) u32 cmd; int ret; - ret = tracecmd_msg_recv(fd, msg); - if (ret < 0) + ret = tracecmd_msg_recv_wait(fd, msg); + if (ret < 0) { + if (ret == -ETIMEDOUT) + warning("Connection timed out\n"); return ret; + } cmd = ntohl(msg->cmd); if (cmd == MSG_CLOSE) @@ -487,9 +511,12 @@ int tracecmd_msg_initial_setting(int fd, int *cpus, int *pagesize) u32 cmd; msg = (struct tracecmd_msg *)buf; - ret = tracecmd_msg_recv(fd, msg); - if (ret < 0) + ret = tracecmd_msg_recv_wait(fd, msg); + if (ret < 0) { + if (ret == -ETIMEDOUT) + warning("Connection timed out\n"); return ret; + } cmd = ntohl(msg->cmd); if (cmd != MSG_TINIT) { @@ -627,9 +654,12 @@ int tracecmd_msg_collect_metadata(int ifd, int ofd) msg = (struct tracecmd_msg *)buf; do { - ret = tracecmd_msg_recv(ifd, msg); + ret = tracecmd_msg_recv_wait(ifd, msg); if (ret < 0) { - warning("reading client"); + if (ret == -ETIMEDOUT) + warning("Connection timed out\n"); + else + warning("reading client"); return ret; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCHV4 0/5] trace-cmd: Support the feature which guests send trace data via virtio
Hi Steven, This is a v4 patch set to support the feature which guests send trace data via virtio. (Previous patch set is here: https://lkml.org/lkml/2013/12/16/688) Any features in this V4 patch series are not changed from previous version. I fixed some typos, rebased for current version, and added usage in this version. Would you review this patch series? 1. Run virt-server on a host # trace-cmd virt-server --dom guest1 -c 2 2. Set up of virtio-serial pipe of guest1 on the host Add the following tags to domain XML files. # virsh edit guest1 3. Boot the guest # virsh start guest1 4. Run the guest1's client(see trace-cmd-record(1) with the *--virt* option) # trace-cmd record -e sched* --virt If you want to boot another guest sends trace-data via virtio-serial, you will manually make the guest domain directory and trace data I/Fs. - Make guest domain directory on the host # mkdir -p /tmp/trace-cmd/virt/ # chmod 710 /tmp/trace-cmd/virt/ # chgrp qemu /tmp/trace-cmd/virt/ - Make FIFO on the host # mkfifo /tmp/trace-cmd/virt//trace-path-cpu{0,1,...,X}.{in,out} I measured CPU usage outputted by top command on a guest when client sends trace data. Client means "record -N"(NW) or "record --virt"(virtio-serial). NW virtio-serial(splice) client(fedora19)~2.9[%] ~1.7[%] Changes in V4: [1/5] Fix some typos, cleanup, and rebase for current trace-cmd-v2.4 Change the argument of tracecmd_msg_recv() [2/5] Fix some typos Change the argument of tracecmd_msg_recv_wait() [3/5] Fix some typos and cleanup [4/5] Introduce parse_args_virt() and add usage of virt-server in trace-usage.c [5/5] Rebase for current trace-cmd-v2.4 and add usage of --virt for record in trace-usage.c Divide tracecmd_msg_connect_to_server() into two functions (tracecmd_msg_connect_to_server() and tracecmd_msg_send_init_data_virt(fd)) Changes in V3: [2/6] Change the license of trace-msg.c to LGPL v2.1 [4/6] Change _nw/_NW to _net/_NET [5/6] Change _nw/_NW to _net/_NET [6/6] Add this patch based on Steven's review (https://lkml.org/lkml/2013/10/14/618) Changes in V2: [1/5] Add a comment in open_udp() [2/5] Regacy protocol support in order to keep backward compatibility Thank you, --- Yoshihiro YUNOMAE (5): trace-cmd/listen: Apply the trace-msg protocol for communication between a server and clients trace-cmd/msg: Use poll(2) to wait for a message trace-cmd/virt-server: Add virt-server mode for a virtualization environment trace-cmd/virt-server: Add --dom option which makes a domain directory to virt-server trace-cmd/record: Add --virt option for record mode Documentation/trace-cmd-record.1.txt | 11 Documentation/trace-cmd-virt-server.1.txt | 113 Makefile |2 trace-cmd.c |3 trace-cmd.h | 15 trace-listen.c| 717 +++- trace-msg.c | 873 + trace-msg.h | 31 + trace-output.c|4 trace-record.c| 146 - trace-recorder.c | 50 +- trace-usage.c | 18 + 12 files changed, 1818 insertions(+), 165 deletions(-) create mode 100644 Documentation/trace-cmd-virt-server.1.txt create mode 100644 trace-msg.c create mode 100644 trace-msg.h -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V4 5/5] trace-cmd/record: Add --virt option for record mode
Add --virt option for record mode for a virtualization environment. If we use this option on a guest, we can send trace data in low-overhead. This is because guests can send trace data to a host without copying the data by using splice(2). The format is: trace-cmd record --virt -e sched* The client using virtio-serial does not wait for the connection message "tracecmd" from the server. The client sends the connection message MSG_TCONNECT first. This feature can use from kernel-3.6 which supports splice_read for ftrace and splice_write for virtio-serial. Changes in V4: Rebase for current trace-cmd-v2.4 Add usage of --virt for record in trace-usage.c Divide tracecmd_msg_connect_to_server() into two functions (tracecmd_msg_connect_to_server() and tracecmd_msg_send_init_data_virt(fd)) Changes in V3: Change _nw/_NW to _net/_NET Signed-off-by: Yoshihiro YUNOMAE --- Documentation/trace-cmd-record.1.txt | 11 - trace-cmd.h |4 +- trace-msg.c | 79 +++--- trace-msg.h |4 ++ trace-record.c | 71 --- trace-usage.c|3 + 6 files changed, 158 insertions(+), 14 deletions(-) diff --git a/Documentation/trace-cmd-record.1.txt b/Documentation/trace-cmd-record.1.txt index 9e63eb4..c0de074 100644 --- a/Documentation/trace-cmd-record.1.txt +++ b/Documentation/trace-cmd-record.1.txt @@ -258,6 +258,15 @@ OPTIONS timestamp to gettimeofday which will allow wall time output from the timestamps reading the created 'trace.dat' file. +*--virt*:: +This option is usded on a guest in a virtualization environment. If a host +is running "trace-cmd virt-server", this option is used to have the data +sent to the host with virtio-serial like *-N* option. (see also +trace-cmd-virt-server(1)) + +Note: This option is not supported with latency tracer plugins: + wakeup, wakeup_rt, irqsoff, preemptoff and preemptirqsoff + EXAMPLES @@ -320,7 +329,7 @@ SEE ALSO trace-cmd(1), trace-cmd-report(1), trace-cmd-start(1), trace-cmd-stop(1), trace-cmd-extract(1), trace-cmd-reset(1), trace-cmd-split(1), -trace-cmd-list(1), trace-cmd-listen(1) +trace-cmd-list(1), trace-cmd-listen(1), trace-cmd-virt-server(1) AUTHOR -- diff --git a/trace-cmd.h b/trace-cmd.h index c4e5beb..1c1b0c3 100644 --- a/trace-cmd.h +++ b/trace-cmd.h @@ -250,7 +250,9 @@ void tracecmd_stat_cpu(struct trace_seq *s, int cpu); long tracecmd_flush_recording(struct tracecmd_recorder *recorder); /* for clients */ -int tracecmd_msg_send_init_data(int fd); +int tracecmd_msg_connect_to_server(int fd); +int tracecmd_msg_send_init_data_net(int fd); +int tracecmd_msg_send_init_data_virt(int fd); int tracecmd_msg_metadata_send(int fd, char *buf, int size); int tracecmd_msg_finish_sending_metadata(int fd); void tracecmd_msg_send_close_msg(void); diff --git a/trace-msg.c b/trace-msg.c index 0d606dc..7ca31d6 100644 --- a/trace-msg.c +++ b/trace-msg.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -72,6 +73,7 @@ int cpu_count; static int psfd; unsigned int page_size; int *client_ports; +int *virt_sfds; bool send_metadata; /* for server */ @@ -272,12 +274,20 @@ static int make_rinit(struct tracecmd_msg *msg) return 0; } +static int make_error_msg(u32 len, struct tracecmd_msg *msg) +{ + bufcpy(msg, TRACECMD_MSG_HDR_LEN, errmsg, len); + return 0; +} + static u32 tracecmd_msg_get_body_length(u32 cmd) { struct tracecmd_msg *msg; u32 len = 0; switch (cmd) { + case MSG_ERROR: + return ntohl(errmsg->size); case MSG_RCONNECT: return sizeof(msg->data.rconnect.str.size) + CONNECTION_MSGSIZE; case MSG_TINIT: @@ -305,6 +315,7 @@ static u32 tracecmd_msg_get_body_length(u32 cmd) + sizeof(msg->data.rinit.port_array); case MSG_SENDMETA: return TRACECMD_MSG_MAX_LEN - TRACECMD_MSG_HDR_LEN; + case MSG_TCONNECT: case MSG_CLOSE: case MSG_FINMETA: break; @@ -313,15 +324,18 @@ static u32 tracecmd_msg_get_body_length(u32 cmd) return 0; } -static int tracecmd_msg_make_body(u32 cmd, struct tracecmd_msg *msg) +static int tracecmd_msg_make_body(u32 cmd, u32 len, struct tracecmd_msg *msg) { switch (cmd) { + case MSG_ERROR: + return make_error_msg(len, msg); case MSG_RCONNECT: return make_rconnect(CONNECTION_MSG, CONNECTION_MSGSIZE, msg); case MSG_TINIT: return make_tinit(msg); case MSG_RINIT: return make_rinit(msg); + case MSG_TCONNECT: case MSG_CLOSE: case MSG_SENDMETA: /*
[PATCH V4 1/5] trace-cmd/listen: Apply the trace-msg protocol for communication between a server and clients
Apply trace-msg protocol for communication between a server and clients. Currently, trace-listen(server) and trace-record -N(client) operate as follows: listen to socket fd connect to socket fd accept the client send "tracecmd" +> receive "tracecmd" check "tracecmd" send cpus receive cpus <+ print "cpus=XXX" send pagesize | receive pagesize <+ print "pagesize=XXX" send option | receive option <--+ understand option send port_array +> receive port_array understand port_array send meta data receive meta data <---+ record meta data (snip) read block --- start sending trace data on child processes --- --- When client finishes sending trace data --- close(socket fd) read size = 0 close(socket fd) All messages are unstructured character strings, so server(client) using the protocol must parse the unstructured messages. Since it is hard to add complex contents in the protocol, structured binary message trace-msg is introduced as the communication protocol. By applying this patch, server and client operate as follows: listen to socket fd connect to socket fd accept the client send "tracecmd" +> receive "tracecmd" check "tracecmd" send "V2\0\00" as the v2 protocol receive "V2" <+ check "V2" read "\00" send "V2" +---> receive "V2" check "V2" send cpus,pagesize,option(MSG_TINIT) receive MSG_TINIT <---+ print "cpus=XXX" print "pagesize=XXX" understand option send port_array +--MSG_RINIT-> receive MSG_RINIT understand port_array send meta data(MSG_SENDMETA) receive MSG_SENDMETA <+ record meta data (snip) send a message to finish sending meta data | (MSG_FINMETA) receive MSG_FINMETA <-+ read block --- start sending trace data on child processes --- --- When client finishes sending trace data --- send MSG_CLOSE receive MSG_CLOSE <---+ close(socket fd)close(socket fd) By introducing the v2 protocol, after the client checks "tracecmd", the client will send "V2\0\00\0". This complex message is used when the new client tries to connect to the old server. The new client wants to check whether the reply message from the server is "V2" or not. However, the old server does not respond to the client before receiving cpu numbers, page size, and options. Each message is separated with "\0" in the old server, so the client send "V2" as cpu numbers, "" as page size, and "0" as no options. On the other hands, the old server will understand the messages as cpus=0, pagesize=, and options=0, and then the server will send the message "\0" as port numbers. Then, the message which the client receives is not "V2" but "\0", so the client will reconnect to the old server as the v1 protocol. [1] Backward compatability checks We need to test backward compatability of this patch for old trace-cmds(client/server). So, this patch was tested for [2] command checks in following 3 types: new old old new new new [2] Command checks - server (common) # trace-cmd listen -p 12345 1) record - client # trace-cmd record -e sched -N :12345 ^C 2) record + multiple buffers - client # trace-cmd record -B foo -e sched -N :12345 ^C 3) extract - client # ./trace-cmd start -e sched # sleep 5 # ./trace-cmd extract -N :12345 4) extract + snapshot - client # ./trace-cmd start -e sched # sleep 5 # ./trace-cmd snapshot -s # ./trace-cmd extract -N :12345 -s Changes in V4: Fix some typos, cleanups and rebase for current trace-cmd-v2.4 Change t
[PATCH V4 4/5] trace-cmd/virt-server: Add --dom option which makes a domain directory to virt-server
Add --dom option which makes a domain directory to virt-server. When a user already knows domain name of a guest before running virt-server, trace-cmd should automatically set up I/Fs of the guest. By adding --dom option, trace-cmd creates a domain directory with 0710 and qemu group. This patch adds additional options for --dom as follows: -m This option changes the permission of domain directory. If you don't use this option, the default permission is 0710. -g This option changes group of domain directory. If you don't use this option, the default group is qemu. -c This option creates trace data I/Fs(trace-path-cpu*.{in,out}) for each CPU of 'domain'. If you don't use this option, those files are not created. Here, an example you use this option is written as follows: - trace-cmd creates a guest1 directory with trace data I/Fs of 2 CPUs. # trace-cmd virt-server --dom guest1 -c 2 - trace-cmd creates guest2 and guest3 directories # trace-cmd virt-server --dom guest2 -c 3 --dom guest3 -c 1 Changes in V4: Introduce parse_args_virt() Add usage of virt-server in trace-usage.c Signed-off-by: Yoshihiro YUNOMAE --- Documentation/trace-cmd-virt-server.1.txt | 56 --- trace-listen.c| 151 ++--- trace-usage.c |5 + 3 files changed, 178 insertions(+), 34 deletions(-) diff --git a/Documentation/trace-cmd-virt-server.1.txt b/Documentation/trace-cmd-virt-server.1.txt index 4168a04..fbd0ad6 100644 --- a/Documentation/trace-cmd-virt-server.1.txt +++ b/Documentation/trace-cmd-virt-server.1.txt @@ -34,40 +34,64 @@ OPTIONS *-l* 'filename':: This option writes the output messages to a log file instead of standard output. +*--dom* 'domain':: +This option makes a directory for the 'domain'. You can use additional options +*-m*, *-g*, *-c* after this option for the 'domain'. If you don't use these +additional options, the directory is made as 0710 and qemu group and +trace data I/Fs(trace-path-cpu*.{in,out}) are not created. + +*-m* 'permission':: +This option changes the permission of 'domain' directory. If you don't use +this option, the default permission is 0710. + +*-g* 'group':: +This option changes group of 'domain' directory. If you don't use this option, +the default group is qemu. + +*-c* 'cpu':: +This option creates trace data I/Fs(trace-path-cpu*.{in,out}) for each CPU +of 'domain'. If you don't use this option, those files are not created. + SET UP -- Here, an example is written as follows: 1. Run virt-server on a host - # trace-cmd virt-server - -2. Make guest domain directory - # mkdir -p /tmp/trace-cmd/virt/ - # chmod 710 /tmp/trace-cmd/virt/ - # chgrp qemu /tmp/trace-cmd/virt/ - -3. Make FIFO on the host - # mkfifo /tmp/trace-cmd/virt//trace-path-cpu{0,1,...,X}.{in,out} + # trace-cmd virt-server --dom guest1 -c 2 -4. Set up of virtio-serial pipe of a guest on the host +2. Set up of virtio-serial pipe of guest1 on the host Add the following tags to domain XML files. - # virsh edit + # virsh edit guest1 - + - ... (cpu1, cpu2, ...) + + + + -5. Boot the guest - # virsh start +3. Boot the guest + # virsh start guest1 -6. Run the guest's client(see trace-cmd-record(1) with the *--virt* option) +4. Run the guest1's client(see trace-cmd-record(1) with the *--virt* option) # trace-cmd record -e sched* --virt +If you want to boot another guest sends trace-data via virtio-serial, +you will manually make the guest domain directory and trace data I/Fs. + +- Make guest domain directory on the host + # mkdir -p /tmp/trace-cmd/virt/ + # chmod 710 /tmp/trace-cmd/virt/ + # chgrp qemu /tmp/trace-cmd/virt/ + +- Make FIFO on the host + # mkfifo /tmp/trace-cmd/virt//trace-path-cpu{0,1,...,X}.{in,out} + SEE ALSO trace-cmd(1), trace-cmd-record(1), trace-cmd-report(1), trace-cmd-start(1), diff --git a/trace-listen.c b/trace-listen.c index 01b7ebf..e424c2a 100644 --- a/trace-listen.c +++ b/trace-listen.c @@ -54,11 +54,21 @@ static int backlog = 5; static int proto_ver; +struct domain_dir { + struct domain_dir *next; + char *name; + char *group; + mode_t perms; + int cpu; +}; + enum { NET = 1, VIRT= 2, }; +struct domain_dir *dom_dir_list; + #define TEMP_FILE_STR_NET "%s.%s:%s.cpu%d", output_file, host, port, cpu #define TEMP_FILE_STR_VIRT "%s.%s:%d.cpu%d", output_file, domain, virtpid, cpu static char *get_temp_file(const char *host, const char *port, @@ -382,7 +392,9 @@ static int open_udp(const char *node, const char *port, int *pid, #define TRACE_CMD_DIR "/tmp/trace-cmd/" #define VIRT_DIR TRACE_CMD_DIR "virt/" #define VIRT_TRACE_CTL_SOCKVIRT_DIR "a
[PATCH V4 3/5] trace-cmd/virt-server: Add virt-server mode for a virtualization environment
Add the virt-server mode for a virtualization environment based on the listen mode for networking. This mode works like client/server mode over TCP/UDP, but it uses virtio-serial channel instead of IP network. Using networking for collecting trace data of guests is generally high overhead caused by processing of the network stack. We use virtio-serial for collecting trace data of guests. virtio-serial is a simple communication path between the guest and the host. Moreover, since virtio-serial and ftrace can use splice(2), memory copying is not occurred on the guests. Therefore, total overhead for collecting trace data of the guests will be reduced. The implementation of clients will be shown in another patch. virt-server uses two kinds of virtio-serial I/Fs: (1) agent-ctl-path(UNIX domain socket) => control path of an agent trace-cmd each guest (2) trace-path-cpuX(named pipe) => trace data path each vcpu Those I/Fs must be defined as below paths: (1) /tmp/trace-cmd/virt/agent-ctl-path (2) /tmp/trace-cmd/virt//trace-path-cpuX If we run virt-server, agent-ctl-path I/F is automatically created because virt-server operates as a server mode of UNIX domain socket. However, trace-path-cpuX is not automatically created because we need to separate trace data for each guests. When the client uses virtio-serial, the client must notify the server of the connection. This is because a virtio-serial I/F on the guest is a just character device. In other words, the server cannot understand whether the client exists or not even if the client opens the I/F. So, the server using virtio-serial waits for the connection message MSG_TCONNECT from the client. The server and the client operate as follows: wait for MSG_TCONNECT open virtio-serial I/F send MSG_TCONNECT receive MSG_TCONNECT <+ send MSG_RCONNECT +---> receive MSG_RCONNECT check "tracecmd-V2" send cpus,pagesize,option(MSG_TINIT) receive MSG_TINIT <---+ print "cpus=XXX" print "pagesize=XXX" understand option send port_array +--MSG_RINIT-> receive MSG_RINIT understand port_array send meta data(MSG_SENDMETA) receive MSG_SENDMETA <+ record meta data (snip) send a message to finish sending meta data | (MSG_FINMETA) receive MSG_FINMETA <-+ read block --- start sending trace data on child processes --- --- When client finishes sending trace data --- send MSG_CLOSE receive MSG_CLOSE <---+ close(socket fd)close(socket fd) 1. Run virt-server on a host before booting guests # trace-cmd virt-server 2. Make guest domain directory # mkdir -p /tmp/trace-cmd/virt/ # chmod 710 /tmp/trace-cmd/virt/ # chgrp qemu /tmp/trace-cmd/virt/ 3. Make FIFO on the host # mkfifo /tmp/trace-cmd/virt//trace-path-cpu{0,1,...,X}.{in,out} 4. Set up of virtio-serial pipe of a guest on the host Add the following tags to domain XML files. # virsh edit ... (cpu1, cpu2, ...) 5. Boot the guest # virsh start 6. Check I/F of virtio-serial on the guest # ls /dev/virtio-ports ... agent-ctl-path ... trace-path-cpu0 ... Next, the user will run trace-cmd with record --virt options or other options for virtualization on the guest. This patch adds only minimum features of virt-server as follows: - virt-server subcommand - Create I/F directory(/tmp/trace-cmd/virt/) - Use named pipe I/Fs of virtio-serial for trace data paths - Use UNIX domain socket for connecting clients on guests - Use splice(2) for collecting trace data of guests - Use libvirt when we boot guests Changes in V4: Fix some typos and cleanup Changes in V3: Change _nw/_NW to _net/_NET Signed-off-by: Yoshihiro YUNOMAE --- Documentation/trace-cmd-virt-server.1.txt | 89 ++ trace-cmd.c |3 trace-cmd.h |2 trace-listen.c| 467 - trace-msg.c | 106 ++- trace-recorder.c | 50 ++- trace-usage.c | 10 + 7 files changed, 624 insertions(+), 103 deletions(-) create mode 100644 Documentation/trace-cmd-virt-server.1.txt diff --git a/Documentation/trace-cmd-virt-server.1.txt b/Documentation/trace-cmd-virt-server.1.txt new file mode 100644 index 000..4168a04 --- /dev/null +++ b/Documentation/trace-cmd-virt-server.1.txt @@ -0,0 +1,89 @@ +TRACE-CMD-VIRT-SER
[PATCH V4 5/5] trace-cmd/record: Add --virt option for record mode
Add --virt option for record mode for a virtualization environment. If we use this option on a guest, we can send trace data in low-overhead. This is because guests can send trace data to a host without copying the data by using splice(2). The format is: trace-cmd record --virt -e sched* Note The client using virtio-serial does not wait for the connection message tracecmd from the server. The client sends the connection message MSG_TCONNECT first. Restriction This feature can use from kernel-3.6 which supports splice_read for ftrace and splice_write for virtio-serial. Changes in V4: Rebase for current trace-cmd-v2.4 Add usage of --virt for record in trace-usage.c Divide tracecmd_msg_connect_to_server() into two functions (tracecmd_msg_connect_to_server() and tracecmd_msg_send_init_data_virt(fd)) Changes in V3: Change _nw/_NW to _net/_NET Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com --- Documentation/trace-cmd-record.1.txt | 11 - trace-cmd.h |4 +- trace-msg.c | 79 +++--- trace-msg.h |4 ++ trace-record.c | 71 --- trace-usage.c|3 + 6 files changed, 158 insertions(+), 14 deletions(-) diff --git a/Documentation/trace-cmd-record.1.txt b/Documentation/trace-cmd-record.1.txt index 9e63eb4..c0de074 100644 --- a/Documentation/trace-cmd-record.1.txt +++ b/Documentation/trace-cmd-record.1.txt @@ -258,6 +258,15 @@ OPTIONS timestamp to gettimeofday which will allow wall time output from the timestamps reading the created 'trace.dat' file. +*--virt*:: +This option is usded on a guest in a virtualization environment. If a host +is running trace-cmd virt-server, this option is used to have the data +sent to the host with virtio-serial like *-N* option. (see also +trace-cmd-virt-server(1)) + +Note: This option is not supported with latency tracer plugins: + wakeup, wakeup_rt, irqsoff, preemptoff and preemptirqsoff + EXAMPLES @@ -320,7 +329,7 @@ SEE ALSO trace-cmd(1), trace-cmd-report(1), trace-cmd-start(1), trace-cmd-stop(1), trace-cmd-extract(1), trace-cmd-reset(1), trace-cmd-split(1), -trace-cmd-list(1), trace-cmd-listen(1) +trace-cmd-list(1), trace-cmd-listen(1), trace-cmd-virt-server(1) AUTHOR -- diff --git a/trace-cmd.h b/trace-cmd.h index c4e5beb..1c1b0c3 100644 --- a/trace-cmd.h +++ b/trace-cmd.h @@ -250,7 +250,9 @@ void tracecmd_stat_cpu(struct trace_seq *s, int cpu); long tracecmd_flush_recording(struct tracecmd_recorder *recorder); /* for clients */ -int tracecmd_msg_send_init_data(int fd); +int tracecmd_msg_connect_to_server(int fd); +int tracecmd_msg_send_init_data_net(int fd); +int tracecmd_msg_send_init_data_virt(int fd); int tracecmd_msg_metadata_send(int fd, char *buf, int size); int tracecmd_msg_finish_sending_metadata(int fd); void tracecmd_msg_send_close_msg(void); diff --git a/trace-msg.c b/trace-msg.c index 0d606dc..7ca31d6 100644 --- a/trace-msg.c +++ b/trace-msg.c @@ -30,6 +30,7 @@ #include stdio.h #include unistd.h #include arpa/inet.h +#include sys/stat.h #include sys/types.h #include linux/types.h @@ -72,6 +73,7 @@ int cpu_count; static int psfd; unsigned int page_size; int *client_ports; +int *virt_sfds; bool send_metadata; /* for server */ @@ -272,12 +274,20 @@ static int make_rinit(struct tracecmd_msg *msg) return 0; } +static int make_error_msg(u32 len, struct tracecmd_msg *msg) +{ + bufcpy(msg, TRACECMD_MSG_HDR_LEN, errmsg, len); + return 0; +} + static u32 tracecmd_msg_get_body_length(u32 cmd) { struct tracecmd_msg *msg; u32 len = 0; switch (cmd) { + case MSG_ERROR: + return ntohl(errmsg-size); case MSG_RCONNECT: return sizeof(msg-data.rconnect.str.size) + CONNECTION_MSGSIZE; case MSG_TINIT: @@ -305,6 +315,7 @@ static u32 tracecmd_msg_get_body_length(u32 cmd) + sizeof(msg-data.rinit.port_array); case MSG_SENDMETA: return TRACECMD_MSG_MAX_LEN - TRACECMD_MSG_HDR_LEN; + case MSG_TCONNECT: case MSG_CLOSE: case MSG_FINMETA: break; @@ -313,15 +324,18 @@ static u32 tracecmd_msg_get_body_length(u32 cmd) return 0; } -static int tracecmd_msg_make_body(u32 cmd, struct tracecmd_msg *msg) +static int tracecmd_msg_make_body(u32 cmd, u32 len, struct tracecmd_msg *msg) { switch (cmd) { + case MSG_ERROR: + return make_error_msg(len, msg); case MSG_RCONNECT: return make_rconnect(CONNECTION_MSG, CONNECTION_MSGSIZE, msg); case MSG_TINIT: return make_tinit(msg); case MSG_RINIT: return make_rinit(msg); + case
[PATCH V4 1/5] trace-cmd/listen: Apply the trace-msg protocol for communication between a server and clients
Apply trace-msg protocol for communication between a server and clients. Currently, trace-listen(server) and trace-record -N(client) operate as follows: server client listen to socket fd connect to socket fd accept the client send tracecmd + receive tracecmd check tracecmd send cpus receive cpus + print cpus=XXX send pagesize | receive pagesize + print pagesize=XXX send option | receive option --+ understand option send port_array + receive port_array understand port_array send meta data receive meta data ---+ record meta data (snip) read block --- start sending trace data on child processes --- --- When client finishes sending trace data --- close(socket fd) read size = 0 close(socket fd) All messages are unstructured character strings, so server(client) using the protocol must parse the unstructured messages. Since it is hard to add complex contents in the protocol, structured binary message trace-msg is introduced as the communication protocol. By applying this patch, server and client operate as follows: server client listen to socket fd connect to socket fd accept the client send tracecmd + receive tracecmd check tracecmd send V2\0MAGIC_NUMBER\00 as the v2 protocol receive V2 + check V2 read MAGIC_NUMBER\00 send V2 +--- receive V2 check V2 send cpus,pagesize,option(MSG_TINIT) receive MSG_TINIT ---+ print cpus=XXX print pagesize=XXX understand option send port_array +--MSG_RINIT- receive MSG_RINIT understand port_array send meta data(MSG_SENDMETA) receive MSG_SENDMETA + record meta data (snip) send a message to finish sending meta data | (MSG_FINMETA) receive MSG_FINMETA -+ read block --- start sending trace data on child processes --- --- When client finishes sending trace data --- send MSG_CLOSE receive MSG_CLOSE ---+ close(socket fd)close(socket fd) By introducing the v2 protocol, after the client checks tracecmd, the client will send V2\0MAGIC_NUMBER\00\0. This complex message is used when the new client tries to connect to the old server. The new client wants to check whether the reply message from the server is V2 or not. However, the old server does not respond to the client before receiving cpu numbers, page size, and options. Each message is separated with \0 in the old server, so the client send V2 as cpu numbers, MAGIC_NUMBER as page size, and 0 as no options. On the other hands, the old server will understand the messages as cpus=0, pagesize=MAGIC_NUMBER, and options=0, and then the server will send the message \0 as port numbers. Then, the message which the client receives is not V2 but \0, so the client will reconnect to the old server as the v1 protocol. How to test [1] Backward compatability checks We need to test backward compatability of this patch for old trace-cmds(client/server). So, this patch was tested for [2] command checks in following 3 types: clientserver new old old new new new [2] Command checks - server (common) # trace-cmd listen -p 12345 1) record - client # trace-cmd record -e sched -N server IP:12345 ^C 2) record + multiple buffers - client # trace-cmd record -B foo -e sched -N server IP:12345 ^C 3) extract - client # ./trace-cmd start -e sched # sleep 5 # ./trace-cmd extract -N server IP:12345 4) extract + snapshot - client # ./trace-cmd start -e sched # sleep 5 # ./trace-cmd snapshot -s # ./trace-cmd extract -N server IP:12345 -s Changes in V4: Fix some typos, cleanups and rebase for current trace-cmd-v2.4 Change the argument of tracecmd_msg_recv() Changes in V3: Change the license of trace-msg.c to LGPL v2.1 Changes in V2: Regacy porotocol support in order to keep backward compatibility Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae
[PATCH V4 4/5] trace-cmd/virt-server: Add --dom option which makes a domain directory to virt-server
Add --dom option which makes a domain directory to virt-server. When a user already knows domain name of a guest before running virt-server, trace-cmd should automatically set up I/Fs of the guest. By adding --dom option, trace-cmd creates a domain directory with 0710 and qemu group. This patch adds additional options for --dom as follows: -m permission This option changes the permission of domain directory. If you don't use this option, the default permission is 0710. -g group This option changes group of domain directory. If you don't use this option, the default group is qemu. -c cpu This option creates trace data I/Fs(trace-path-cpu*.{in,out}) for each CPU of 'domain'. If you don't use this option, those files are not created. Here, an example you use this option is written as follows: - trace-cmd creates a guest1 directory with trace data I/Fs of 2 CPUs. # trace-cmd virt-server --dom guest1 -c 2 - trace-cmd creates guest2 and guest3 directories # trace-cmd virt-server --dom guest2 -c 3 --dom guest3 -c 1 Changes in V4: Introduce parse_args_virt() Add usage of virt-server in trace-usage.c Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com --- Documentation/trace-cmd-virt-server.1.txt | 56 --- trace-listen.c| 151 ++--- trace-usage.c |5 + 3 files changed, 178 insertions(+), 34 deletions(-) diff --git a/Documentation/trace-cmd-virt-server.1.txt b/Documentation/trace-cmd-virt-server.1.txt index 4168a04..fbd0ad6 100644 --- a/Documentation/trace-cmd-virt-server.1.txt +++ b/Documentation/trace-cmd-virt-server.1.txt @@ -34,40 +34,64 @@ OPTIONS *-l* 'filename':: This option writes the output messages to a log file instead of standard output. +*--dom* 'domain':: +This option makes a directory for the 'domain'. You can use additional options +*-m*, *-g*, *-c* after this option for the 'domain'. If you don't use these +additional options, the directory is made as 0710 and qemu group and +trace data I/Fs(trace-path-cpu*.{in,out}) are not created. + +*-m* 'permission':: +This option changes the permission of 'domain' directory. If you don't use +this option, the default permission is 0710. + +*-g* 'group':: +This option changes group of 'domain' directory. If you don't use this option, +the default group is qemu. + +*-c* 'cpu':: +This option creates trace data I/Fs(trace-path-cpu*.{in,out}) for each CPU +of 'domain'. If you don't use this option, those files are not created. + SET UP -- Here, an example is written as follows: 1. Run virt-server on a host - # trace-cmd virt-server - -2. Make guest domain directory - # mkdir -p /tmp/trace-cmd/virt/DOMAIN - # chmod 710 /tmp/trace-cmd/virt/DOMAIN - # chgrp qemu /tmp/trace-cmd/virt/DOMAIN - -3. Make FIFO on the host - # mkfifo /tmp/trace-cmd/virt/DOMAIN/trace-path-cpu{0,1,...,X}.{in,out} + # trace-cmd virt-server --dom guest1 -c 2 -4. Set up of virtio-serial pipe of a guest on the host +2. Set up of virtio-serial pipe of guest1 on the host Add the following tags to domain XML files. - # virsh edit guest domain + # virsh edit guest1 channel type='unix' source mode='connect' path='/tmp/trace-cmd/virt/agent-ctl-path'/ target type='virtio' name='agent-ctl-path'/ /channel channel type='pipe' - source path='/tmp/trace-cmd/virt/DOMAIN/trace-path-cpu0'/ + source path='/tmp/trace-cmd/virt/guest1/trace-path-cpu0'/ target type='virtio' name='trace-path-cpu0'/ /channel - ... (cpu1, cpu2, ...) + channel type='pipe' + source path='/tmp/trace-cmd/virt/guest1/trace-path-cpu1'/ + target type='virtio' name='trace-path-cpu1'/ + /channel -5. Boot the guest - # virsh start DOMAIN +3. Boot the guest + # virsh start guest1 -6. Run the guest's client(see trace-cmd-record(1) with the *--virt* option) +4. Run the guest1's client(see trace-cmd-record(1) with the *--virt* option) # trace-cmd record -e sched* --virt +If you want to boot another guest sends trace-data via virtio-serial, +you will manually make the guest domain directory and trace data I/Fs. + +- Make guest domain directory on the host + # mkdir -p /tmp/trace-cmd/virt/DOMAIN + # chmod 710 /tmp/trace-cmd/virt/DOMAIN + # chgrp qemu /tmp/trace-cmd/virt/DOMAIN + +- Make FIFO on the host + # mkfifo /tmp/trace-cmd/virt/DOMAIN/trace-path-cpu{0,1,...,X}.{in,out} + SEE ALSO trace-cmd(1), trace-cmd-record(1), trace-cmd-report(1), trace-cmd-start(1), diff --git a/trace-listen.c b/trace-listen.c index 01b7ebf..e424c2a 100644 --- a/trace-listen.c +++ b/trace-listen.c @@ -54,11 +54,21 @@ static int backlog = 5; static int proto_ver; +struct domain_dir { + struct domain_dir *next; + char *name; + char *group; + mode_t perms; + int cpu; +}; + enum { NET = 1
[PATCH V4 3/5] trace-cmd/virt-server: Add virt-server mode for a virtualization environment
Add the virt-server mode for a virtualization environment based on the listen mode for networking. This mode works like client/server mode over TCP/UDP, but it uses virtio-serial channel instead of IP network. Using networking for collecting trace data of guests is generally high overhead caused by processing of the network stack. We use virtio-serial for collecting trace data of guests. virtio-serial is a simple communication path between the guest and the host. Moreover, since virtio-serial and ftrace can use splice(2), memory copying is not occurred on the guests. Therefore, total overhead for collecting trace data of the guests will be reduced. The implementation of clients will be shown in another patch. virt-server uses two kinds of virtio-serial I/Fs: (1) agent-ctl-path(UNIX domain socket) = control path of an agent trace-cmd each guest (2) trace-path-cpuX(named pipe) = trace data path each vcpu Those I/Fs must be defined as below paths: (1) /tmp/trace-cmd/virt/agent-ctl-path (2) /tmp/trace-cmd/virt/guest domain/trace-path-cpuX If we run virt-server, agent-ctl-path I/F is automatically created because virt-server operates as a server mode of UNIX domain socket. However, trace-path-cpuX is not automatically created because we need to separate trace data for each guests. When the client uses virtio-serial, the client must notify the server of the connection. This is because a virtio-serial I/F on the guest is a just character device. In other words, the server cannot understand whether the client exists or not even if the client opens the I/F. So, the server using virtio-serial waits for the connection message MSG_TCONNECT from the client. The server and the client operate as follows: server client wait for MSG_TCONNECT open virtio-serial I/F send MSG_TCONNECT receive MSG_TCONNECT + send MSG_RCONNECT +--- receive MSG_RCONNECT check tracecmd-V2 send cpus,pagesize,option(MSG_TINIT) receive MSG_TINIT ---+ print cpus=XXX print pagesize=XXX understand option send port_array +--MSG_RINIT- receive MSG_RINIT understand port_array send meta data(MSG_SENDMETA) receive MSG_SENDMETA + record meta data (snip) send a message to finish sending meta data | (MSG_FINMETA) receive MSG_FINMETA -+ read block --- start sending trace data on child processes --- --- When client finishes sending trace data --- send MSG_CLOSE receive MSG_CLOSE ---+ close(socket fd)close(socket fd) How to set up 1. Run virt-server on a host before booting guests # trace-cmd virt-server 2. Make guest domain directory # mkdir -p /tmp/trace-cmd/virt/domain # chmod 710 /tmp/trace-cmd/virt/domain # chgrp qemu /tmp/trace-cmd/virt/domain 3. Make FIFO on the host # mkfifo /tmp/trace-cmd/virt/domain/trace-path-cpu{0,1,...,X}.{in,out} 4. Set up of virtio-serial pipe of a guest on the host Add the following tags to domain XML files. # virsh edit domain channel type='unix' source mode='connect' path='/tmp/trace-cmd/virt/agent-ctl-path'/ target type='virtio' name='agent-ctl-path'/ /channel channel type='pipe' source path='/tmp/trace-cmd/virt/domain/trace-path-cpu0'/ target type='virtio' name='trace-path-cpu0'/ /channel ... (cpu1, cpu2, ...) 5. Boot the guest # virsh start domain 6. Check I/F of virtio-serial on the guest # ls /dev/virtio-ports ... agent-ctl-path ... trace-path-cpu0 ... Next, the user will run trace-cmd with record --virt options or other options for virtualization on the guest. This patch adds only minimum features of virt-server as follows: Features - virt-server subcommand - Create I/F directory(/tmp/trace-cmd/virt/) - Use named pipe I/Fs of virtio-serial for trace data paths - Use UNIX domain socket for connecting clients on guests - Use splice(2) for collecting trace data of guests Restrictions - Use libvirt when we boot guests Changes in V4: Fix some typos and cleanup Changes in V3: Change _nw/_NW to _net/_NET Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com --- Documentation/trace-cmd-virt-server.1.txt | 89 ++ trace-cmd.c |3 trace-cmd.h |2 trace-listen.c| 467 - trace-msg.c | 106 ++- trace-recorder.c | 50 ++- trace-usage.c | 10 + 7 files changed, 624 insertions(+), 103
[PATCH V4 2/5] trace-cmd/msg: Use poll(2) to wait for a message
Use poll(2) to wait for a message. If a client/server cannot send a message for any reasons, the current server/client will wait in a blocking read operation. So, we use poll(2) for avoiding remaining in a blocking state. Changes in V4: Change the argument of tracecmd_msg_recv_wait() Fix some typos Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com --- trace-msg.c | 42 -- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/trace-msg.c b/trace-msg.c index 08fa2a6..db48365 100644 --- a/trace-msg.c +++ b/trace-msg.c @@ -395,6 +395,27 @@ error: return -ENOMSG; } +#define MSG_WAIT_MSEC 5000 + +/* + * A return value of 0 indicates time-out + */ +static int tracecmd_msg_recv_wait(int fd, struct tracecmd_msg *msg) +{ + struct pollfd pfd; + int ret; + + pfd.fd = fd; + pfd.events = POLLIN; + ret = poll(pfd, 1, MSG_WAIT_MSEC); + if (ret 0) + return -errno; + else if (ret == 0) + return -ETIMEDOUT; + + return tracecmd_msg_recv(fd, msg); +} + static void *tracecmd_msg_buf_access(struct tracecmd_msg *msg, int offset) { return (void *)msg + offset; @@ -405,9 +426,12 @@ static int tracecmd_msg_wait_for_msg(int fd, struct tracecmd_msg *msg) u32 cmd; int ret; - ret = tracecmd_msg_recv(fd, msg); - if (ret 0) + ret = tracecmd_msg_recv_wait(fd, msg); + if (ret 0) { + if (ret == -ETIMEDOUT) + warning(Connection timed out\n); return ret; + } cmd = ntohl(msg-cmd); if (cmd == MSG_CLOSE) @@ -487,9 +511,12 @@ int tracecmd_msg_initial_setting(int fd, int *cpus, int *pagesize) u32 cmd; msg = (struct tracecmd_msg *)buf; - ret = tracecmd_msg_recv(fd, msg); - if (ret 0) + ret = tracecmd_msg_recv_wait(fd, msg); + if (ret 0) { + if (ret == -ETIMEDOUT) + warning(Connection timed out\n); return ret; + } cmd = ntohl(msg-cmd); if (cmd != MSG_TINIT) { @@ -627,9 +654,12 @@ int tracecmd_msg_collect_metadata(int ifd, int ofd) msg = (struct tracecmd_msg *)buf; do { - ret = tracecmd_msg_recv(ifd, msg); + ret = tracecmd_msg_recv_wait(ifd, msg); if (ret 0) { - warning(reading client); + if (ret == -ETIMEDOUT) + warning(Connection timed out\n); + else + warning(reading client); return ret; } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCHV4 0/5] trace-cmd: Support the feature which guests send trace data via virtio
Hi Steven, This is a v4 patch set to support the feature which guests send trace data via virtio. (Previous patch set is here: https://lkml.org/lkml/2013/12/16/688) Any features in this V4 patch series are not changed from previous version. I fixed some typos, rebased for current version, and added usage in this version. Would you review this patch series? How to use 1. Run virt-server on a host # trace-cmd virt-server --dom guest1 -c 2 2. Set up of virtio-serial pipe of guest1 on the host Add the following tags to domain XML files. # virsh edit guest1 channel type='unix' source mode='connect' path='/tmp/trace-cmd/virt/agent-ctl-path'/ target type='virtio' name='agent-ctl-path'/ /channel channel type='pipe' source path='/tmp/trace-cmd/virt/guest1/trace-path-cpu0'/ target type='virtio' name='trace-path-cpu0'/ /channel channel type='pipe' source path='/tmp/trace-cmd/virt/guest1/trace-path-cpu1'/ target type='virtio' name='trace-path-cpu1'/ /channel 3. Boot the guest # virsh start guest1 4. Run the guest1's client(see trace-cmd-record(1) with the *--virt* option) # trace-cmd record -e sched* --virt If you want to boot another guest sends trace-data via virtio-serial, you will manually make the guest domain directory and trace data I/Fs. - Make guest domain directory on the host # mkdir -p /tmp/trace-cmd/virt/DOMAIN # chmod 710 /tmp/trace-cmd/virt/DOMAIN # chgrp qemu /tmp/trace-cmd/virt/DOMAIN - Make FIFO on the host # mkfifo /tmp/trace-cmd/virt/DOMAIN/trace-path-cpu{0,1,...,X}.{in,out} Result I measured CPU usage outputted by top command on a guest when client sends trace data. Client means record -N(NW) or record --virt(virtio-serial). NW virtio-serial(splice) client(fedora19)~2.9[%] ~1.7[%] Changes in V4: [1/5] Fix some typos, cleanup, and rebase for current trace-cmd-v2.4 Change the argument of tracecmd_msg_recv() [2/5] Fix some typos Change the argument of tracecmd_msg_recv_wait() [3/5] Fix some typos and cleanup [4/5] Introduce parse_args_virt() and add usage of virt-server in trace-usage.c [5/5] Rebase for current trace-cmd-v2.4 and add usage of --virt for record in trace-usage.c Divide tracecmd_msg_connect_to_server() into two functions (tracecmd_msg_connect_to_server() and tracecmd_msg_send_init_data_virt(fd)) Changes in V3: [2/6] Change the license of trace-msg.c to LGPL v2.1 [4/6] Change _nw/_NW to _net/_NET [5/6] Change _nw/_NW to _net/_NET [6/6] Add this patch based on Steven's review (https://lkml.org/lkml/2013/10/14/618) Changes in V2: [1/5] Add a comment in open_udp() [2/5] Regacy protocol support in order to keep backward compatibility Thank you, --- Yoshihiro YUNOMAE (5): trace-cmd/listen: Apply the trace-msg protocol for communication between a server and clients trace-cmd/msg: Use poll(2) to wait for a message trace-cmd/virt-server: Add virt-server mode for a virtualization environment trace-cmd/virt-server: Add --dom option which makes a domain directory to virt-server trace-cmd/record: Add --virt option for record mode Documentation/trace-cmd-record.1.txt | 11 Documentation/trace-cmd-virt-server.1.txt | 113 Makefile |2 trace-cmd.c |3 trace-cmd.h | 15 trace-listen.c| 717 +++- trace-msg.c | 873 + trace-msg.h | 31 + trace-output.c|4 trace-record.c| 146 - trace-recorder.c | 50 +- trace-usage.c | 18 + 12 files changed, 1818 insertions(+), 165 deletions(-) create mode 100644 Documentation/trace-cmd-virt-server.1.txt create mode 100644 trace-msg.c create mode 100644 trace-msg.h -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[ PATCH 0/2] [BUGFIX] trace-cmd: Fix two small bugs
Hi Steven, I found two small bugs for current trace-cmd, so I fixed those. 1st patch fixes the problem which listen server reader processes abort silently. 2nd patch fixes the problem which trace-cmd cannot record trace data of multiple buffers in old kernels. Thank you, --- Yoshihiro YUNOMAE (2): trace-cmd: [BUGFIX] Initialize handle->options list in tracecmd_attach_cpu_data_fd() trace-cmd: [BUGFIX] Don't die if an instance does not have 'current_tracer' file trace-output.c |1 + trace-record.c | 12 +++- 2 files changed, 12 insertions(+), 1 deletion(-) -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/2] trace-cmd: [BUGFIX] Initialize handle->options list in tracecmd_attach_cpu_data_fd()
This patch initializes handle->options list in tracecmd_attach_cpu_data_fd(). When recorder sends trace data via network, server recording process is killed by SIGSEGV from the patch 71484a0854f7. This is because add_options() uses handle->options list from the patch, but tracecmd_attach_cpu_data_fd() calling add_options() does not initialize the list in spite of allocation of new handle. As the result, the server recording process will be killed because handle->options is cleared to zero in tracecmd_attach_cpu_data_fd(). 1. Execute network(listen) server # trace-cmd listen -p 12345 2. Execute network client # trace-cmd record -e sched* -N :12345 3. Stop the record on client ^C Here, network server should output a line "CPUX data recorded at offset=", but current network server aborts silently. Moreover the client's per-cpu files are separated. (Normally those files are merged into one trace file.) 4. Confirm error on network server # dmesg | tail -1 [18551.537113] trace-cmd[23073]: segfault at ffe8 ip 00432fd1 sp 7fa4caa0 error 5 in trace-cmd[40+47000] After we would introduce this patch, the server will be fully able to output the client's tracing data and we will not get this error. Signed-off-by: Yoshihiro YUNOMAE Cc: Steven Rostedt --- trace-output.c |1 + 1 file changed, 1 insertion(+) diff --git a/trace-output.c b/trace-output.c index ed81466..b033baa 100644 --- a/trace-output.c +++ b/trace-output.c @@ -1202,6 +1202,7 @@ int tracecmd_attach_cpu_data_fd(int fd, int cpus, char * const *cpu_data_files) handle->pevent = tracecmd_get_pevent(ihandle); pevent_ref(pevent); handle->page_size = tracecmd_page_size(ihandle); + list_head_init(>options); if (tracecmd_append_cpu_data(handle, cpus, cpu_data_files) >= 0) ret = 0; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/2] trace-cmd: [BUGFIX] Don't die if an instance does not have 'current_tracer' file
Current trace-cmd requires 'current_tracer' file for an instance, and if the file is nothing, trace-cmd dies. However, current_tracer file was introduced from 607e2ea167e patch in Linux kernel 3.14-rc3, so current trace-cmd cannot use multiple buffers for old kernels. This patch avoids to die if current_tracer file is nothing in an instance and the plugin name is "nop". This is because old kernels always trace as nop mode in an instance. 1) # ./trace-cmd record -B foo -e sched Before introducing this patch, following error message is output in an old kernel: trace-cmd: Permission denied writing to '/sys/kernel/debug/tracing/instances/foo/current_tracer' trace-cmd dies in disable_trace() calling set_plugin("nop"). After introducing this patch, trace-cmd works fine in both old kernels and current kernel. 2) # ./trace-cmd record -B foo -e sched -p nop It also works fine after introducing this patch in both old kernels and current kernel. 3) # ./trace-cmd record -B foo -e sched -p function For old kernels, it dies because an user should not set plugin tracer. For current kernel, it works fine. Note that this patch was tested for kernel 3.11.9-200 and 3.15.0-rc2+. Signed-off-by: Yoshihiro YUNOMAE Cc: Steven Rostedt --- trace-record.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/trace-record.c b/trace-record.c index d3dd0c5..1912175 100644 --- a/trace-record.c +++ b/trace-record.c @@ -890,8 +890,18 @@ set_plugin_instance(struct buffer_instance *instance, const char *name) path = get_instance_file(instance, "current_tracer"); fp = fopen(path, "w"); - if (!fp) + if (!fp) { + /* +* Legacy kernels do not have current_tracer file, and they +* always use nop. So, it doesn't need to try to change the +* plugin for those if name is "nop". +*/ + if (!strncmp(name, "nop", 3)) { + tracecmd_put_tracing_file(path); + return; + } die("writing to '%s'", path); + } tracecmd_put_tracing_file(path); fwrite(name, 1, strlen(name), fp); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/2] trace-cmd: [BUGFIX] Initialize handle-options list in tracecmd_attach_cpu_data_fd()
This patch initializes handle-options list in tracecmd_attach_cpu_data_fd(). When recorder sends trace data via network, server recording process is killed by SIGSEGV from the patch 71484a0854f7. This is because add_options() uses handle-options list from the patch, but tracecmd_attach_cpu_data_fd() calling add_options() does not initialize the list in spite of allocation of new handle. As the result, the server recording process will be killed because handle-options is cleared to zero in tracecmd_attach_cpu_data_fd(). How to test 1. Execute network(listen) server # trace-cmd listen -p 12345 2. Execute network client # trace-cmd record -e sched* -N server IP:12345 3. Stop the record on client ^C Here, network server should output a line CPUX data recorded at offset=, but current network server aborts silently. Moreover the client's per-cpu files are separated. (Normally those files are merged into one trace file.) 4. Confirm error on network server # dmesg | tail -1 [18551.537113] trace-cmd[23073]: segfault at ffe8 ip 00432fd1 sp 7fa4caa0 error 5 in trace-cmd[40+47000] After we would introduce this patch, the server will be fully able to output the client's tracing data and we will not get this error. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Steven Rostedt rost...@goodmis.org --- trace-output.c |1 + 1 file changed, 1 insertion(+) diff --git a/trace-output.c b/trace-output.c index ed81466..b033baa 100644 --- a/trace-output.c +++ b/trace-output.c @@ -1202,6 +1202,7 @@ int tracecmd_attach_cpu_data_fd(int fd, int cpus, char * const *cpu_data_files) handle-pevent = tracecmd_get_pevent(ihandle); pevent_ref(pevent); handle-page_size = tracecmd_page_size(ihandle); + list_head_init(handle-options); if (tracecmd_append_cpu_data(handle, cpus, cpu_data_files) = 0) ret = 0; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/2] trace-cmd: [BUGFIX] Don't die if an instance does not have 'current_tracer' file
Current trace-cmd requires 'current_tracer' file for an instance, and if the file is nothing, trace-cmd dies. However, current_tracer file was introduced from 607e2ea167e patch in Linux kernel 3.14-rc3, so current trace-cmd cannot use multiple buffers for old kernels. This patch avoids to die if current_tracer file is nothing in an instance and the plugin name is nop. This is because old kernels always trace as nop mode in an instance. How to test 1) # ./trace-cmd record -B foo -e sched Before introducing this patch, following error message is output in an old kernel: trace-cmd: Permission denied writing to '/sys/kernel/debug/tracing/instances/foo/current_tracer' trace-cmd dies in disable_trace() calling set_plugin(nop). After introducing this patch, trace-cmd works fine in both old kernels and current kernel. 2) # ./trace-cmd record -B foo -e sched -p nop It also works fine after introducing this patch in both old kernels and current kernel. 3) # ./trace-cmd record -B foo -e sched -p function For old kernels, it dies because an user should not set plugin tracer. For current kernel, it works fine. Note that this patch was tested for kernel 3.11.9-200 and 3.15.0-rc2+. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Steven Rostedt rost...@goodmis.org --- trace-record.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/trace-record.c b/trace-record.c index d3dd0c5..1912175 100644 --- a/trace-record.c +++ b/trace-record.c @@ -890,8 +890,18 @@ set_plugin_instance(struct buffer_instance *instance, const char *name) path = get_instance_file(instance, current_tracer); fp = fopen(path, w); - if (!fp) + if (!fp) { + /* +* Legacy kernels do not have current_tracer file, and they +* always use nop. So, it doesn't need to try to change the +* plugin for those if name is nop. +*/ + if (!strncmp(name, nop, 3)) { + tracecmd_put_tracing_file(path); + return; + } die(writing to '%s', path); + } tracecmd_put_tracing_file(path); fwrite(name, 1, strlen(name), fp); -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[ PATCH 0/2] [BUGFIX] trace-cmd: Fix two small bugs
Hi Steven, I found two small bugs for current trace-cmd, so I fixed those. 1st patch fixes the problem which listen server reader processes abort silently. 2nd patch fixes the problem which trace-cmd cannot record trace data of multiple buffers in old kernels. Thank you, --- Yoshihiro YUNOMAE (2): trace-cmd: [BUGFIX] Initialize handle-options list in tracecmd_attach_cpu_data_fd() trace-cmd: [BUGFIX] Don't die if an instance does not have 'current_tracer' file trace-output.c |1 + trace-record.c | 12 +++- 2 files changed, 12 insertions(+), 1 deletion(-) -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RESEND PATCH V8 0/2] serial/uart/8250: Introduce tunable RX trigger I/F
Hi Greg, This patch set introduces tunable RX interrupt trigger I/F for 8250 serials. I just split V7's patch up into 2 patches, and all functions are not changed from previous version. V6 patch was reviewed by Stephen Warren and acked, but I removed the 'Reviewed-by' for this patch set just in case. Would you review this patch set? Thanks! Changes in V8: - Split V7's patch up into 2 patches Changes in V7: - Add Documentation - Change I/F name from rx_int_trig to rx_trig_bytes because the name rx_int_trig is hard to understand how users specify the value Changes in V6: - Move FCR_RX_TRIG_* definition in 8250.h to include/uapi/linux/serial_reg.h, rename those to UART_FCR_R_TRIG_*, and use UART_FCR_TRIGGER_MASK to UART_FCR_R_TRIG_BITS() - Change following function names: convert_fcr2val() => fcr_get_rxtrig_bytes() convert_val2rxtrig() => bytes_to_fcr_rxtrig() - Fix typo in serial8250_do_set_termios() - Delete the verbose error message pr_info() in bytes_to_fcr_rxtrig() - Rename *rx_int_trig/rx_trig* to *rxtrig* for several functions or variables (but UI remains rx_int_trig) - Change the meaningless variable name 'val' to 'bytes' following functions: fcr_get_rxtrig_bytes(), bytes_to_fcr_rxtrig(), do_set_rxtrig(), do_serial8250_set_rxtrig(), and serial8250_set_attr_rxtrig() - Use up->fcr in order to get rxtrig_bytes instead of rx_trig_raw in fcr_get_rxtrig_bytes() - Use conf_type->rxtrig_bytes[0] instead of switch statement for support check in register_dev_spec_attr_grp() - Delete the checking whether a user changed FCR or not when minimum buffer is needed in serial8250_do_set_termios() Changes in V5.1: - Fix FCR_RX_TRIG_MAX_STATE definition Changes in V5: - Support Tegra, 16650V2, 16654, and 16750 - Store default FCR value to up->fcr when the port is first created - Add rx_trig_byte[] in uart_config[] for each device and use rx_trig_byte[] in convert_fcr2val() and convert_val2rxtrig() Changes in V4: - Introduce fifo_bug flag in uart_8250_port structure This is enabled only when parity is enabled and UART_BUG_PARITY is enabled for up->bugs. If this flag is enabled, user cannot set RX trigger. - Return -EOPNOTSUPP when it does not support device at convert_fcr2val() and at convert_val2rxtrig() - Set the nearest lower RX trigger when users input a meaningless value at convert_val2rxtrig() - Check whether p->fcr is existing at serial8250_clear_and_reinit_fifos() - Set fcr = up->fcr in the begging of serial8250_do_set_termios() Changes in V3: - Change I/F from ioctl(2) to sysfs(rx_int_trig) Changed in V2: - Use _IOW for TIOCSFIFORTRIG definition - Pass the interrupt trigger value itself --- Yoshihiro YUNOMAE (2): serial/uart: Introduce device specific attribute group to uart_port structure serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers Documentation/ABI/testing/sysfs-tty | 16 +++ drivers/tty/serial/8250/8250.h |2 drivers/tty/serial/8250/8250_core.c | 173 --- drivers/tty/serial/serial_core.c| 18 ++-- include/linux/serial_8250.h |2 include/linux/serial_core.h |4 + include/uapi/linux/serial_reg.h |5 + 7 files changed, 198 insertions(+), 22 deletions(-) -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RESEND PATCH V8 2/2] serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers
Add tunable RX interrupt trigger I/F of FIFO buffers. Serial devices are used as not only message communication devices but control or sending communication devices. For the latter uses, normally small data will be exchanged, so user applications want to receive data unit as soon as possible for real-time tendency. If we have a sensor which sends a 1 byte data each time and must control a device based on the sensor feedback, the RX interrupt should be triggered for each data. According to HW specification of serial UART devices, RX interrupt trigger can be changed, but the trigger is hard-coded. For example, RX interrupt trigger in 16550A can be set to 1, 4, 8, or 14 bytes for HW, but current driver sets the trigger to only 8bytes. This patch makes some devices change RX interrupt trigger from userland. - Read current setting # cat /sys/class/tty/ttyS0/rx_trig_bytes 8 - Write user setting # echo 1 > /sys/class/tty/ttyS0/rx_trig_bytes # cat /sys/class/tty/ttyS0/rx_trig_bytes 1 - 16550A and Tegra (1, 4, 8, or 14 bytes) - 16650V2 (8, 16, 24, or 28 bytes) - 16654 (8, 16, 56, or 60 bytes) - 16750 (1, 16, 32, or 56 bytes) Changes in V8: - Divide this patch from V7's patch based on Greg's comment Changes in V7: - Add Documentation - Change I/F name from rx_int_trig to rx_trig_bytes because the name rx_int_trig is hard to understand how users specify the value Changes in V6: - Move FCR_RX_TRIG_* definition in 8250.h to include/uapi/linux/serial_reg.h, rename those to UART_FCR_R_TRIG_*, and use UART_FCR_TRIGGER_MASK to UART_FCR_R_TRIG_BITS() - Change following function names: convert_fcr2val() => fcr_get_rxtrig_bytes() convert_val2rxtrig() => bytes_to_fcr_rxtrig() - Fix typo in serial8250_do_set_termios() - Delete the verbose error message pr_info() in bytes_to_fcr_rxtrig() - Rename *rx_int_trig/rx_trig* to *rxtrig* for several functions or variables (but UI remains rx_int_trig) - Change the meaningless variable name 'val' to 'bytes' following functions: fcr_get_rxtrig_bytes(), bytes_to_fcr_rxtrig(), do_set_rxtrig(), do_serial8250_set_rxtrig(), and serial8250_set_attr_rxtrig() - Use up->fcr in order to get rxtrig_bytes instead of rx_trig_raw in fcr_get_rxtrig_bytes() - Use conf_type->rxtrig_bytes[0] instead of switch statement for support check in register_dev_spec_attr_grp() - Delete the checking whether a user changed FCR or not when minimum buffer is needed in serial8250_do_set_termios() Changes in V5.1: - Fix FCR_RX_TRIG_MAX_STATE definition Changes in V5: - Support Tegra, 16650V2, 16654, and 16750 - Store default FCR value to up->fcr when the port is first created - Add rx_trig_byte[] in uart_config[] for each device and use rx_trig_byte[] in convert_fcr2val() and convert_val2rxtrig() Changes in V4: - Introduce fifo_bug flag in uart_8250_port structure This is enabled only when parity is enabled and UART_BUG_PARITY is enabled for up->bugs. If this flag is enabled, user cannot set RX trigger. - Return -EOPNOTSUPP when it does not support device at convert_fcr2val() and at convert_val2rxtrig() - Set the nearest lower RX trigger when users input a meaningless value at convert_val2rxtrig() - Check whether p->fcr is existing at serial8250_clear_and_reinit_fifos() - Set fcr = up->fcr in the begging of serial8250_do_set_termios() Changes in V3: - Change I/F from ioctl(2) to sysfs(rx_int_trig) Changed in V2: - Use _IOW for TIOCSFIFORTRIG definition - Pass the interrupt trigger value itself Signed-off-by: Yoshihiro YUNOMAE --- Documentation/ABI/testing/sysfs-tty | 16 +++ drivers/tty/serial/8250/8250.h |2 drivers/tty/serial/8250/8250_core.c | 173 --- include/linux/serial_8250.h |2 include/uapi/linux/serial_reg.h |5 + 5 files changed, 183 insertions(+), 15 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-tty b/Documentation/ABI/testing/sysfs-tty index ad22fb0..9eb3c2b 100644 --- a/Documentation/ABI/testing/sysfs-tty +++ b/Documentation/ABI/testing/sysfs-tty @@ -138,3 +138,19 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. + +What: /sys/class/tty/ttyS0/rx_trig_bytes +Date: May 2014 +Contact: Yoshihiro YUNOMAE +Description: +Shows current RX interrupt trigger bytes or sets the +user specified value to change it for the FIFO buffer. +Users can show or set this value regardless of opening the +serial device file or not. + +The RX trigger can be set one of four kinds of values for UART +serials. When users input a meaning less value to this I/F, +the RX trigger is changed to the nearest lower value for the +device specification. For example, when user sets 7bytes on +
[RESEND PATCH V8 1/2] serial/uart: Introduce device specific attribute group to uart_port structure
Current serial device driver has the common sysfs I/F for all serial devices, but it does not have device specific sysfs I/F. To make device specific sysfs I/F, this patch introduces device specific attribute group to uart_port structure. Changes in V8: - Divide this patch from V7's patch based on Greg's comment Signed-off-by: Yoshihiro YUNOMAE --- drivers/tty/serial/serial_core.c | 18 +++--- include/linux/serial_core.h |4 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index fbf6c5a..ed6ec1c 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2559,15 +2559,16 @@ static struct attribute *tty_dev_attrs[] = { NULL, }; -static const struct attribute_group tty_dev_attr_group = { +static struct attribute_group tty_dev_attr_group = { .attrs = tty_dev_attrs, }; -static const struct attribute_group *tty_dev_attr_groups[] = { - _dev_attr_group, - NULL - }; - +static void make_uport_attr_grps(struct uart_port *uport) +{ + uport->attr_grps[0] = _dev_attr_group; + if (uport->dev_spec_attr_group) + uport->attr_grps[1] = uport->dev_spec_attr_group; +} /** * uart_add_one_port - attach a driver-defined port structure @@ -2618,12 +2619,15 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport) uart_configure_port(drv, state, uport); + make_uport_attr_grps(uport); + /* * Register the port whether it's detected or not. This allows * setserial to be used to alter this port's parameters. */ tty_dev = tty_port_register_device_attr(port, drv->tty_driver, - uport->line, uport->dev, port, tty_dev_attr_groups); + uport->line, uport->dev, port, + (const struct attribute_group **)uport->attr_grps); if (likely(!IS_ERR(tty_dev))) { device_set_wakeup_capable(tty_dev, 1); } else { diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 5bbb809..3b20c17 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -113,6 +113,8 @@ struct uart_icount { typedef unsigned int __bitwise__ upf_t; +#define MAX_ATTR_GRPS 3 + struct uart_port { spinlock_t lock; /* port lock */ unsigned long iobase; /* in/out[bwl] */ @@ -195,6 +197,8 @@ struct uart_port { unsigned intline; /* port index */ resource_size_t mapbase;/* for ioremap */ struct device *dev; /* parent device */ + struct attribute_group *dev_spec_attr_group; /* specific attribute */ + struct attribute_group *attr_grps[MAX_ATTR_GRPS];/* all attr. groups */ unsigned char hub6; /* this should be in the 8250 driver */ unsigned char suspended; unsigned char irq_wake; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [tracing] 939c7a4f04f: -46.4% cpuidle.C3-IVT.time
Hi Jet, Thank you for your report. I have some questions for your test. 1. Did you enable ftrace? This patch added a feature for ftrace. If you disabled ftrace in this test, my patch will not affect the system. Moreover, in my patch, arrays for saved_cmdlines were just changed from using static global variables to using kmalloc() on default setting. So, even if you enabled ftrace, this patch will not induce a big problem, I think. 2. How did you test it and what does the result mean? Please tell me the workload, how to calculate the score, system settings, etc... Thanks, Yoshihiro YUNOMAE (2014/06/18 12:15), Jet Chen wrote: Hi Yoshihiro, FYI, we noticed the below changes on commit 939c7a4f04fcd2162109744e8bf88194948a6e65 ("tracing: Introduce saved_cmdlines_size file") test case: brickland3/aim7/3000-brk_test beba4bb096201ce 939c7a4f04fcd2162109744e8 --- - 352643 ~40% -46.4% 189136 ~15% TOTAL cpuidle.C3-IVT.time 750 ~ 2% -13.3%650 ~ 2% TOTAL vmstat.procs.b 362016 ~ 3% -6.0% 340296 ~ 3% TOTAL proc-vmstat.pgmigrate_success 362016 ~ 3% -6.0% 340296 ~ 3% TOTAL proc-vmstat.numa_pages_migrated 1642328 ~ 3% +13.3%1860721 ~ 2% TOTAL softirqs.RCU 2278829 ~ 2% -14.0%1959647 ~ 2% TOTAL time.voluntary_context_switches 207 ~ 0% -10.4%185 ~ 0% TOTAL time.user_time ~ 0% +8.5%~ 0% TOTAL turbostat.RAM_W 4418246 ~ 3% -6.4%4136447 ~ 1% TOTAL time.minor_page_faults ~ 0% +3.4%~ 0% TOTAL turbostat.Cor_W ~ 0% +3.0%~ 0% TOTAL turbostat.Pkg_W 11354889 ~ 0% +2.0% 11579897 ~ 0% TOTAL time.involuntary_context_switches Legend: ~XX%- stddev percent [+-]XX% - change percent time.voluntary_context_switches 2.4e+06 ++---*+ *.. *.... .. | 2.3e+06 ++ .*.. *.. .. * | | *..*.. .*.. .. * *.. + *.. *..* |*.* . .*..*.. + .. | 2.2e+06 ++ *..*. * * | | | 2.1e+06 ++| | | 2e+06 O+ O O O | | O O O O| |O O O O O | 1.9e+06 ++ O O O O| |O O O | 1.8e+06 +++ turbostat.Pkg_W +++ O+ O O O OO| | O O O O O O O O O O O O | ++ O O | ++| ++| ++| | | ++| ++| ++*.. .*.. | *+.*... .. *...*.*...*..*..*...*..*.. ..*.. *...*..*..*...*..* | * *. .. | ++* | +++ turbostat.Cor_W +++ O+ O O O O O OO O O | | O O O O O O O
Re: [tracing] 939c7a4f04f: -46.4% cpuidle.C3-IVT.time
Hi Jet, Thank you for your report. I have some questions for your test. 1. Did you enable ftrace? This patch added a feature for ftrace. If you disabled ftrace in this test, my patch will not affect the system. Moreover, in my patch, arrays for saved_cmdlines were just changed from using static global variables to using kmalloc() on default setting. So, even if you enabled ftrace, this patch will not induce a big problem, I think. 2. How did you test it and what does the result mean? Please tell me the workload, how to calculate the score, system settings, etc... Thanks, Yoshihiro YUNOMAE (2014/06/18 12:15), Jet Chen wrote: Hi Yoshihiro, FYI, we noticed the below changes on commit 939c7a4f04fcd2162109744e8bf88194948a6e65 (tracing: Introduce saved_cmdlines_size file) test case: brickland3/aim7/3000-brk_test beba4bb096201ce 939c7a4f04fcd2162109744e8 --- - 352643 ~40% -46.4% 189136 ~15% TOTAL cpuidle.C3-IVT.time 750 ~ 2% -13.3%650 ~ 2% TOTAL vmstat.procs.b 362016 ~ 3% -6.0% 340296 ~ 3% TOTAL proc-vmstat.pgmigrate_success 362016 ~ 3% -6.0% 340296 ~ 3% TOTAL proc-vmstat.numa_pages_migrated 1642328 ~ 3% +13.3%1860721 ~ 2% TOTAL softirqs.RCU 2278829 ~ 2% -14.0%1959647 ~ 2% TOTAL time.voluntary_context_switches 207 ~ 0% -10.4%185 ~ 0% TOTAL time.user_time ~ 0% +8.5%~ 0% TOTAL turbostat.RAM_W 4418246 ~ 3% -6.4%4136447 ~ 1% TOTAL time.minor_page_faults ~ 0% +3.4%~ 0% TOTAL turbostat.Cor_W ~ 0% +3.0%~ 0% TOTAL turbostat.Pkg_W 11354889 ~ 0% +2.0% 11579897 ~ 0% TOTAL time.involuntary_context_switches Legend: ~XX%- stddev percent [+-]XX% - change percent time.voluntary_context_switches 2.4e+06 ++---*+ *.. *.... .. | 2.3e+06 ++ .*.. *.. .. * | | *..*.. .*.. .. * *.. + *.. *..* |*.* . .*..*.. + .. | 2.2e+06 ++ *..*. * * | | | 2.1e+06 ++| | | 2e+06 O+ O O O | | O O O O| |O O O O O | 1.9e+06 ++ O O O O| |O O O | 1.8e+06 +++ turbostat.Pkg_W +++ O+ O O O OO| | O O O O O O O O O O O O | ++ O O | ++| ++| ++| | | ++| ++| ++*.. .*.. | *+.*... .. *...*.*...*..*..*...*..*.. ..*.. *...*..*..*...*..* | * *. .. | ++* | +++ turbostat.Cor_W +++ O+ O O O O O OO O O | | O O O O O O O O O O
[RESEND PATCH V8 1/2] serial/uart: Introduce device specific attribute group to uart_port structure
Current serial device driver has the common sysfs I/F for all serial devices, but it does not have device specific sysfs I/F. To make device specific sysfs I/F, this patch introduces device specific attribute group to uart_port structure. Changes in V8: - Divide this patch from V7's patch based on Greg's comment Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com --- drivers/tty/serial/serial_core.c | 18 +++--- include/linux/serial_core.h |4 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index fbf6c5a..ed6ec1c 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2559,15 +2559,16 @@ static struct attribute *tty_dev_attrs[] = { NULL, }; -static const struct attribute_group tty_dev_attr_group = { +static struct attribute_group tty_dev_attr_group = { .attrs = tty_dev_attrs, }; -static const struct attribute_group *tty_dev_attr_groups[] = { - tty_dev_attr_group, - NULL - }; - +static void make_uport_attr_grps(struct uart_port *uport) +{ + uport-attr_grps[0] = tty_dev_attr_group; + if (uport-dev_spec_attr_group) + uport-attr_grps[1] = uport-dev_spec_attr_group; +} /** * uart_add_one_port - attach a driver-defined port structure @@ -2618,12 +2619,15 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport) uart_configure_port(drv, state, uport); + make_uport_attr_grps(uport); + /* * Register the port whether it's detected or not. This allows * setserial to be used to alter this port's parameters. */ tty_dev = tty_port_register_device_attr(port, drv-tty_driver, - uport-line, uport-dev, port, tty_dev_attr_groups); + uport-line, uport-dev, port, + (const struct attribute_group **)uport-attr_grps); if (likely(!IS_ERR(tty_dev))) { device_set_wakeup_capable(tty_dev, 1); } else { diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 5bbb809..3b20c17 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -113,6 +113,8 @@ struct uart_icount { typedef unsigned int __bitwise__ upf_t; +#define MAX_ATTR_GRPS 3 + struct uart_port { spinlock_t lock; /* port lock */ unsigned long iobase; /* in/out[bwl] */ @@ -195,6 +197,8 @@ struct uart_port { unsigned intline; /* port index */ resource_size_t mapbase;/* for ioremap */ struct device *dev; /* parent device */ + struct attribute_group *dev_spec_attr_group; /* specific attribute */ + struct attribute_group *attr_grps[MAX_ATTR_GRPS];/* all attr. groups */ unsigned char hub6; /* this should be in the 8250 driver */ unsigned char suspended; unsigned char irq_wake; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RESEND PATCH V8 2/2] serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers
Add tunable RX interrupt trigger I/F of FIFO buffers. Serial devices are used as not only message communication devices but control or sending communication devices. For the latter uses, normally small data will be exchanged, so user applications want to receive data unit as soon as possible for real-time tendency. If we have a sensor which sends a 1 byte data each time and must control a device based on the sensor feedback, the RX interrupt should be triggered for each data. According to HW specification of serial UART devices, RX interrupt trigger can be changed, but the trigger is hard-coded. For example, RX interrupt trigger in 16550A can be set to 1, 4, 8, or 14 bytes for HW, but current driver sets the trigger to only 8bytes. This patch makes some devices change RX interrupt trigger from userland. How to use - Read current setting # cat /sys/class/tty/ttyS0/rx_trig_bytes 8 - Write user setting # echo 1 /sys/class/tty/ttyS0/rx_trig_bytes # cat /sys/class/tty/ttyS0/rx_trig_bytes 1 Support uart devices - 16550A and Tegra (1, 4, 8, or 14 bytes) - 16650V2 (8, 16, 24, or 28 bytes) - 16654 (8, 16, 56, or 60 bytes) - 16750 (1, 16, 32, or 56 bytes) Change log Changes in V8: - Divide this patch from V7's patch based on Greg's comment Changes in V7: - Add Documentation - Change I/F name from rx_int_trig to rx_trig_bytes because the name rx_int_trig is hard to understand how users specify the value Changes in V6: - Move FCR_RX_TRIG_* definition in 8250.h to include/uapi/linux/serial_reg.h, rename those to UART_FCR_R_TRIG_*, and use UART_FCR_TRIGGER_MASK to UART_FCR_R_TRIG_BITS() - Change following function names: convert_fcr2val() = fcr_get_rxtrig_bytes() convert_val2rxtrig() = bytes_to_fcr_rxtrig() - Fix typo in serial8250_do_set_termios() - Delete the verbose error message pr_info() in bytes_to_fcr_rxtrig() - Rename *rx_int_trig/rx_trig* to *rxtrig* for several functions or variables (but UI remains rx_int_trig) - Change the meaningless variable name 'val' to 'bytes' following functions: fcr_get_rxtrig_bytes(), bytes_to_fcr_rxtrig(), do_set_rxtrig(), do_serial8250_set_rxtrig(), and serial8250_set_attr_rxtrig() - Use up-fcr in order to get rxtrig_bytes instead of rx_trig_raw in fcr_get_rxtrig_bytes() - Use conf_type-rxtrig_bytes[0] instead of switch statement for support check in register_dev_spec_attr_grp() - Delete the checking whether a user changed FCR or not when minimum buffer is needed in serial8250_do_set_termios() Changes in V5.1: - Fix FCR_RX_TRIG_MAX_STATE definition Changes in V5: - Support Tegra, 16650V2, 16654, and 16750 - Store default FCR value to up-fcr when the port is first created - Add rx_trig_byte[] in uart_config[] for each device and use rx_trig_byte[] in convert_fcr2val() and convert_val2rxtrig() Changes in V4: - Introduce fifo_bug flag in uart_8250_port structure This is enabled only when parity is enabled and UART_BUG_PARITY is enabled for up-bugs. If this flag is enabled, user cannot set RX trigger. - Return -EOPNOTSUPP when it does not support device at convert_fcr2val() and at convert_val2rxtrig() - Set the nearest lower RX trigger when users input a meaningless value at convert_val2rxtrig() - Check whether p-fcr is existing at serial8250_clear_and_reinit_fifos() - Set fcr = up-fcr in the begging of serial8250_do_set_termios() Changes in V3: - Change I/F from ioctl(2) to sysfs(rx_int_trig) Changed in V2: - Use _IOW for TIOCSFIFORTRIG definition - Pass the interrupt trigger value itself Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com --- Documentation/ABI/testing/sysfs-tty | 16 +++ drivers/tty/serial/8250/8250.h |2 drivers/tty/serial/8250/8250_core.c | 173 --- include/linux/serial_8250.h |2 include/uapi/linux/serial_reg.h |5 + 5 files changed, 183 insertions(+), 15 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-tty b/Documentation/ABI/testing/sysfs-tty index ad22fb0..9eb3c2b 100644 --- a/Documentation/ABI/testing/sysfs-tty +++ b/Documentation/ABI/testing/sysfs-tty @@ -138,3 +138,19 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. + +What: /sys/class/tty/ttyS0/rx_trig_bytes +Date: May 2014 +Contact: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com +Description: +Shows current RX interrupt trigger bytes or sets the +user specified value to change it for the FIFO buffer. +Users can show or set this value regardless of opening the +serial device file or not. + +The RX trigger can be set one of four kinds of values for UART +serials. When users input a meaning less value to this I/F, +the RX trigger is changed to the nearest lower value for the +device
[RESEND PATCH V8 0/2] serial/uart/8250: Introduce tunable RX trigger I/F
Hi Greg, This patch set introduces tunable RX interrupt trigger I/F for 8250 serials. I just split V7's patch up into 2 patches, and all functions are not changed from previous version. V6 patch was reviewed by Stephen Warren and acked, but I removed the 'Reviewed-by' for this patch set just in case. Would you review this patch set? Thanks! Change log Changes in V8: - Split V7's patch up into 2 patches Changes in V7: - Add Documentation - Change I/F name from rx_int_trig to rx_trig_bytes because the name rx_int_trig is hard to understand how users specify the value Changes in V6: - Move FCR_RX_TRIG_* definition in 8250.h to include/uapi/linux/serial_reg.h, rename those to UART_FCR_R_TRIG_*, and use UART_FCR_TRIGGER_MASK to UART_FCR_R_TRIG_BITS() - Change following function names: convert_fcr2val() = fcr_get_rxtrig_bytes() convert_val2rxtrig() = bytes_to_fcr_rxtrig() - Fix typo in serial8250_do_set_termios() - Delete the verbose error message pr_info() in bytes_to_fcr_rxtrig() - Rename *rx_int_trig/rx_trig* to *rxtrig* for several functions or variables (but UI remains rx_int_trig) - Change the meaningless variable name 'val' to 'bytes' following functions: fcr_get_rxtrig_bytes(), bytes_to_fcr_rxtrig(), do_set_rxtrig(), do_serial8250_set_rxtrig(), and serial8250_set_attr_rxtrig() - Use up-fcr in order to get rxtrig_bytes instead of rx_trig_raw in fcr_get_rxtrig_bytes() - Use conf_type-rxtrig_bytes[0] instead of switch statement for support check in register_dev_spec_attr_grp() - Delete the checking whether a user changed FCR or not when minimum buffer is needed in serial8250_do_set_termios() Changes in V5.1: - Fix FCR_RX_TRIG_MAX_STATE definition Changes in V5: - Support Tegra, 16650V2, 16654, and 16750 - Store default FCR value to up-fcr when the port is first created - Add rx_trig_byte[] in uart_config[] for each device and use rx_trig_byte[] in convert_fcr2val() and convert_val2rxtrig() Changes in V4: - Introduce fifo_bug flag in uart_8250_port structure This is enabled only when parity is enabled and UART_BUG_PARITY is enabled for up-bugs. If this flag is enabled, user cannot set RX trigger. - Return -EOPNOTSUPP when it does not support device at convert_fcr2val() and at convert_val2rxtrig() - Set the nearest lower RX trigger when users input a meaningless value at convert_val2rxtrig() - Check whether p-fcr is existing at serial8250_clear_and_reinit_fifos() - Set fcr = up-fcr in the begging of serial8250_do_set_termios() Changes in V3: - Change I/F from ioctl(2) to sysfs(rx_int_trig) Changed in V2: - Use _IOW for TIOCSFIFORTRIG definition - Pass the interrupt trigger value itself --- Yoshihiro YUNOMAE (2): serial/uart: Introduce device specific attribute group to uart_port structure serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers Documentation/ABI/testing/sysfs-tty | 16 +++ drivers/tty/serial/8250/8250.h |2 drivers/tty/serial/8250/8250_core.c | 173 --- drivers/tty/serial/serial_core.c| 18 ++-- include/linux/serial_8250.h |2 include/linux/serial_core.h |4 + include/uapi/linux/serial_reg.h |5 + 7 files changed, 198 insertions(+), 22 deletions(-) -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH ftrace/core] tracing: Remove return value in event_trace_self_tests() when top_trace_array() returns NULL
Hi Steven, Thank you for applying my patches. I received build warning report from kbuild test bot, so I fixed it. Would you apply this patch? Thank you, Yoshihiro YUNOMAE (2014/06/06 15:28), Yoshihiro YUNOMAE wrote: Remove return value in event_trace_self_tests() when top_trace_array() returns NULL because event_trace_self_tests() is void type. Signed-off-by: Yoshihiro YUNOMAE Cc: Steven Rostedt Cc: Ingo Molnar Cc: linux-kernel@vger.kernel.org --- kernel/trace/trace_events.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 1349870..f99e0b3 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2547,7 +2547,7 @@ static __init void event_trace_self_tests(void) tr = top_trace_array(); if (!tr) - return -ENODEV; + return; pr_info("Running tests on trace events:\n"); -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH ftrace/core] tracing: Remove return value in event_trace_self_tests() when top_trace_array() returns NULL
Remove return value in event_trace_self_tests() when top_trace_array() returns NULL because event_trace_self_tests() is void type. Signed-off-by: Yoshihiro YUNOMAE Cc: Steven Rostedt Cc: Ingo Molnar Cc: linux-kernel@vger.kernel.org --- kernel/trace/trace_events.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 1349870..f99e0b3 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2547,7 +2547,7 @@ static __init void event_trace_self_tests(void) tr = top_trace_array(); if (!tr) - return -ENODEV; + return; pr_info("Running tests on trace events:\n"); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH ftrace/core] tracing: Remove return value in event_trace_self_tests() when top_trace_array() returns NULL
Remove return value in event_trace_self_tests() when top_trace_array() returns NULL because event_trace_self_tests() is void type. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Steven Rostedt rost...@goodmis.org Cc: Ingo Molnar mi...@redhat.com Cc: linux-kernel@vger.kernel.org --- kernel/trace/trace_events.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 1349870..f99e0b3 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2547,7 +2547,7 @@ static __init void event_trace_self_tests(void) tr = top_trace_array(); if (!tr) - return -ENODEV; + return; pr_info(Running tests on trace events:\n); -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH ftrace/core] tracing: Remove return value in event_trace_self_tests() when top_trace_array() returns NULL
Hi Steven, Thank you for applying my patches. I received build warning report from kbuild test bot, so I fixed it. Would you apply this patch? Thank you, Yoshihiro YUNOMAE (2014/06/06 15:28), Yoshihiro YUNOMAE wrote: Remove return value in event_trace_self_tests() when top_trace_array() returns NULL because event_trace_self_tests() is void type. Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Steven Rostedt rost...@goodmis.org Cc: Ingo Molnar mi...@redhat.com Cc: linux-kernel@vger.kernel.org --- kernel/trace/trace_events.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 1349870..f99e0b3 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2547,7 +2547,7 @@ static __init void event_trace_self_tests(void) tr = top_trace_array(); if (!tr) - return -ENODEV; + return; pr_info(Running tests on trace events:\n); -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH ftrace/core 0/3] ftrace: Fix three small bugs
Hi Steven, I found three small bugs for current ftrace/core, so I fixed those. Would you apply these patches? Thanks! --- Yoshihiro YUNOMAE (3): trace/event: Return error if ftrace_trace_arrays is empty list trace/kprobes: Avoid self tests if tracing is disabled on boot up trace: Fix memory leak when new instance creation failed kernel/trace/trace.c| 23 ++- kernel/trace/trace.h|3 +++ kernel/trace/trace_events.c | 13 + kernel/trace/trace_kprobe.c |3 +++ 4 files changed, 33 insertions(+), 9 deletions(-) -- Yoshihiro YUNOMAE Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: yoshihiro.yunomae...@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH ftrace/core 3/3] trace: Fix memory leak when new instance creation failed
Current new_instance_create() implements just two fail paths for four allocation operations. So, it can induce memory leak if new instance creation failed. This patch fixes it by defining all fail paths and freeing allocated memories appropriately. Signed-off-by: Yoshihiro YUNOMAE Cc: Steven Rostedt Cc: Ingo Molnar Cc: linux-kernel@vger.kernel.org --- kernel/trace/trace.c | 23 ++- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 473eb68..bbd86d2 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -6277,7 +6277,7 @@ static int new_instance_create(const char *name) goto out_free_tr; if (!alloc_cpumask_var(>tracing_cpumask, GFP_KERNEL)) - goto out_free_tr; + goto out_free_tr_name; cpumask_copy(tr->tracing_cpumask, cpu_all_mask); @@ -6291,16 +6291,16 @@ static int new_instance_create(const char *name) INIT_LIST_HEAD(>events); if (allocate_trace_buffers(tr, trace_buf_size) < 0) - goto out_free_tr; + goto out_free_cpumask_var; tr->dir = debugfs_create_dir(name, trace_instance_dir); if (!tr->dir) - goto out_free_tr; + goto out_free_trace_buffers; ret = event_trace_add_tracer(tr->dir, tr); if (ret) { debugfs_remove_recursive(tr->dir); - goto out_free_tr; + goto out_free_trace_buffers; } init_tracer_debugfs(tr, tr->dir); @@ -6311,18 +6311,23 @@ static int new_instance_create(const char *name) return 0; - out_free_tr: - if (tr->trace_buffer.buffer) - ring_buffer_free(tr->trace_buffer.buffer); + out_free_trace_buffers: + ring_buffer_free(tr->trace_buffer.buffer); + free_percpu(tr->trace_buffer.data); +#ifdef CONFIG_TRACER_MAX_TRACE + ring_buffer_free(tr->max_buffer.buffer); + free_percpu(tr->max_buffer.data); +#endif + out_free_cpumask_var: free_cpumask_var(tr->tracing_cpumask); + out_free_tr_name: kfree(tr->name); + out_free_tr: kfree(tr); - out_unlock: mutex_unlock(_types_lock); return ret; - } static int instance_delete(const char *name) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH ftrace/core 1/3] trace/event: Return error if ftrace_trace_arrays is empty list
ftrace_trace_arrays links global_trace.list. However, global_trace is not added to ftrace_trace_arrays if trace_alloc_buffers() failed. As the result, ftrace_trace_arrays becomes empty list. If ftrace_trace_arrays is empty list, current top_trace_array() returns invalid pointer. As the result, the kernel can induce memory corruption or panic. Current implementation does not check whether ftrace_trace_arrays is empty list or not. So, in this patch, if ftrace_trace_arrays is empty list, top_trace_array() returns NULL. Moreover, this patch makes all functions calling top_trace_array() handle it appropriately. Signed-off-by: Yoshihiro YUNOMAE Cc: Steven Rostedt Cc: Ingo Molnar Cc: linux-kernel@vger.kernel.org --- kernel/trace/trace.h|3 +++ kernel/trace/trace_events.c | 13 + 2 files changed, 16 insertions(+) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 217207a..9e82551 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -252,6 +252,9 @@ static inline struct trace_array *top_trace_array(void) { struct trace_array *tr; + if (list_empty(ftrace_trace_arrays.prev)) + return NULL; + tr = list_entry(ftrace_trace_arrays.prev, typeof(*tr), list); WARN_ON(!(tr->flags & TRACE_ARRAY_FL_GLOBAL)); diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 3ddfd8f..1349870 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -574,6 +574,9 @@ int trace_set_clr_event(const char *system, const char *event, int set) { struct trace_array *tr = top_trace_array(); + if (!tr) + return -ENODEV; + return __ftrace_set_clr_event(tr, NULL, system, event, set); } EXPORT_SYMBOL_GPL(trace_set_clr_event); @@ -2065,6 +2068,9 @@ event_enable_func(struct ftrace_hash *hash, bool enable; int ret; + if (!tr) + return -ENODEV; + /* hash funcs only work with set_ftrace_filter */ if (!enabled || !param) return -EINVAL; @@ -2396,6 +2402,9 @@ static __init int event_trace_enable(void) char *token; int ret; + if (!tr) + return -ENODEV; + for_each_event(iter, __start_ftrace_events, __stop_ftrace_events) { call = *iter; @@ -2442,6 +2451,8 @@ static __init int event_trace_init(void) int ret; tr = top_trace_array(); + if (!tr) + return -ENODEV; d_tracer = tracing_init_dentry(); if (!d_tracer) @@ -2535,6 +2546,8 @@ static __init void event_trace_self_tests(void) int ret; tr = top_trace_array(); + if (!tr) + return -ENODEV; pr_info("Running tests on trace events:\n"); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH ftrace/core 2/3] trace/kprobes: Avoid self tests if tracing is disabled on boot up
If tracing is disabled on boot up, the kernel should not execute self tests. In this patch, the kernel checks whether tracing is disabled or not before executing self tests. Signed-off-by: Yoshihiro YUNOMAE Cc: Steven Rostedt Cc: Ingo Molnar Cc: Masami Hiramatsu Cc: linux-kernel@vger.kernel.org --- kernel/trace/trace_kprobe.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 903ae28..ef2fba1 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -1377,6 +1377,9 @@ static __init int kprobe_trace_self_tests_init(void) struct trace_kprobe *tk; struct ftrace_event_file *file; + if (tracing_is_disabled()) + return -ENODEV; + target = kprobe_trace_selftest_target; pr_info("Testing kprobe tracing: "); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/