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 "pf/pf_group.h"
28 #include "sspt/sspt_proc.h"
30 #include "us_manager.h"
31 #include "debugfs_us_manager.h"
33 #include <writer/event_filter.h>
35 /* FIXME: move /un/init_msg() elsewhere and remove this include */
36 #include <writer/swap_writer_module.h> /* for /un/init_msg() */
40 static DEFINE_MUTEX(mutex_inst);
41 static enum status_type status = ST_OFF;
44 static void do_usm_stop(void)
51 static int do_usm_start(void)
55 ret = register_helper();
64 enum status_type usm_get_status(void)
66 mutex_lock(&mutex_inst);
69 EXPORT_SYMBOL_GPL(usm_get_status);
71 void usm_put_status(enum status_type st)
74 mutex_unlock(&mutex_inst);
76 EXPORT_SYMBOL_GPL(usm_put_status);
82 if (usm_get_status() == ST_OFF) {
83 printk("US instrumentation is not running!\n");
91 usm_put_status(ST_OFF);
95 EXPORT_SYMBOL_GPL(usm_stop);
102 st = usm_get_status();
104 printk("US instrumentation is already run!\n");
108 ret = do_usm_start();
117 EXPORT_SYMBOL_GPL(usm_start);
123 /* ============================================================================
125 * ============================================================================
127 static enum quiet_type quiet = QT_ON;
129 void set_quiet(enum quiet_type q)
133 EXPORT_SYMBOL_GPL(set_quiet);
135 enum quiet_type get_quiet(void)
139 EXPORT_SYMBOL_GPL(get_quiet);
145 /* ============================================================================
147 * ============================================================================
149 static int us_filter(struct task_struct *task)
151 return !!sspt_proc_get_by_task(task);
154 static struct ev_filter ev_us_filter = {
155 .name = "traced_process_only",
159 static int init_us_filter(void)
163 ret = event_filter_register(&ev_us_filter);
167 return event_filter_set(ev_us_filter.name);
170 static void exit_us_filter(void)
172 event_filter_unregister(&ev_us_filter);
179 static int __init init_us_manager(void)
183 ret = init_us_filter();
185 goto us_filter_init_fail;
191 goto helper_init_fail;
193 ret = init_debugfs_us_manager();
195 goto debugfs_init_fail;
210 static void __exit exit_us_manager(void)
215 exit_debugfs_us_manager();
221 module_init(init_us_manager);
222 module_exit(exit_us_manager);
224 MODULE_LICENSE ("GPL");