From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753585AbdA0Crl (ORCPT ); Thu, 26 Jan 2017 21:47:41 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33869 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752326AbdA0Crk (ORCPT ); Thu, 26 Jan 2017 21:47:40 -0500 From: Wei Yang To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [Resend PATCH] x86/e820: break the loop when the region is less then current region Date: Fri, 27 Jan 2017 10:47:24 +0800 Message-Id: <20170127024724.38506-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org e820_all_mapped() iterates the e820 table to check whether a region is mapped or not. Since the e820 table is sorted, when the region is less than the current region, no need to continue the iteration. The patch breaks the loop accordingly. Signed-off-by: Wei Yang --- arch/x86/kernel/e820.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 90e8dde..f4fb197 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -86,10 +86,16 @@ int __init e820_all_mapped(u64 start, u64 end, unsigned type) for (i = 0; i < e820->nr_map; i++) { struct e820entry *ei = &e820->map[i]; + /* Since the e820 table is sorted, when the region is less + * than the current region, break it. + */ + if (ei->addr >= end) + break; + if (type && ei->type != type) continue; /* is the region (part) in overlap with the current region ?*/ - if (ei->addr >= end || ei->addr + ei->size <= start) + if (ei->addr + ei->size <= start) continue; /* if the region is at the beginning of we move -- 2.5.0