From patchwork Tue Mar 26 16:58:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 1065803 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44THQJ66Fzz9sSZ for ; Wed, 27 Mar 2019 03:58:32 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 855B0CB2; Tue, 26 Mar 2019 16:58:29 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 2BA88CA6 for ; Tue, 26 Mar 2019 16:58:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C8FA3775 for ; Tue, 26 Mar 2019 16:58:26 +0000 (UTC) Received: from sigill.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay10.mail.gandi.net (Postfix) with ESMTPSA id D95FD240003; Tue, 26 Mar 2019 16:58:23 +0000 (UTC) From: Ben Pfaff To: dev@openvswitch.org Date: Tue, 26 Mar 2019 09:58:20 -0700 Message-Id: <20190326165820.31931-1-blp@ovn.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH v2] hmap: Improve debug log message when reporting unusually large buckets. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org I was seeing a lot of these messages, including a lot of them suppressed by rate-limiting, and I wondered whether any really big messages were being suppressed. By reporting the largest bucket, instead of just every large bucket, it becomes more likely that the truly too-large buckets get reported. (The problem I saw was a false alarm.) Signed-off-by: Ben Pfaff Acked-by: Han Zhou --- v1->v2: Further improve the log message, thanks Han. lib/hmap.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/hmap.c b/lib/hmap.c index 1ba4a5716a78..9ee05b6d499b 100644 --- a/lib/hmap.c +++ b/lib/hmap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015, 2019 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,6 +103,9 @@ resize(struct hmap *hmap, size_t new_mask, const char *where) tmp.buckets[i] = NULL; } } + int n_big_buckets = 0; + int biggest_count = 0; + int n_biggest_buckets = 0; for (i = 0; i <= hmap->mask; i++) { struct hmap_node *node, *next; int count = 0; @@ -112,14 +115,30 @@ resize(struct hmap *hmap, size_t new_mask, const char *where) count++; } if (count > 5) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 10); - COVERAGE_INC(hmap_pathological); - VLOG_DBG_RL(&rl, "%s: %d nodes in bucket (%"PRIuSIZE" nodes, %"PRIuSIZE" buckets)", - where, count, hmap->n, hmap->mask + 1); + n_big_buckets++; + if (count > biggest_count) { + biggest_count = count; + n_biggest_buckets = 1; + } else if (count == biggest_count) { + n_biggest_buckets++; + } } } hmap_swap(hmap, &tmp); hmap_destroy(&tmp); + + if (n_big_buckets) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 10); + COVERAGE_INC(hmap_pathological); + VLOG_DBG_RL(&rl, "%s: %d bucket%s with 6+ nodes, " + "including %d bucket%s with %d nodes " + "(%"PRIuSIZE" nodes total across %"PRIuSIZE" buckets)", + where, + n_big_buckets, n_big_buckets > 1 ? "s" : "", + n_biggest_buckets, n_biggest_buckets > 1 ? "s" : "", + biggest_count, + hmap->n, hmap->mask + 1); + } } static size_t