~ubuntu-branches/ubuntu/wily/ust/wily-proposed

« back to all changes in this revision

Viewing changes to liblttng-ust/tracepoint.c

  • Committer: Package Import Robot
  • Author(s): Artur Rona
  • Date: 2015-06-24 14:18:03 UTC
  • mfrom: (11.2.11 sid)
  • Revision ID: package-import@ubuntu.com-20150624141803-zfj6xzpr7dlxiysg
Tags: 2.6.2-1ubuntu1
* Merge from Debian unstable. (LP: #1468345) Remaining changes:
  - debian/control, debian/patches/use-python3.patch:
    + Switch to use python3. (Closes: #789790)
* Drop following changes, fixed in Debian / upstream:
  - debian/patches/0001-Add-aarch64-host-cpu-in-configure.ac.patch:
    + Add arm64 host_cpu stanzas in configure.ac
  - debian/liblttng-ust0.symbols:
    + Update symbols file.
  - debian/control:
    + Enable builds on arm64 and ppc64el.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
/* Set to 1 to enable tracepoint debug output */
46
46
static const int tracepoint_debug;
47
47
static int initialized;
48
 
static void (*new_tracepoint_cb)(struct tracepoint *);
 
48
static void (*new_tracepoint_cb)(struct lttng_ust_tracepoint *);
49
49
 
50
50
/*
51
51
 * tracepoint_mutex nests inside UST mutex.
93
93
 */
94
94
struct tracepoint_entry {
95
95
        struct cds_hlist_node hlist;
96
 
        struct tracepoint_probe *probes;
 
96
        struct lttng_ust_tracepoint_probe *probes;
97
97
        int refcount;   /* Number of times armed. 0 if disarmed. */
98
98
        int callsite_refcount;  /* how many libs use this tracepoint */
99
99
        const char *signature;
106
106
                /* Field below only used for call_rcu scheme */
107
107
                /* struct rcu_head head; */
108
108
        } u;
109
 
        struct tracepoint_probe probes[0];
 
109
        struct lttng_ust_tracepoint_probe probes[0];
110
110
};
111
111
 
112
112
/*
120
120
struct callsite_entry {
121
121
        struct cds_hlist_node hlist;    /* hash table node */
122
122
        struct cds_list_head node;      /* lib list of callsites node */
123
 
        struct tracepoint *tp;
 
123
        struct lttng_ust_tracepoint *tp;
124
124
};
125
125
 
126
126
/* coverity[+alloc] */
127
127
static void *allocate_probes(int count)
128
128
{
129
 
        struct tp_probes *p  = zmalloc(count * sizeof(struct tracepoint_probe)
130
 
                        + sizeof(struct tp_probes));
 
129
        struct tp_probes *p =
 
130
                zmalloc(count * sizeof(struct lttng_ust_tracepoint_probe)
 
131
                + sizeof(struct tp_probes));
131
132
        return p == NULL ? NULL : p->probes;
132
133
}
133
134
 
158
159
                           void (*probe)(void), void *data)
159
160
{
160
161
        int nr_probes = 0;
161
 
        struct tracepoint_probe *old, *new;
 
162
        struct lttng_ust_tracepoint_probe *old, *new;
162
163
 
163
164
        if (!probe) {
164
165
                WARN_ON(1);
178
179
        if (new == NULL)
179
180
                return ERR_PTR(-ENOMEM);
180
181
        if (old)
181
 
                memcpy(new, old, nr_probes * sizeof(struct tracepoint_probe));
 
182
                memcpy(new, old,
 
183
                       nr_probes * sizeof(struct lttng_ust_tracepoint_probe));
182
184
        new[nr_probes].func = probe;
183
185
        new[nr_probes].data = data;
184
186
        new[nr_probes + 1].func = NULL;
193
195
                              void (*probe)(void), void *data)
194
196
{
195
197
        int nr_probes = 0, nr_del = 0, i;
196
 
        struct tracepoint_probe *old, *new;
 
198
        struct lttng_ust_tracepoint_probe *old, *new;
197
199
 
198
200
        old = entry->probes;
199
201
 
316
318
 * Sets the probe callback corresponding to one tracepoint.
317
319
 */
318
320
static void set_tracepoint(struct tracepoint_entry **entry,
319
 
        struct tracepoint *elem, int active)
 
321
        struct lttng_ust_tracepoint *elem, int active)
320
322
{
321
323
        WARN_ON(strncmp((*entry)->name, elem->name, LTTNG_UST_SYM_NAME_LEN - 1) != 0);
322
324
        /*
354
356
 * function insures that the original callback is not used anymore. This insured
355
357
 * by preempt_disable around the call site.
356
358
 */
357
 
static void disable_tracepoint(struct tracepoint *elem)
 
359
static void disable_tracepoint(struct lttng_ust_tracepoint *elem)
358
360
{
359
361
        elem->state = 0;
360
362
        rcu_assign_pointer(elem->probes, NULL);
364
366
 * Add the callsite to the callsite hash table. Must be called with
365
367
 * tracepoint mutex held.
366
368
 */
367
 
static void add_callsite(struct tracepoint_lib * lib, struct tracepoint *tp)
 
369
static void add_callsite(struct tracepoint_lib * lib, struct lttng_ust_tracepoint *tp)
368
370
{
369
371
        struct cds_hlist_head *head;
370
372
        struct callsite_entry *e;
435
437
        hash = jhash(name, name_len, 0);
436
438
        head = &callsite_table[hash & (CALLSITE_TABLE_SIZE - 1)];
437
439
        cds_hlist_for_each_entry(e, node, head, hlist) {
438
 
                struct tracepoint *tp = e->tp;
 
440
                struct lttng_ust_tracepoint *tp = e->tp;
439
441
 
440
442
                if (strncmp(name, tp->name, LTTNG_UST_SYM_NAME_LEN - 1))
441
443
                        continue;
456
458
 * Updates the probe callback corresponding to a range of tracepoints.
457
459
 */
458
460
static
459
 
void tracepoint_update_probe_range(struct tracepoint * const *begin,
460
 
                                   struct tracepoint * const *end)
 
461
void tracepoint_update_probe_range(struct lttng_ust_tracepoint * const *begin,
 
462
                                   struct lttng_ust_tracepoint * const *end)
461
463
{
462
 
        struct tracepoint * const *iter;
 
464
        struct lttng_ust_tracepoint * const *iter;
463
465
        struct tracepoint_entry *mark_entry;
464
466
 
465
467
        for (iter = begin; iter < end; iter++) {
487
489
 
488
490
static void lib_register_callsites(struct tracepoint_lib *lib)
489
491
{
490
 
        struct tracepoint * const *begin;
491
 
        struct tracepoint * const *end;
492
 
        struct tracepoint * const *iter;
 
492
        struct lttng_ust_tracepoint * const *begin;
 
493
        struct lttng_ust_tracepoint * const *end;
 
494
        struct lttng_ust_tracepoint * const *iter;
493
495
 
494
496
        begin = lib->tracepoints_start;
495
497
        end = lib->tracepoints_start + lib->tracepoints_count;
524
526
                lib_update_tracepoints(lib);
525
527
}
526
528
 
527
 
static struct tracepoint_probe *
 
529
static struct lttng_ust_tracepoint_probe *
528
530
tracepoint_add_probe(const char *name, void (*probe)(void), void *data,
529
531
                const char *signature)
530
532
{
531
533
        struct tracepoint_entry *entry;
532
 
        struct tracepoint_probe *old;
 
534
        struct lttng_ust_tracepoint_probe *old;
533
535
 
534
536
        entry = get_tracepoint(name);
535
537
        if (!entry) {
536
538
                entry = add_tracepoint(name, signature);
537
539
                if (IS_ERR(entry))
538
 
                        return (struct tracepoint_probe *)entry;
 
540
                        return (struct lttng_ust_tracepoint_probe *)entry;
539
541
        }
540
542
        old = tracepoint_entry_add_probe(entry, probe, data);
541
543
        if (IS_ERR(old) && !entry->refcount)
707
709
        pthread_mutex_unlock(&tracepoint_mutex);
708
710
}
709
711
 
710
 
void tracepoint_set_new_tracepoint_cb(void (*cb)(struct tracepoint *))
 
712
void tracepoint_set_new_tracepoint_cb(void (*cb)(struct lttng_ust_tracepoint *))
711
713
{
712
714
        new_tracepoint_cb = cb;
713
715
}
714
716
 
715
 
static void new_tracepoints(struct tracepoint * const *start, struct tracepoint * const *end)
 
717
static void new_tracepoints(struct lttng_ust_tracepoint * const *start,
 
718
                            struct lttng_ust_tracepoint * const *end)
716
719
{
717
720
        if (new_tracepoint_cb) {
718
 
                struct tracepoint * const *t;
 
721
                struct lttng_ust_tracepoint * const *t;
719
722
 
720
723
                for (t = start; t < end; t++) {
721
724
                        if (*t)
724
727
        }
725
728
}
726
729
 
727
 
int tracepoint_register_lib(struct tracepoint * const *tracepoints_start,
 
730
int tracepoint_register_lib(struct lttng_ust_tracepoint * const *tracepoints_start,
728
731
                            int tracepoints_count)
729
732
{
730
733
        struct tracepoint_lib *pl, *iter;
773
776
        return 0;
774
777
}
775
778
 
776
 
int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_start)
 
779
int tracepoint_unregister_lib(struct lttng_ust_tracepoint * const *tracepoints_start)
777
780
{
778
781
        struct tracepoint_lib *lib;
779
782