From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yk0-f169.google.com (mail-yk0-f169.google.com [209.85.160.169]) by dpdk.org (Postfix) with ESMTP id DD32F8042 for ; Wed, 17 Dec 2014 14:56:26 +0100 (CET) Received: by mail-yk0-f169.google.com with SMTP id 79so6897615ykr.14 for ; Wed, 17 Dec 2014 05:56:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=jXDlYRA4UkYWj1luCtmaefwKxq45pI1OTMx6kB7urv8=; b=Ixo3nA/xi1vV3e2J+ttNMDVJak2zDyneOEJCTWts3M1nYsZP/0cfn1xRb4v40jeCM2 Q9EgHRjm9NjXRRC03jU94XER6Sc4ZGt4TXMsmjKB0zZkuXVzQq6YKMgSvodrH6Pop9mh df3U2ZPDOQH3vePpVa/GWlXfhh8Sjfe5I5yIrnS/2R/uL67uzeFJOUbeN/bJCAHCTF1S xZflhcJoSQ6w430+tFNuzBvUzJrBTkyewCVbjANQ21OYbh8VdvwuxIwdBeJocnolEcJN 0qIaQU/vhvDoNxBWARhc+hEwq683AB7whiUbKjPzlQdFCnulUr4hFZFM9Ic4lQ9hopc2 S/VQ== X-Gm-Message-State: ALoCoQkKvCyxIO3hhN+0yP91wSpd7uwVWf5vibKAwblFqAd3UNWNYWW32TlptTGfIO549zo7/vmH MIME-Version: 1.0 X-Received: by 10.170.63.212 with SMTP id f203mr27798552ykf.63.1418824586329; Wed, 17 Dec 2014 05:56:26 -0800 (PST) Received: by 10.170.54.78 with HTTP; Wed, 17 Dec 2014 05:56:26 -0800 (PST) In-Reply-To: References: Date: Wed, 17 Dec 2014 07:56:26 -0600 Message-ID: From: Jay Rolette To: Dev Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH] Fixed spam from kni_allocate_mbufs() when no mbufs are free. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Dec 2014 13:56:27 -0000 self-NAK now that I know that gmail web client borks up the patches. I'll re-submit. Jay On Fri, Dec 12, 2014 at 7:28 PM, Jay Rolette wrote: > > 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 > > Signed-off-by: Jay Rolette > --- > 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 > #include > > +#include > #include > #include > #include > @@ -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; > } > } > -- > >