fix timerfd support
PATCH 1/1 fix timerfd support
From: vonnyfly <[email protected]>
There are some exceptions when checking features in Makefile. In my debian, timerfd.h path is not '/usr/include/sys/timerfd.h'.
$ find /usr/include -name "timerfd.h" | head -n1 /usr/include/x86_64-linux-gnu/sys/timerfd.h
In my raspberrypi, the path is also not here.
So, it will not enable timerfd, even though it supports actually. When I enable it after fix. I have seen error logs. "Failed to write to pipe".
From the code, we could know in add_work, it calls work_timer_schedule_evt. work_timer_schedule_evt will call write(timer_fd[1], ...), then it will print error log, because timer_fd[1] == -1.
When enable timerfd support, makefile check incorrectly. work_timer_schedule_evt should check support of timerfd.
--- usr/Makefile | 2 +- usr/work.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
usr/Makefile +1 -1
@@ -5,7 +5,7 @@ ifneq ($(shell test -e /usr/include/linux/signalfd.h && echo 1),) CFLAGS += -DUSE_SIGNALFD endif -ifneq ($(shell test -e /usr/include/sys/timerfd.h && echo 1),) +ifneq ($(shell test -n $(shell find /usr/include -name "timerfd.h" | head -n1) && echo 1),) CFLAGS += -DUSE_TIMERFD endif
usr/work.c +1 -1
@@ -59,7 +59,7 @@ static void work_timer_schedule_evt(void)unsigned int n =0 ;int err; -if (timer_pending) +if (timer_pending || timer_fd[1 ] <0 )return ; timer_pending =1 ;
Signature · 1 line
2.8.1
FUJITA Tomonori
AppliedQuoted 10 lines · On Tue, 3 May 2016 16:45:38 +0800 Feng Li <[email protected]> wrote:
From: vonnyfly <[email protected]>
There are some exceptions when checking features in
Makefile. In my debian,timerfd.hpath is not '/usr/include/sys/timerfd.h'.$ find /usr/include -name "timerfd.h" | head -n1 /usr/include/x86_64-linux-gnu/sys/timerfd.hIn my raspberrypi, the path is also not here.
Quoted 7 lines
So, it will not enable timerfd, even though it supports actually. When I enable it after fix. I have seen error logs. "Failed to write to pipe".
From the code, we could know in
add_work, it callswork_timer_schedule_evt.work_timer_schedule_evtwill callwrite(timer_fd[1], ...), then it will print error log, because timer_fd[1] == -1.
Looks like with timerfd enabled, work_timer_schedule_evt() isn't called. add_work() is always called with the non-zero second argument. How you hit the above bug?
Quoted 8 lines
When enable timerfd support, makefile check incorrectly.
work_timer_schedule_evtshould check support of timerfd.Signed-off-by vonnyfly <[email protected]>--- usr/Makefile | 2 +- usr/work.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Applied, thanks.
Hi Tomonori ,
Thanks for your response.
Please see my response inline.
Quoted 17 lines · FUJITA Tomonori
Quoted 14 lines · On Tue, 3 May 2016 16:45:38 +0800 Feng Li <[email protected]> wrote:
From: vonnyfly <[email protected]>
There are some exceptions when checking features in
Makefile. In my debian,timerfd.hpath is not '/usr/include/sys/timerfd.h'.$ find /usr/include -name "timerfd.h" | head -n1 /usr/include/x86_64-linux-gnu/sys/timerfd.hIn my raspberrypi, the path is also not here.
So, it will not enable timerfd, even though it supports actually. When I enable it after fix. I have seen error logs. "Failed to write to pipe".
Quoted 6 lines
Quoted 3 lines
From the code, we could know in
add_work, it callswork_timer_schedule_evt.work_timer_schedule_evtwill callwrite(timer_fd[1], ...), then it will print error log, because timer_fd[1] == -1.Looks like with timerfd enabled,
work_timer_schedule_evt()isn't called.add_work()is always called with the non-zero second argument. How you hit the above bug?
The easiest way to see this log is to replace 'add_work(&nop_work, 1);' to 'add_work(&nop_work, 0);'. Like this:
usr/iscsi/iscsi_tcp.c +1 -1
@@ -438,7 +438,7 @@ static int iscsi_tcp_init(void) nop_work.func = iscsi_tcp_nop_work_handler; nop_work.data = &nop_work; -add_work (&nop_work,1 ); +add_work (&nop_work,0 );
tgtd: work_timer_schedule_evt(69) Failed to write to pipe, Bad file descriptor
Quoted 10 lines
Quoted 9 lines
When enable timerfd support, makefile check incorrectly.
work_timer_schedule_evtshould check support of timerfd.Signed-off-by vonnyfly <[email protected]>--- usr/Makefile | 2 +- usr/work.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)Applied, thanks.