From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [kvm-unit-tests PATCH] alloc: only warn once if we run out of log entries Date: Fri, 24 Jul 2015 14:07:27 +0200 Message-ID: <1437739647-30313-1-git-send-email-drjones@redhat.com> Cc: pbonzini@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:49114 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753826AbbGXMfy (ORCPT ); Fri, 24 Jul 2015 08:35:54 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 17C598E228 for ; Fri, 24 Jul 2015 12:35:54 +0000 (UTC) Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Andrew Jones --- lib/alloc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/alloc.c b/lib/alloc.c index 1abe4961ae9dd..fc85d5952c91c 100644 --- a/lib/alloc.c +++ b/lib/alloc.c @@ -44,6 +44,7 @@ void phys_alloc_init(phys_addr_t base_addr, phys_addr_t size) base = base_addr; top = base + size; align_min = DEFAULT_MINIMUM_ALIGNMENT; + nr_regions = 0; spin_unlock(&lock); } @@ -58,6 +59,7 @@ void phys_alloc_set_minimum_alignment(phys_addr_t align) static phys_addr_t phys_alloc_aligned_safe(phys_addr_t size, phys_addr_t align, bool safe) { + static bool not_warned = true; phys_addr_t addr, size_orig = size; u64 top_safe = top; @@ -72,9 +74,9 @@ static phys_addr_t phys_alloc_aligned_safe(phys_addr_t size, size += addr - base; if ((top_safe - base) < size) { - printf("%s: requested=0x%llx (align=0x%llx), " + printf("phys_alloc: requested=0x%llx (align=0x%llx), " "need=0x%llx, but free=0x%llx. " - "top=0x%llx, top_safe=0x%llx\n", __func__, + "top=0x%llx, top_safe=0x%llx\n", size_orig, align, size, top_safe - base, top, top_safe); spin_unlock(&lock); @@ -87,9 +89,10 @@ static phys_addr_t phys_alloc_aligned_safe(phys_addr_t size, regions[nr_regions].base = addr; regions[nr_regions].size = size_orig; ++nr_regions; - } else { - printf("%s: WARNING: no free log entries, " - "can't log allocation...\n", __func__); + } else if (not_warned) { + printf("WARNING: phys_alloc: No free log entries, " + "can no longer log allocations...\n"); + not_warned = false; } spin_unlock(&lock); -- 2.4.3