diff options
author | Vyacheslav Cherkashin <v.cherkashin@samsung.com> | 2015-07-27 19:26:40 +0300 |
---|---|---|
committer | Dmitry Kovalenko <d.kovalenko@samsung.com> | 2015-08-27 23:45:05 -0700 |
commit | 195a72abdfa1fb6923df7c6fc342808c52fd0bab (patch) | |
tree | e321826ca976984266cf81b91d843e8d95b375ce | |
parent | ea80e0154da6f2461e754a7479eb6c253a3bf44f (diff) | |
download | swap-modules-195a72abdfa1fb6923df7c6fc342808c52fd0bab.tar.gz swap-modules-195a72abdfa1fb6923df7c6fc342808c52fd0bab.tar.bz2 swap-modules-195a72abdfa1fb6923df7c6fc342808c52fd0bab.zip |
[FIX] Preload: dentry balance counter
Use atomic_t instead of int to avoid race conditions
Change-Id: Ie32d46a8c822ef8ef6110832c0fcc14ea1594e9c
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
-rw-r--r-- | preload/preload_module.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/preload/preload_module.c b/preload/preload_module.c index 580c066d..0563eb7f 100644 --- a/preload/preload_module.c +++ b/preload/preload_module.c @@ -41,7 +41,7 @@ struct us_priv { unsigned long origin; }; -static int get_put_counter; +static atomic_t dentry_balance = ATOMIC_INIT(0); enum preload_status_t { SWAP_PRELOAD_NOT_READY = 0, @@ -69,7 +69,7 @@ static inline struct process_data *__get_process_data(struct uretprobe *rp) static struct dentry *__get_dentry(struct dentry *dentry) { - get_put_counter++; + atomic_inc(&dentry_balance); return dget(dentry); } @@ -129,7 +129,7 @@ struct dentry *get_dentry(const char *filepath) void put_dentry(struct dentry *dentry) { - get_put_counter--; + atomic_dec(&dentry_balance); dput(dentry); } @@ -980,6 +980,8 @@ out_err: static void preload_module_exit(void) { + int balance; + us_manager_unreg_cb(__preload_cbs_start_h); us_manager_unreg_cb(__preload_cbs_stop_h); unregister_preload_probes(); @@ -990,7 +992,10 @@ static void preload_module_exit(void) preload_storage_exit(); preload_debugfs_exit(); - WARN(get_put_counter, "Bad GET/PUT balance: %d\n", get_put_counter); + balance = atomic_read(&dentry_balance); + atomic_set(&dentry_balance, 0); + + WARN(balance, "Bad GET/PUT dentry balance: %d\n", balance); } SWAP_LIGHT_INIT_MODULE(NULL, preload_module_init, preload_module_exit, |