cansend app will block while it is sending RTR frames
Hi all,
I want to test sending a lot of RTR frames, because select/poll is no
effect on the flow control, I add the usleep in the cansend app.
The code segment is :
while (infinite || loopcount--) {
ret = write(s, &frame, sizeof(frame));
if (ret == -1) {
perror("write");
printf("Please specify a more long delay time!\n");
break;
}
usleep(delay);//flow control
} Here the "delay" is about 200us, and I used "cansend can0 -r -e -l 500 -
i 0x1234567 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88" command to send 500 RTR frames.but candump on
the another board could only received the 336 frames,and candump app hasn't print the received RTR frames,and only count the received frmaes.
and I debugged the send process in the kernel, and I found that it sleep
on the copy_from_user in the memcpy_fromiovec of the raw_sendmsg
err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size); // in
the raw_sendmsg function of the net/can/raw.c file.
if (err < 0) goto free_skb;
What about happens with the write of the cansend app? and I used the
same way to send the 5000000 data frames, it didn't blocked.
Thanks a lot.
Marc Kleine-Budde
maintainerQuoted 27 lines · xuewentian
Hi all,
I want to test sending a lot of RTR frames, because select/poll is no
effect on the flow control, I add the usleep in the cansend app.The code segment is :
while (infinite || loopcount--) { ret = write(s, &frame, sizeof(frame)); if (ret == -1) { perror("write"); printf("Please specify a more long delay time!\n"); break; } usleep(delay);//flow control }Here the "delay" is about 200us, and I used "cansend can0 -r -e -l 500 -
i0x12345670x110x220x330x440x550x660x770x88" command to send 500 RTR frames.but candump on
the another board could only received the 336 frames,and candump app hasn't print the received RTR frames,and only count the received frmaes.
and I debugged the send process in the kernel, and I found that it sleep
on thecopy_from_userin thememcpy_fromiovecof theraw_sendmsg
Quoted 4 lines
err =
memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size); // in
theraw_sendmsgfunction of thenet/can/raw.cfile.if (err < 0) goto free_skb;
How have you measured that the kernel sleeps in that function? How long does it sleep?
Quoted 2 lines
What about happens with the write of the cansend app? and I used the
same way to send the 5000000 data frames, it didn't blocked.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Quoted 21 lines · Marc Kleine-Budde <mkl <at> pengutronix.de> writes:
Quoted 19 lines · xuewentian
Hi all,
I want to test sending a lot of RTR frames, because select/poll is no
effect on the flow control, I add the usleep in the cansend app.The code segment is :
while (infinite || loopcount--) { ret = write(s, &frame, sizeof(frame)); if (ret == -1) { perror("write"); printf("Please specify a more long delay time!\n"); break; } usleep(delay);//flow control }
Quoted 1 line
Quoted 1 line
Here the "delay" is about 200us, and I used "cansend can0 -r -e -l 500
-
Quoted 1 line
Quoted 1 line
i
0x12345670x110x220x330x440x550x660x770x88" command to send
500
Quoted 4 lines
Quoted 4 lines
RTR frames.but candump on
the another board could only received the 336 frames,and candump app hasn't print the received RTR frames,and only count the received frmaes.
and I debugged the send process in the kernel, and I found that it
sleep
Quoted 9 lines
Quoted 6 lines
on the
copy_from_userin thememcpy_fromiovecof theraw_sendmsgerr =
memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size); // in
theraw_sendmsgfunction of thenet/can/raw.cfile.if (err < 0) goto free_skb;How have you measured that the kernel sleeps in that function? How long does it sleep?
**************
my reply:
I found the cansend app will always sleep after sending 336 RTR frames by using "cansend can0 -r -e -l 500 -i 0x1234567 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88". I must press ctrl+c to cancel it,after cancelling it,and I ran "cansend can0 -r -e -i 0x1234567 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88" for send another RTR frame, it could be sent successfully. and I tested "cansend can0 -r -e -l 500 -i 0x1234567 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88 &" to run background, and it still sent 336 RTR frames, and the process was pending, and I could still send RTR
frames on the serial terminal.
And I used command "cansend can0 -e -l 5000000 -i 0x1234567 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88" to send 50000000 data frames,the cansend app could return to serial terminal. It didn't block.
The problem seemed to has no relationship with can driver because it still could send RTR frames after the problem occurred. I didn't know why it was always sleeping on the copy_from_user function.
any suggestion for me?
Thanks a lot for your reply.
Marc Kleine-Budde
maintainerQuoted 1 line · xuewt
I found that I didn't free the skb buffer for RTR frame. It was resolved.
Please don't top post. Oh, you're writing a new driver. What hardware are you supporting? If you post it here, we'll review it.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |