[PATCH] can: m_can: apply rate-limiting to lost msg in rx

Sean Nyekjaer posted 1 patch 3 months, 2 weeks ago
There is a newer version of this series
drivers/net/can/m_can/m_can.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] can: m_can: apply rate-limiting to lost msg in rx
Posted by Sean Nyekjaer 3 months, 2 weeks ago
Wrap the "msg lost in rxf0" error in m_can_handle_lost_msg() with
a call to net_ratelimit() to prevent flooding the kernel log
with repeated error messages.

Fixes: e0d1f4816f2a ("can: m_can: add Bosch M_CAN controller support")
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
---
 drivers/net/can/m_can/m_can.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 6c656bfdb3235e1f5d6405c49b07b821ddacc1b9..b0638d23879cf4257b8f4555d1123f45f9595ad7 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -665,7 +665,8 @@ static int m_can_handle_lost_msg(struct net_device *dev)
 	struct can_frame *frame;
 	u32 timestamp = 0;
 
-	netdev_err(dev, "msg lost in rxf0\n");
+	if (net_ratelimit())
+		netdev_err(dev, "msg lost in rxf0\n");
 
 	stats->rx_errors++;
 	stats->rx_over_errors++;

---
base-commit: db22720545207f734aaa9d9f71637bfc8b0155e0
change-id: 20250620-mcan_ratelimit-e7e1f9d8fa9c

Best regards,
-- 
Sean Nyekjaer <sean@geanix.com>
Re: [PATCH] can: m_can: apply rate-limiting to lost msg in rx
Posted by Vincent Mailhol 3 months, 2 weeks ago
On 20/06/2025 at 19:00, Sean Nyekjaer wrote:
> Wrap the "msg lost in rxf0" error in m_can_handle_lost_msg() with
> a call to net_ratelimit() to prevent flooding the kernel log
> with repeated error messages.

Note that another solution is to simply remove the error message. The users can
use the CAN error frames or the netstasts instead to see if lost messages occurred.

That said, I am OK with your proposed patch. See above comment as a simple FYI.

> Fixes: e0d1f4816f2a ("can: m_can: add Bosch M_CAN controller support")
> Signed-off-by: Sean Nyekjaer <sean@geanix.com>

Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>


Yours sincerely,
Vincent Mailhol
Re: [PATCH] can: m_can: apply rate-limiting to lost msg in rx
Posted by Sean Nyekjaer 3 months, 2 weeks ago
Hi,

On Sat, Jun 21, 2025 at 11:13:33AM +0100, Vincent Mailhol wrote:
> On 20/06/2025 at 19:00, Sean Nyekjaer wrote:
> > Wrap the "msg lost in rxf0" error in m_can_handle_lost_msg() with
> > a call to net_ratelimit() to prevent flooding the kernel log
> > with repeated error messages.
> 
> Note that another solution is to simply remove the error message. The users can
> use the CAN error frames or the netstasts instead to see if lost messages occurred.
> 
> That said, I am OK with your proposed patch. See above comment as a simple FYI.

I'm up for both solutions :)

@Marc what would you prefer?

> 
> > Fixes: e0d1f4816f2a ("can: m_can: add Bosch M_CAN controller support")
> > Signed-off-by: Sean Nyekjaer <sean@geanix.com>
> 
> Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
> 
> 
> Yours sincerely,
> Vincent Mailhol
> 

/Sean
Re: [PATCH] can: m_can: apply rate-limiting to lost msg in rx
Posted by Marc Kleine-Budde 3 months, 2 weeks ago
On 26.06.2025 13:45:09, Sean Nyekjaer wrote:
> Hi,
> 
> On Sat, Jun 21, 2025 at 11:13:33AM +0100, Vincent Mailhol wrote:
> > On 20/06/2025 at 19:00, Sean Nyekjaer wrote:
> > > Wrap the "msg lost in rxf0" error in m_can_handle_lost_msg() with
> > > a call to net_ratelimit() to prevent flooding the kernel log
> > > with repeated error messages.
> > 
> > Note that another solution is to simply remove the error message. The users can
> > use the CAN error frames or the netstasts instead to see if lost messages occurred.
> > 
> > That said, I am OK with your proposed patch. See above comment as a simple FYI.
> 
> I'm up for both solutions :)
> 
> @Marc what would you prefer?

If it is my call, then make it a netdev_dbg();

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |
Re: [PATCH] can: m_can: apply rate-limiting to lost msg in rx
Posted by Vincent Mailhol 3 months, 2 weeks ago
On 26/06/2025 at 22:57, Marc Kleine-Budde wrote:
> On 26.06.2025 13:45:09, Sean Nyekjaer wrote:
>> Hi,
>>
>> On Sat, Jun 21, 2025 at 11:13:33AM +0100, Vincent Mailhol wrote:
>>> On 20/06/2025 at 19:00, Sean Nyekjaer wrote:
>>>> Wrap the "msg lost in rxf0" error in m_can_handle_lost_msg() with
>>>> a call to net_ratelimit() to prevent flooding the kernel log
>>>> with repeated error messages.
>>>
>>> Note that another solution is to simply remove the error message. The users can
>>> use the CAN error frames or the netstasts instead to see if lost messages occurred.
>>>
>>> That said, I am OK with your proposed patch. See above comment as a simple FYI.
>>
>> I'm up for both solutions :)
>>
>> @Marc what would you prefer?
> 
> If it is my call, then make it a netdev_dbg();

I am also OK with that :)

Yours sincerely,
Vincent Mailhol