cfs_expr_list_values_free(u32 *values, int num)
 {
        /*
-        * This array is allocated by LIBCFS_ALLOC(), so it shouldn't be freed
+        * This array is allocated by kvalloc(), so it shouldn't be freed
         * by OBD_FREE() if it's called by module other than libcfs & LNet,
         * otherwise we will see fake memory leak
         */
-       LIBCFS_FREE(values, num * sizeof(values[0]));
+       kvfree(values);
 }
 
 void cfs_expr_list_free(struct cfs_expr_list *expr_list);
 
                break;
        }
 
-       if (kiblnd_data.kib_peers) {
-               LIBCFS_FREE(kiblnd_data.kib_peers,
-                           sizeof(struct list_head) *
-                           kiblnd_data.kib_peer_hash_size);
-       }
+       kvfree(kiblnd_data.kib_peers);
 
        if (kiblnd_data.kib_scheds)
                cfs_percpt_free(kiblnd_data.kib_scheds);
        INIT_LIST_HEAD(&kiblnd_data.kib_failed_devs);
 
        kiblnd_data.kib_peer_hash_size = IBLND_PEER_HASH_SIZE;
-       LIBCFS_ALLOC(kiblnd_data.kib_peers,
-                    sizeof(struct list_head) * kiblnd_data.kib_peer_hash_size);
+       kiblnd_data.kib_peers = kvmalloc_array(kiblnd_data.kib_peer_hash_size,
+                                              sizeof(struct list_head),
+                                              GFP_KERNEL);
        if (!kiblnd_data.kib_peers)
                goto failed;
        for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++)
 
        conn->ksnc_tx_carrier = NULL;
        atomic_set(&conn->ksnc_tx_nob, 0);
 
-       LIBCFS_ALLOC(hello, offsetof(struct ksock_hello_msg,
-                                    kshm_ips[LNET_MAX_INTERFACES]));
+       hello = kvzalloc(offsetof(struct ksock_hello_msg,
+                                 kshm_ips[LNET_MAX_INTERFACES]),
+                        GFP_KERNEL);
        if (!hello) {
                rc = -ENOMEM;
                goto failed_1;
                rc = ksocknal_send_hello(ni, conn, peerid.nid, hello);
        }
 
-       LIBCFS_FREE(hello, offsetof(struct ksock_hello_msg,
-                                   kshm_ips[LNET_MAX_INTERFACES]));
+       kvfree(hello);
 
        /*
         * setup the socket AFTER I've received hello (it disables
        ksocknal_peer_decref(peer);
 
 failed_1:
-       if (hello)
-               LIBCFS_FREE(hello, offsetof(struct ksock_hello_msg,
-                                           kshm_ips[LNET_MAX_INTERFACES]));
+       kvfree(hello);
 
        kfree(conn);
 
                cfs_percpt_free(ksocknal_data.ksnd_sched_info);
        }
 
-       LIBCFS_FREE(ksocknal_data.ksnd_peers,
-                   sizeof(struct list_head) *
-                   ksocknal_data.ksnd_peer_hash_size);
+       kvfree(ksocknal_data.ksnd_peers);
 
        spin_lock(&ksocknal_data.ksnd_tx_lock);
 
        memset(&ksocknal_data, 0, sizeof(ksocknal_data)); /* zero pointers */
 
        ksocknal_data.ksnd_peer_hash_size = SOCKNAL_PEER_HASH_SIZE;
-       LIBCFS_ALLOC(ksocknal_data.ksnd_peers,
-                    sizeof(struct list_head) *
-                    ksocknal_data.ksnd_peer_hash_size);
+       ksocknal_data.ksnd_peers = kvmalloc_array(ksocknal_data.ksnd_peer_hash_size,
+                                                 sizeof(struct list_head),
+                                                 GFP_KERNEL);
        if (!ksocknal_data.ksnd_peers)
                return -ENOMEM;
 
 
 {
        int i;
 
-       for (i = prev_size; i < size; i++) {
-               if (buckets[i])
-                       LIBCFS_FREE(buckets[i], bkt_size);
-       }
+       for (i = prev_size; i < size; i++)
+               kfree(buckets[i]);
 
-       LIBCFS_FREE(buckets, sizeof(buckets[0]) * size);
+       kvfree(buckets);
 }
 
 /*
        if (old_bkts && old_size == new_size)
                return old_bkts;
 
-       LIBCFS_ALLOC(new_bkts, sizeof(new_bkts[0]) * new_size);
+       new_bkts = kvmalloc_array(new_size, sizeof(new_bkts[0]), GFP_KERNEL);
        if (!new_bkts)
                return NULL;
 
                struct hlist_head *hhead;
                struct cfs_hash_bd bd;
 
-               LIBCFS_ALLOC(new_bkts[i], cfs_hash_bkt_size(hs));
+               new_bkts[i] = kzalloc(cfs_hash_bkt_size(hs), GFP_KERNEL);
                if (!new_bkts[i]) {
                        cfs_hash_buckets_free(new_bkts, cfs_hash_bkt_size(hs),
                                              old_size, new_size);
 
        len = !(flags & CFS_HASH_BIGNAME) ?
              CFS_HASH_NAME_LEN : CFS_HASH_BIGNAME_LEN;
-       LIBCFS_ALLOC(hs, offsetof(struct cfs_hash, hs_name[len]));
+       hs = kzalloc(offsetof(struct cfs_hash, hs_name[len]), GFP_KERNEL);
        if (!hs)
                return NULL;
 
        if (hs->hs_buckets)
                return hs;
 
-       LIBCFS_FREE(hs, offsetof(struct cfs_hash, hs_name[len]));
+       kfree(hs);
        return NULL;
 }
 EXPORT_SYMBOL(cfs_hash_create);
                              0, CFS_HASH_NBKT(hs));
        i = cfs_hash_with_bigname(hs) ?
            CFS_HASH_BIGNAME_LEN : CFS_HASH_NAME_LEN;
-       LIBCFS_FREE(hs, offsetof(struct cfs_hash, hs_name[i]));
+       kfree(hs);
 }
 
 struct cfs_hash *cfs_hash_getref(struct cfs_hash *hs)
 
                if (!arr->va_ptrs[i])
                        continue;
 
-               LIBCFS_FREE(arr->va_ptrs[i], arr->va_size);
+               kvfree(arr->va_ptrs[i]);
        }
-       LIBCFS_FREE(arr, offsetof(struct cfs_var_array,
-                                 va_ptrs[arr->va_count]));
+       kvfree(arr);
 }
 EXPORT_SYMBOL(cfs_array_free);
 
        struct cfs_var_array *arr;
        int i;
 
-       LIBCFS_ALLOC(arr, offsetof(struct cfs_var_array, va_ptrs[count]));
+       arr = kvmalloc(offsetof(struct cfs_var_array, va_ptrs[count]), GFP_KERNEL);
        if (!arr)
                return NULL;
 
        arr->va_size = size;
 
        for (i = 0; i < count; i++) {
-               LIBCFS_ALLOC(arr->va_ptrs[i], size);
+               arr->va_ptrs[i] = kvzalloc(size, GFP_KERNEL);
 
                if (!arr->va_ptrs[i]) {
                        cfs_array_free((void *)&arr->va_ptrs[0]);
 
                return -EINVAL;
        }
 
-       LIBCFS_ALLOC(val, sizeof(val[0]) * count);
+       val = kvmalloc_array(count, sizeof(val[0]), GFP_KERNEL | __GFP_ZERO);
        if (!val)
                return -ENOMEM;
 
 
 
                LASSERT(rc <= LNET_CPT_NUMBER);
                if (rc == LNET_CPT_NUMBER) {
-                       LIBCFS_FREE(ni->ni_cpts, rc * sizeof(ni->ni_cpts[0]));
+                       cfs_expr_list_values_free(ni->ni_cpts, LNET_CPT_NUMBER);
                        ni->ni_cpts = NULL;
                }