Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cxl/trace: Properly initialize cxl_poison region name

The TP_STRUCT__entry that gets assigned the region name, or an
empty string if no region is present, is erroneously initialized
to the cxl_region pointer. It needs to be properly initialized
otherwise it's length is wrong and garbage chars can appear in
the kernel trace output: /sys/kernel/tracing/trace

The bad initialization was due in part to a naming conflict with
the parameter: struct cxl_region *region. The field 'region' is
already exposed externally as the region name, so changing that
to something logical, like 'region_name' is not an option. Instead
rename the internal only struct cxl_region to the commonly used
'cxlr'.

Impact is that tooling depending on that trace data can miss
picking up a valid event when searching by region name. The
TP_printk() output, if enabled, does emit the correct region
names in the dmesg log.

This was found during testing of the cxl-list option to report
media-errors for a region.

Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: stable@vger.kernel.org
Fixes: ddf49d57b841 ("cxl/trace: Add TRACE support for CXL media-error records")
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Alison Schofield and committed by
Steven Rostedt (Google)
6c871260 3f9952e8

+7 -7
+7 -7
drivers/cxl/core/trace.h
··· 646 646 647 647 TRACE_EVENT(cxl_poison, 648 648 649 - TP_PROTO(struct cxl_memdev *cxlmd, struct cxl_region *region, 649 + TP_PROTO(struct cxl_memdev *cxlmd, struct cxl_region *cxlr, 650 650 const struct cxl_poison_record *record, u8 flags, 651 651 __le64 overflow_ts, enum cxl_poison_trace_type trace_type), 652 652 653 - TP_ARGS(cxlmd, region, record, flags, overflow_ts, trace_type), 653 + TP_ARGS(cxlmd, cxlr, record, flags, overflow_ts, trace_type), 654 654 655 655 TP_STRUCT__entry( 656 656 __string(memdev, dev_name(&cxlmd->dev)) 657 657 __string(host, dev_name(cxlmd->dev.parent)) 658 658 __field(u64, serial) 659 659 __field(u8, trace_type) 660 - __string(region, region) 660 + __string(region, cxlr ? dev_name(&cxlr->dev) : "") 661 661 __field(u64, overflow_ts) 662 662 __field(u64, hpa) 663 663 __field(u64, dpa) ··· 677 677 __entry->source = cxl_poison_record_source(record); 678 678 __entry->trace_type = trace_type; 679 679 __entry->flags = flags; 680 - if (region) { 681 - __assign_str(region, dev_name(&region->dev)); 682 - memcpy(__entry->uuid, &region->params.uuid, 16); 683 - __entry->hpa = cxl_trace_hpa(region, cxlmd, 680 + if (cxlr) { 681 + __assign_str(region, dev_name(&cxlr->dev)); 682 + memcpy(__entry->uuid, &cxlr->params.uuid, 16); 683 + __entry->hpa = cxl_trace_hpa(cxlr, cxlmd, 684 684 __entry->dpa); 685 685 } else { 686 686 __assign_str(region, "");