Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad2acbd

Browse files
Fix deadlock over hsk->protect_count in homa_rpc_reap
Must return from homa_rpc_reap if hsk->protect_count > 0, even if reap_all is specified. Otherwise self-deadlock can occur, where homa_timer protects a socket, then gets interrupted by homa_softirq, which calls homa_rpc_reap with reap_all.
1 parent 54e8390 commit ad2acbd

File tree

2 files changed

+0
-46
lines changed

2 files changed

+0
-46
lines changed

homa_rpc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,6 @@ int homa_rpc_reap(struct homa_sock *hsk, bool reap_all)
502502
hsk->port, atomic_read(&hsk->protect_count),
503503
hsk->dead_skbs);
504504
homa_sock_unlock(hsk);
505-
if (reap_all)
506-
continue;
507505
return 0;
508506
}
509507

test/unit_homa_rpc.c

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,6 @@
1414
#define n(x) htons(x)
1515
#define N(x) htonl(x)
1616

17-
static struct homa_sock *hook_hsk;
18-
void unprotect_hsk_hook(char *id)
19-
{
20-
if (strcmp(id, "unlock") != 0)
21-
return;
22-
if (hook_hsk) {
23-
homa_unprotect_rpcs(hook_hsk);
24-
hook_hsk = NULL;
25-
}
26-
}
27-
28-
#if 0
29-
static struct homa_rpc *hook_rpc;
30-
static int hook_count;
31-
static void unlink_rpc_hook(char *id)
32-
{
33-
if (strcmp(id, "spin_lock")!= 0)
34-
return;
35-
if (hook_count == 0)
36-
return;
37-
hook_count--;
38-
if (hook_count == 0) {
39-
list_del_init(&hook_rpc->ready_links);
40-
homa_rpc_put(hook_rpc);
41-
}
42-
}
43-
#endif
44-
4517
FIXTURE(homa_rpc) {
4618
struct in6_addr client_ip[1];
4719
int client_port;
@@ -606,22 +578,6 @@ TEST_F(homa_rpc, homa_rpc_reap__protected)
606578
homa_unprotect_rpcs(&self->hsk);
607579
EXPECT_STREQ("", unit_log_get());
608580
}
609-
TEST_F(homa_rpc, homa_rpc_reap__protected_and_reap_all)
610-
{
611-
struct homa_rpc *crpc1 = unit_client_rpc(&self->hsk,
612-
UNIT_RCVD_ONE_PKT, self->client_ip, self->server_ip,
613-
self->server_port, self->client_id, 5000, 2000);
614-
615-
ASSERT_NE(NULL, crpc1);
616-
homa_rpc_end(crpc1);
617-
unit_log_clear();
618-
homa_protect_rpcs(&self->hsk);
619-
hook_hsk = &self->hsk;
620-
unit_hook_register(unprotect_hsk_hook);
621-
EXPECT_EQ(0, homa_rpc_reap(&self->hsk, true));
622-
EXPECT_STREQ("reaped 1234", unit_log_get());
623-
EXPECT_EQ(0, self->hsk.dead_skbs);
624-
}
625581
TEST_F(homa_rpc, homa_rpc_reap__skip_rpc_because_locked)
626582
{
627583
struct homa_rpc *crpc1 = unit_client_rpc(&self->hsk,

0 commit comments

Comments
 (0)