diff mbox series

[v2,03/24] EDAC, ghes: Remove pvt->detail_location string

Message ID 20190624150758.6695-4-rrichter@marvell.com
State New
Headers show
Series EDAC, mc, ghes: Fixes and updates to improve memory error reporting | expand

Commit Message

Robert Richter June 24, 2019, 3:08 p.m. UTC
The detail_location[] string in struct ghes_edac_pvt is complete
useless and data is just copied around. Put everything into
e->other_detail from the beginning.

Signed-off-by: Robert Richter <rrichter@marvell.com>

---
 drivers/edac/ghes_edac.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

-- 
2.20.1

Comments

James Morse Aug. 2, 2019, 5:04 p.m. UTC | #1
Hi Robert,

On 24/06/2019 16:08, Robert Richter wrote:
> The detail_location[] string in struct ghes_edac_pvt is complete

> useless and data is just copied around. Put everything into

> e->other_detail from the beginning.

> 

> Signed-off-by: Robert Richter <rrichter@marvell.com>

> ---



> diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c

> index d095d98d6a8d..049de73c3bad 100644

> --- a/drivers/edac/ghes_edac.c

> +++ b/drivers/edac/ghes_edac.c

> @@ -21,8 +21,7 @@ struct ghes_edac_pvt {

>  	struct mem_ctl_info *mci;

>  

>  	/* Buffers for the error handling routine */

> -	char detail_location[240];

> -	char other_detail[160];

> +	char other_detail[400];

>  	char msg[80];

>  };

>  

> @@ -224,13 +223,14 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)

>  	e->error_count = 1;

>  	e->grain = 1;

>  	strcpy(e->label, "unknown label");

> -	e->msg = pvt->msg;

> -	e->other_detail = pvt->other_detail;

>  	e->top_layer = -1;

>  	e->mid_layer = -1;

>  	e->low_layer = -1;

> -	*pvt->other_detail = '\0';

> +	e->msg = pvt->msg;

> +	e->other_detail = pvt->other_detail;

> +

>  	*pvt->msg = '\0';

> +	*pvt->other_detail = '\0';

>  

>  	switch (sev) {

>  	case GHES_SEV_CORRECTED:

> @@ -361,6 +361,8 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)

>  

>  	/* All other fields are mapped on e->other_detail */

>  	p = pvt->other_detail;

> +	p += snprintf(p, sizeof(pvt->other_detail),

> +		"APEI location: %s ", e->location);

>  	if (mem_err->validation_bits & CPER_MEM_VALID_ERROR_STATUS) {

>  		u64 status = mem_err->error_status;

>  

> @@ -443,12 +445,10 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)

>  	grain_bits = fls_long(e->grain - 1);

>  

>  	/* Generate the trace event */

> -	snprintf(pvt->detail_location, sizeof(pvt->detail_location),

> -		 "APEI location: %s %s", e->location, e->other_detail);

>  	trace_mc_event(type, e->msg, e->label, e->error_count,

>  		       mci->mc_idx, e->top_layer, e->mid_layer, e->low_layer,

>  		       (e->page_frame_number << PAGE_SHIFT) | e->offset_in_page,

> -		       grain_bits, e->syndrome, pvt->detail_location);

> +		       grain_bits, e->syndrome, e->other_detail);

>  

>  	edac_raw_mc_handle_error(type, mci, e);

>  	spin_unlock_irqrestore(&ghes_lock, flags);


After a game of spot-the-difference: you added a newline.
Reviewed-by: James Morse <james.morse@arm.com>


Previously here:
https://lore.kernel.org/linux-edac/7017c91e-8923-c8d2-26ca-875328ab855a@arm.com/

Please pick up tags when posting a new version.


Thanks,

James
Robert Richter Aug. 7, 2019, 9 a.m. UTC | #2
On 02.08.19 18:04:46, James Morse wrote:
> On 24/06/2019 16:08, Robert Richter wrote:

> > The detail_location[] string in struct ghes_edac_pvt is complete

> > useless and data is just copied around. Put everything into

> > e->other_detail from the beginning.


I am updating the description here to clarify it is only the internal
buffer that is removed. The other_detail[] string still provides a
decoded information of the apei error record.

> > 

> > Signed-off-by: Robert Richter <rrichter@marvell.com>

> > ---

> 

> 

> > diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c

> > index d095d98d6a8d..049de73c3bad 100644

> > --- a/drivers/edac/ghes_edac.c

> > +++ b/drivers/edac/ghes_edac.c

> > @@ -21,8 +21,7 @@ struct ghes_edac_pvt {

> >  	struct mem_ctl_info *mci;

> >  

> >  	/* Buffers for the error handling routine */

> > -	char detail_location[240];

> > -	char other_detail[160];

> > +	char other_detail[400];

> >  	char msg[80];

> >  };

> >  

> > @@ -224,13 +223,14 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)

> >  	e->error_count = 1;

> >  	e->grain = 1;

> >  	strcpy(e->label, "unknown label");

> > -	e->msg = pvt->msg;

> > -	e->other_detail = pvt->other_detail;

> >  	e->top_layer = -1;

> >  	e->mid_layer = -1;

> >  	e->low_layer = -1;

> > -	*pvt->other_detail = '\0';

> > +	e->msg = pvt->msg;

> > +	e->other_detail = pvt->other_detail;

> > +

> >  	*pvt->msg = '\0';

> > +	*pvt->other_detail = '\0';


There are not code changes here, just a reordering for better
comparization with its counterpart in edac_mc.c. However, I am
removing this hunk here.

> >  

> >  	switch (sev) {

> >  	case GHES_SEV_CORRECTED:

> > @@ -361,6 +361,8 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)

> >  

> >  	/* All other fields are mapped on e->other_detail */

> >  	p = pvt->other_detail;

> > +	p += snprintf(p, sizeof(pvt->other_detail),

> > +		"APEI location: %s ", e->location);

> >  	if (mem_err->validation_bits & CPER_MEM_VALID_ERROR_STATUS) {

> >  		u64 status = mem_err->error_status;

> >  

> > @@ -443,12 +445,10 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)

> >  	grain_bits = fls_long(e->grain - 1);

> >  

> >  	/* Generate the trace event */

> > -	snprintf(pvt->detail_location, sizeof(pvt->detail_location),

> > -		 "APEI location: %s %s", e->location, e->other_detail);

> >  	trace_mc_event(type, e->msg, e->label, e->error_count,

> >  		       mci->mc_idx, e->top_layer, e->mid_layer, e->low_layer,

> >  		       (e->page_frame_number << PAGE_SHIFT) | e->offset_in_page,

> > -		       grain_bits, e->syndrome, pvt->detail_location);

> > +		       grain_bits, e->syndrome, e->other_detail);

> >  

> >  	edac_raw_mc_handle_error(type, mci, e);

> >  	spin_unlock_irqrestore(&ghes_lock, flags);

> 

> After a game of spot-the-difference: you added a newline.

> Reviewed-by: James Morse <james.morse@arm.com>

> 

> Previously here:

> https://lore.kernel.org/linux-edac/7017c91e-8923-c8d2-26ca-875328ab855a@arm.com/

> 

> Please pick up tags when posting a new version.


Let me know what you mean with this, I would like to ease review for
you. I tried to describe changes for v2 as detailed as possible.

Thank you.

-Robert
Borislav Petkov Aug. 13, 2019, 8:09 a.m. UTC | #3
On Mon, Jun 24, 2019 at 03:08:59PM +0000, Robert Richter wrote:
> The detail_location[] string in struct ghes_edac_pvt is complete


s/complete/completely/

> useless and data is just copied around. Put everything into

> e->other_detail from the beginning.

> 

> Signed-off-by: Robert Richter <rrichter@marvell.com>

> ---

>  drivers/edac/ghes_edac.c | 16 ++++++++--------

>  1 file changed, 8 insertions(+), 8 deletions(-)


-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
diff mbox series

Patch

diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
index d095d98d6a8d..049de73c3bad 100644
--- a/drivers/edac/ghes_edac.c
+++ b/drivers/edac/ghes_edac.c
@@ -21,8 +21,7 @@  struct ghes_edac_pvt {
 	struct mem_ctl_info *mci;
 
 	/* Buffers for the error handling routine */
-	char detail_location[240];
-	char other_detail[160];
+	char other_detail[400];
 	char msg[80];
 };
 
@@ -224,13 +223,14 @@  void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
 	e->error_count = 1;
 	e->grain = 1;
 	strcpy(e->label, "unknown label");
-	e->msg = pvt->msg;
-	e->other_detail = pvt->other_detail;
 	e->top_layer = -1;
 	e->mid_layer = -1;
 	e->low_layer = -1;
-	*pvt->other_detail = '\0';
+	e->msg = pvt->msg;
+	e->other_detail = pvt->other_detail;
+
 	*pvt->msg = '\0';
+	*pvt->other_detail = '\0';
 
 	switch (sev) {
 	case GHES_SEV_CORRECTED:
@@ -361,6 +361,8 @@  void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
 
 	/* All other fields are mapped on e->other_detail */
 	p = pvt->other_detail;
+	p += snprintf(p, sizeof(pvt->other_detail),
+		"APEI location: %s ", e->location);
 	if (mem_err->validation_bits & CPER_MEM_VALID_ERROR_STATUS) {
 		u64 status = mem_err->error_status;
 
@@ -443,12 +445,10 @@  void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
 	grain_bits = fls_long(e->grain - 1);
 
 	/* Generate the trace event */
-	snprintf(pvt->detail_location, sizeof(pvt->detail_location),
-		 "APEI location: %s %s", e->location, e->other_detail);
 	trace_mc_event(type, e->msg, e->label, e->error_count,
 		       mci->mc_idx, e->top_layer, e->mid_layer, e->low_layer,
 		       (e->page_frame_number << PAGE_SHIFT) | e->offset_in_page,
-		       grain_bits, e->syndrome, pvt->detail_location);
+		       grain_bits, e->syndrome, e->other_detail);
 
 	edac_raw_mc_handle_error(type, mci, e);
 	spin_unlock_irqrestore(&ghes_lock, flags);