Skip to content

Commit

Permalink
tracing/treewide: Remove second parameter of __assign_str()
Browse files Browse the repository at this point in the history
With the rework of how the __string() handles dynamic strings where it
saves off the source string in field in the helper structure[1], the
assignment of that value to the trace event field is stored in the helper
value and does not need to be passed in again.

This means that with:

  __string(field, mystring)

Which use to be assigned with __assign_str(field, mystring), no longer
needs the second parameter and it is unused. With this, __assign_str()
will now only get a single parameter.

There's over 700 users of __assign_str() and because coccinelle does not
handle the TRACE_EVENT() macro I ended up using the following sed script:

  git grep -l __assign_str | while read a ; do
      sed -e 's/\(__assign_str([^,]*[^ ,]\) *,[^;]*/\1)/' $a > /tmp/test-file;
      mv /tmp/test-file $a;
  done

I then searched for __assign_str() that did not end with ';' as those
were multi line assignments that the sed script above would fail to catch.

Note, the same updates will need to be done for:

  __assign_str_len()
  __assign_rel_str()
  __assign_rel_str_len()

I tested this with both an allmodconfig and an allyesconfig (build only for both).

[1] https://lore.kernel.org/linux-trace-kernel/[email protected]/

Link: https://lore.kernel.org/linux-trace-kernel/[email protected]

Cc: Masami Hiramatsu <[email protected]>
Cc: Mathieu Desnoyers <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Julia Lawall <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>
Acked-by: Jani Nikula <[email protected]>
Acked-by: Christian König <[email protected]> for the amdgpu parts.
Acked-by: Thomas Hellström <[email protected]> #for
Acked-by: Rafael J. Wysocki <[email protected]> # for thermal
Acked-by: Takashi Iwai <[email protected]>
Acked-by: Darrick J. Wong <[email protected]>	# xfs
Tested-by: Guenter Roeck <[email protected]>
  • Loading branch information
rostedt committed May 23, 2024
1 parent de7e71e commit 2c92ca8
Show file tree
Hide file tree
Showing 147 changed files with 794 additions and 808 deletions.
2 changes: 1 addition & 1 deletion arch/arm64/kernel/trace-events-emulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TRACE_EVENT(instruction_emulation,
),

TP_fast_assign(
__assign_str(instr, instr);
__assign_str(instr);
__entry->addr = addr;
),

Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/include/asm/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ TRACE_EVENT(rtas_input,

TP_fast_assign(
__entry->nargs = be32_to_cpu(rtas_args->nargs);
__assign_str(name, name);
__assign_str(name);
be32_to_cpu_array(__get_dynamic_array(inputs), rtas_args->args, __entry->nargs);
),

Expand All @@ -162,7 +162,7 @@ TRACE_EVENT(rtas_output,
TP_fast_assign(
__entry->nr_other = be32_to_cpu(rtas_args->nret) - 1;
__entry->status = be32_to_cpu(rtas_args->rets[0]);
__assign_str(name, name);
__assign_str(name);
be32_to_cpu_array(__get_dynamic_array(other_outputs),
&rtas_args->rets[1], __entry->nr_other);
),
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kvm/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@ TRACE_EVENT(kvm_nested_vmenter_failed,
),

TP_fast_assign(
__assign_str(msg, msg);
__assign_str(msg);
__entry->err = err;
),

Expand Down
18 changes: 9 additions & 9 deletions drivers/base/regmap/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DECLARE_EVENT_CLASS(regmap_reg,
),

TP_fast_assign(
__assign_str(name, regmap_name(map));
__assign_str(name);
__entry->reg = reg;
__entry->val = val;
),
Expand Down Expand Up @@ -74,7 +74,7 @@ DECLARE_EVENT_CLASS(regmap_bulk,
),

TP_fast_assign(
__assign_str(name, regmap_name(map));
__assign_str(name);
__entry->reg = reg;
__entry->val_len = val_len;
memcpy(__get_dynamic_array(buf), val, val_len);
Expand Down Expand Up @@ -113,7 +113,7 @@ DECLARE_EVENT_CLASS(regmap_block,
),

TP_fast_assign(
__assign_str(name, regmap_name(map));
__assign_str(name);
__entry->reg = reg;
__entry->count = count;
),
Expand Down Expand Up @@ -163,9 +163,9 @@ TRACE_EVENT(regcache_sync,
),

TP_fast_assign(
__assign_str(name, regmap_name(map));
__assign_str(status, status);
__assign_str(type, type);
__assign_str(name);
__assign_str(status);
__assign_str(type);
),

TP_printk("%s type=%s status=%s", __get_str(name),
Expand All @@ -184,7 +184,7 @@ DECLARE_EVENT_CLASS(regmap_bool,
),

TP_fast_assign(
__assign_str(name, regmap_name(map));
__assign_str(name);
__entry->flag = flag;
),

Expand Down Expand Up @@ -216,7 +216,7 @@ DECLARE_EVENT_CLASS(regmap_async,
),

TP_fast_assign(
__assign_str(name, regmap_name(map));
__assign_str(name);
),

TP_printk("%s", __get_str(name))
Expand Down Expand Up @@ -264,7 +264,7 @@ TRACE_EVENT(regcache_drop_region,
),

TP_fast_assign(
__assign_str(name, regmap_name(map));
__assign_str(name);
__entry->from = from;
__entry->to = to;
),
Expand Down
2 changes: 1 addition & 1 deletion drivers/base/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DECLARE_EVENT_CLASS(devres,
__field(size_t, size)
),
TP_fast_assign(
__assign_str(devname, dev_name(dev));
__assign_str(devname);
__entry->op = op;
__entry->node = node;
__entry->name = name;
Expand Down
12 changes: 6 additions & 6 deletions drivers/block/rnbd/rnbd-srv-trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DECLARE_EVENT_CLASS(rnbd_srv_link_class,

TP_fast_assign(
__entry->qdepth = srv->queue_depth;
__assign_str(sessname, srv->sessname);
__assign_str(sessname);
),

TP_printk("sessname: %s qdepth: %d",
Expand Down Expand Up @@ -85,7 +85,7 @@ TRACE_EVENT(process_rdma,
),

TP_fast_assign(
__assign_str(sessname, srv->sessname);
__assign_str(sessname);
__entry->dir = id->dir;
__entry->ver = srv->ver;
__entry->device_id = le32_to_cpu(msg->device_id);
Expand Down Expand Up @@ -130,7 +130,7 @@ TRACE_EVENT(process_msg_sess_info,
__entry->proto_ver = srv->ver;
__entry->clt_ver = msg->ver;
__entry->srv_ver = RNBD_PROTO_VER_MAJOR;
__assign_str(sessname, srv->sessname);
__assign_str(sessname);
),

TP_printk("Session %s using proto-ver %d (clt-ver: %d, srv-ver: %d)",
Expand Down Expand Up @@ -165,8 +165,8 @@ TRACE_EVENT(process_msg_open,

TP_fast_assign(
__entry->access_mode = msg->access_mode;
__assign_str(sessname, srv->sessname);
__assign_str(dev_name, msg->dev_name);
__assign_str(sessname);
__assign_str(dev_name);
),

TP_printk("Open message received: session='%s' path='%s' access_mode=%s",
Expand All @@ -189,7 +189,7 @@ TRACE_EVENT(process_msg_close,

TP_fast_assign(
__entry->device_id = le32_to_cpu(msg->device_id);
__assign_str(sessname, srv->sessname);
__assign_str(sessname);
),

TP_printk("Close message received: session='%s' device id='%d'",
Expand Down
12 changes: 6 additions & 6 deletions drivers/bus/mhi/host/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ TRACE_EVENT(mhi_gen_tre,
),

TP_fast_assign(
__assign_str(name, mhi_cntrl->mhi_dev->name);
__assign_str(name);
__entry->ch_num = mhi_chan->chan;
__entry->wp = mhi_tre;
__entry->tre_ptr = mhi_tre->ptr;
Expand Down Expand Up @@ -131,7 +131,7 @@ TRACE_EVENT(mhi_intvec_states,
),

TP_fast_assign(
__assign_str(name, mhi_cntrl->mhi_dev->name);
__assign_str(name);
__entry->local_ee = mhi_cntrl->ee;
__entry->state = mhi_cntrl->dev_state;
__entry->dev_ee = dev_ee;
Expand All @@ -158,7 +158,7 @@ TRACE_EVENT(mhi_tryset_pm_state,
),

TP_fast_assign(
__assign_str(name, mhi_cntrl->mhi_dev->name);
__assign_str(name);
if (pm_state)
pm_state = __fls(pm_state);
__entry->pm_state = pm_state;
Expand All @@ -184,7 +184,7 @@ DECLARE_EVENT_CLASS(mhi_process_event_ring,
),

TP_fast_assign(
__assign_str(name, mhi_cntrl->mhi_dev->name);
__assign_str(name);
__entry->rp = rp;
__entry->ptr = rp->ptr;
__entry->dword0 = rp->dword[0];
Expand Down Expand Up @@ -226,7 +226,7 @@ DECLARE_EVENT_CLASS(mhi_update_channel_state,
),

TP_fast_assign(
__assign_str(name, mhi_cntrl->mhi_dev->name);
__assign_str(name);
__entry->ch_num = mhi_chan->chan;
__entry->state = state;
__entry->reason = reason;
Expand Down Expand Up @@ -265,7 +265,7 @@ TRACE_EVENT(mhi_pm_st_transition,
),

TP_fast_assign(
__assign_str(name, mhi_cntrl->mhi_dev->name);
__assign_str(name);
__entry->state = state;
),

Expand Down
32 changes: 16 additions & 16 deletions drivers/cxl/core/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ TRACE_EVENT(cxl_aer_uncorrectable_error,
__array(u32, header_log, CXL_HEADERLOG_SIZE_U32)
),
TP_fast_assign(
__assign_str(memdev, dev_name(&cxlmd->dev));
__assign_str(host, dev_name(cxlmd->dev.parent));
__assign_str(memdev);
__assign_str(host);
__entry->serial = cxlmd->cxlds->serial;
__entry->status = status;
__entry->first_error = fe;
Expand Down Expand Up @@ -106,8 +106,8 @@ TRACE_EVENT(cxl_aer_correctable_error,
__field(u32, status)
),
TP_fast_assign(
__assign_str(memdev, dev_name(&cxlmd->dev));
__assign_str(host, dev_name(cxlmd->dev.parent));
__assign_str(memdev);
__assign_str(host);
__entry->serial = cxlmd->cxlds->serial;
__entry->status = status;
),
Expand Down Expand Up @@ -142,8 +142,8 @@ TRACE_EVENT(cxl_overflow,
),

TP_fast_assign(
__assign_str(memdev, dev_name(&cxlmd->dev));
__assign_str(host, dev_name(cxlmd->dev.parent));
__assign_str(memdev);
__assign_str(host);
__entry->serial = cxlmd->cxlds->serial;
__entry->log = log;
__entry->count = le16_to_cpu(payload->overflow_err_count);
Expand Down Expand Up @@ -200,8 +200,8 @@ TRACE_EVENT(cxl_overflow,
__field(u8, hdr_maint_op_class)

#define CXL_EVT_TP_fast_assign(cxlmd, l, hdr) \
__assign_str(memdev, dev_name(&(cxlmd)->dev)); \
__assign_str(host, dev_name((cxlmd)->dev.parent)); \
__assign_str(memdev); \
__assign_str(host); \
__entry->log = (l); \
__entry->serial = (cxlmd)->cxlds->serial; \
__entry->hdr_length = (hdr).length; \
Expand Down Expand Up @@ -359,10 +359,10 @@ TRACE_EVENT(cxl_general_media,
__entry->validity_flags = get_unaligned_le16(&rec->validity_flags);
__entry->hpa = hpa;
if (cxlr) {
__assign_str(region_name, dev_name(&cxlr->dev));
__assign_str(region_name);
uuid_copy(&__entry->region_uuid, &cxlr->params.uuid);
} else {
__assign_str(region_name, "");
__assign_str(region_name);
uuid_copy(&__entry->region_uuid, &uuid_null);
}
),
Expand Down Expand Up @@ -462,10 +462,10 @@ TRACE_EVENT(cxl_dram,
CXL_EVENT_DER_CORRECTION_MASK_SIZE);
__entry->hpa = hpa;
if (cxlr) {
__assign_str(region_name, dev_name(&cxlr->dev));
__assign_str(region_name);
uuid_copy(&__entry->region_uuid, &cxlr->params.uuid);
} else {
__assign_str(region_name, "");
__assign_str(region_name);
uuid_copy(&__entry->region_uuid, &uuid_null);
}
),
Expand Down Expand Up @@ -692,8 +692,8 @@ TRACE_EVENT(cxl_poison,
),

TP_fast_assign(
__assign_str(memdev, dev_name(&cxlmd->dev));
__assign_str(host, dev_name(cxlmd->dev.parent));
__assign_str(memdev);
__assign_str(host);
__entry->serial = cxlmd->cxlds->serial;
__entry->overflow_ts = cxl_poison_overflow(flags, overflow_ts);
__entry->dpa = cxl_poison_record_dpa(record);
Expand All @@ -702,12 +702,12 @@ TRACE_EVENT(cxl_poison,
__entry->trace_type = trace_type;
__entry->flags = flags;
if (cxlr) {
__assign_str(region, dev_name(&cxlr->dev));
__assign_str(region);
memcpy(__entry->uuid, &cxlr->params.uuid, 16);
__entry->hpa = cxl_trace_hpa(cxlr, cxlmd,
__entry->dpa);
} else {
__assign_str(region, "");
__assign_str(region);
memset(__entry->uuid, 0, 16);
__entry->hpa = ULLONG_MAX;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/dma-buf/sync_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TRACE_EVENT(sync_timeline,
),

TP_fast_assign(
__assign_str(name, timeline->name);
__assign_str(name);
__entry->value = timeline->value;
),

Expand Down
16 changes: 8 additions & 8 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ TRACE_EVENT(amdgpu_cs_ioctl,

TP_fast_assign(
__entry->sched_job_id = job->base.id;
__assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job));
__assign_str(timeline);
__entry->context = job->base.s_fence->finished.context;
__entry->seqno = job->base.s_fence->finished.seqno;
__assign_str(ring, to_amdgpu_ring(job->base.sched)->name);
__assign_str(ring);
__entry->num_ibs = job->num_ibs;
),
TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
Expand All @@ -203,10 +203,10 @@ TRACE_EVENT(amdgpu_sched_run_job,

TP_fast_assign(
__entry->sched_job_id = job->base.id;
__assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job));
__assign_str(timeline);
__entry->context = job->base.s_fence->finished.context;
__entry->seqno = job->base.s_fence->finished.seqno;
__assign_str(ring, to_amdgpu_ring(job->base.sched)->name);
__assign_str(ring);
__entry->num_ibs = job->num_ibs;
),
TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
Expand All @@ -231,7 +231,7 @@ TRACE_EVENT(amdgpu_vm_grab_id,

TP_fast_assign(
__entry->pasid = vm->pasid;
__assign_str(ring, ring->name);
__assign_str(ring);
__entry->vmid = job->vmid;
__entry->vm_hub = ring->vm_hub,
__entry->pd_addr = job->vm_pd_addr;
Expand Down Expand Up @@ -425,7 +425,7 @@ TRACE_EVENT(amdgpu_vm_flush,
),

TP_fast_assign(
__assign_str(ring, ring->name);
__assign_str(ring);
__entry->vmid = vmid;
__entry->vm_hub = ring->vm_hub;
__entry->pd_addr = pd_addr;
Expand Down Expand Up @@ -526,7 +526,7 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
),

TP_fast_assign(
__assign_str(ring, sched_job->base.sched->name);
__assign_str(ring);
__entry->id = sched_job->base.id;
__entry->fence = fence;
__entry->ctx = fence->context;
Expand Down Expand Up @@ -563,7 +563,7 @@ TRACE_EVENT(amdgpu_runpm_reference_dumps,
),
TP_fast_assign(
__entry->index = index;
__assign_str(func, func);
__assign_str(func);
),
TP_printk("amdgpu runpm reference dump 0x%x: 0x%s\n",
__entry->index,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ TRACE_EVENT(amdgpu_dc_performance,
__entry->writes = write_count;
__entry->read_delta = read_count - *last_read;
__entry->write_delta = write_count - *last_write;
__assign_str(func, func);
__assign_str(func);
__entry->line = line;
*last_read = read_count;
*last_write = write_count;
Expand Down
Loading

0 comments on commit 2c92ca8

Please sign in to comment.