From patchwork Tue Jun 7 10:59:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 12871719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64A60C43334 for ; Tue, 7 Jun 2022 11:00:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EFF7E6B0074; Tue, 7 Jun 2022 07:00:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EAE766B0075; Tue, 7 Jun 2022 07:00:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D77296B0078; Tue, 7 Jun 2022 07:00:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C7E5D6B0074 for ; Tue, 7 Jun 2022 07:00:16 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8BA88210E7 for ; Tue, 7 Jun 2022 11:00:16 +0000 (UTC) X-FDA: 79551145632.08.3928D89 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 701524006D for ; Tue, 7 Jun 2022 11:00:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654599614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9uBpnVqgcJOFWLuohPGx+SoAF7D/2Ubnp34dnbaPDjs=; b=Mx8I6t8yicUMGFgtokdagrv78+tbZ+MX7njuNSyz+vz+0r9SwCO9RcXFCOdgesRBBV4YIQ JX+1pCazJdeymHXSHmwmo1TLnudlt9dK6NnR2h/jd1jzUCVQyEci4hzUWq54NsONAnvoF8 aOJ2VZ9xNaj3WAgY7IvyPcLQIqY/Pzc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661-3cDmdNlANbKZTPkErSmrAA-1; Tue, 07 Jun 2022 07:00:13 -0400 X-MC-Unique: 3cDmdNlANbKZTPkErSmrAA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 764328027EE; Tue, 7 Jun 2022 11:00:12 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-113.pek2.redhat.com [10.72.13.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EB921121314; Tue, 7 Jun 2022 11:00:09 +0000 (UTC) From: Baoquan He To: akpm@linux-foundation.org, urezki@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, hch@infradead.org, Baoquan He Subject: [PATCH v2 2/4] mm/vmalloc: remove the redundant boundary check Date: Tue, 7 Jun 2022 18:59:56 +0800 Message-Id: <20220607105958.382076-3-bhe@redhat.com> In-Reply-To: <20220607105958.382076-1-bhe@redhat.com> References: <20220607105958.382076-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Stat-Signature: 778q54cm788qn6rpun5uhcbyy5y8ha5q Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Mx8I6t8y; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf11.hostedemail.com: domain of bhe@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=bhe@redhat.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 701524006D X-HE-Tag: 1654599605-961911 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In function find_va_links(), when traversing the vmap_area tree, the comparing to check if the passed in 'va' is above or below 'tmp_va' is redundant, assuming both 'va' and 'tmp_va' has ->va_start <= ->va_end. Here, to simplify the checking as code change. Signed-off-by: Baoquan He Reviewed-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index f9d45aa90b7c..b711bf82fd5d 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -874,11 +874,9 @@ find_va_links(struct vmap_area *va, * Trigger the BUG() if there are sides(left/right) * or full overlaps. */ - if (va->va_start < tmp_va->va_end && - va->va_end <= tmp_va->va_start) + if (va->va_end <= tmp_va->va_start) link = &(*link)->rb_left; - else if (va->va_end > tmp_va->va_start && - va->va_start >= tmp_va->va_end) + else if (va->va_start >= tmp_va->va_end) link = &(*link)->rb_right; else { WARN(1, "vmalloc bug: 0x%lx-0x%lx overlaps with 0x%lx-0x%lx\n",