From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f50.google.com (mail-oi0-f50.google.com [209.85.218.50]) by dpdk.org (Postfix) with ESMTP id D4E521F7 for ; Wed, 17 Dec 2014 14:57:26 +0100 (CET) Received: by mail-oi0-f50.google.com with SMTP id a141so11038076oig.37 for ; Wed, 17 Dec 2014 05:57: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:from:to:cc:subject:date:message-id; bh=VP9yV2bdSnOOKcbOum04fb6H427GeSOMlOqiKtRoRUg=; b=V9O0tXG6snE3sxCZYGVkkgImywegQKAr2+xO6pk5qVYcLpFYf9hVqjFWyXSgvH9L8n nYsSIwRKop3LLg44nTrHOoCg4lnueX4duVYb75c+bQFhsFNZJ0KcoJFnyhkfT2+rf7g+ 74xcpAFgP+on4Xn/ZFrRe+14GDyTU7KwHFqVXw1PBuZUd7KhEcgEN6/CvSS6Wk0f9d0r TzZCxSHkFVISfZgshxWA/DC8jcJScgqskeSiUxSb90sMF8Qe79OupI5q0KFXz1uV1ZRX Jpgt9VwWiPIT9vrpxtSnqMPbbzK5xyzt74ZAmkCtVYehjbzFuzJSMMxSv386F9eIzqDA 2+7g== X-Gm-Message-State: ALoCoQmbX0b6ZKLNbTvs4jWRBBD+Z8vSfE7rgiPymLewS+EGeEaKc4TpwErcwXDr+QTUQ9WPJckb X-Received: by 10.60.133.108 with SMTP id pb12mr10900424oeb.39.1418824646143; Wed, 17 Dec 2014 05:57:26 -0800 (PST) Received: from localhost.localdomain (104-57-181-38.lightspeed.austtx.sbcglobal.net. [104.57.181.38]) by mx.google.com with ESMTPSA id kv10sm1775529obb.15.2014.12.17.05.57.23 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 17 Dec 2014 05:57:25 -0800 (PST) From: Jay Rolette To: dev@dpdk.org Date: Wed, 17 Dec 2014 07:57:02 -0600 Message-Id: <1418824622-9212-1-git-send-email-rolette@infiniteio.com> X-Mailer: git-send-email 1.9.3 (Apple Git-50) Subject: [dpdk-dev] [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 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:57:27 -0000 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; } } -- 1.9.3 (Apple Git-50)