From: Stephen Hemminger <stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
To: Jay Rolette <rolette-bIuJOMs36aleGPcbtGPokg@public.gmane.org>
Cc: dev-VfR2kkLFssw@public.gmane.org
Subject: Re: [PATCH] Fixed spam from kni_allocate_mbufs() when no mbufs are free. If mbufs exhausted, 'out of memory' message logged at EXTREMELY high rates. Now logs no more than once per 10 mins
Date: Mon, 13 Apr 2015 18:09:58 -0700 [thread overview]
Message-ID: <20150413180958.506cbac6@urahara> (raw)
In-Reply-To: <1418824622-9212-1-git-send-email-rolette-bIuJOMs36aleGPcbtGPokg@public.gmane.org>
On Wed, 17 Dec 2014 07:57:02 -0600
Jay Rolette <rolette-bIuJOMs36aleGPcbtGPokg@public.gmane.org> wrote:
> Signed-off-by: Jay Rolette <rolette-bIuJOMs36aleGPcbtGPokg@public.gmane.org>
> ---
> lib/librte_kni/rte_kni.c | 21 ++++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
> index fdb7509..f89319c 100644
> --- a/lib/librte_kni/rte_kni.c
> +++ b/lib/librte_kni/rte_kni.c
> @@ -40,6 +40,7 @@
> #include <unistd.h>
> #include <sys/ioctl.h>
>
> +#include <rte_cycles.h>
> #include <rte_spinlock.h>
> #include <rte_string_fns.h>
> #include <rte_ethdev.h>
> @@ -61,6 +62,9 @@
>
> #define KNI_MEM_CHECK(cond) do { if (cond) goto kni_fail; } while (0)
>
> +// Configure how often we log "out of memory" messages (in seconds)
> +#define KNI_SPAM_SUPPRESSION_PERIOD 60*10
> +
> /**
> * KNI context
> */
> @@ -592,6 +596,10 @@ kni_free_mbufs(struct rte_kni *kni)
> static void
> kni_allocate_mbufs(struct rte_kni *kni)
> {
> + static uint64_t no_mbufs = 0;
> + static uint64_t spam_filter = 0;
> + static uint64_t delayPeriod = 0;
> +
> int i, ret;
> struct rte_mbuf *pkts[MAX_MBUF_BURST_NUM];
>
> @@ -620,7 +628,18 @@ kni_allocate_mbufs(struct rte_kni *kni)
> pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool);
> if (unlikely(pkts[i] == NULL)) {
> /* Out of memory */
> - RTE_LOG(ERR, KNI, "Out of memory\n");
> + no_mbufs++;
> +
> + // Memory leak or need to tune? Regardless, if we get here once,
> + // we will get here a *lot*. Don't spam the logs!
> + now = rte_get_tsc_cycles();
> + if (!delayPeriod)
> + delayPeriod = rte_get_tsc_hz() * KNI_SPAM_SUPPRESSION_PERIOD;
> +
> + if (!spam_filter || (now - spam_filter) > delayPeriod) {
> + RTE_LOG(ERR, KNI, "No mbufs available (%llu)\n", (unsigned long long)no_mbufs);
> + spam_filter = now;
> + }
> break;
> }
> }
I agree whole completely with the intent of this.
But just remove the log message completely. It doesn't
help at all, use a statistic instead.
If you want to do ratelimiting, then it is better to create
a common function (see net_ratelimit() in Linux kernel) to
have all code use the same method, rather than reinventing private
code to do it.
Minor style complaints:
* don't use camelCase, it goes against the style of the rest of the code.
* don't use C++ style comments.
* always use rte_cycles() not TSC for things like this.
Please resubmit removing the log message and adding a statistic.
next prev parent reply other threads:[~2015-04-14 1:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-17 13:57 [PATCH] Fixed spam from kni_allocate_mbufs() when no mbufs are free. If mbufs exhausted, 'out of memory' message logged at EXTREMELY high rates. Now logs no more than once per 10 mins Jay Rolette
[not found] ` <1418824622-9212-1-git-send-email-rolette-bIuJOMs36aleGPcbtGPokg@public.gmane.org>
2015-04-14 1:09 ` Stephen Hemminger [this message]
2015-04-14 12:58 ` Jay Rolette
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=20150413180958.506cbac6@urahara \
--to=stephen-otpzqlsittunbdjkjebofr2eb7je58tq@public.gmane.org \
--cc=dev-VfR2kkLFssw@public.gmane.org \
--cc=rolette-bIuJOMs36aleGPcbtGPokg@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.