[oe-commits] [openembedded-core] 05/07: unfs3: fixed the issue that unfsd consumes 100% CPU

git at git.openembedded.org git at git.openembedded.org
Thu Oct 24 11:06:07 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 1f6784d2e839f81749d21ad1b615a9f7bb0e64d6
Author: Haiqing Bai <Haiqing.Bai at windriver.com>
AuthorDate: Thu Oct 24 10:33:04 2019 +0800

    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.
    
    Signed-off-by: Haiqing Bai <Haiqing.Bai at windriver.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 .../0001-Add-listen-action-for-a-tcp-socket.patch  | 54 ++++++++++++++++++++++
 meta/recipes-devtools/unfs3/unfs3_git.bb           |  1 +
 2 files changed, 55 insertions(+)

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 0000000..e9b9d3d
--- /dev/null
+++ b/meta/recipes-devtools/unfs3/unfs3/0001-Add-listen-action-for-a-tcp-socket.patch
@@ -0,0 +1,54 @@
+From b42ab8e1aca951dd06c113159491b3fd5cf06f2e Mon Sep 17 00:00:00 2001
+From: Haiqing Bai <Haiqing.Bai at windriver.com>
+Date: Thu, 24 Oct 2019 09:39:04 +0800
+Subject: [PATCH] Add "listen" action for a tcp socket which does not call
+ 'listen' after 'bind'
+
+It is found that /usr/bin/unfsd customus 100% cpu after starting qemu with 'nfs'
+option, and below lots of error messages shows when strace the process:
+
+poll([{fd=3, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND},{fd=4, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND},
+{fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND},{fd=6, events =POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}],
+4, 2000) = 2 ([{fd=4, revents=POLLHUP},{fd=6, revents=POLLHUP}])
+accept(4, 0x7ffd5e6dddc0, [128]) = -1 EINVAL (Invalid argument)
+accept(6, 0x7ffd5e6dddc0, [128]) = -1 EINVAL (Invalid argument)
+
+% time     seconds  usecs/call     calls    errors syscall
+------ ----------- ----------- --------- --------- ----------------
+ 70.87    0.005392           0    513886    513886 accept
+ 29.13    0.002216           0    256943           poll
+  0.00    0.000000           0         4           read
+
+The root cause is that 'listen' is not called for the binded
+socket. The depended libtipc does not call 'listen' if found
+the incomming socket is binded, so 'accept' reports the error
+in the 'for' loop and cpu consumed.
+
+Upstream-Status: Pending
+
+Signed-off-by: Haiqing Bai <Haiqing.Bai at windriver.com>
+---
+ daemon.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/daemon.c b/daemon.c
+index 028a181..4c85903 100644
+--- a/daemon.c
++++ b/daemon.c
+@@ -814,6 +814,13 @@ static SVCXPRT *create_tcp_transport(unsigned int port)
+ 	    fprintf(stderr, "Couldn't bind to tcp port %d\n", port);
+ 	    exit(1);
+ 	}
++
++	if (listen(sock, SOMAXCONN) < 0) {
++	    perror("listen");
++	    fprintf(stderr, "Couldn't listen on the address \n");
++	    close(sock);
++	    exit(1);
++	}
+     }
+ 
+     transp = svctcp_create(sock, 0, 0);
+-- 
+1.9.1
+
diff --git a/meta/recipes-devtools/unfs3/unfs3_git.bb b/meta/recipes-devtools/unfs3/unfs3_git.bb
index 79d0978..d60cee8 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 \
            file://tcp_no_delay.patch \
            file://0001-daemon.c-Libtirpc-porting-fixes.patch \
            file://0001-attr-fix-utime-for-symlink.patch \
+           file://0001-Add-listen-action-for-a-tcp-socket.patch \
           "
 SRCREV = "c12a5c69a8d59be6916cbd0e0f41c159f1962425"
 UPSTREAM_CHECK_GITTAGREGEX = "unfs3\-(?P<pver>.+)"

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list