Re: [RFC PATCH 6/9] cxl/mem: Trace Memory Module Event Record

From: Ira Weiny
Date: Wed Sep 14 2022 - 17:17:30 EST


On Thu, Aug 25, 2022 at 11:58:42AM +0100, Jonathan Cameron wrote:
> On Fri, 12 Aug 2022 22:32:40 -0700
> ira.weiny@xxxxxxxxx wrote:
>
> > From: Ira Weiny <ira.weiny@xxxxxxxxx>
> >
> > CXL v3.0 section 8.2.9.2.1.3 defines the Memory Module Event Record.
> >
> > Determine if the event read is memory module record and if so trace the
> > record.
> >
> > Signed-off-by: Ira Weiny <ira.weiny@xxxxxxxxx>
> Similar comments to on previous patches around using
> get_unaligned_le*()

Yep...

[snip]

> >
> > +/*
> > + * Get Health Info Record
> > + * CXL v3.0 section 8.2.9.8.3.1; Table 8-100
> > + */
> > +struct cxl_get_health_info {
> > + u8 health_status;
> > + u8 media_status;
> > + u8 add_status;
> > + u8 life_used;
> > + u16 device_temp;
>
> As previous - even though they aren't aligned, I'd have thought
> __le16 etc will still work. The unaligned accessors are fine
> taking __le16 * for example.

Ok my bad on using u16 here and I will change it. I 100% agree that these
should be __le16/__le32. That said there is no need to use the unaligned
accessors for the 16/32 bit fields.

The unaligned accessors cast the pointer to a __le16/__le32 type and no
architecture redefines those. So using le{16,32}_to_cpu() should work just
fine on all archs.

[snip]

> > +
> > + TP_fast_assign(
> > + /* Common */
> > + __assign_str(dev_name, dev_name);
> > + memcpy(__entry->id, &rec->hdr.id, UUID_SIZE);
> > + __entry->log = log;
> > + __entry->flags = le32_to_cpu(rec->hdr.flags_length) >> 8;
> > + __entry->handle = le16_to_cpu(rec->hdr.handle);
> > + __entry->related_handle = le16_to_cpu(rec->hdr.related_handle);
> > + __entry->timestamp = le64_to_cpu(rec->hdr.timestamp);
> > +
> > + /* Memory Module Event */
> > + __entry->event_type = rec->event_type;
> > +
> > + /* Device Health Info */
> > + __entry->health_status = rec->info.health_status;
> > + __entry->media_status = rec->info.media_status;
> > + __entry->life_used = rec->info.life_used;
> > + __entry->dirty_shutdown_cnt = le32_to_cpu(rec->info.dirty_shutdown_cnt);
> > + __entry->cor_vol_err_cnt = le32_to_cpu(rec->info.cor_vol_err_cnt);
>
> I've lost track, but my guess is some / all of these need the unaligned_get_le32()
> etc rather than aligned form. Maybe just be lazy and use the unaligned versions
> even when things happen to be aligned - then we don't have to think about it
> when reviewing :)

See above. I think the 16/32 bit fields work as intended except for my lack of
using the correct type.

Ira