Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homa_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ int homa_rpc_reap(struct homa_sock *hsk)
WARN_ON(refcount_sub_and_test(rpc->msgout.frag_bytes,
&hsk->sock.sk_wmem_alloc));
if (rpc->msgout.frags != &rpc->msgout.frag)
kfree(rpc->msgout.frags);
kvfree(rpc->msgout.frags);
tt_record2("homa_rpc_reap finished reaping id %d, port %d",
rpc->id, rpc->hsk->port);
#ifndef __STRIP__ /* See strip.py */
Expand Down
4 changes: 2 additions & 2 deletions homa_tx_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ int homa_tx_pool_alloc(struct homa *homa, int length, int *num_frags,
memcpy(new_frags, cur_frags,
frags_allocated * sizeof(*new_frags));
if (cur_frags != *frags)
kfree(cur_frags);
kvfree(cur_frags);
cur_frags = new_frags;
max_frags = num_new;
}
Expand All @@ -224,7 +224,7 @@ int homa_tx_pool_alloc(struct homa *homa, int length, int *num_frags,
error:
homa_tx_pool_free(homa, tx_core->nid, frags_allocated, cur_frags);
if (cur_frags != *frags)
kfree(cur_frags);
kvfree(cur_frags);
*num_frags = 0;
local_bh_enable();
return err;
Expand Down
12 changes: 11 additions & 1 deletion test/mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,9 @@ void kfree(const void *block)
FAIL(" %s on unknown block %p", __func__, block);
return;
}
if (strcmp(unit_hash_get(kmallocs_in_use, block), "kvmalloc") == 0)
FAIL(" %s on block %p from kvmalloc (needs kvfree)", __func__,
block);
unit_hash_erase(kmallocs_in_use, block);
free((void *) block);
}
Expand Down Expand Up @@ -1202,6 +1205,8 @@ int kstrtoint(const char *s, unsigned int base, int *res)

void kvfree(const void *addr)
{
if (addr && kmallocs_in_use && unit_hash_get(kmallocs_in_use, addr))
unit_hash_set(kmallocs_in_use, addr, "used");
kfree(addr);
}

Expand All @@ -1212,7 +1217,12 @@ void *__kvmalloc_node_noprof(DECL_BUCKET_PARAMS(size, b), unsigned long align,
void *__kvmalloc_node_noprof(DECL_BUCKET_PARAMS(size, b), gfp_t flags, int node)
#endif
{
return mock_kmalloc(size, flags);
void *block = mock_kmalloc(size, flags);

/* Real kvmalloc may return vmalloc memory, which kfree can't free. */
if (block)
unit_hash_set(kmallocs_in_use, block, "kvmalloc");
return block;
}

struct task_struct *kthread_create_on_node(int (*threadfn)(void *data),
Expand Down
10 changes: 5 additions & 5 deletions test/unit_homa_tx_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ TEST_F(homa_tx_pool, homa_tx_pool_alloc__reallocate_frags_array_large_pages)
EXPECT_STREQ("kmalloc 3 units", unit_log_get());

homa_tx_pool_free(&self->homa, 0, num_frags, frags);
kfree(frags);
kvfree(frags);
}
TEST_F(homa_tx_pool, homa_tx_pool_alloc__reallocate_frags_array_small_pages)
{
Expand All @@ -173,7 +173,7 @@ TEST_F(homa_tx_pool, homa_tx_pool_alloc__reallocate_frags_array_small_pages)
EXPECT_STREQ("kmalloc 10 units; kmalloc 160 units", unit_log_get());

homa_tx_pool_free(&self->homa, 0, num_frags, frags);
kfree(frags);
kvfree(frags);
}
TEST_F(homa_tx_pool, homa_tx_pool_alloc__cant_reallocate_frags_array)
{
Expand Down Expand Up @@ -470,7 +470,7 @@ TEST_F(homa_tx_pool, homa_tx_pool_free__basics)
EXPECT_EQ(skb_frag_page(&frags[3]), tx_pool->pages[1]);

put_page(skb_frag_page(&frags[0]));
kfree(frags);
kvfree(frags);
}
TEST_F(homa_tx_pool, homa_tx_pool_free__pages_not_in_right_numa)
{
Expand All @@ -489,7 +489,7 @@ TEST_F(homa_tx_pool, homa_tx_pool_free__pages_not_in_right_numa)
mock_page_nid_mask = 5;
homa_tx_pool_free(&self->homa, 0, num_frags, frags);
EXPECT_EQ(2, tx_pool->avail);
kfree(frags);
kvfree(frags);
}
TEST_F(homa_tx_pool, homa_tx_pool_free__pool_overflow)
{
Expand Down Expand Up @@ -519,7 +519,7 @@ TEST_F(homa_tx_pool, homa_tx_pool_free__pool_overflow)
put_page(skb_frag_page(&frags[0]));
put_page(skb_frag_page(&frags[1]));
tx_pool->avail = 0;
kfree(frags);
kvfree(frags);
}

TEST_F(homa_tx_pool, homa_tx_pool_gc__basics)
Expand Down