Commit | Line | Data |
---|---|---|
21f58fb7 FD |
1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
2 | * | |
3 | * lttng-event-notifier-notification.c | |
4 | * | |
5 | * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com> | |
6 | */ | |
7 | ||
8 | #include <lttng/events.h> | |
9 | #include <lttng/event-notifier-notification.h> | |
10 | ||
11 | void lttng_event_notifier_notification_send(struct lttng_event_notifier *event_notifier) | |
12 | { | |
13 | struct lttng_event_notifier_group *event_notifier_group = event_notifier->group; | |
14 | struct lib_ring_buffer_ctx ctx; | |
15 | int ret; | |
16 | ||
17 | if (unlikely(!READ_ONCE(event_notifier->enabled))) | |
18 | return; | |
19 | ||
20 | lib_ring_buffer_ctx_init(&ctx, event_notifier_group->chan, NULL, | |
21 | sizeof(event_notifier->user_token), | |
22 | lttng_alignof(event_notifier->user_token), -1); | |
23 | ret = event_notifier_group->ops->event_reserve(&ctx, 0); | |
24 | if (ret < 0) { | |
25 | //TODO: error handling with counter maps | |
26 | //silently drop for now. | |
27 | WARN_ON_ONCE(1); | |
28 | return; | |
29 | } | |
30 | lib_ring_buffer_align_ctx(&ctx, lttng_alignof(event_notifier->user_token)); | |
31 | event_notifier_group->ops->event_write(&ctx, &event_notifier->user_token, | |
32 | sizeof(event_notifier->user_token)); | |
33 | event_notifier_group->ops->event_commit(&ctx); | |
34 | irq_work_queue(&event_notifier_group->wakeup_pending); | |
35 | } |