]> sourceware.org Git - lvm2.git/commitdiff
Speedup memory un/locking
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 15 Oct 2010 09:48:23 +0000 (09:48 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 15 Oct 2010 09:48:23 +0000 (09:48 +0000)
Move the call of find_config_tree_node() from inner loop to outer
section of maps scanning.

lib/mm/memlock.c

index 5225eeafd5799396bf183a91a7e82f1e36ac3669..3de8cc1c69ea7f7bfb7690ec091d049c2c6ae33d 100644 (file)
@@ -121,10 +121,9 @@ static void _release_memory(void)
  * mlock/munlock memory areas from /proc/self/maps
  * format described in kernel/Documentation/filesystem/proc.txt
  */
-static int _maps_line(struct cmd_context *cmd, lvmlock_t lock,
+static int _maps_line(const struct config_node *cn, lvmlock_t lock,
                      const char* line, size_t* mstats)
 {
-       const struct config_node *cn;
        struct config_value *cv;
        long from, to;
        int pos, i;
@@ -153,7 +152,7 @@ static int _maps_line(struct cmd_context *cmd, lvmlock_t lock,
                }
 
        sz = to - from;
-       if (!(cn = find_config_tree_node(cmd, "activation/mlock_filter"))) {
+       if (!cn) {
                /* If no blacklist configured, use an internal set */
                for (i = 0; i < sizeof(_blacklist_maps) / sizeof(_blacklist_maps[0]); ++i)
                        if (strstr(line + pos, _blacklist_maps[i])) {
@@ -195,6 +194,7 @@ static int _maps_line(struct cmd_context *cmd, lvmlock_t lock,
 
 static int _memlock_maps(struct cmd_context *cmd, lvmlock_t lock, size_t *mstats)
 {
+       const struct config_node *cn;
        char *line, *line_end;
        size_t len;
        ssize_t n;
@@ -250,10 +250,11 @@ static int _memlock_maps(struct cmd_context *cmd, lvmlock_t lock, size_t *mstats
        }
 
        line = _maps_buffer;
+       cn = find_config_tree_node(cmd, "activation/mlock_filter");
 
        while ((line_end = strchr(line, '\n'))) {
                *line_end = '\0'; /* remove \n */
-               if (!_maps_line(cmd, lock, line, mstats))
+               if (!_maps_line(cn, lock, line, mstats))
                        ret = 0;
                line = line_end + 1;
        }
This page took 0.038583 seconds and 5 git commands to generate.