+
+/*
+ * Add context to a specific channel for global UST domain.
+ */
+int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx)
+{
+ int ret = 0;
+ struct cds_lfht_node *ua_chan_node;
+ struct cds_lfht_iter iter, uiter;
+ struct ust_app_channel *ua_chan = NULL;
+ struct ust_app_session *ua_sess;
+ struct ust_app *app;
+
+ rcu_read_lock();
+
+ cds_lfht_for_each_entry(ust_app_ht, &iter, app, node) {
+ ua_sess = lookup_session_by_app(usess, app);
+ if (ua_sess == NULL) {
+ continue;
+ }
+
+ /* Lookup channel in the ust app session */
+ ua_chan_node = hashtable_lookup(ua_sess->channels,
+ (void *)uchan->name, strlen(uchan->name), &uiter);
+ if (ua_chan_node == NULL) {
+ continue;
+ }
+ ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel,
+ node);
+
+ ret = create_ust_app_channel_context(ua_sess, ua_chan, &uctx->ctx, app);
+ if (ret < 0) {
+ continue;
+ }
+ }
+
+ /* Add ltt UST context node to ltt UST channel */
+ hashtable_add_unique(uchan->ctx, &uctx->node);
+
+ rcu_read_unlock();
+ return ret;
+}
+
+/*
+ * Add context to a specific event in a channel for global UST domain.
+ */
+int ust_app_add_ctx_event_glb(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
+ struct ltt_ust_context *uctx)
+{
+ int ret = 0;
+ struct cds_lfht_node *ua_chan_node, *ua_event_node;
+ struct cds_lfht_iter iter, uiter;
+ struct ust_app_session *ua_sess;
+ struct ust_app_event *ua_event;
+ struct ust_app_channel *ua_chan = NULL;
+ struct ust_app *app;
+
+ rcu_read_lock();
+
+ cds_lfht_for_each_entry(ust_app_ht, &iter, app, node) {
+ ua_sess = lookup_session_by_app(usess, app);
+ if (ua_sess == NULL) {
+ continue;
+ }
+
+ /* Lookup channel in the ust app session */
+ ua_chan_node = hashtable_lookup(ua_sess->channels,
+ (void *)uchan->name, strlen(uchan->name), &uiter);
+ if (ua_chan_node == NULL) {
+ continue;
+ }
+ ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel,
+ node);
+
+ ua_event_node = hashtable_lookup(ua_chan->events,
+ (void *)uevent->attr.name, strlen(uevent->attr.name), &uiter);
+ if (ua_event_node == NULL) {
+ continue;
+ }
+ ua_event = caa_container_of(ua_event_node, struct ust_app_event,
+ node);
+
+ ret = create_ust_app_event_context(ua_sess, ua_event, &uctx->ctx, app);
+ if (ret < 0) {
+ continue;
+ }
+ }
+
+ /* Add ltt UST context node to ltt UST event */
+ hashtable_add_unique(uevent->ctx, &uctx->node);
+
+ rcu_read_unlock();
+ return ret;
+}