struct delayed_work destroy_dwork;
 };
 
-/*
- * The following two functions "fix" the issue where there are more pids
- * than kmalloc will give memory for; in such cases, we use vmalloc/vfree.
- * TODO: replace with a kernel-wide solution to this problem
- */
-#define PIDLIST_TOO_LARGE(c) ((c) * sizeof(pid_t) > (PAGE_SIZE * 2))
-static void *pidlist_allocate(int count)
-{
-       if (PIDLIST_TOO_LARGE(count))
-               return vmalloc(array_size(count, sizeof(pid_t)));
-       else
-               return kmalloc_array(count, sizeof(pid_t), GFP_KERNEL);
-}
-
-static void pidlist_free(void *p)
-{
-       kvfree(p);
-}
-
 /*
  * Used to destroy all pidlists lingering waiting for destroy timer.  None
  * should be left afterwards.
         */
        if (!delayed_work_pending(dwork)) {
                list_del(&l->links);
-               pidlist_free(l->list);
+               kvfree(l->list);
                put_pid_ns(l->key.ns);
                tofree = l;
        }
         * show up until sometime later on.
         */
        length = cgroup_task_count(cgrp);
-       array = pidlist_allocate(length);
+       array = kvmalloc_array(length, sizeof(pid_t), GFP_KERNEL);
        if (!array)
                return -ENOMEM;
        /* now, populate the array */
 
        l = cgroup_pidlist_find_create(cgrp, type);
        if (!l) {
-               pidlist_free(array);
+               kvfree(array);
                return -ENOMEM;
        }
 
        /* store array, freeing old if necessary */
-       pidlist_free(l->list);
+       kvfree(l->list);
        l->list = array;
        l->length = length;
        *lp = l;