imamnurby/smpl_train_seed8 huggingface dataset:
--- initial
+++ final
@@ -1,43 +1,43 @@
 static int __proc_lnet_portal_rotor(void *data, int write, loff_t pos, void __user *buffer, int nob) {
   const int buf_len = 128;
   char *buf;
   char *tmp;
   int rc;
   int i;
-  LIBCFS_ALLOC(buf, buf_len);
+  buf = kmalloc(buf_len, GFP_NOFS);
   if (!buf) return -ENOMEM;
   if (!write) {
     lnet_res_lock(0);
     for (i = 0; portal_rotors[i].pr_value >= 0; i++) {
       if (portal_rotors[i].pr_value == portal_rotor) break;
     }
     LASSERT(portal_rotors[i].pr_value == portal_rotor);
     lnet_res_unlock(0);
     rc = snprintf(buf, buf_len,
                   "{\n\tportals: all\n"
                   "\trotor: %s\n\tdescription: %s\n}",
                   portal_rotors[i].pr_name, portal_rotors[i].pr_desc);
     if (pos >= min_t(int, rc, buf_len)) {
       rc = 0;
     } else {
       rc = cfs_trace_copyout_string(buffer, nob, buf + pos, "\n");
     }
     goto out;
   }
   rc = cfs_trace_copyin_string(buf, buf_len, buffer, nob);
   if (rc < 0) goto out;
   tmp = strim(buf);
   rc = -EINVAL;
   lnet_res_lock(0);
   for (i = 0; portal_rotors[i].pr_name; i++) {
     if (!strncasecmp(portal_rotors[i].pr_name, tmp, strlen(portal_rotors[i].pr_name))) {
       portal_rotor = portal_rotors[i].pr_value;
       rc = 0;
       break;
     }
   }
   lnet_res_unlock(0);
 out:
-  LIBCFS_FREE(buf, buf_len);
+  kfree(buf);
   return rc;
 }<sep>@@
expression buf,data;
@@
-	LIBCFS_ALLOC(buf, data);
+	buf = kmalloc(data, GFP_NOFS);

@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,19 +1,19 @@
 static int lstcon_rpc_prep(struct lstcon_node *nd, int service, unsigned int feats, int bulk_npg, int bulk_len, struct lstcon_rpc **crpcpp) {
   struct lstcon_rpc *crpc = NULL;
   int rc;
   spin_lock(&console_session.ses_rpc_lock);
   crpc = list_first_entry_or_null(&console_session.ses_rpc_freelist, struct lstcon_rpc, crp_link);
   if (crpc) list_del_init(&crpc->crp_link);
   spin_unlock(&console_session.ses_rpc_lock);
   if (!crpc) {
-    LIBCFS_ALLOC(crpc, sizeof(*crpc));
+    crpc = kmalloc(sizeof(*crpc), GFP_NOFS);
     if (!crpc) return -ENOMEM;
   }
   rc = lstcon_rpc_init(nd, service, feats, bulk_npg, bulk_len, 0, crpc);
   if (!rc) {
     *crpcpp = crpc;
     return 0;
   }
-  LIBCFS_FREE(crpc, sizeof(*crpc));
+  kfree(crpc);
   return rc;
 }<sep>@@
expression buf,data;
@@
-	LIBCFS_ALLOC(buf, data);
+	buf = kmalloc(data, GFP_NOFS);

@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,32 +1,32 @@
 void ksocknal_destroy_conn(struct ksock_conn *conn) {
   unsigned long last_rcv;
   /* Final coup-de-grace of the reaper */
   CDEBUG(D_NET, "connection %p\n", conn);
   LASSERT(!atomic_read(&conn->ksnc_conn_refcount));
   LASSERT(!atomic_read(&conn->ksnc_sock_refcount));
   LASSERT(!conn->ksnc_sock);
   LASSERT(!conn->ksnc_route);
   LASSERT(!conn->ksnc_tx_scheduled);
   LASSERT(!conn->ksnc_rx_scheduled);
   LASSERT(list_empty(&conn->ksnc_tx_queue));
   /* complete current receive if any */
   switch (conn->ksnc_rx_state) {
   case SOCKNAL_RX_LNET_PAYLOAD:
     last_rcv = conn->ksnc_rx_deadline - cfs_time_seconds(*ksocknal_tunables.ksnd_timeout);
     CERROR("Completing partial receive from %s[%d], ip %pI4h:%d, with error, wanted: %zd, left: %d, last alive is %ld secs ago\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type, &conn->ksnc_ipaddr, conn->ksnc_port, iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left, cfs_duration_sec(cfs_time_sub(cfs_time_current(), last_rcv)));
     lnet_finalize(conn->ksnc_peer->ksnp_ni, conn->ksnc_cookie, -EIO);
     break;
   case SOCKNAL_RX_LNET_HEADER:
     if (conn->ksnc_rx_started) CERROR("Incomplete receive of lnet header from %s, ip %pI4h:%d, with error, protocol: %d.x.\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_proto->pro_version);
     break;
   case SOCKNAL_RX_KSM_HEADER:
     if (conn->ksnc_rx_started) CERROR("Incomplete receive of ksock message from %s, ip %pI4h:%d, with error, protocol: %d.x.\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_proto->pro_version);
     break;
   case SOCKNAL_RX_SLOP:
     if (conn->ksnc_rx_started) CERROR("Incomplete receive of slops from %s, ip %pI4h:%d, with error\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), &conn->ksnc_ipaddr, conn->ksnc_port);
     break;
   default: LBUG(); break;
   }
   ksocknal_peer_decref(conn->ksnc_peer);
-  LIBCFS_FREE(conn, sizeof(*conn));
+  kfree(conn);
 }<sep>@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,7 +1,7 @@
 void lnet_ipif_free_enumeration(char **names, int n) {
   int i;
   LASSERT(n > 0);
   for (i = 0; i < n && names[i]; i++)
-    LIBCFS_FREE(names[i], IFNAMSIZ);
-  LIBCFS_FREE(names, n * sizeof(*names));
+    kfree(names[i]);
+  kfree(names);
 }<sep>@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,5 +1,5 @@
 void ksocknal_destroy_route(struct ksock_route *route) {
   LASSERT(!atomic_read(&route->ksnr_refcount));
   if (route->ksnr_peer) ksocknal_peer_decref(route->ksnr_peer);
-  LIBCFS_FREE(route, sizeof(*route));
+  kfree(route);
 }<sep>@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,27 +1,27 @@
 static void ksocknal_free_buffers(void) {
   LASSERT(!atomic_read(&ksocknal_data.ksnd_nactive_txs));
   if (ksocknal_data.ksnd_sched_info) {
     struct ksock_sched_info *info;
     int i;
     cfs_percpt_for_each(info, i, ksocknal_data.ksnd_sched_info) {
-      if (info->ksi_scheds) { LIBCFS_FREE(info->ksi_scheds, info->ksi_nthreads_max * sizeof(info->ksi_scheds[0])); }
+      if (info->ksi_scheds) { kfree(info->ksi_scheds); }
     }
     cfs_percpt_free(ksocknal_data.ksnd_sched_info);
   }
   kvfree(ksocknal_data.ksnd_peers);
   spin_lock(&ksocknal_data.ksnd_tx_lock);
   if (!list_empty(&ksocknal_data.ksnd_idle_noop_txs)) {
     struct list_head zlist;
     struct ksock_tx *tx;
     struct ksock_tx *temp;
     list_add(&zlist, &ksocknal_data.ksnd_idle_noop_txs);
     list_del_init(&ksocknal_data.ksnd_idle_noop_txs);
     spin_unlock(&ksocknal_data.ksnd_tx_lock);
     list_for_each_entry_safe(tx, temp, &zlist, tx_list) {
       list_del(&tx->tx_list);
       kfree(tx);
     }
   } else {
     spin_unlock(&ksocknal_data.ksnd_tx_lock);
   }
 }<sep>@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,13 +1,13 @@
 void lnet_ni_free(struct lnet_ni *ni) {
   int i;
   if (ni->ni_refs) cfs_percpt_free(ni->ni_refs);
   if (ni->ni_tx_queues) cfs_percpt_free(ni->ni_tx_queues);
   if (ni->ni_cpts) cfs_expr_list_values_free(ni->ni_cpts, ni->ni_ncpts);
   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);
+    kfree(ni->ni_interfaces[i]);
   }
   /* release reference to net namespace */
   if (ni->ni_net_ns) put_net(ni->ni_net_ns);
   kfree(ni);
 }<sep>@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,9 +1,9 @@
 void cfs_percpt_free(void *vars) {
   struct cfs_var_array *arr;
   int i;
   arr = container_of(vars, struct cfs_var_array, va_ptrs[0]);
   for (i = 0; i < arr->va_count; i++) {
-    if (arr->va_ptrs[i]) LIBCFS_FREE(arr->va_ptrs[i], arr->va_size);
+    if (arr->va_ptrs[i]) kfree(arr->va_ptrs[i]);
   }
   kvfree(arr);
 }<sep>@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,11 +1,11 @@
 void ksocknal_free_tx(struct ksock_tx *tx) {
   atomic_dec(&ksocknal_data.ksnd_nactive_txs);
   if (!tx->tx_lnetmsg && tx->tx_desc_size == KSOCK_NOOP_TX_SIZE) {
     /* it's a noop tx */
     spin_lock(&ksocknal_data.ksnd_tx_lock);
     list_add(&tx->tx_list, &ksocknal_data.ksnd_idle_noop_txs);
     spin_unlock(&ksocknal_data.ksnd_tx_lock);
   } else {
-    LIBCFS_FREE(tx, tx->tx_desc_size);
+    kfree(tx);
   }
 }<sep>@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,10 +1,10 @@
 void cfs_array_free(void *vars) {
   struct cfs_var_array *arr;
   int i;
   arr = container_of(vars, struct cfs_var_array, va_ptrs[0]);
   for (i = 0; i < arr->va_count; i++) {
     if (!arr->va_ptrs[i]) continue;
-    LIBCFS_FREE(arr->va_ptrs[i], arr->va_size);
+    kfree(arr->va_ptrs[i]);
   }
-  LIBCFS_FREE(arr, offsetof(struct cfs_var_array, va_ptrs[arr->va_count]));
+  kfree(arr);
 }<sep>@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,16 +1,16 @@
 void kiblnd_destroy_peer(struct kib_peer *peer) {
   struct kib_net *net = peer->ibp_ni->ni_data;
   LASSERT(net);
   LASSERT(!atomic_read(&peer->ibp_refcount));
   LASSERT(!kiblnd_peer_active(peer));
   LASSERT(kiblnd_peer_idle(peer));
   LASSERT(list_empty(&peer->ibp_tx_queue));
-  LIBCFS_FREE(peer, sizeof(*peer));
+  kfree(peer);
   /*
    * NB a peer's connections keep a reference on their peer until
    * they are destroyed, so we can be assured that _all_ state to do
    * with this peer has been cleaned up when its refcount drops to
    * zero.
    */
   atomic_dec(&net->ibn_npeers);
 }<sep>@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,31 +1,31 @@
 int kiblnd_create_peer(struct lnet_ni *ni, struct kib_peer **peerp, lnet_nid_t nid) {
   struct kib_peer *peer;
   struct kib_net *net = ni->ni_data;
   int cpt = lnet_cpt_of_nid(nid);
   unsigned long flags;
   LASSERT(net);
   LASSERT(nid != LNET_NID_ANY);
-  LIBCFS_CPT_ALLOC(peer, lnet_cpt_table(), cpt, sizeof(*peer));
+  peer = kzalloc_cpt(sizeof(*peer), GFP_NOFS, cpt);
   if (!peer) {
     CERROR("Cannot allocate peer\n");
     return -ENOMEM;
   }
   peer->ibp_ni = ni;
   peer->ibp_nid = nid;
   peer->ibp_error = 0;
   peer->ibp_last_alive = 0;
   peer->ibp_max_frags = kiblnd_cfg_rdma_frags(peer->ibp_ni);
   peer->ibp_queue_depth = ni->ni_peertxcredits;
   atomic_set(&peer->ibp_refcount, 1); /* 1 ref for caller */
   INIT_LIST_HEAD(&peer->ibp_list);    /* not in the peer table yet */
   INIT_LIST_HEAD(&peer->ibp_conns);
   INIT_LIST_HEAD(&peer->ibp_tx_queue);
   write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
   /* always called with a ref on ni, which prevents ni being shutdown */
   LASSERT(!net->ibn_shutdown);
   /* npeers only grows with the global lock held */
   atomic_inc(&net->ibn_npeers);
   write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
   *peerp = peer;
   return 0;
 }<sep>@@
expression peer,cpt;
@@
-	LIBCFS_CPT_ALLOC(peer, lnet_cpt_table(), cpt, sizeof(*peer));
+	peer = kzalloc_cpt(sizeof(*peer), GFP_NOFS, cpt);
--- initial
+++ final
@@ -1,35 +1,35 @@
 static int kiblnd_alloc_freg_pool(struct kib_fmr_poolset *fps, struct kib_fmr_pool *fpo) {
   struct kib_fast_reg_descriptor *frd, *tmp;
   int i, rc;
   INIT_LIST_HEAD(&fpo->fast_reg.fpo_pool_list);
   fpo->fast_reg.fpo_pool_size = 0;
   for (i = 0; i < fps->fps_pool_size; i++) {
-    LIBCFS_CPT_ALLOC(frd, lnet_cpt_table(), fps->fps_cpt, sizeof(*frd));
+    frd = kzalloc_cpt(sizeof(*frd), GFP_NOFS, fps->fps_cpt);
     if (!frd) {
       CERROR("Failed to allocate a new fast_reg descriptor\n");
       rc = -ENOMEM;
       goto out;
     }
     frd->frd_mr = ib_alloc_mr(fpo->fpo_hdev->ibh_pd, IB_MR_TYPE_MEM_REG, LNET_MAX_PAYLOAD / PAGE_SIZE);
     if (IS_ERR(frd->frd_mr)) {
       rc = PTR_ERR(frd->frd_mr);
       CERROR("Failed to allocate ib_alloc_mr: %d\n", rc);
       frd->frd_mr = NULL;
       goto out_middle;
     }
     frd->frd_valid = true;
     list_add_tail(&frd->frd_list, &fpo->fast_reg.fpo_pool_list);
     fpo->fast_reg.fpo_pool_size++;
   }
   return 0;
 out_middle:
   if (frd->frd_mr) ib_dereg_mr(frd->frd_mr);
   kfree(frd);
 out:
   list_for_each_entry_safe(frd, tmp, &fpo->fast_reg.fpo_pool_list, frd_list) {
     list_del(&frd->frd_list);
     ib_dereg_mr(frd->frd_mr);
     kfree(frd);
   }
   return rc;
 }<sep>@@
expression peer,cpt;
@@
-	LIBCFS_CPT_ALLOC(peer, lnet_cpt_table(), cpt, sizeof(*peer));
+	peer = kzalloc_cpt(sizeof(*peer), GFP_NOFS, cpt);
--- initial
+++ final
@@ -1,29 +1,29 @@
 int lstcon_group_info(char *name, struct lstcon_ndlist_ent __user *gents_p, int *index_p, int *count_p, struct lstcon_node_ent __user *dents_up) {
   struct lstcon_ndlist_ent *gentp;
   struct lstcon_group *grp;
   struct lstcon_ndlink *ndl;
   int rc;
   rc = lstcon_group_find(name, &grp);
   if (rc) {
     CDEBUG(D_NET, "Can't find group %s\n", name);
     return rc;
   }
   if (dents_up) {
     /* verbose query */
     rc = lstcon_nodes_getent(&grp->grp_ndl_list, index_p, count_p, dents_up);
     lstcon_group_decref(grp);
     return rc;
   }
   /* non-verbose query */
-  LIBCFS_ALLOC(gentp, sizeof(struct lstcon_ndlist_ent));
+  gentp = kmalloc(sizeof(struct lstcon_ndlist_ent), GFP_NOFS);
   if (!gentp) {
     CERROR("Can't allocate ndlist_ent\n");
     lstcon_group_decref(grp);
     return -ENOMEM;
   }
   list_for_each_entry(ndl, &grp->grp_ndl_list, ndl_link) LST_NODE_STATE_COUNTER(ndl->ndl_node, gentp);
   rc = copy_to_user(gents_p, gentp, sizeof(struct lstcon_ndlist_ent)) ? -EFAULT : 0;
-  LIBCFS_FREE(gentp, sizeof(struct lstcon_ndlist_ent));
+  kfree(gentp);
   lstcon_group_decref(grp);
   return rc;
 }<sep>@@
expression buf,data;
@@
-	LIBCFS_ALLOC(buf, data);
+	buf = kmalloc(data, GFP_NOFS);

@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,24 +1,24 @@
 int lnet_parse_ip2nets(char **networksp, char *ip2nets) {
   __u32 *ipaddrs = NULL;
   int nip = lnet_ipaddr_enumerate(&ipaddrs);
   int rc;
   if (nip < 0) {
     LCONSOLE_ERROR_MSG(0x117, "Error %d enumerating local IP interfaces for ip2nets to match\n", nip);
     return nip;
   }
   if (!nip) {
     LCONSOLE_ERROR_MSG(0x118, "No local IP interfaces for ip2nets to match\n");
     return -ENOENT;
   }
   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);
     return rc;
   }
   if (!rc) {
     LCONSOLE_ERROR_MSG(0x11a, "ip2nets does not match any local IP interfaces\n");
     return -ENOENT;
   }
   return 0;
 }<sep>@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,51 +1,51 @@
 int lnet_del_route(__u32 net, lnet_nid_t gw_nid) {
   struct lnet_peer *gateway;
   struct lnet_remotenet *rnet;
   struct lnet_route *route;
   struct list_head *e1;
   struct list_head *e2;
   int rc = -ENOENT;
   struct list_head *rn_list;
   int idx = 0;
   CDEBUG(D_NET, "Del route: net %s : gw %s\n", libcfs_net2str(net), libcfs_nid2str(gw_nid));
   /*
    * NB Caller may specify either all routes via the given gateway
    * or a specific route entry actual NIDs)
    */
   lnet_net_lock(LNET_LOCK_EX);
   if (net == LNET_NIDNET(LNET_NID_ANY))
     rn_list = &the_lnet.ln_remote_nets_hash[0];
   else
     rn_list = lnet_net2rnethash(net);
 again:
   list_for_each(e1, rn_list) {
     rnet = list_entry(e1, struct lnet_remotenet, lrn_list);
     if (!(net == LNET_NIDNET(LNET_NID_ANY) || net == rnet->lrn_net)) continue;
     list_for_each(e2, &rnet->lrn_routes) {
       route = list_entry(e2, struct lnet_route, lr_list);
       gateway = route->lr_gateway;
       if (!(gw_nid == LNET_NID_ANY || gw_nid == gateway->lp_nid)) continue;
       list_del(&route->lr_list);
       list_del(&route->lr_gwlist);
       the_lnet.ln_remote_nets_version++;
       if (list_empty(&rnet->lrn_routes))
         list_del(&rnet->lrn_list);
       else
         rnet = NULL;
       lnet_rtr_decref_locked(gateway);
       lnet_peer_decref_locked(gateway);
       lnet_net_unlock(LNET_LOCK_EX);
-      LIBCFS_FREE(route, sizeof(*route));
-      if (rnet) LIBCFS_FREE(rnet, sizeof(*rnet));
+      kfree(route);
+      if (rnet) kfree(rnet);
       rc = 0;
       lnet_net_lock(LNET_LOCK_EX);
       goto again;
     }
   }
   if (net == LNET_NIDNET(LNET_NID_ANY) && ++idx < LNET_REMOTE_NETS_HASH_SIZE) {
     rn_list = &the_lnet.ln_remote_nets_hash[idx];
     goto again;
   }
   lnet_net_unlock(LNET_LOCK_EX);
   return rc;
 }<sep>@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,9 +1,9 @@
 static void lstcon_group_decref(struct lstcon_group *grp) {
   int i;
   if (--grp->grp_ref > 0) return;
   if (!list_empty(&grp->grp_link)) list_del(&grp->grp_link);
   lstcon_group_drain(grp, 0);
   for (i = 0; i < LST_NODE_HASHSIZE; i++)
     LASSERT(list_empty(&grp->grp_ndl_hash[i]));
-  LIBCFS_FREE(grp, offsetof(struct lstcon_group, grp_ndl_hash[LST_NODE_HASHSIZE]));
+  kfree(grp);
 }<sep>@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,7 +1,7 @@
 struct srpc_client_rpc *srpc_create_client_rpc(struct lnet_process_id peer, int service, int nbulkiov, int bulklen, void (*rpc_done)(struct srpc_client_rpc *), void (*rpc_fini)(struct srpc_client_rpc *), void *priv) {
   struct srpc_client_rpc *rpc;
-  LIBCFS_ALLOC(rpc, offsetof(struct srpc_client_rpc, crpc_bulk.bk_iovs[nbulkiov]));
+  rpc = kmalloc(offsetof(struct srpc_client_rpc, crpc_bulk.bk_iovs[nbulkiov]), GFP_NOFS);
   if (!rpc) return NULL;
   srpc_init_client_rpc(rpc, peer, service, nbulkiov, bulklen, rpc_done, rpc_fini, priv);
   return rpc;
 }<sep>@@
expression buf,data;
@@
-	LIBCFS_ALLOC(buf, data);
+	buf = kmalloc(data, GFP_NOFS);
--- initial
+++ final
@@ -1,7 +1,7 @@
 static void cfs_hash_buckets_free(struct cfs_hash_bucket **buckets, int bkt_size, int prev_size, int size) {
   int i;
   for (i = prev_size; i < size; i++) {
-    if (buckets[i]) LIBCFS_FREE(buckets[i], bkt_size);
+    if (buckets[i]) kfree(buckets[i]);
   }
-  LIBCFS_FREE(buckets, sizeof(buckets[0]) * size);
+  kfree(buckets);
 }<sep>@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,56 +1,56 @@
 int lstcon_test_add(char *batch_name, int type, int loop, int concur, int dist, int span, char *src_name, char *dst_name, void *param, int paramlen, int *retp, struct list_head __user *result_up) {
   struct lstcon_test *test = NULL;
   int rc;
   struct lstcon_group *src_grp = NULL;
   struct lstcon_group *dst_grp = NULL;
   struct lstcon_batch *batch = NULL;
   /*
    * verify that a batch of the given name exists, and the groups
    * that will be part of the batch exist and have at least one
    * active node
    */
   rc = lstcon_verify_batch(batch_name, &batch);
   if (rc) goto out;
   rc = lstcon_verify_group(src_name, &src_grp);
   if (rc) goto out;
   rc = lstcon_verify_group(dst_name, &dst_grp);
   if (rc) goto out;
   if (dst_grp->grp_userland) *retp = 1;
-  LIBCFS_ALLOC(test, offsetof(struct lstcon_test, tes_param[paramlen]));
+  test = kmalloc(offsetof(struct lstcon_test, tes_param[paramlen]), GFP_NOFS);
   if (!test) {
     CERROR("Can't allocate test descriptor\n");
     rc = -ENOMEM;
     goto out;
   }
   test->tes_hdr.tsb_id = batch->bat_hdr.tsb_id;
   test->tes_batch = batch;
   test->tes_type = type;
   test->tes_oneside = 0; /* TODO */
   test->tes_loop = loop;
   test->tes_concur = concur;
   test->tes_stop_onerr = 1; /* TODO */
   test->tes_span = span;
   test->tes_dist = dist;
   test->tes_cliidx = 0; /* just used for creating RPC */
   test->tes_src_grp = src_grp;
   test->tes_dst_grp = dst_grp;
   INIT_LIST_HEAD(&test->tes_trans_list);
   if (param) {
     test->tes_paramlen = paramlen;
     memcpy(&test->tes_param[0], param, paramlen);
   }
   rc = lstcon_test_nodes_add(test, result_up);
   if (rc) goto out;
   if (lstcon_trans_stat()->trs_rpc_errno || lstcon_trans_stat()->trs_fwk_errno) CDEBUG(D_NET, "Failed to add test %d to batch %s\n", type, batch_name);
   /* add to test list anyway, so user can check what's going on */
   list_add_tail(&test->tes_link, &batch->bat_test_list);
   batch->bat_ntest++;
   test->tes_hdr.tsb_index = batch->bat_ntest;
   /*  hold groups so nobody can change them */
   return rc;
 out:
-  if (test) LIBCFS_FREE(test, offsetof(struct lstcon_test, tes_param[paramlen]));
+  if (test) kfree(test);
   if (dst_grp) lstcon_group_decref(dst_grp);
   if (src_grp) lstcon_group_decref(src_grp);
   return rc;
 }<sep>@@
expression buf,data;
@@
-	LIBCFS_ALLOC(buf, data);
+	buf = kmalloc(data, GFP_NOFS);

@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);
--- initial
+++ final
@@ -1,14 +1,14 @@
 static void nv04_cursor_set_offset(struct nouveau_crtc *nv_crtc, uint32_t offset) {
   struct drm_device *dev = nv_crtc->base.dev;
   struct nouveau_drm *drm = nouveau_drm(dev);
   struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index];
   struct drm_crtc *crtc = &nv_crtc->base;
   regp->CRTC[NV_CIO_CRE_HCUR_ADDR0_INDEX] = MASK(NV_CIO_CRE_HCUR_ASI) | XLATE(offset, 17, NV_CIO_CRE_HCUR_ADDR0_ADR);
   regp->CRTC[NV_CIO_CRE_HCUR_ADDR1_INDEX] = XLATE(offset, 11, NV_CIO_CRE_HCUR_ADDR1_ADR);
   if (crtc->mode.flags & DRM_MODE_FLAG_DBLSCAN) regp->CRTC[NV_CIO_CRE_HCUR_ADDR1_INDEX] |= MASK(NV_CIO_CRE_HCUR_ADDR1_CUR_DBL);
   regp->CRTC[NV_CIO_CRE_HCUR_ADDR2_INDEX] = offset >> 24;
   crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR0_INDEX);
   crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR1_INDEX);
   crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR2_INDEX);
-  if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) nv_fix_nv40_hw_cursor(dev, nv_crtc->index);
+  if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE) nv_fix_nv40_hw_cursor(dev, nv_crtc->index);
 }<sep>@@
struct nouveau_drm *drm;
@@
- drm->device
+ drm->client.device
--- initial
+++ final
@@ -1,26 +1,26 @@
 static int nouveau_gart_manager_new(struct ttm_mem_type_manager *man, struct ttm_buffer_object *bo, const struct ttm_place *place, struct ttm_mem_reg *mem) {
   struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
   struct nouveau_bo *nvbo = nouveau_bo(bo);
   struct nvkm_mem *node;
   node = kzalloc(sizeof(*node), GFP_KERNEL);
   if (!node) return -ENOMEM;
   node->page_shift = 12;
-  switch (drm->device.info.family) {
+  switch (drm->client.device.info.family) {
   case NV_DEVICE_INFO_V0_TNT:
   case NV_DEVICE_INFO_V0_CELSIUS:
   case NV_DEVICE_INFO_V0_KELVIN:
   case NV_DEVICE_INFO_V0_RANKINE:
   case NV_DEVICE_INFO_V0_CURIE: break;
   case NV_DEVICE_INFO_V0_TESLA:
-    if (drm->device.info.chipset != 0x50) node->memtype = (nvbo->tile_flags & 0x7f00) >> 8;
+    if (drm->client.device.info.chipset != 0x50) node->memtype = (nvbo->tile_flags & 0x7f00) >> 8;
     break;
   case NV_DEVICE_INFO_V0_FERMI:
   case NV_DEVICE_INFO_V0_KEPLER:
   case NV_DEVICE_INFO_V0_MAXWELL:
   case NV_DEVICE_INFO_V0_PASCAL: node->memtype = (nvbo->tile_flags & 0xff00) >> 8; break;
-  default: NV_WARN(drm, "%s: unhandled family type %x\n", __func__, drm->device.info.family); break;
+  default: NV_WARN(drm, "%s: unhandled family type %x\n", __func__, drm->client.device.info.family); break;
   }
   mem->mm_node = node;
   mem->start = 0;
   return 0;
 }<sep>@@
struct nouveau_drm *drm;
@@
- drm->device
+ drm->client.device