Skip to content

Commit ad584d7

Browse files
committed
Merge tag 'trace-v6.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing updates from Steven Rostedt: "Main user visible change: - User events can now have "multi formats" The current user events have a single format. If another event is created with a different format, it will fail to be created. That is, once an event name is used, it cannot be used again with a different format. This can cause issues if a library is using an event and updates its format. An application using the older format will prevent an application using the new library from registering its event. A task could also DOS another application if it knows the event names, and it creates events with different formats. The multi-format event is in a different name space from the single format. Both the event name and its format are the unique identifier. This will allow two different applications to use the same user event name but with different payloads. - Added support to have ftrace_dump_on_oops dump out instances and not just the main top level tracing buffer. Other changes: - Add eventfs_root_inode Only the root inode has a dentry that is static (never goes away) and stores it upon creation. There's no reason that the thousands of other eventfs inodes should have a pointer that never gets set in its descriptor. Create a eventfs_root_inode desciptor that has a eventfs_inode descriptor and a dentry pointer, and only the root inode will use this. - Added WARN_ON()s in eventfs There's some conditionals remaining in eventfs that should never be hit, but instead of removing them, add WARN_ON() around them to make sure that they are never hit. - Have saved_cmdlines allocation also include the map_cmdline_to_pid array The saved_cmdlines structure allocates a large amount of data to hold its mappings. Within it, it has three arrays. Two are already apart of it: map_pid_to_cmdline[] and saved_cmdlines[]. More memory can be saved by also including the map_cmdline_to_pid[] array as well. - Restructure __string() and __assign_str() macros used in TRACE_EVENT() Dynamic strings in TRACE_EVENT() are declared with: __string(name, source) And assigned with: __assign_str(name, source) In the tracepoint callback of the event, the __string() is used to get the size needed to allocate on the ring buffer and __assign_str() is used to copy the string into the ring buffer. There's a helper structure that is created in the TRACE_EVENT() macro logic that will hold the string length and its position in the ring buffer which is created by __string(). There are several trace events that have a function to create the string to save. This function is executed twice. Once for __string() and again for __assign_str(). There's no reason for this. The helper structure could also save the string it used in __string() and simply copy that into __assign_str() (it also already has its length). By using the structure to store the source string for the assignment, it means that the second argument to __assign_str() is no longer needed. It will be removed in the next merge window, but for now add a warning if the source string given to __string() is different than the source string given to __assign_str(), as the source to __assign_str() isn't even used and will be going away. - Added checks to make sure that the source of __string() is also the source of __assign_str() so that it can be safely removed in the next merge window. Included fixes that the above check found. - Other minor clean ups and fixes" * tag 'trace-v6.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: (34 commits) tracing: Add __string_src() helper to help compilers not to get confused tracing: Use strcmp() in __assign_str() WARN_ON() check tracepoints: Use WARN() and not WARN_ON() for warnings tracing: Use div64_u64() instead of do_div() tracing: Support to dump instance traces by ftrace_dump_on_oops tracing: Remove second parameter to __assign_rel_str() tracing: Add warning if string in __assign_str() does not match __string() tracing: Add __string_len() example tracing: Remove __assign_str_len() ftrace: Fix most kernel-doc warnings tracing: Decrement the snapshot if the snapshot trigger fails to register tracing: Fix snapshot counter going between two tracers that use it tracing: Use EVENT_NULL_STR macro instead of open coding "(null)" tracing: Use ? : shortcut in trace macros tracing: Do not calculate strlen() twice for __string() fields tracing: Rework __assign_str() and __string() to not duplicate getting the string cxl/trace: Properly initialize cxl_poison region name net: hns3: tracing: fix hclgevf trace event strings drm/i915: Add missing ; to __assign_str() macros in tracepoint code NFSD: Fix nfsd_clid_class use of __string_len() macro ...
2 parents 2cb5c86 + 7604256 commit ad584d7

File tree

31 files changed

+1363
-799
lines changed

31 files changed

+1363
-799
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,12 +1572,28 @@
15721572
The above will cause the "foo" tracing instance to trigger
15731573
a snapshot at the end of boot up.
15741574

1575-
ftrace_dump_on_oops[=orig_cpu]
1575+
ftrace_dump_on_oops[=2(orig_cpu) | =<instance>][,<instance> |
1576+
,<instance>=2(orig_cpu)]
15761577
[FTRACE] will dump the trace buffers on oops.
1577-
If no parameter is passed, ftrace will dump
1578-
buffers of all CPUs, but if you pass orig_cpu, it will
1579-
dump only the buffer of the CPU that triggered the
1580-
oops.
1578+
If no parameter is passed, ftrace will dump global
1579+
buffers of all CPUs, if you pass 2 or orig_cpu, it
1580+
will dump only the buffer of the CPU that triggered
1581+
the oops, or the specific instance will be dumped if
1582+
its name is passed. Multiple instance dump is also
1583+
supported, and instances are separated by commas. Each
1584+
instance supports only dump on CPU that triggered the
1585+
oops by passing 2 or orig_cpu to it.
1586+
1587+
ftrace_dump_on_oops=foo=orig_cpu
1588+
1589+
The above will dump only the buffer of "foo" instance
1590+
on CPU that triggered the oops.
1591+
1592+
ftrace_dump_on_oops,foo,bar=orig_cpu
1593+
1594+
The above will dump global buffer on all CPUs, the
1595+
buffer of "foo" instance on all CPUs and the buffer
1596+
of "bar" instance on CPU that triggered the oops.
15811597

15821598
ftrace_filter=[function-list]
15831599
[FTRACE] Limit the functions traced by the function

Documentation/admin-guide/sysctl/kernel.rst

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,30 @@ kernel panic). This will output the contents of the ftrace buffers to
296296
the console. This is very useful for capturing traces that lead to
297297
crashes and outputting them to a serial console.
298298

299-
= ===================================================
300-
0 Disabled (default).
301-
1 Dump buffers of all CPUs.
302-
2 Dump the buffer of the CPU that triggered the oops.
303-
= ===================================================
304-
299+
======================= ===========================================
300+
0 Disabled (default).
301+
1 Dump buffers of all CPUs.
302+
2(orig_cpu) Dump the buffer of the CPU that triggered the
303+
oops.
304+
<instance> Dump the specific instance buffer on all CPUs.
305+
<instance>=2(orig_cpu) Dump the specific instance buffer on the CPU
306+
that triggered the oops.
307+
======================= ===========================================
308+
309+
Multiple instance dump is also supported, and instances are separated
310+
by commas. If global buffer also needs to be dumped, please specify
311+
the dump mode (1/2/orig_cpu) first for global buffer.
312+
313+
So for example to dump "foo" and "bar" instance buffer on all CPUs,
314+
user can::
315+
316+
echo "foo,bar" > /proc/sys/kernel/ftrace_dump_on_oops
317+
318+
To dump global buffer and "foo" instance buffer on all
319+
CPUs along with the "bar" instance buffer on CPU that triggered the
320+
oops, user can::
321+
322+
echo "1,foo,bar=2" > /proc/sys/kernel/ftrace_dump_on_oops
305323

306324
ftrace_enabled, stack_tracer_enabled
307325
====================================

Documentation/trace/user_events.rst

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,24 @@ The following flags are currently supported.
9292
process closes or unregisters the event. Requires CAP_PERFMON otherwise
9393
-EPERM is returned.
9494

95+
+ USER_EVENT_REG_MULTI_FORMAT: The event can contain multiple formats. This
96+
allows programs to prevent themselves from being blocked when their event
97+
format changes and they wish to use the same name. When this flag is used the
98+
tracepoint name will be in the new format of "name.unique_id" vs the older
99+
format of "name". A tracepoint will be created for each unique pair of name
100+
and format. This means if several processes use the same name and format,
101+
they will use the same tracepoint. If yet another process uses the same name,
102+
but a different format than the other processes, it will use a different
103+
tracepoint with a new unique id. Recording programs need to scan tracefs for
104+
the various different formats of the event name they are interested in
105+
recording. The system name of the tracepoint will also use "user_events_multi"
106+
instead of "user_events". This prevents single-format event names conflicting
107+
with any multi-format event names within tracefs. The unique_id is output as
108+
a hex string. Recording programs should ensure the tracepoint name starts with
109+
the event name they registered and has a suffix that starts with . and only
110+
has hex characters. For example to find all versions of the event "test" you
111+
can use the regex "^test\.[0-9a-fA-F]+$".
112+
95113
Upon successful registration the following is set.
96114

97115
+ write_index: The index to use for this file descriptor that represents this
@@ -106,6 +124,9 @@ or perf record -e user_events:[name] when attaching/recording.
106124
**NOTE:** The event subsystem name by default is "user_events". Callers should
107125
not assume it will always be "user_events". Operators reserve the right in the
108126
future to change the subsystem name per-process to accommodate event isolation.
127+
In addition if the USER_EVENT_REG_MULTI_FORMAT flag is used the tracepoint name
128+
will have a unique id appended to it and the system name will be
129+
"user_events_multi" as described above.
109130

110131
Command Format
111132
^^^^^^^^^^^^^^
@@ -156,7 +177,11 @@ to request deletes than the one used for registration due to this.
156177
to the event. If programs do not want auto-delete, they must use the
157178
USER_EVENT_REG_PERSIST flag when registering the event. Once that flag is used
158179
the event exists until DIAG_IOCSDEL is invoked. Both register and delete of an
159-
event that persists requires CAP_PERFMON, otherwise -EPERM is returned.
180+
event that persists requires CAP_PERFMON, otherwise -EPERM is returned. When
181+
there are multiple formats of the same event name, all events with the same
182+
name will be attempted to be deleted. If only a specific version is wanted to
183+
be deleted then the /sys/kernel/tracing/dynamic_events file should be used for
184+
that specific format of the event.
160185

161186
Unregistering
162187
-------------

drivers/cxl/core/trace.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -646,18 +646,18 @@ u64 cxl_trace_hpa(struct cxl_region *cxlr, struct cxl_memdev *memdev, u64 dpa);
646646

647647
TRACE_EVENT(cxl_poison,
648648

649-
TP_PROTO(struct cxl_memdev *cxlmd, struct cxl_region *region,
649+
TP_PROTO(struct cxl_memdev *cxlmd, struct cxl_region *cxlr,
650650
const struct cxl_poison_record *record, u8 flags,
651651
__le64 overflow_ts, enum cxl_poison_trace_type trace_type),
652652

653-
TP_ARGS(cxlmd, region, record, flags, overflow_ts, trace_type),
653+
TP_ARGS(cxlmd, cxlr, record, flags, overflow_ts, trace_type),
654654

655655
TP_STRUCT__entry(
656656
__string(memdev, dev_name(&cxlmd->dev))
657657
__string(host, dev_name(cxlmd->dev.parent))
658658
__field(u64, serial)
659659
__field(u8, trace_type)
660-
__string(region, region)
660+
__string(region, cxlr ? dev_name(&cxlr->dev) : "")
661661
__field(u64, overflow_ts)
662662
__field(u64, hpa)
663663
__field(u64, dpa)
@@ -677,10 +677,10 @@ TRACE_EVENT(cxl_poison,
677677
__entry->source = cxl_poison_record_source(record);
678678
__entry->trace_type = trace_type;
679679
__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,
684684
__entry->dpa);
685685
} else {
686686
__assign_str(region, "");

drivers/gpu/drm/i915/display/intel_display_trace.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ TRACE_EVENT(intel_fbc_activate,
411411
struct intel_crtc *crtc = intel_crtc_for_pipe(to_i915(plane->base.dev),
412412
plane->pipe);
413413
__assign_str(dev, __dev_name_kms(plane));
414-
__assign_str(name, plane->base.name)
414+
__assign_str(name, plane->base.name);
415415
__entry->pipe = crtc->pipe;
416416
__entry->frame = intel_crtc_get_vblank_counter(crtc);
417417
__entry->scanline = intel_get_crtc_scanline(crtc);
@@ -438,7 +438,7 @@ TRACE_EVENT(intel_fbc_deactivate,
438438
struct intel_crtc *crtc = intel_crtc_for_pipe(to_i915(plane->base.dev),
439439
plane->pipe);
440440
__assign_str(dev, __dev_name_kms(plane));
441-
__assign_str(name, plane->base.name)
441+
__assign_str(name, plane->base.name);
442442
__entry->pipe = crtc->pipe;
443443
__entry->frame = intel_crtc_get_vblank_counter(crtc);
444444
__entry->scanline = intel_get_crtc_scanline(crtc);
@@ -465,7 +465,7 @@ TRACE_EVENT(intel_fbc_nuke,
465465
struct intel_crtc *crtc = intel_crtc_for_pipe(to_i915(plane->base.dev),
466466
plane->pipe);
467467
__assign_str(dev, __dev_name_kms(plane));
468-
__assign_str(name, plane->base.name)
468+
__assign_str(name, plane->base.name);
469469
__entry->pipe = crtc->pipe;
470470
__entry->frame = intel_crtc_get_vblank_counter(crtc);
471471
__entry->scanline = intel_get_crtc_scanline(crtc);

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ TRACE_EVENT(hclge_pf_mbx_get,
2424
__field(u8, code)
2525
__field(u8, subcode)
2626
__string(pciname, pci_name(hdev->pdev))
27-
__string(devname, &hdev->vport[0].nic.kinfo.netdev->name)
27+
__string(devname, hdev->vport[0].nic.kinfo.netdev->name)
2828
__array(u32, mbx_data, PF_GET_MBX_LEN)
2929
),
3030

@@ -33,7 +33,7 @@ TRACE_EVENT(hclge_pf_mbx_get,
3333
__entry->code = req->msg.code;
3434
__entry->subcode = req->msg.subcode;
3535
__assign_str(pciname, pci_name(hdev->pdev));
36-
__assign_str(devname, &hdev->vport[0].nic.kinfo.netdev->name);
36+
__assign_str(devname, hdev->vport[0].nic.kinfo.netdev->name);
3737
memcpy(__entry->mbx_data, req,
3838
sizeof(struct hclge_mbx_vf_to_pf_cmd));
3939
),
@@ -56,15 +56,15 @@ TRACE_EVENT(hclge_pf_mbx_send,
5656
__field(u8, vfid)
5757
__field(u16, code)
5858
__string(pciname, pci_name(hdev->pdev))
59-
__string(devname, &hdev->vport[0].nic.kinfo.netdev->name)
59+
__string(devname, hdev->vport[0].nic.kinfo.netdev->name)
6060
__array(u32, mbx_data, PF_SEND_MBX_LEN)
6161
),
6262

6363
TP_fast_assign(
6464
__entry->vfid = req->dest_vfid;
6565
__entry->code = le16_to_cpu(req->msg.code);
6666
__assign_str(pciname, pci_name(hdev->pdev));
67-
__assign_str(devname, &hdev->vport[0].nic.kinfo.netdev->name);
67+
__assign_str(devname, hdev->vport[0].nic.kinfo.netdev->name);
6868
memcpy(__entry->mbx_data, req,
6969
sizeof(struct hclge_mbx_pf_to_vf_cmd));
7070
),

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ TRACE_EVENT(hclge_vf_mbx_get,
2323
__field(u8, vfid)
2424
__field(u16, code)
2525
__string(pciname, pci_name(hdev->pdev))
26-
__string(devname, &hdev->nic.kinfo.netdev->name)
26+
__string(devname, hdev->nic.kinfo.netdev->name)
2727
__array(u32, mbx_data, VF_GET_MBX_LEN)
2828
),
2929

3030
TP_fast_assign(
3131
__entry->vfid = req->dest_vfid;
3232
__entry->code = le16_to_cpu(req->msg.code);
3333
__assign_str(pciname, pci_name(hdev->pdev));
34-
__assign_str(devname, &hdev->nic.kinfo.netdev->name);
34+
__assign_str(devname, hdev->nic.kinfo.netdev->name);
3535
memcpy(__entry->mbx_data, req,
3636
sizeof(struct hclge_mbx_pf_to_vf_cmd));
3737
),
@@ -55,7 +55,7 @@ TRACE_EVENT(hclge_vf_mbx_send,
5555
__field(u8, code)
5656
__field(u8, subcode)
5757
__string(pciname, pci_name(hdev->pdev))
58-
__string(devname, &hdev->nic.kinfo.netdev->name)
58+
__string(devname, hdev->nic.kinfo.netdev->name)
5959
__array(u32, mbx_data, VF_SEND_MBX_LEN)
6060
),
6161

@@ -64,7 +64,7 @@ TRACE_EVENT(hclge_vf_mbx_send,
6464
__entry->code = req->msg.code;
6565
__entry->subcode = req->msg.subcode;
6666
__assign_str(pciname, pci_name(hdev->pdev));
67-
__assign_str(devname, &hdev->nic.kinfo.netdev->name);
67+
__assign_str(devname, hdev->nic.kinfo.netdev->name);
6868
memcpy(__entry->mbx_data, req,
6969
sizeof(struct hclge_mbx_vf_to_pf_cmd));
7070
),

fs/nfsd/trace.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ TRACE_EVENT(nfsd_compound,
104104
TP_fast_assign(
105105
__entry->xid = be32_to_cpu(rqst->rq_xid);
106106
__entry->opcnt = opcnt;
107-
__assign_str_len(tag, tag, taglen);
107+
__assign_str(tag, tag);
108108
),
109109
TP_printk("xid=0x%08x opcnt=%u tag=%s",
110110
__entry->xid, __entry->opcnt, __get_str(tag)
@@ -485,7 +485,7 @@ TRACE_EVENT(nfsd_dirent,
485485
TP_fast_assign(
486486
__entry->fh_hash = fhp ? knfsd_fh_hash(&fhp->fh_handle) : 0;
487487
__entry->ino = ino;
488-
__assign_str_len(name, name, namlen)
488+
__assign_str(name, name);
489489
),
490490
TP_printk("fh_hash=0x%08x ino=%llu name=%s",
491491
__entry->fh_hash, __entry->ino, __get_str(name)
@@ -896,7 +896,7 @@ DECLARE_EVENT_CLASS(nfsd_clid_class,
896896
__array(unsigned char, addr, sizeof(struct sockaddr_in6))
897897
__field(unsigned long, flavor)
898898
__array(unsigned char, verifier, NFS4_VERIFIER_SIZE)
899-
__string_len(name, name, clp->cl_name.len)
899+
__string_len(name, clp->cl_name.data, clp->cl_name.len)
900900
),
901901
TP_fast_assign(
902902
__entry->cl_boot = clp->cl_clientid.cl_boot;
@@ -906,7 +906,7 @@ DECLARE_EVENT_CLASS(nfsd_clid_class,
906906
__entry->flavor = clp->cl_cred.cr_flavor;
907907
memcpy(__entry->verifier, (void *)&clp->cl_verifier,
908908
NFS4_VERIFIER_SIZE);
909-
__assign_str_len(name, clp->cl_name.data, clp->cl_name.len);
909+
__assign_str(name, clp->cl_name.data);
910910
),
911911
TP_printk("addr=%pISpc name='%s' verifier=0x%s flavor=%s client=%08x:%08x",
912912
__entry->addr, __get_str(name),
@@ -1976,7 +1976,7 @@ TRACE_EVENT(nfsd_ctl_time,
19761976
TP_fast_assign(
19771977
__entry->netns_ino = net->ns.inum;
19781978
__entry->time = time;
1979-
__assign_str_len(name, name, namelen);
1979+
__assign_str(name, name);
19801980
),
19811981
TP_printk("file=%s time=%d\n",
19821982
__get_str(name), __entry->time

0 commit comments

Comments
 (0)