3 * modules/us_manager/us_manager.c
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Copyright (C) Samsung Electronics, 2013
21 * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
25 #include <linux/module.h>
26 #include <linux/mutex.h>
27 #include <linux/stop_machine.h>
28 #include "pf/pf_group.h"
29 #include "sspt/sspt_proc.h"
30 #include "probes/probe_info_new.h"
32 #include "us_manager.h"
33 #include "debugfs_us_manager.h"
34 #include "callbacks.h"
35 #include <writer/event_filter.h>
36 #include <master/swap_initializer.h>
39 static DEFINE_MUTEX(mutex_inst);
40 static enum status_type status = ST_OFF;
43 static int __do_usm_stop(void *data)
50 static void do_usm_stop(void)
55 unregister_helper_top();
57 ret = stop_machine(__do_usm_stop, NULL, NULL);
59 printk("do_usm_stop failed: %d\n", ret);
62 unregister_helper_bottom();
63 sspt_proc_check_empty();
66 static int do_usm_start(void)
70 ret = register_helper();
82 * @brief Get instrumentation status
84 * @return Instrumentation status
86 enum status_type usm_get_status(void)
88 mutex_lock(&mutex_inst);
91 EXPORT_SYMBOL_GPL(usm_get_status);
94 * @brief Put instrumentation status
96 * @param st Instrumentation status
99 void usm_put_status(enum status_type st)
102 mutex_unlock(&mutex_inst);
104 EXPORT_SYMBOL_GPL(usm_put_status);
107 * @brief Stop instrumentation
115 if (usm_get_status() == ST_OFF) {
116 printk(KERN_INFO "US instrumentation is not running!\n");
124 usm_put_status(ST_OFF);
128 EXPORT_SYMBOL_GPL(usm_stop);
131 * @brief Start instrumentation
140 st = usm_get_status();
142 printk(KERN_INFO "US instrumentation is already run!\n");
146 ret = do_usm_start();
155 EXPORT_SYMBOL_GPL(usm_start);
161 /* ============================================================================
163 * ============================================================================
165 static enum quiet_type quiet = QT_ON;
168 * @brief Set quiet mode
170 * @param q Quiet mode
173 void set_quiet(enum quiet_type q)
177 EXPORT_SYMBOL_GPL(set_quiet);
180 * @brief Get quiet mode
184 enum quiet_type get_quiet(void)
188 EXPORT_SYMBOL_GPL(get_quiet);
194 /* ============================================================================
196 * ============================================================================
198 static int us_filter(struct task_struct *task)
200 struct sspt_proc *proc;
202 /* FIXME: add read lock (deadlock in sampler) */
203 proc = sspt_proc_by_task(task);
205 return sspt_proc_is_send_event(proc);
210 static struct ev_filter ev_us_filter = {
211 .name = "traced_process_only",
215 static int init_us_filter(void)
219 ret = event_filter_register(&ev_us_filter);
223 return event_filter_set(ev_us_filter.name);
226 static void exit_us_filter(void)
228 event_filter_unregister(&ev_us_filter);
235 static int usm_once(void)
244 static int init_us_manager(void)
248 ret = sspt_proc_init();
256 ret = init_us_filter();
270 static void exit_us_manager(void)
282 SWAP_LIGHT_INIT_MODULE(usm_once, init_us_manager, exit_us_manager,
283 init_debugfs_us_manager, exit_debugfs_us_manager);
285 MODULE_LICENSE("GPL");