From patchwork Sat Dec 13 01:28:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jay Rolette X-Patchwork-Id: 1972 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 7839B68BE; Sat, 13 Dec 2014 02:28:23 +0100 (CET) Received: from mail-yk0-f174.google.com (mail-yk0-f174.google.com [209.85.160.174]) by dpdk.org (Postfix) with ESMTP id 62B6E6896 for ; Sat, 13 Dec 2014 02:28:21 +0100 (CET) Received: by mail-yk0-f174.google.com with SMTP id 10so3605279ykt.5 for ; Fri, 12 Dec 2014 17:28:20 -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:date:message-id:subject:from:to :content-type; bh=fLh2rUFIlDFWhC+pUdCA+IxykjImY0SWNf97xPvjgd8=; b=C7iPSnq7aJ5pYSPMpa4/K4M76OIGMIlE/xkxryuq3TK1lkwh3knkP977iFYOUh4B3y Zmp3Su89siM9UVSV1XWtsaME4CHyl3pU2+aUpGeS46XhtyPPlaNPCo9G2T/Nx5UoguSu DdlsU78Kj+BUY5M5I0O2+xRn3Rw252SUyFZijqUAFHLnRXwWpBO5H48gDyrQyTW4/zJr 4vtV/ED0eTElSzJOKZfT880Gi31QYRwxuDu70JsTlzxKlsZhNSzEtyL7mm8pTQ37RTd5 nlvmrDKeD3wikdVb8FgREG5fh8bT1+tOxO0uSAJHjvInU/rAujASBgDKmRpYa48L9Lsd 62Zg== X-Gm-Message-State: ALoCoQlbDwbl3Io5l2Sprs29PWLlAKB3khsRjFEkWH+ZLSvlhleENY/v+d/Yna0pHeSfJNN7Ibmf MIME-Version: 1.0 X-Received: by 10.170.47.210 with SMTP id 201mr15971734ykp.30.1418434100819; Fri, 12 Dec 2014 17:28:20 -0800 (PST) Received: by 10.170.54.78 with HTTP; Fri, 12 Dec 2014 17:28:20 -0800 (PST) Date: Fri, 12 Dec 2014 19:28:20 -0600 Message-ID: From: Jay Rolette To: Dev X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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; }