Skip to contentSkip to conversation

cansend app will block while it is sending RTR frames

DISCUSSION xuewentian 2 participants 4 messages Aug 28, 2013 – Aug 30, 2013 1 message not in the archive CAN network drivers

lore
Share & tools
lore

xuewentian

author
#0 lore raw

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.

#1 lore raw
Quoted 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 -
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

Quoted 4 lines

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;

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   |
author
#2 lore raw
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 0x1234567 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88" 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_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;

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.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 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   |