- struct user_marker *umark;
- struct hlist_node *pos, *n;
-
- hlist_for_each_entry_safe(umark, pos, n, head, hlist) {
- if (umark->state == state) {
- hlist_del(&umark->hlist);
- kfree(umark);
- }
- }
-}
-
-//ust// asmlinkage long sys_marker(char __user *name, char __user *format,
-//ust// char __user *state, int reg)
-//ust// {
-//ust// struct user_marker *umark;
-//ust// long len;
-//ust// struct marker_entry *entry;
-//ust// int ret = 0;
-//ust//
-//ust// printk(KERN_DEBUG "Program %s %s marker [%p, %p]\n",
-//ust// current->comm, reg ? "registers" : "unregisters",
-//ust// name, state);
-//ust// if (reg) {
-//ust// umark = kmalloc(sizeof(struct user_marker), GFP_KERNEL);
-//ust// umark->name[MAX_USER_MARKER_NAME_LEN - 1] = '\0';
-//ust// umark->format[MAX_USER_MARKER_FORMAT_LEN - 1] = '\0';
-//ust// umark->state = state;
-//ust// len = strncpy_from_user(umark->name, name,
-//ust// MAX_USER_MARKER_NAME_LEN - 1);
-//ust// if (len < 0) {
-//ust// ret = -EFAULT;
-//ust// goto error;
-//ust// }
-//ust// len = strncpy_from_user(umark->format, format,
-//ust// MAX_USER_MARKER_FORMAT_LEN - 1);
-//ust// if (len < 0) {
-//ust// ret = -EFAULT;
-//ust// goto error;
-//ust// }
-//ust// printk(KERN_DEBUG "Marker name : %s, format : %s", umark->name,
-//ust// umark->format);
-//ust// mutex_lock(&markers_mutex);
-//ust// entry = get_marker("userspace", umark->name);
-//ust// if (entry) {
-//ust// if (entry->format &&
-//ust// strcmp(entry->format, umark->format) != 0) {
-//ust// printk(" error, wrong format in process %s",
-//ust// current->comm);
-//ust// ret = -EPERM;
-//ust// goto error_unlock;
-//ust// }
-//ust// printk(" %s", !!entry->refcount
-//ust// ? "enabled" : "disabled");
-//ust// if (put_user(!!entry->refcount, state)) {
-//ust// ret = -EFAULT;
-//ust// goto error_unlock;
-//ust// }
-//ust// printk("\n");
-//ust// } else {
-//ust// printk(" disabled\n");
-//ust// if (put_user(0, umark->state)) {
-//ust// printk(KERN_WARNING
-//ust// "Marker in %s caused a fault\n",
-//ust// current->comm);
-//ust// goto error_unlock;
-//ust// }
-//ust// }
-//ust// mutex_lock(¤t->group_leader->user_markers_mutex);
-//ust// hlist_add_head(&umark->hlist,
-//ust// ¤t->group_leader->user_markers);
-//ust// current->group_leader->user_markers_sequence++;
-//ust// mutex_unlock(¤t->group_leader->user_markers_mutex);
-//ust// mutex_unlock(&markers_mutex);
-//ust// } else {
-//ust// mutex_lock(¤t->group_leader->user_markers_mutex);
-//ust// free_user_marker(state,
-//ust// ¤t->group_leader->user_markers);
-//ust// current->group_leader->user_markers_sequence++;
-//ust// mutex_unlock(¤t->group_leader->user_markers_mutex);
-//ust// }
-//ust// goto end;
-//ust// error_unlock:
-//ust// mutex_unlock(&markers_mutex);
-//ust// error:
-//ust// kfree(umark);
-//ust// end:
-//ust// return ret;
-//ust// }
-//ust//
-//ust// /*
-//ust// * Types :
-//ust// * string : 0
-//ust// */
-//ust// asmlinkage long sys_trace(int type, uint16_t id,
-//ust// char __user *ubuf)
-//ust// {
-//ust// long ret = -EPERM;
-//ust// char *page;
-//ust// int len;
-//ust//
-//ust// switch (type) {
-//ust// case 0: /* String */
-//ust// ret = -ENOMEM;
-//ust// page = (char *)__get_free_page(GFP_TEMPORARY);
-//ust// if (!page)
-//ust// goto string_out;
-//ust// len = strncpy_from_user(page, ubuf, PAGE_SIZE);
-//ust// if (len < 0) {
-//ust// ret = -EFAULT;
-//ust// goto string_err;
-//ust// }
-//ust// trace_mark(userspace, string, "string %s", page);
-//ust// string_err:
-//ust// free_page((unsigned long) page);
-//ust// string_out:
-//ust// break;
-//ust// default:
-//ust// break;
-//ust// }
-//ust// return ret;
-//ust// }
-
-//ust// static void marker_update_processes(void)
-//ust// {
-//ust// struct task_struct *g, *t;
-//ust//
-//ust// /*
-//ust// * markers_mutex is taken to protect the p->user_markers read.
-//ust// */
-//ust// mutex_lock(&markers_mutex);
-//ust// read_lock(&tasklist_lock);
-//ust// for_each_process(g) {
-//ust// WARN_ON(!thread_group_leader(g));
-//ust// if (hlist_empty(&g->user_markers))
-//ust// continue;
-//ust// if (strcmp(g->comm, "testprog") == 0)
-//ust// printk(KERN_DEBUG "set update pending for testprog\n");
-//ust// t = g;
-//ust// do {
-//ust// /* TODO : implement this thread flag in each arch. */
-//ust// set_tsk_thread_flag(t, TIF_MARKER_PENDING);
-//ust// } while ((t = next_thread(t)) != g);
-//ust// }
-//ust// read_unlock(&tasklist_lock);
-//ust// mutex_unlock(&markers_mutex);
-//ust// }
-
-/*
- * Update current process.
- * Note that we have to wait a whole scheduler period before we are sure that
- * every running userspace threads have their markers updated.
- * (synchronize_sched() can be used to insure this).
- */
-void marker_update_process(void)
-{
- struct user_marker *umark;
- struct hlist_node *pos;
- struct marker_entry *entry;
-
- mutex_lock(&markers_mutex);
- mutex_lock(¤t->group_leader->user_markers_mutex);
- if (strcmp(current->comm, "testprog") == 0)
- printk(KERN_DEBUG "do update pending for testprog\n");
- hlist_for_each_entry(umark, pos,
- ¤t->group_leader->user_markers, hlist) {
- printk(KERN_DEBUG "Updating marker %s in %s\n",
- umark->name, current->comm);
- entry = get_marker("userspace", umark->name);
- if (entry) {
- if (entry->format &&
- strcmp(entry->format, umark->format) != 0) {
- printk(KERN_WARNING
- " error, wrong format in process %s\n",
- current->comm);
- break;
- }
- if (put_user(!!entry->refcount, umark->state)) {
- printk(KERN_WARNING
- "Marker in %s caused a fault\n",
- current->comm);
- break;
- }
- } else {
- if (put_user(0, umark->state)) {
- printk(KERN_WARNING
- "Marker in %s caused a fault\n",
- current->comm);
- break;
- }
- }
- }
- clear_thread_flag(TIF_MARKER_PENDING);
- mutex_unlock(¤t->group_leader->user_markers_mutex);
- mutex_unlock(&markers_mutex);
-}
-
-/*
- * Called at process exit and upon do_execve().
- * We assume that when the leader exits, no more references can be done to the
- * leader structure by the other threads.
- */
-void exit_user_markers(struct task_struct *p)
-{
- struct user_marker *umark;
- struct hlist_node *pos, *n;
-
- if (thread_group_leader(p)) {
- mutex_lock(&markers_mutex);
- mutex_lock(&p->user_markers_mutex);
- hlist_for_each_entry_safe(umark, pos, n, &p->user_markers,
- hlist)
- kfree(umark);
- INIT_HLIST_HEAD(&p->user_markers);
- p->user_markers_sequence++;
- mutex_unlock(&p->user_markers_mutex);
- mutex_unlock(&markers_mutex);
- }
-}
-
-int is_marker_enabled(const char *channel, const char *name)
-{
- struct marker_entry *entry;
-
- mutex_lock(&markers_mutex);
- entry = get_marker(channel, name);
- mutex_unlock(&markers_mutex);
-
- return entry && !!entry->refcount;
-}
-//ust// #endif
-
-int marker_module_notify(struct notifier_block *self,
- unsigned long val, void *data)
-{
- struct module *mod = data;
-
- switch (val) {
- case MODULE_STATE_COMING:
- marker_update_probe_range(mod->markers,
- mod->markers + mod->num_markers);
- break;
- case MODULE_STATE_GOING:
- marker_update_probe_range(mod->markers,
- mod->markers + mod->num_markers);
- break;
- }
- return 0;
-}
-
-struct notifier_block marker_module_nb = {
- .notifier_call = marker_module_notify,
- .priority = 0,
-};
-
-//ust// static int init_markers(void)
-//ust// {
-//ust// return register_module_notifier(&marker_module_nb);
-//ust// }
-//ust// __initcall(init_markers);
-/* TODO: call marker_module_nb() when a library is linked at runtime (dlopen)? */
-
-#endif /* CONFIG_MODULES */
-
-void ltt_dump_marker_state(struct ltt_trace_struct *trace)
-{
- struct marker_entry *entry;