Skip to content

Commit 3e71f46

Browse files
committed
refactor(ff_epoll): drop ff_epoll_pairs_lock, F-Stack is single-threaded
F-Stack runs a single-threaded per-process polling model, so the mutex around the kqueue<->host-epoll pair table is unnecessary. Remove ff_epoll_pairs_lock and the pthread.h include from the FF_KERNEL_COEXIST block. Verified: macro-on build rc=0 (P1 unit tests 26/21/54 pass incl. test_ff_epoll); macro-off rc=0 with size 6539682 byte-identical to baseline (zero regression).
1 parent 16e32da commit 3e71f46

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

lib/ff_epoll.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "ff_errno.h"
2222
#ifdef FF_KERNEL_COEXIST
2323
#include "ff_host_interface.h"
24-
#include <pthread.h>
2524

2625
/*
2726
* Kernel-stack coexistence for native epoll (FR-6: unified event loop).
@@ -36,7 +35,6 @@
3635
*/
3736
#define FF_EPOLL_COEXIST_MAX 64
3837
static struct { int kq; int host_ep; } ff_epoll_pairs[FF_EPOLL_COEXIST_MAX];
39-
static pthread_mutex_t ff_epoll_pairs_lock = PTHREAD_MUTEX_INITIALIZER;
4038

4139
/* Return the host epoll fd paired with kqueue fd kq; create it lazily when
4240
* 'create' is non-zero. Returns -1 if none (and create==0) or on failure. */
@@ -45,14 +43,10 @@ ff_epoll_host_ep(int kq, int create)
4543
{
4644
int i, slot = -1, ep = -1;
4745

48-
pthread_mutex_lock(&ff_epoll_pairs_lock);
4946
for (i = 0; i < FF_EPOLL_COEXIST_MAX; i++) {
5047
if (ff_epoll_pairs[i].host_ep > 0) {
51-
if (ff_epoll_pairs[i].kq == kq) {
52-
ep = ff_epoll_pairs[i].host_ep;
53-
pthread_mutex_unlock(&ff_epoll_pairs_lock);
54-
return ep;
55-
}
48+
if (ff_epoll_pairs[i].kq == kq)
49+
return ff_epoll_pairs[i].host_ep;
5650
} else if (slot < 0) {
5751
slot = i;
5852
}
@@ -64,7 +58,6 @@ ff_epoll_host_ep(int kq, int create)
6458
ff_epoll_pairs[slot].host_ep = ep;
6559
}
6660
}
67-
pthread_mutex_unlock(&ff_epoll_pairs_lock);
6861
return (ep > 0) ? ep : -1;
6962
}
7063

@@ -75,7 +68,6 @@ ff_epoll_close_pair(int kq)
7568
{
7669
int i;
7770

78-
pthread_mutex_lock(&ff_epoll_pairs_lock);
7971
for (i = 0; i < FF_EPOLL_COEXIST_MAX; i++) {
8072
if (ff_epoll_pairs[i].host_ep > 0 && ff_epoll_pairs[i].kq == kq) {
8173
ff_host_close(ff_epoll_pairs[i].host_ep);
@@ -84,7 +76,6 @@ ff_epoll_close_pair(int kq)
8476
break;
8577
}
8678
}
87-
pthread_mutex_unlock(&ff_epoll_pairs_lock);
8879
}
8980
#endif /* FF_KERNEL_COEXIST */
9081

0 commit comments

Comments
 (0)