Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp550670rwb; Tue, 27 Sep 2022 00:56:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7niwpD7DqQwacZkdCf5Xw63jizn3iWUWPU2qj+1Oy+DXuQMQt9gNXxU3MRrE2LBeo/wNKJ X-Received: by 2002:a17:903:489:b0:176:e84a:90be with SMTP id jj9-20020a170903048900b00176e84a90bemr26298791plb.34.1664265406746; Tue, 27 Sep 2022 00:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664265406; cv=none; d=google.com; s=arc-20160816; b=PuxIaXRiDw6GKmFdAEjBS0+h7PwTvS0N1uc/2Xsaww+cgd6LHm6VHIOX8wUJAVhD22 UrdiBh7QXbl9RWSM4kC6lpHA/3SuMeq4qajfQtuP10F254ABNZViWcpd3x8nnjks5lmM +G/MYdLkrGFch0AXk+95fa7EY74N6hggmBGcBbwqOdw91wmdmMzqjpPjvwHPQRZSLV4E q1EvWBHbQBZhQ0rFw64RTZ103PUF/6LvZwdvB7B1pcPuKdxHsWHsaMbGfpZ6XD+VLJjc Kg3q3zpWk4570bqIYJB758h/iyoB6gVc3F1rx2sOiNGBkghGYKPKDTEJozvZUjLPKG7T QVWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=QARHQJJqXFRMVlOzDzMQADfn54pG19eVVGeo/uHoR54=; b=xVkcri7g6agLocYzKGo1qYdoQuk0TJXWIRwJ/yPj1/g3ZBZtb2+3OG6nOp7Ur955Fv D0ah6TiV3hGZcxp8jxCKGrv71jjbBpAXHWWfFha+jiIy7m6SjEpterDjiVwi6hltzOru eG01drFtqygOwqztCcsCjjwqCAatjQiYgIk4GlmAcbWiV1lUk31c2OFoVoK8HSgvNDgl E4osGpv0zto0n9uO5pJx7VddqBMsr4SIruLiaSW0JTVWbdMHwUyP7RX+F6o4Fo34XuYn evzWxzKzr2lgygaM0mDYI5nQVwyBokkJ89KCmGXRe5Js/5YDcWPVBH20he0lrvpk7a3d A7vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=mwS5stQ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c16-20020a056a00249000b005583264623csi1325808pfv.278.2022.09.27.00.56.35; Tue, 27 Sep 2022 00:56:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=mwS5stQ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231220AbiI0HxU (ORCPT + 99 others); Tue, 27 Sep 2022 03:53:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231239AbiI0HxR (ORCPT ); Tue, 27 Sep 2022 03:53:17 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ABAFAB42A for ; Tue, 27 Sep 2022 00:53:14 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1664265192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QARHQJJqXFRMVlOzDzMQADfn54pG19eVVGeo/uHoR54=; b=mwS5stQ5zKqAEvrTnAEnNq2aehk18zEWWgwhz4mJvHGsxxyN7AQuOyAIBbQYedA19wZOFl WotowCGn46UDCjOZj8wXkdxxX+xhMBo3WImju8ItTznhseB0gKLqmlv3IR+06f6JnVAc+f ueOL+nTj+IXmt0Bfu+aQ9wyLmLi3pMk= From: Yajun Deng To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH] mm/early_ioremap: Combine two loops to improve performance Date: Tue, 27 Sep 2022 15:52:39 +0800 Message-Id: <20220927075239.270583-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The first loop will waring once if prev_map is init, we can add a boolean variable to do that. So those two loops can be combined to improve performance. Signed-off-by: Yajun Deng --- mm/early_ioremap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/early_ioremap.c b/mm/early_ioremap.c index 9bc12e526ed0..3076fb47c685 100644 --- a/mm/early_ioremap.c +++ b/mm/early_ioremap.c @@ -70,14 +70,15 @@ static unsigned long slot_virt[FIX_BTMAPS_SLOTS] __initdata; void __init early_ioremap_setup(void) { + bool init_prev_map = false; int i; - for (i = 0; i < FIX_BTMAPS_SLOTS; i++) - if (WARN_ON(prev_map[i])) - break; + for (i = 0; i < FIX_BTMAPS_SLOTS; i++) { + if (!init_prev_map && WARN_ON(prev_map[i])) + init_prev_map = true; - for (i = 0; i < FIX_BTMAPS_SLOTS; i++) slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i); + } } static int __init check_early_ioremap_leak(void) -- 2.25.1