From: Jay Vosburgh <jay.vosburgh@canonical.com>
To: Praveen Kumar Kannoju <praveen.kannoju@oracle.com>
Cc: andy@greyhouse.net, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
rajesh.sivaramasubramaniom@oracle.com,
rama.nichanamatlu@oracle.com, manjunath.b.patil@oracle.com
Subject: Re: [PATCH RFC] bonding: rate-limit bonding driver inspect messages
Date: Wed, 14 Feb 2024 10:34:35 -0800 [thread overview]
Message-ID: <7713.1707935675@famine> (raw)
In-Reply-To: <20240214044245.33170-1-praveen.kannoju@oracle.com>
Praveen Kumar Kannoju <praveen.kannoju@oracle.com> wrote:
>Rate limit bond driver log messages, to prevent a log flood in a run-away
>situation, e.g couldn't get rtnl lock. Message flood leads to instability
>of system and loss of other crucial messages.
>
>Signed-off-by: Praveen Kumar Kannoju <praveen.kannoju@oracle.com>
>---
> drivers/net/bonding/bond_main.c | 34 +++++++++++++++++++---------------
> include/net/bonding.h | 11 +++++++++++
> 2 files changed, 30 insertions(+), 15 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index 4e0600c..32098dd 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -2610,12 +2610,13 @@ static int bond_miimon_inspect(struct bonding *bond)
> commit++;
> slave->delay = bond->params.downdelay;
> if (slave->delay) {
>- slave_info(bond->dev, slave->dev, "link status down for %sinterface, disabling it in %d ms\n",
>- (BOND_MODE(bond) ==
>- BOND_MODE_ACTIVEBACKUP) ?
>- (bond_is_active_slave(slave) ?
>+ bond_info_rl(bond->dev, slave->dev,
>+ "link status down for %sinterface, disabling it in %d ms\n",
>+ (BOND_MODE(bond) ==
>+ BOND_MODE_ACTIVEBACKUP) ?
>+ (bond_is_active_slave(slave) ?
> "active " : "backup ") : "",
>- bond->params.downdelay * bond->params.miimon);
>+ bond->params.downdelay * bond->params.miimon);
Why not use net_info_ratelimited() or net_ratelimit()? The rest
of the bonding messages that are rate limited are almost all gated by
the net rate limiter.
-J
> }
> fallthrough;
> case BOND_LINK_FAIL:
>@@ -2623,9 +2624,10 @@ static int bond_miimon_inspect(struct bonding *bond)
> /* recovered before downdelay expired */
> bond_propose_link_state(slave, BOND_LINK_UP);
> slave->last_link_up = jiffies;
>- slave_info(bond->dev, slave->dev, "link status up again after %d ms\n",
>- (bond->params.downdelay - slave->delay) *
>- bond->params.miimon);
>+ bond_info_rl(bond->dev, slave->dev,
>+ "link status up again after %d ms\n",
>+ (bond->params.downdelay - slave->delay) *
>+ bond->params.miimon);
> commit++;
> continue;
> }
>@@ -2648,18 +2650,20 @@ static int bond_miimon_inspect(struct bonding *bond)
> slave->delay = bond->params.updelay;
>
> if (slave->delay) {
>- slave_info(bond->dev, slave->dev, "link status up, enabling it in %d ms\n",
>- ignore_updelay ? 0 :
>- bond->params.updelay *
>- bond->params.miimon);
>+ bond_info_rl(bond->dev, slave->dev,
>+ "link status up, enabling it in %d ms\n",
>+ ignore_updelay ? 0 :
>+ bond->params.updelay *
>+ bond->params.miimon);
> }
> fallthrough;
> case BOND_LINK_BACK:
> if (!link_state) {
> bond_propose_link_state(slave, BOND_LINK_DOWN);
>- slave_info(bond->dev, slave->dev, "link status down again after %d ms\n",
>- (bond->params.updelay - slave->delay) *
>- bond->params.miimon);
>+ bond_info_rl(bond->dev, slave->dev,
>+ "link status down again after %d ms\n",
>+ (bond->params.updelay - slave->delay) *
>+ bond->params.miimon);
> commit++;
> continue;
> }
>diff --git a/include/net/bonding.h b/include/net/bonding.h
>index 5b8b1b6..ebdfaf0 100644
>--- a/include/net/bonding.h
>+++ b/include/net/bonding.h
>@@ -39,8 +39,19 @@
> #define __long_aligned __attribute__((aligned((sizeof(long)))))
> #endif
>
>+DEFINE_RATELIMIT_STATE(bond_rs, DEFAULT_RATELIMIT_INTERVAL,
>+ DEFAULT_RATELIMIT_BURST);
>+
>+#define bond_ratelimited_function(function, ...) \
>+do { \
>+ if (__ratelimit(&bond_rs)) \
>+ function(__VA_ARGS__); \
>+} while (0)
>+
> #define slave_info(bond_dev, slave_dev, fmt, ...) \
> netdev_info(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
>+#define bond_info_rl(bond_dev, slave_dev, fmt, ...) \
>+ bond_ratelimited_function(slave_info, fmt, ##__VA_ARGS__)
> #define slave_warn(bond_dev, slave_dev, fmt, ...) \
> netdev_warn(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
> #define slave_dbg(bond_dev, slave_dev, fmt, ...) \
>--
>1.8.3.1
>
>
---
-Jay Vosburgh, jay.vosburgh@canonical.com
next prev parent reply other threads:[~2024-02-14 18:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-14 4:42 [PATCH RFC] bonding: rate-limit bonding driver inspect messages Praveen Kumar Kannoju
2024-02-14 18:34 ` Jay Vosburgh [this message]
2024-02-15 18:03 ` Praveen Kannoju
-- strict thread matches above, loose matches on Subject: below --
2024-02-15 17:25 Praveen Kumar Kannoju
2024-02-16 9:03 ` Hangbin Liu
2024-02-17 12:39 ` Praveen Kannoju
2024-02-18 3:09 ` Hangbin Liu
2024-02-19 11:35 ` Praveen Kannoju
2024-02-19 11:31 Praveen Kumar Kannoju
2024-02-19 13:36 ` Praveen Kannoju
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=7713.1707935675@famine \
--to=jay.vosburgh@canonical.com \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manjunath.b.patil@oracle.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=praveen.kannoju@oracle.com \
--cc=rajesh.sivaramasubramaniom@oracle.com \
--cc=rama.nichanamatlu@oracle.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;
as well as URLs for NNTP newsgroup(s).