From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Michal Sojka <sojkam1@fel.cvut.cz>, linux-can@vger.kernel.org
Cc: yegorslists@googlemail.com
Subject: Re: [PATCH RFC 1/2] can: Limit default size of CAN_RAW socket send queue
Date: Fri, 17 Jan 2014 10:13:46 +0100 [thread overview]
Message-ID: <52D8F44A.7000007@pengutronix.de> (raw)
In-Reply-To: <1389902301-24505-1-git-send-email-sojkam1@fel.cvut.cz>
[-- Attachment #1: Type: text/plain, Size: 2980 bytes --]
On 01/16/2014 08:58 PM, Michal Sojka wrote:
> This fixes the infamous ENOBUFS problem, which appears when an
> application sends CAN frames faster than they leave the system.
>
> Packets for sending can be queued at three places: socket, queueing
> discipline and device driver. Only the socket queue is able to block
> the sender; other queues are non-blocking. Since the size of the qdisc
> queue was set by default to 10 packets, this queue was full much
> earlier than the socket queue and this resulted in ENOBUFS error.
>
> This patch limits the default size of the socket send queue to
> approximately 3 CAN frames and increases the size of the qdisc queue
> to 100 frames. This setting allows for at least 33 CAN_RAW sockets to
> be used simultaneously in the system without getting ENOBUFS errors.
Do you mean in the system, per CAN interface or per socket? How many CAN
frames does a socket take before it blocks (with the default values), in
case the CAN interface doesn't send any messages?
> Note that the size of the socket queue is only approximate, because it
> is counted in bytes and the realy allocated memory (skb->truesize) can
> be bigger than what is reported by SKB_TRUESIZE(). For example, on my
> 32 bit PowerPC system, SKB_TRUESIZE() = 408, but skb->truesize = 448.
What does that mean for number of CAN frames in the above question?
> Open issues:
> - Will this work with CANFD?
Can you calculate the size in bytes depending if we have a CAN or a
CANFD network card at this socket?
> - What about other AF_CAN protocols?
>
> Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
> ---
> drivers/net/can/dev.c | 2 +-
> net/can/raw.c | 4 ++++
> 2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
> index 1870c47..a0bce83 100644
> --- a/drivers/net/can/dev.c
> +++ b/drivers/net/can/dev.c
> @@ -492,7 +492,7 @@ static void can_setup(struct net_device *dev)
> dev->mtu = CAN_MTU;
> dev->hard_header_len = 0;
> dev->addr_len = 0;
> - dev->tx_queue_len = 10;
> + dev->tx_queue_len = 100;
>
> /* New-style flags. */
> dev->flags = IFF_NOARP;
> diff --git a/net/can/raw.c b/net/can/raw.c
> index fdda5f6..4ad0bb2 100644
> --- a/net/can/raw.c
> +++ b/net/can/raw.c
> @@ -291,6 +291,10 @@ static int raw_init(struct sock *sk)
> {
> struct raw_sock *ro = raw_sk(sk);
>
> + /* allow at most 3 frames to wait for transmission in socket queue */
> + sk->sk_sndbuf = 3 * SKB_TRUESIZE(sizeof(struct can_frame) +
> + sizeof(struct can_skb_priv));
> +
> ro->bound = 0;
> ro->ifindex = 0;
>
>
Marc
--
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 |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]
next prev parent reply other threads:[~2014-01-17 9:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-16 19:58 [PATCH RFC 1/2] can: Limit default size of CAN_RAW socket send queue Michal Sojka
2014-01-16 19:58 ` [PATCH RFC 2/2] net: Make minimum SO_SNDBUF size dependent on the protocol family Michal Sojka
2014-01-17 9:08 ` Marc Kleine-Budde
2014-01-17 9:13 ` Marc Kleine-Budde [this message]
2014-01-17 12:11 ` [PATCH RFC 1/2] can: Limit default size of CAN_RAW socket send queue Michal Sojka
2014-01-17 15:31 ` Michal Sojka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52D8F44A.7000007@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=sojkam1@fel.cvut.cz \
--cc=yegorslists@googlemail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox