Skip to content

Commit 9f3653e

Browse files
committed
address clanker review comments
1 parent 8dc3819 commit 9f3653e

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

libdd-profiling-heap-sampler/include/datadog/heap/probes.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@
3131
*/
3232
void dd_probe_alloc(void *user, uint64_t size, uint64_t weight);
3333

34-
#if DD_HEAP_LIVE_TRACKING
3534
/*
3635
* Emits the `ddheap:free` USDT.
3736
* ptr - user-visible pointer being freed
3837
*
39-
* Only available when compiled with live-heap tracking. The absence of
40-
* the `ddheap:free` note in .note.stapsdt signals to external profilers
41-
* that this binary does not support live-heap correlation.
38+
* The symbol always exists, but the USDT is only emitted when compiled
39+
* with live-heap tracking. The absence of the `ddheap:free` note in
40+
* .note.stapsdt signals to external profilers that this binary does not
41+
* support live-heap correlation.
4242
*/
4343
void dd_probe_free(void *ptr);
44-
#endif
4544

4645
#endif

libdd-profiling-heap-sampler/src/allocation_freed.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
* dd_sample_flag_check confirmed that ptr carries the sample flag,
1313
* meaning this allocation was previously sampled.
1414
*
15-
* Fires the ddheap:free USDT with the user-visible pointer, then returns
15+
* Fires the ddheap:free USDT (when live-heap tracking is enabled) with the
16+
* user-visible pointer, then returns
1617
* the raw pointer and adjusted size that the caller must forward to the
1718
* real deallocator. On x86-64 the size grows by DD_HEADER_BYTES to cover
1819
* the header that was reserved at allocation time; on arm64 the size is
@@ -21,10 +22,10 @@
2122
dd_alloc_freed_t dd_allocation_freed_slow(void *ptr, void *raw, size_t size,
2223
size_t alignment) {
2324
/* Fire with the user-visible pointer, matching what was reported at alloc
24-
* time, so the profiler can correlate the two events by address. */
25-
#if DD_HEAP_LIVE_TRACKING
25+
* time, so the profiler can correlate the two events by address. Safe to
26+
* call unconditionally: dd_probe_free is a no-op USDT-wise when live-heap
27+
* tracking is off. */
2628
dd_probe_free(ptr);
27-
#endif
2829

2930
dd_alloc_freed_t out = {
3031
/* Return the raw pointer so the caller passes the real allocation base

libdd-profiling-heap-sampler/src/probes.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
*/
1919

2020
#include <datadog/heap/probes.h>
21+
#include <datadog/heap/sample_flag.h>
2122

2223
void dd_probe_alloc(void *user, uint64_t size, uint64_t weight) {
2324
USDT(ddheap, alloc, user, size, weight);
2425
}
2526

26-
#if DD_HEAP_LIVE_TRACKING
2727
void dd_probe_free(void *ptr) {
28+
#if DD_HEAP_LIVE_TRACKING
2829
USDT(ddheap, free, ptr);
29-
}
30-
#endif
30+
#else
31+
(void)ptr;
32+
#endif
33+
}

0 commit comments

Comments
 (0)