From 18b82048e457d6ff426d9dd828475d4dd02b8204 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 5 Mar 2010 14:48:33 +0000 Subject: mlockall() -> mlock() This patch adds a new implementation of locking function instead of mlockall() that may lock way too much memory (>100MB). New function instead uses mlock() system call and selectively locks memory areas from /proc/self/maps trying to avoid locking areas unused during lock-ed state. Patch also adds struct cmd_context to all memlock() calls to have access to configuration. For backward compatibility functionality of mlockall() is preserved with "activation/use_mlockall" flag. As a simple check, locking and unlocking counts the amount of memory and compares whether values are matching. --- lib/locking/locking.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/locking') diff --git a/lib/locking/locking.c b/lib/locking/locking.c index a636f7c7..76dbda53 100644 --- a/lib/locking/locking.c +++ b/lib/locking/locking.c @@ -161,22 +161,22 @@ static void _unblock_signals(void) _signals_blocked = 0; } -static void _lock_memory(lv_operation_t lv_op) +static void _lock_memory(struct cmd_context *cmd, lv_operation_t lv_op) { if (!(_locking.flags & LCK_PRE_MEMLOCK)) return; if (lv_op == LV_SUSPEND) - memlock_inc(); + memlock_inc(cmd); } -static void _unlock_memory(lv_operation_t lv_op) +static void _unlock_memory(struct cmd_context *cmd, lv_operation_t lv_op) { if (!(_locking.flags & LCK_PRE_MEMLOCK)) return; if (lv_op == LV_RESUME) - memlock_dec(); + memlock_dec(cmd); } void reset_locking(void) @@ -363,7 +363,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource, int ret = 0; _block_signals(flags); - _lock_memory(lv_op); + _lock_memory(cmd, lv_op); assert(resource); @@ -390,7 +390,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource, _update_vg_lock_count(resource, flags); } - _unlock_memory(lv_op); + _unlock_memory(cmd, lv_op); _unblock_signals(); return ret; -- cgit