Report APEI GHES error information via printk
cover Report APEI GHES error information via printk
Hi, Len,
Although we have no consensus on whether we need a hardware error specific reporting interface. We have the consensus that we need to report hardware error information via printk. This patchset adds that to APEI GHES.
v2:
- Some minor adjustment of PCIe error section definition and printk format
[PATCH -v2 1/3] Add CPER PCIe error section structure and constants definition [PATCH -v2 2/3] ACPI, APEI, Add APEI generic error status print support [PATCH -v2 3/3] ACPI, APEI, report GHES error information via printk
Best Regards,
Huang Ying
PATCH 1/3 Add CPER PCIe error section structure and constants definition
On some machine, PCIe error is reported via APEI (ACPI Platform Error Interface). The error data is passed from firmware to Linux via CPER PCIe error section structure.
This patch adds CPER PCIe error section structure and constants definition.
--- include/linux/cper.h | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+)
include/linux/cper.h +76 -0
@@ -201,6 +201,47 @@UUID_LE (0x036F84E1 ,0x7F37 ,0x428c ,0xA7 ,0x9E ,0x57 ,0x5F , \ 0xDF, 0xAA, 0x84, 0xEC) +#define CPER_PROC_VALID_TYPE 0x0001 +#define CPER_PROC_VALID_ISA 0x0002 +#define CPER_PROC_VALID_ERROR_TYPE 0x0004 +#define CPER_PROC_VALID_OPERATION 0x0008 +#define CPER_PROC_VALID_FLAGS 0x0010 +#define CPER_PROC_VALID_LEVEL 0x0020 +#define CPER_PROC_VALID_VERSION 0x0040 +#define CPER_PROC_VALID_BRAND_INFO 0x0080 +#define CPER_PROC_VALID_ID 0x0100 +#define CPER_PROC_VALID_TARGET_ADDRESS 0x0200 +#define CPER_PROC_VALID_REQUESTOR_ID 0x0400 +#define CPER_PROC_VALID_RESPONDER_ID 0x0800 +#define CPER_PROC_VALID_IP 0x1000 + +#define CPER_MEM_VALID_ERROR_STATUS 0x0001 +#define CPER_MEM_VALID_PHYSICAL_ADDRESS 0x0002 +#define CPER_MEM_VALID_PHYSICAL_ADDRESS_MASK 0x0004 +#define CPER_MEM_VALID_NODE 0x0008 +#define CPER_MEM_VALID_CARD 0x0010 +#define CPER_MEM_VALID_MODULE 0x0020 +#define CPER_MEM_VALID_BANK 0x0040 +#define CPER_MEM_VALID_DEVICE 0x0080 +#define CPER_MEM_VALID_ROW 0x0100 +#define CPER_MEM_VALID_COLUMN 0x0200 +#define CPER_MEM_VALID_BIT_POSITION 0x0400 +#define CPER_MEM_VALID_REQUESTOR_ID 0x0800 +#define CPER_MEM_VALID_RESPONDER_ID 0x1000 +#define CPER_MEM_VALID_TARGET_ID 0x2000 +#define CPER_MEM_VALID_ERROR_TYPE 0x4000 + +#define CPER_PCIE_VALID_PORT_TYPE 0x0001 +#define CPER_PCIE_VALID_VERSION 0x0002 +#define CPER_PCIE_VALID_COMMAND_STATUS 0x0004 +#define CPER_PCIE_VALID_DEVICE_ID 0x0008 +#define CPER_PCIE_VALID_SERIAL_NUMBER 0x0010 +#define CPER_PCIE_VALID_BRIDGE_CONTROL_STATUS 0x0020 +#define CPER_PCIE_VALID_CAPABILITY 0x0040 +#define CPER_PCIE_VALID_AER_INFO 0x0080 + +#define CPER_PCIE_SLOT_SHIFT 3 +/* * All tables and structs must be byte-packed to match CPER * specification, since the tables are provided by the system BIOS
@@ -306,6 +347,41 @@ struct cper_sec_mem_err {__u8 error_type; }; +struct cper_sec_pcie { +__u64 validation_bits; +__u32 port_type; +struct { +__u8 minor; +__u8 major; +__u8 reserved[2 ]; + } version; +__u16 command; +__u16 status; +__u32 reserved; +struct { +__u16 vendor_id; +__u16 device_id; +__u8 class_code[3 ]; +__u8 function; +__u8 device; +__u16 segment; +__u8 bus; +__u8 secondary_bus; +__u16 slot; +__u8 reserved; + } device_id; +struct { +__u32 lower; +__u32 upper; + } serial_number; +struct { +__u16 secondary_status; +__u16 control; + } bridge; +__u8 capability[60 ]; +__u8 aer_info[96 ]; +}; +/* Reset to default packing */ #pragma pack()
PATCH 2/3 ACPI, APEI, Add APEI generic error status print support
In reply to Huang Yingprintk is one of the methods to report hardware errors to user space. Hardware error information reported by firmware to Linux kernel is in the format of APEI generic error status (struct acpi_hes_generic_status). This patch adds print support for the format, so that the corresponding hardware error information can be reported to user space via printk.
PCIe AER information print is not implemented yet. Will refactor the original PCIe AER information printing code to avoid code duplicating.
--- drivers/acpi/apei/apei-internal.h | 2 drivers/acpi/apei/cper.c | 299 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 301 insertions(+)
drivers/acpi/apei/apei-internal.h +2 -0
@@ -109,6 +109,8 @@ static inline u32 apei_estatus_len(struc return sizeof(*estatus) + estatus->data_length; } +void apei_estatus_print (const char *pfx, +const struct acpi_hest_generic_status *estatus);int apei_estatus_check_header (const struct acpi_hest_generic_status *estatus);int apei_estatus_check (const struct acpi_hest_generic_status *estatus);#endif
drivers/acpi/apei/cper.c +299 -0
311 lines not on this page · raw message
Re: [PATCH -v2 2/3] ACPI, APEI, Add APEI generic error status print support
Quoted 12 lines · On Tue, 30 Nov 2010 10:51:40 +0800 Huang Ying <[email protected]> wrote:
printk is one of the methods to report hardware errors to user space. Hardware error information reported by firmware to Linux kernel is in the format of APEI generic error status (struct
acpi_hes_generic_status). This patch adds print support for the format, so that the corresponding hardware error information can be reported to user space via printk.PCIe AER information print is not implemented yet. Will refactor the original PCIe AER information printing code to avoid code duplicating.
...
drivers/acpi/apei/cper.c line 34
Quoted 2 lines
drivers/acpi/apei/cper.c +2
-0+#define pr_pfx (pfx, fmt, ...) \ + printk("%s" fmt, pfx, ##__VA_ARGS__)
hm, why does so much code create little printk helper macros. Isn't there something generic somewhere?
Quoted 9 lines
/*
* CPER record ID need to be unique even after reboot, because record
* ID is used as index for ERST storage, while CPER records fromdrivers/acpi/apei/cper.c +2
-0@@ -46,6 +49,302 @@ u64 cper_next_record_id(void) }EXPORT_SYMBOL_GPL (cper_next_record_id); +static const char *cper_severity_strs[] = { + [CPER_SEV_RECOVERABLE ] ="recoverable" ,
drivers/acpi/apei/cper.c u64 cper_next_record_id(void) · line 63
Quoted 10 lines
drivers/acpi/apei/cper.c +10
-0+ [CPER_SEV_FATAL] = "fatal", + [CPER_SEV_CORRECTED] = "corrected", + [CPER_SEV_INFORMATIONAL] = "info", +}; + +static const char *cper_severity_str (unsigned int severity) +{ +return severity <ARRAY_SIZE (cper_severity_strs) ? + cper_severity_strs[severity] :"unknown" ; +}
This code will explode nastily if CPER_SEV_RECOVERABLE .. CPER_SEV_INFORMATIONAL do not exactly have the values 0, 1, 2 and 3. They do have those values, but it would be a bit safer if they were enumerated types and not #defines..
Quoted 12 lines
drivers/acpi/apei/cper.c +12
-0+static void cper_print_bits (const char *pfx,unsigned int bits, +const char *strs[],unsigned int strs_size) +{ +int i, len =0 ; +const char *str; + +for (i =0 ; i < strs_size; i++) { +if (!(bits & (1U << i))) +continue ; + str = strs[i]; +if (len && len +strlen (str) +2 >80 ) { +printk ("\n" );
drivers/acpi/apei/cper.c u64 cper_next_record_id(void) · line 86
Quoted 10 lines
drivers/acpi/apei/cper.c +10
-0+ len =0 ; + } +if (!len) + len =pr_pfx (pfx,"%s" , str); +else + len +=printk (", %s" , str); + } +if (len) +printk ("\n" ); +}
geeze, that's the sort of code you have to execute to find out what it does. Or ask the author to document it.
This patchset appears to implement a new kernel->userspace interface. But that interface isn't actually described anywhere, so reviewers must reverse-engineer the interface from the implementation to be able to review the interface. Nobody bothers doing that so we end up with an unreviewed interface, which we must maintain for eternity.
Please fully document all proposed interfaces?
Re: [PATCH -v2 2/3] ACPI, APEI, Add APEI generic error status print support
Quoted 12 lines · Andrew Morton
Quoted 10 lines · On Tue, 30 Nov 2010 10:51:40 +0800 Huang Ying <[email protected]> wrote:
printk is one of the methods to report hardware errors to user space. Hardware error information reported by firmware to Linux kernel is in the format of APEI generic error status (struct
acpi_hes_generic_status). This patch adds print support for the format, so that the corresponding hardware error information can be reported to user space via printk.PCIe AER information print is not implemented yet. Will refactor the original PCIe AER information printing code to avoid code duplicating.
Quoted 7 lines
drivers/acpi/apei/cper.c line 34
Quoted 4 lines
...
drivers/acpi/apei/cper.c +2
-0+#define pr_pfx (pfx, fmt, ...) \ + printk("%s" fmt, pfx, ##__VA_ARGS__)hm, why does so much code create little printk helper macros. Isn't there something generic somewhere?
Sorry, I do not find the generic code for this helper. But I think this macro may be helpful for others too, who need to determine the log level only at runtime. Here corrected errors should have log level:KERN_WARNING, while uncorrected errors should have log level: KERN_ERR.
Do you think it is a good idea to make this macro generic?
Quoted 16 lines
Quoted 16 lines
/*
* CPER record ID need to be unique even after reboot, because record
* ID is used as index for ERST storage, while CPER records fromdrivers/acpi/apei/cper.c +9
-0@@ -46,6 +49,302 @@ u64 cper_next_record_id(void) }EXPORT_SYMBOL_GPL (cper_next_record_id); +static const char *cper_severity_strs[] = { + [CPER_SEV_RECOVERABLE ] ="recoverable" , + [CPER_SEV_FATAL ] ="fatal" , + [CPER_SEV_CORRECTED ] ="corrected" , + [CPER_SEV_INFORMATIONAL ] ="info" , +}; + +static const char *cper_severity_str (unsigned int severity) +{
Quoted 8 lines
drivers/acpi/apei/cper.c u64 cper_next_record_id(void) · line 63
Quoted 3 lines
drivers/acpi/apei/cper.c +3
-0+return severity <ARRAY_SIZE (cper_severity_strs) ? + cper_severity_strs[severity] :"unknown" ; +}This code will explode nastily if
CPER_SEV_RECOVERABLE..CPER_SEV_INFORMATIONALdo not exactly have the values 0, 1, 2 and 3. They do have those values, but it would be a bit safer if they were enumerated types and not #defines..
OK. I will change this.
Quoted 17 lines
Quoted 17 lines
drivers/acpi/apei/cper.c +17
-0+static void cper_print_bits (const char *pfx,unsigned int bits, +const char *strs[],unsigned int strs_size) +{ +int i, len =0 ; +const char *str; + +for (i =0 ; i < strs_size; i++) { +if (!(bits & (1U << i))) +continue ; + str = strs[i]; +if (len && len +strlen (str) +2 >80 ) { +printk ("\n" ); + len =0 ; + } +if (!len) + len =pr_pfx (pfx,"%s" , str); +else
Quoted 8 lines
drivers/acpi/apei/cper.c u64 cper_next_record_id(void) · line 86
Quoted 5 lines
drivers/acpi/apei/cper.c +5
-0+ len +=printk (", %s" , str); + } +if (len) +printk ("\n" ); +}geeze, that's the sort of code you have to execute to find out what it does. Or ask the author to document it.
OK. I will add comments for all necessary functions in the patch.
Quoted 7 lines
This patchset appears to implement a new
kernel->userspaceinterface. But that interface isn't actually described anywhere, so reviewers must reverse-engineer the interface from the implementation to be able to review the interface. Nobody bothers doing that so we end up with an unreviewed interface, which we must maintain for eternity.Please fully document all proposed interfaces?
Sorry. I don't realize that printk-ing something means implementing a new kernel->userspace interface. I think the messages resulted are self-explaining for human. Is it sufficient just to add example messages in patch description?
Best Regards,
Huang Ying
Re: [PATCH -v2 2/3] ACPI, APEI, Add APEI generic error status print support
Quoted 21 lines · On Tue, 30 Nov 2010 11:29:12 +0800 Huang Ying <[email protected]> wrote:
Quoted 12 lines · Andrew Morton
Quoted 10 lines · On Tue, 30 Nov 2010 10:51:40 +0800 Huang Ying <[email protected]> wrote:
printk is one of the methods to report hardware errors to user space. Hardware error information reported by firmware to Linux kernel is in the format of APEI generic error status (struct
acpi_hes_generic_status). This patch adds print support for the format, so that the corresponding hardware error information can be reported to user space via printk.PCIe AER information print is not implemented yet. Will refactor the original PCIe AER information printing code to avoid code duplicating.
Quoted 7 lines
drivers/acpi/apei/cper.c line 34
Quoted 4 lines
...
drivers/acpi/apei/cper.c +2
-0+#define pr_pfx (pfx, fmt, ...) \ + printk("%s" fmt, pfx, ##__VA_ARGS__)hm, why does so much code create little printk helper macros. Isn't there something generic somewhere?
Quoted 4 lines
Sorry, I do not find the generic code for this helper. But I think this macro may be helpful for others too, who need to determine the log level only at runtime. Here corrected errors should have log level:
KERN_WARNING, while uncorrected errors should have log level:KERN_ERR.
Oh, is that what it does. Replacing "pfx" everywhere with "loglevel" (or similar) would have been much clearer?
Quoted 1 line
Do you think it is a good idea to make this macro generic?
hm, maybe. It's the sort of thing which gives rise to much chin-scratching, which is why people usually avoid doing it ;) If the macro is well-named and its intended use is quite clear then yes, it's probably worth pursuing.
Quoted 6 lines
Quoted 6 lines
This patchset appears to implement a new
kernel->userspaceinterface. But that interface isn't actually described anywhere, so reviewers must reverse-engineer the interface from the implementation to be able to review the interface. Nobody bothers doing that so we end up with an unreviewed interface, which we must maintain for eternity.
Quoted 6 lines
Quoted 1 line
Please fully document all proposed interfaces?
Sorry. I don't realize that printk-ing something means implementing a new
kernel->userspaceinterface. I think the messages resulted are self-explaining for human. Is it sufficient just to add example messages in patch description?
Well normally a printk() isn't really considered a "userspace interface". This allows us to change them even though there surely _are_ existing tools which treat particular messages as a userspace interface. But I don't recall hearing of much breakage from changed kernel printks.
However in this case you are avowedly treating the printks as a userspace interface, with the intention that software be written to parse them, yes? So once they're in place, we cannot change them? That makes it more important.
Re: [PATCH -v2 2/3] ACPI, APEI, Add APEI generic error status print support
Quoted 23 lines · Andrew Morton
Quoted 21 lines · On Tue, 30 Nov 2010 11:29:12 +0800 Huang Ying <[email protected]> wrote:
Quoted 19 lines · Andrew Morton
Quoted 12 lines · On Tue, 30 Nov 2010 10:51:40 +0800 Huang Ying <[email protected]> wrote:
printk is one of the methods to report hardware errors to user space. Hardware error information reported by firmware to Linux kernel is in the format of APEI generic error status (struct
acpi_hes_generic_status). This patch adds print support for the format, so that the corresponding hardware error information can be reported to user space via printk.PCIe AER information print is not implemented yet. Will refactor the original PCIe AER information printing code to avoid code duplicating.
...
drivers/acpi/apei/cper.c line 34
Quoted 2 lines
drivers/acpi/apei/cper.c +2
-0+#define pr_pfx (pfx, fmt, ...) \ + printk("%s" fmt, pfx, ##__VA_ARGS__)hm, why does so much code create little printk helper macros. Isn't there something generic somewhere?
Quoted 7 lines
Quoted 4 lines
Sorry, I do not find the generic code for this helper. But I think this macro may be helpful for others too, who need to determine the log level only at runtime. Here corrected errors should have log level:
KERN_WARNING, while uncorrected errors should have log level:KERN_ERR.Oh, is that what it does. Replacing "pfx" everywhere with "loglevel" (or similar) would have been much clearer?
The pfx (prefix) here is more than "loglevel", I prefix each line with "[Hardware Error:]" to make it clear that this is a hardware error reporting. I think that can be useful for some shared functions doing printk, the prefix parameter can provide sufficient flexibility for caller to use prefix like <module name> or <device ID>.
Quoted 26 lines
Quoted 1 line
Do you think it is a good idea to make this macro generic?
hm, maybe. It's the sort of thing which gives rise to much chin-scratching, which is why people usually avoid doing it ;) If the macro is well-named and its intended use is quite clear then yes, it's probably worth pursuing.
Quoted 6 lines
Quoted 6 lines
This patchset appears to implement a new
kernel->userspaceinterface. But that interface isn't actually described anywhere, so reviewers must reverse-engineer the interface from the implementation to be able to review the interface. Nobody bothers doing that so we end up with an unreviewed interface, which we must maintain for eternity.Quoted 6 lines
Quoted 1 line
Please fully document all proposed interfaces?
Sorry. I don't realize that printk-ing something means implementing a new
kernel->userspaceinterface. I think the messages resulted are self-explaining for human. Is it sufficient just to add example messages in patch description?Well normally a
printk()isn't really considered a "userspace interface". This allows us to change them even though there surely _are_ existing tools which treat particular messages as a userspace interface. But I don't recall hearing of much breakage from changed kernel printks.
Quoted 4 lines
However in this case you are avowedly treating the printks as a userspace interface, with the intention that software be written to parse them, yes? So once they're in place, we cannot change them? That makes it more important.
If my understanding is correct, Linus still don't like the idea of user space hardware error tool. On the other hand, if we need this tool, I think printk is not a good tool-oriented hardware error reporting interface for it, because:
- There is no overall format or record boundaries for printk, because printk is traditionally for 1-2 lines. This makes that printk is hard to parse in general.
- Messages from different CPUs may be interleaved.
- Good error reporting is too verbose for kernel log
- printk has no internal priority support, so that high severity errors has no more priority than low severity ones.
So my opinion is:
- Use printk as human oriented hardware error reporting.
- Use another tool oriented interface for user space hardware error tool if necessary.
Do you agree? Do you think printk can be used as a good tool-oriented hardware error reporting interface too?
Best Regards,
Huang Ying
Re: [PATCH -v2 2/3] ACPI, APEI, Add APEI generic error status print support
Quoted 7 lines · On Tue, 30 Nov 2010 15:00:31 +0800 Huang Ying <[email protected]> wrote:
Quoted 4 lines
However in this case you are avowedly treating the printks as a userspace interface, with the intention that software be written to parse them, yes? So once they're in place, we cannot change them? That makes it more important.
If my understanding is correct, Linus still don't like the idea of user space hardware error tool.
I'm sure he has no problem with a userspace tool ;) Surely what he doesn't like is the proposed kernel interface.
Quoted 7 lines
On the other hand, if we need this tool, I
think printk is not a good tool-oriented hardware error reporting interface for it, because:- There is no overall format or record boundaries for printk, because printk is traditionally for 1-2 lines. This makes that printk is hard to parse in general.
Well. These things can be addressed by careful choice of output format.
Quoted 1 line
- Messages from different CPUs may be interleaved.
A single printk() should be atomic.
Quoted 6 lines
- Good error reporting is too verbose for kernel log
- printk has no internal priority support, so that high severity errors has no more priority than low severity ones.
Quoted 8 lines
So my opinion is:
- Use printk as human oriented hardware error reporting.
- Use another tool oriented interface for user space hardware error tool if necessary.Do you agree? Do you think printk can be used as a good tool-oriented hardware error reporting interface too?
I agree that using printk() is pretty sucky.
However your proposals are waaaaaaaaay too narrow and specific IMO. There are several reasons why people want more regular and structured kerenl->userspace messaging features. One such requirement is for
internationalisation: people want messages to come out in some non-language-specific manner so that userspace tools can perform catalogue lookups and display the messages in the appropriate language.
Others (eg google) want to feed the messages into large-scale
capturing systems for offline analysis. And there are other requirements which I forget. Such a messaging/logging system would also incorporate the requirement to log to a persistent store.
So I think that quite a lot of people would be interested in proposals for a new and improved kernel->userspace messaging/logging facility. But talking about "hardware error reporting" (especially when it covers only a teeny subset of possible hardware errors!) is very myopic.
And implementing the broad facility would be a pretty big project. Simply chasing down all the stakeholders and understanding their needs would turn one's hair grey.
So we're a bit stuck, really. We would benefit from a quite broad and expensive-to-implement messaging/logging system, but we don't even know what that will look like yet. You have a small and highly-specific subset of that. If we merge the subset then it probably will live forever even if the broader feature gets written one day, because the subset is userspace-visible and adds interfaces which the larger system probably won't even implement.
So... for your pretty narrow and specific problem, perhaps using printk as a stopgap until somethine better to come along is the correct choice.
Re: [PATCH -v2 2/3] ACPI, APEI, Add APEI generic error status print support
Quoted 74 lines · Andrew Morton
Quoted 7 lines · On Tue, 30 Nov 2010 15:00:31 +0800 Huang Ying <[email protected]> wrote:
Quoted 4 lines
However in this case you are avowedly treating the printks as a userspace interface, with the intention that software be written to parse them, yes? So once they're in place, we cannot change them? That makes it more important.
If my understanding is correct, Linus still don't like the idea of user space hardware error tool.
I'm sure he has no problem with a userspace tool ;) Surely what he doesn't like is the proposed kernel interface.
Quoted 7 lines
On the other hand, if we need this tool, I
think printk is not a good tool-oriented hardware error reporting interface for it, because:- There is no overall format or record boundaries for printk, because printk is traditionally for 1-2 lines. This makes that printk is hard to parse in general.
Well. These things can be addressed by careful choice of output format.
Quoted 1 line
- Messages from different CPUs may be interleaved.
A single
printk()should be atomic.Quoted 6 lines
- Good error reporting is too verbose for kernel log
- printk has no internal priority support, so that high severity errors has no more priority than low severity ones.
Quoted 8 lines
So my opinion is:
- Use printk as human oriented hardware error reporting.
- Use another tool oriented interface for user space hardware error tool if necessary.Do you agree? Do you think printk can be used as a good tool-oriented hardware error reporting interface too?
I agree that using
printk()is pretty sucky.However your proposals are waaaaaaaaay too narrow and specific IMO. There are several reasons why people want more regular and structured
kerenl->userspacemessaging features. One such requirement is for
internationalisation: people want messages to come out in some non-language-specific manner so that userspace tools can perform catalogue lookups and display the messages in the appropriate language. Others (eg google) want to feed the messages into large-scale capturing systems for offline analysis. And there are other requirements which I forget. Such a messaging/logging system would also incorporate the requirement to log to a persistent store.So I think that quite a lot of people would be interested in proposals for a new and improved
kernel->userspacemessaging/logging facility. But talking about "hardware error reporting" (especially when it covers only a teeny subset of possible hardware errors!) is very myopic.And implementing the broad facility would be a pretty big project. Simply chasing down all the stakeholders and understanding their needs would turn one's hair grey.
So we're a bit stuck, really. We would benefit from a quite broad and expensive-to-implement messaging/logging system, but we don't even know what that will look like yet. You have a small and highly-specific subset of that. If we merge the subset then it probably will live forever even if the broader feature gets written one day, because the subset is userspace-visible and adds interfaces which the larger system probably won't even implement.
Quoted 3 lines
So... for your pretty narrow and specific problem, perhaps using printk as a stopgap until somethine better to come along is the correct choice.
OK. I will work on the printk based solution, at least as the first step.
Best Regards,
Huang Ying
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Luck, Tony
reviewerRE: [PATCH -v2 2/3] ACPI, APEI, Add APEI generic error status print support
In reply to Andrew MortonQuoted 5 lines
drivers/acpi/apei/cper.c +5
-0+for (i =0 ; i < strs_size; i++) { +if (!(bits & (1U << i))) +continue ; + str = strs[i]; +if (len && len +strlen (str) +2 >80 ) {
drivers/acpi/apei/cper.c u64 cper_next_record_id(void) · line 85
Quoted 10 lines
drivers/acpi/apei/cper.c +10
-0+printk ("\n" ); + len =0 ; + } +if (!len) + len =pr_pfx (pfx,"%s" , str); +else + len +=printk (", %s" , str); + } +if (len) +printk ("\n" );
Does printk() offer any guarantees about getting all the characters from a single printk() call out to the console without interleaving with messages from printk() calls on other cpus? If it does, then it would be a good idea to sprintf() the parts of this message to a buffer and then use one printk() call. I think I read that netconsole ends up with one packet on the wire for each call to printk().
Trying to parse output jumbled together from multiple cpus doesn't sound like fun.
-Tony
Re: [PATCH -v2 2/3] ACPI, APEI, Add APEI generic error status print support
Quoted 11 lines · Tony
Quoted 11 lines
drivers/acpi/apei/cper.c +11
-0+for (i =0 ; i < strs_size; i++) { +if (!(bits & (1U << i))) +continue ; + str = strs[i]; +if (len && len +strlen (str) +2 >80 ) { +printk ("\n" ); + len =0 ; + } +if (!len) + len =pr_pfx (pfx,"%s" , str); +else
Quoted 8 lines
drivers/acpi/apei/cper.c u64 cper_next_record_id(void) · line 85
Quoted 4 lines
drivers/acpi/apei/cper.c +4
-0+ len +=printk (", %s" , str); + } +if (len) +printk ("\n" );Does
printk()offer any guarantees about getting all the characters from a singleprintk()call out to the console without interleaving with messages fromprintk()calls on other cpus?
Yes, it uses logbuf_lock to atomically append all the output from a printk into log_buf[]. Then it calls the console drivers against log_buf[]. It's hard to see how a console driver could then screw that up.
Quoted 3 lines
If it does, then
it would be a good idea tosprintf()the parts of this message to a buffer and then use oneprintk()call.
yup.
Quoted 7 lines
I think I read that netconsole
ends up with one packet on the wire for each call toprintk().Trying to parse output jumbled together from multiple cpus doesn't sound like fun.
-Tony
Re: [PATCH -v2 2/3] ACPI, APEI, Add APEI generic error status print support
In reply to Luck, TonyQuoted 23 lines · Tony
Quoted 7 lines
+ for (i = 0; i <
strs_size; i++) {
+ if (!(bits & (1U << i)))
+ continue;
+ str = strs[i];
+ if (len && len + strlen(str) + 2 > 80) {
+printk("\n");
+ len = 0;Quoted 8 lines
+ }
+ if (!len)
+ len =pr_pfx(pfx, "%s", str);
+ else
+ len +=printk(", %s", str);
+ }
+ if (len)
+printk("\n");Does
printk()offer any guarantees about getting all the characters from a singleprintk()call out to the console without interleaving with messages fromprintk()calls on other cpus? If it does, then it would be a good idea tosprintf()the parts of this message to a buffer and then use oneprintk()call. I think I read that netconsole ends up with one packet on the wire for each call toprintk().
Quoted 2 lines
Trying to parse output jumbled together from multiple cpus doesn't sound like fun.
Yes. Will do that.
Best Regards,
Huang Ying
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/3 ACPI, APEI, report GHES error information via printk
In reply to Huang Yingprintk is one of the methods to report hardware errors to user space. This patch implements hardware error reporting for GHES via printk.
--- drivers/acpi/apei/ghes.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/acpi/apei/ghes.c +17 -4
@@ -255,11 +255,23 @@ static void ghes_do_proc(struct ghes *gh }#endif } +} -if (!processed &&printk_ratelimit ()) -pr_warning (GHES_PFX -"Unknown error record from generic hardware error source: %d\n" , - ghes->generic->header.source_id); +static void ghes_print_estatus (const char *pfx,struct ghes *ghes) +{ +if (pfx ==NULL ) { +if (ghes_severity (ghes->estatus->error_severity) <= +GHES_SEV_CORRECTED ) + pfx = KERN_WARNING HW_ERR; +else + pfx = KERN_ERR HW_ERR; + } +if (printk_ratelimit ()) { +printk ( +"%s""Hardware error from APEI Generic Hardware Error Source: %d\n" , + pfx, ghes->generic->header.source_id); +apei_estatus_print (pfx, ghes->estatus); + } }static int ghes_proc (struct ghes *ghes)
@@ -269,6 +281,7 @@ static int ghes_proc(struct ghes *ghes) rc =ghes_read_estatus (ghes,0 );if (rc) goto out; +ghes_print_estatus (NULL , ghes);ghes_do_proc (ghes); out:
Re: [PATCH -v2 3/3] ACPI, APEI, report GHES error information via printk
Quoted 24 lines · On Tue, 30 Nov 2010 10:51:41 +0800 Huang Ying <[email protected]> wrote:
printk is one of the methods to report hardware errors to user space. This patch implements hardware error reporting for GHES via printk.
Signed-off-by Huang Ying <[email protected]>--- drivers/acpi/apei/ghes.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)drivers/acpi/apei/ghes.c +5
-4@@ -255,11 +255,23 @@ static void ghes_do_proc(struct ghes *gh }#endif } +} -if (!processed &&printk_ratelimit ()) -pr_warning (GHES_PFX -"Unknown error record from generic hardware error source: %d\n" , - ghes->generic->header.source_id); +static void ghes_print_estatus (const char *pfx,struct ghes *ghes) +{ +if (pfx ==NULL ) { + if (ghes_severity(ghes->estatus->error_severity) <=
drivers/acpi/apei/ghes.c static void ghes_do_proc(struct ghes *gh · line 273
Quoted 10 lines
drivers/acpi/apei/ghes.c +10
-0+ GHES_SEV_CORRECTED) + pfx = KERN_WARNING HW_ERR; + else + pfx = KERN_ERR HW_ERR; + } +if (printk_ratelimit ()) { +printk ( +"%s""Hardware error from APEI Generic Hardware Error Source: %d\n" , + pfx, ghes->generic->header.source_id); +apei_estatus_print (pfx, ghes->estatus);
That code layout is just ghastly. Please, if it can't be done nicely in 80-cols then simply exceed the 80 cols.
And please don't use (or retain) printk_ratelimit(). It was a mistake. A printk_ratelimt() site shares state with all other printk_ratelimit() states, so if a random firewire driver is doing a lot of printk_ratelimit() calls, your messages get suppressed! Use printk_ratelimited() or __ratelimit().
Quoted 3 lines
...
Re: [PATCH -v2 3/3] ACPI, APEI, report GHES error information via printk
Quoted 31 lines · Andrew Morton
Quoted 29 lines · On Tue, 30 Nov 2010 10:51:41 +0800 Huang Ying <[email protected]> wrote:
printk is one of the methods to report hardware errors to user space. This patch implements hardware error reporting for GHES via printk.
Signed-off-by Huang Ying <[email protected]>--- drivers/acpi/apei/ghes.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)drivers/acpi/apei/ghes.c +10
-4@@ -255,11 +255,23 @@ static void ghes_do_proc(struct ghes *gh }#endif } +} -if (!processed &&printk_ratelimit ()) -pr_warning (GHES_PFX -"Unknown error record from generic hardware error source: %d\n" , - ghes->generic->header.source_id); +static void ghes_print_estatus (const char *pfx,struct ghes *ghes) +{ +if (pfx ==NULL ) { +if (ghes_severity (ghes->estatus->error_severity) <= +GHES_SEV_CORRECTED ) + pfx = KERN_WARNING HW_ERR; +else + pfx = KERN_ERR HW_ERR; + }
Quoted 8 lines
drivers/acpi/apei/ghes.c static void ghes_do_proc(struct ghes *gh · line 273
Quoted 5 lines
drivers/acpi/apei/ghes.c +5
-0+if (printk_ratelimit ()) { +printk ( +"%s""Hardware error from APEI Generic Hardware Error Source: %d\n" , + pfx, ghes->generic->header.source_id); +apei_estatus_print (pfx, ghes->estatus);That code layout is just ghastly. Please, if it can't be done nicely in 80-cols then simply exceed the 80 cols.
Just for printk, I think sometimes it may be helpful to put the "format" string at a new line in source code. Because it may be helpful to check whether the resulting string from printk fits 80 cols.
Quoted 5 lines
And please don't use (or retain)
printk_ratelimit(). It was a mistake. Aprintk_ratelimt()site shares state with all otherprintk_ratelimit()states, so if a random firewire driver is doing a lot ofprintk_ratelimit()calls, your messages get suppressed! Useprintk_ratelimited()or__ratelimit().
Yes. Will change this.
Best Regards,
Huang Ying
Re: [PATCH -v2 3/3] ACPI, APEI, report GHES error information via printk
Quoted 41 lines · Andrew Morton
Quoted 31 lines · On Tue, 30 Nov 2010 10:51:41 +0800 Huang Ying <[email protected]> wrote:
Quoted 30 lines
printk is one of the methods to report hardware errors to user space. This patch implements hardware error reporting for GHES via printk.
Signed-off-by Huang Ying <[email protected]>--- drivers/acpi/apei/ghes.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)drivers/acpi/apei/ghes.c +10
-4@@ -255,11 +255,23 @@ static void ghes_do_proc(struct ghes *gh }#endif } +} -if (!processed &&printk_ratelimit ()) -pr_warning (GHES_PFX -"Unknown error record from generic hardware error source: %d\n" , - ghes->generic->header.source_id); +static void ghes_print_estatus (const char *pfx,struct ghes *ghes) +{ +if (pfx ==NULL ) { +if (ghes_severity (ghes->estatus->error_severity) <= +GHES_SEV_CORRECTED ) + pfx = KERN_WARNING HW_ERR; +else + pfx = KERN_ERR HW_ERR; + }Quoted 8 lines
drivers/acpi/apei/ghes.c static void ghes_do_proc(struct ghes *gh · line 273
Quoted 5 lines
drivers/acpi/apei/ghes.c +5
-0+if (printk_ratelimit ()) { +printk ( +"%s""Hardware error from APEI Generic Hardware Error Source: %d\n" , + pfx, ghes->generic->header.source_id); +apei_estatus_print (pfx, ghes->estatus);That code layout is just ghastly. Please, if it can't be done nicely in 80-cols then simply exceed the 80 cols.
Quoted 3 lines
Just for printk, I think sometimes it may be helpful to put the "format" string at a new line in source code. Because it may be helpful to check whether the resulting string from printk fits 80 cols.
No. please reconsider why all other persons don't do that. It's beyond ugly.
Re: [PATCH -v2 3/3] ACPI, APEI, report GHES error information via printk
Quoted 2 lines · KOSAKI Motohiro
Quoted 2 lines · Andrew Morton
Quoted 1 line · On Tue, 30 Nov 2010 10:51:41 +0800 Huang Ying <[email protected]> wrote:
[...]
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 4 lines
drivers/acpi/apei/ghes.c +4
-0+static void ghes_print_estatus (const char *pfx,struct ghes *ghes) +{ +if (pfx ==NULL ) { + if (ghes_severity(ghes->estatus->error_severity) <=drivers/acpi/apei/ghes.c static void ghes_do_proc(struct ghes *gh · line 273
Quoted 10 lines
drivers/acpi/apei/ghes.c +10
-0+ GHES_SEV_CORRECTED) + pfx = KERN_WARNING HW_ERR; + else + pfx = KERN_ERR HW_ERR; + } +if (printk_ratelimit ()) { +printk ( +"%s""Hardware error from APEI Generic Hardware Error Source: %d\n" , + pfx, ghes->generic->header.source_id); +apei_estatus_print (pfx, ghes->estatus);That code layout is just ghastly. Please, if it can't be done nicely in 80-cols then simply exceed the 80 cols.
Quoted 6 lines
Quoted 3 lines
Just for printk, I think sometimes it may be helpful to put the "format" string at a new line in source code. Because it may be helpful to check whether the resulting string from printk fits 80 cols.
No. please reconsider why all other persons don't do that. It's beyond ugly.
I think that "why other persons don't/do do that" is not good reasoning.
Best Regards,
Huang Ying