diff options
author | Haiqing Bai <Haiqing.Bai@windriver.com> | 2019-10-24 10:33:04 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-10-28 05:31:42 +0000 |
commit | 6d77529d62248d77aff8e293905d9a156997a12c (patch) | |
tree | cff87894652c720058c6ef53770f95ee3e4c8fed /meta/recipes-devtools/unfs3 | |
parent | 85903df1c1545da372c556cf12066d535355465a (diff) | |
download | poky-6d77529d62248d77aff8e293905d9a156997a12c.tar.gz |
unfs3: fixed the issue that unfsd consumes 100% CPU
The 'accept' function on the socket of unfsd daemon
is always in below error state:
accept(4, 0x7ffd5e6dddc0, [128]) = -1 EINVAL (Invalid argument)
accept(6, 0x7ffd5e6dddc0, [128]) = -1 EINVAL (Invalid argument)
And 'strace -c -p <the pid of unfsd>' shows:
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
70.87 0.005392 0 513886 513886 accept
29.13 0.002216 0 256943 poll
This error state is in the 'for' loop of the daemon, so it consumes 100%
CPU. The reason is that 'listen' is not called for the TCP socket before
'accept'. Actually the called 'svc_tli_create' from libtirpc will not call
'listen' on a bound socket.
(From OE-Core rev: 1f6784d2e839f81749d21ad1b615a9f7bb0e64d6)
Signed-off-by: Haiqing Bai <Haiqing.Bai@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/unfs3')
-rw-r--r-- | meta/recipes-devtools/unfs3/unfs3/0001-Add-listen-action-for-a-tcp-socket.patch | 54 | ||||
-rw-r--r-- | meta/recipes-devtools/unfs3/unfs3_git.bb | 1 |
2 files changed, 55 insertions, 0 deletions
diff --git a/meta/recipes-devtools/unfs3/unfs3/0001-Add-listen-action-for-a-tcp-socket.patch b/meta/recipes-devtools/unfs3/unfs3/0001-Add-listen-action-for-a-tcp-socket.patch new file mode 100644 index 0000000000..e9b9d3df46 --- /dev/null +++ b/meta/recipes-devtools/unfs3/unfs3/0001-Add-listen-action-for-a-tcp-socket.patch | |||
@@ -0,0 +1,54 @@ | |||
1 | From b42ab8e1aca951dd06c113159491b3fd5cf06f2e Mon Sep 17 00:00:00 2001 | ||
2 | From: Haiqing Bai <Haiqing.Bai@windriver.com> | ||
3 | Date: Thu, 24 Oct 2019 09:39:04 +0800 | ||
4 | Subject: [PATCH] Add "listen" action for a tcp socket which does not call | ||
5 | 'listen' after 'bind' | ||
6 | |||
7 | It is found that /usr/bin/unfsd customus 100% cpu after starting qemu with 'nfs' | ||
8 | option, and below lots of error messages shows when strace the process: | ||
9 | |||
10 | poll([{fd=3, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND},{fd=4, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}, | ||
11 | {fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND},{fd=6, events =POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], | ||
12 | 4, 2000) = 2 ([{fd=4, revents=POLLHUP},{fd=6, revents=POLLHUP}]) | ||
13 | accept(4, 0x7ffd5e6dddc0, [128]) = -1 EINVAL (Invalid argument) | ||
14 | accept(6, 0x7ffd5e6dddc0, [128]) = -1 EINVAL (Invalid argument) | ||
15 | |||
16 | % time seconds usecs/call calls errors syscall | ||
17 | ------ ----------- ----------- --------- --------- ---------------- | ||
18 | 70.87 0.005392 0 513886 513886 accept | ||
19 | 29.13 0.002216 0 256943 poll | ||
20 | 0.00 0.000000 0 4 read | ||
21 | |||
22 | The root cause is that 'listen' is not called for the binded | ||
23 | socket. The depended libtipc does not call 'listen' if found | ||
24 | the incomming socket is binded, so 'accept' reports the error | ||
25 | in the 'for' loop and cpu consumed. | ||
26 | |||
27 | Upstream-Status: Pending | ||
28 | |||
29 | Signed-off-by: Haiqing Bai <Haiqing.Bai@windriver.com> | ||
30 | --- | ||
31 | daemon.c | 7 +++++++ | ||
32 | 1 file changed, 7 insertions(+) | ||
33 | |||
34 | diff --git a/daemon.c b/daemon.c | ||
35 | index 028a181..4c85903 100644 | ||
36 | --- a/daemon.c | ||
37 | +++ b/daemon.c | ||
38 | @@ -814,6 +814,13 @@ static SVCXPRT *create_tcp_transport(unsigned int port) | ||
39 | fprintf(stderr, "Couldn't bind to tcp port %d\n", port); | ||
40 | exit(1); | ||
41 | } | ||
42 | + | ||
43 | + if (listen(sock, SOMAXCONN) < 0) { | ||
44 | + perror("listen"); | ||
45 | + fprintf(stderr, "Couldn't listen on the address \n"); | ||
46 | + close(sock); | ||
47 | + exit(1); | ||
48 | + } | ||
49 | } | ||
50 | |||
51 | transp = svctcp_create(sock, 0, 0); | ||
52 | -- | ||
53 | 1.9.1 | ||
54 | |||
diff --git a/meta/recipes-devtools/unfs3/unfs3_git.bb b/meta/recipes-devtools/unfs3/unfs3_git.bb index 79d09788d3..d60cee87c9 100644 --- a/meta/recipes-devtools/unfs3/unfs3_git.bb +++ b/meta/recipes-devtools/unfs3/unfs3_git.bb | |||
@@ -23,6 +23,7 @@ SRC_URI = "git://github.com/unfs3/unfs3.git;protocol=https \ | |||
23 | file://tcp_no_delay.patch \ | 23 | file://tcp_no_delay.patch \ |
24 | file://0001-daemon.c-Libtirpc-porting-fixes.patch \ | 24 | file://0001-daemon.c-Libtirpc-porting-fixes.patch \ |
25 | file://0001-attr-fix-utime-for-symlink.patch \ | 25 | file://0001-attr-fix-utime-for-symlink.patch \ |
26 | file://0001-Add-listen-action-for-a-tcp-socket.patch \ | ||
26 | " | 27 | " |
27 | SRCREV = "c12a5c69a8d59be6916cbd0e0f41c159f1962425" | 28 | SRCREV = "c12a5c69a8d59be6916cbd0e0f41c159f1962425" |
28 | UPSTREAM_CHECK_GITTAGREGEX = "unfs3\-(?P<pver>.+)" | 29 | UPSTREAM_CHECK_GITTAGREGEX = "unfs3\-(?P<pver>.+)" |