LASSERT(!the_lnet.ln_remote_nets_hash);
        LASSERT(the_lnet.ln_remote_nets_hbits > 0);
-       LIBCFS_ALLOC(hash, LNET_REMOTE_NETS_HASH_SIZE * sizeof(*hash));
+       hash = kvmalloc_array(LNET_REMOTE_NETS_HASH_SIZE, sizeof(*hash),
+                             GFP_KERNEL);
        if (!hash) {
                CERROR("Failed to create remote nets hash table\n");
                return -ENOMEM;
        for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++)
                LASSERT(list_empty(&the_lnet.ln_remote_nets_hash[i]));
 
-       LIBCFS_FREE(the_lnet.ln_remote_nets_hash,
-                   LNET_REMOTE_NETS_HASH_SIZE *
-                   sizeof(the_lnet.ln_remote_nets_hash[0]));
+       kvfree(the_lnet.ln_remote_nets_hash);
        the_lnet.ln_remote_nets_hash = NULL;
 }
 
        unsigned int infosz;
 
        infosz = offsetof(struct lnet_ping_info, pi_ni[num_ni]);
-       LIBCFS_ALLOC(ping_info, infosz);
+       ping_info = kvzalloc(infosz, GFP_KERNEL);
        if (!ping_info) {
                CERROR("Can't allocate ping info[%d]\n", num_ni);
                return NULL;
 static inline void
 lnet_ping_info_free(struct lnet_ping_info *pinfo)
 {
-       LIBCFS_FREE(pinfo,
-                   offsetof(struct lnet_ping_info,
-                            pi_ni[pinfo->pi_nnis]));
+       kvfree(pinfo);
 }
 
 static void
        if (id.pid == LNET_PID_ANY)
                id.pid = LNET_PID_LUSTRE;
 
-       LIBCFS_ALLOC(info, infosz);
+       info = kzalloc(infosz, GFP_KERNEL);
        if (!info)
                return -ENOMEM;
 
        LASSERT(!rc2);
 
  out_0:
-       LIBCFS_FREE(info, infosz);
+       kfree(info);
        return rc;
 }
 
 
        kfree(ni->ni_lnd_tunables);
 
-       for (i = 0; i < LNET_MAX_INTERFACES && ni->ni_interfaces[i]; i++) {
-               LIBCFS_FREE(ni->ni_interfaces[i],
-                           strlen(ni->ni_interfaces[i]) + 1);
-       }
+       for (i = 0; i < LNET_MAX_INTERFACES && ni->ni_interfaces[i]; i++)
+               kfree(ni->ni_interfaces[i]);
 
        /* release reference to net namespace */
        if (ni->ni_net_ns)
 lnet_parse_networks(struct list_head *nilist, char *networks)
 {
        struct cfs_expr_list *el = NULL;
-       int tokensize;
        char *tokens;
        char *str;
        char *tmp;
                return -EINVAL;
        }
 
-       tokensize = strlen(networks) + 1;
-
-       LIBCFS_ALLOC(tokens, tokensize);
+       tokens = kstrdup(networks, GFP_KERNEL);
        if (!tokens) {
                CERROR("Can't allocate net tokens\n");
                return -ENOMEM;
        }
 
-       memcpy(tokens, networks, tokensize);
        tmp = tokens;
        str = tokens;
 
                         * The newly allocated ni_interfaces[] can be
                         * freed when freeing the NI
                         */
-                       LIBCFS_ALLOC(ni->ni_interfaces[niface],
-                                    strlen(iface) + 1);
+                       ni->ni_interfaces[niface] = kstrdup(iface, GFP_KERNEL);
                        if (!ni->ni_interfaces[niface]) {
                                CERROR("Can't allocate net interface name\n");
                                goto failed;
                        }
-                       strncpy(ni->ni_interfaces[niface], iface,
-                               strlen(iface));
                        niface++;
                        iface = comma;
                } while (iface);
        list_for_each(temp_node, nilist)
                nnets++;
 
-       LIBCFS_FREE(tokens, tokensize);
+       kfree(tokens);
        return nnets;
 
  failed_syntax:
        if (el)
                cfs_expr_list_free(el);
 
-       LIBCFS_FREE(tokens, tokensize);
+       kfree(tokens);
 
        return -EINVAL;
 }
                return NULL;
        }
 
-       LIBCFS_ALLOC(ltb, nob);
+       ltb = kzalloc(nob, GFP_KERNEL);
        if (!ltb)
                return NULL;
 
 lnet_free_text_buf(struct lnet_text_buf *ltb)
 {
        lnet_tbnob -= ltb->ltb_size;
-       LIBCFS_FREE(ltb, ltb->ltb_size);
+       kfree(ltb);
 }
 
 static void
        if (nif <= 0)
                return nif;
 
-       LIBCFS_ALLOC(ipaddrs, nif * sizeof(*ipaddrs));
+       ipaddrs = kzalloc(nif * sizeof(*ipaddrs), GFP_KERNEL);
        if (!ipaddrs) {
                CERROR("Can't allocate ipaddrs[%d]\n", nif);
                lnet_ipif_free_enumeration(ifnames, nif);
                *ipaddrsp = ipaddrs;
        } else {
                if (nip > 0) {
-                       LIBCFS_ALLOC(ipaddrs2, nip * sizeof(*ipaddrs2));
+                       ipaddrs2 = kzalloc(nip * sizeof(*ipaddrs2),
+                                          GFP_KERNEL);
                        if (!ipaddrs2) {
                                CERROR("Can't allocate ipaddrs[%d]\n", nip);
                                nip = -ENOMEM;
                                rc = nip;
                        }
                }
-               LIBCFS_FREE(ipaddrs, nip * sizeof(*ipaddrs));
+               kfree(ipaddrs);
        }
        return nip;
 }
        }
 
        rc = lnet_match_networks(networksp, ip2nets, ipaddrs, nip);
-       LIBCFS_FREE(ipaddrs, nip * sizeof(*ipaddrs));
+       kfree(ipaddrs);
 
        if (rc < 0) {
                LCONSOLE_ERROR_MSG(0x119, "Error %d parsing ip2nets\n", rc);