On Thu, Feb 04, 2021 at 10:54:24AM +0000, Suzuki Kuruppassery Poulose wrote:
[...] > > > > +int cs_etm__get_pid_fmt(u8 trace_chan_id, u64 *pid_fmt) > > > > +{ > > > > + struct int_node *inode; > > > > + u64 *metadata, val; > > > > + > > > > + inode = intlist__find(traceid_list, trace_chan_id); > > > > + if (!inode) > > > > + return -EINVAL; > > > > + > > > > + metadata = inode->priv; > > > > + > > > > + if (metadata[CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { > > > > + val = metadata[CS_ETM_ETMCR]; > > > > + /* CONTEXTIDR is traced */ > > > > + if (val & BIT(ETM_OPT_CTXTID)) > > > > + *pid_fmt = BIT(ETM_OPT_CTXTID); > > > > + } else { > > > > + val = metadata[CS_ETMV4_TRCCONFIGR]; > > > > + > > > > + *pid_fmt = 0; > > > > + > > > > + /* CONTEXTIDR_EL2 is traced */ > > > > + if (val & (BIT(ETM4_CFG_BIT_VMID) | > > > > BIT(ETM4_CFG_BIT_VMID_OPT))) > > > > + *pid_fmt = BIT(ETM_OPT_CTXTID2); > > > > + > > > > + /* CONTEXTIDR_EL1 is traced */ > > > > + if (val & BIT(ETM4_CFG_BIT_CTXTID)) > > > > > > I haven't looked at how this gets used. But, Shouldn't this be : > > > > > > else if (val & BIT(ETM4_CFG_BIT_CTXTID)) ? > > > > Actually it's deliberately to set both bits ETM_OPT_CTXTID2 and > > ETM_OPT_CTXTID if user has enable configs "contextid1" and > > "contextid2". So this is exactly the reversed flow in the > > function cs_etmv4_get_config(). > > The point is, we don't care if the user selected both options. What we > care is, where can we find the PID. CONTEXTIDR_EL1 or CONTEXTIDR_EL2. > As such, get_pid_fmt simply should make that decision and pass it on. > So, if the CONTEXTIDR_EL2 is selected (which can only be done successfully > on an EL2 kernel), thats our pid. > > So we should return the format for the PID here. i.e > ETM_OPT_CTXTID2 OR ETM_OPT_CTXTID. But not both. Okay, if so I will follow your suggestion. Thanks, Leo