Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4987930iob; Mon, 9 May 2022 06:23:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJXTaK0ZLIJJGyafMrriN0FOLYKa36X5z+VmQTBdIqCg4Fm++eY91UMAMmDZv+CURjRb1z X-Received: by 2002:a17:90a:9109:b0:1cb:a814:8947 with SMTP id k9-20020a17090a910900b001cba8148947mr25935716pjo.52.1652102594456; Mon, 09 May 2022 06:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652102594; cv=none; d=google.com; s=arc-20160816; b=Tj0rBppIHb5ttgWa6Sk1o2I2bIPndRhy0+Du3Zw+TPzas/IaJU+zmlrNNh34yrCPAu 6eLHPV7reCp8A6ENy5nDjlrcGI3OY7By2KatZmhGZTUiSe5cTGPUNFhDt0N3G4bbwexC Hes4ePS/wqLDLegdaxKQuAaf7XtJFQdeUExd6LUtva+FAG2bwQNgRdrwy5I4bLZHDUWI 7OMkGy+5eKR4p4ZiuEfSmSJ0stCoF2DI8hZvp8Tu9Z0L3uOiWKhfkn4kpUZAL2fOYcrf T+C7LQL5qGQv4Ijw6EX/X+8hXeznCLvXygYq9yNvLLodOa1ezzucCW4axJ9aNRUuMFAN ySWA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=khtZIX872uWHu4sVbOYZs1eLS/actGsHDBV1EgUEcDM=; b=gWa9elrIkOsWf5xFt8f0D4Gp4vunsjYKCrpzCL/L6jzppvzcsv2ttoH4Iedgkog8Tc E50nUe7E4aWEuJxXPNs6J4urqEQVju8b245SJkHY3R1ydxs5xpdMwXB6r0d5SDvspyun CPC+dh9a3fr8wki8eQQXYMHcXx3h6o5o2bvXDlEKa8i0soovE7ajyNC5DUeeElEh0SJI 1wOG/d6Niqn4v3Li8WqoIj+KxZjuRilpWbpGdt3pKyE1g9AEV8O1B/6YxyKOY2WJ/UYU JhgsIbKOIUPJ55Zu5cA18FjZGq6GlrtrskzBUhc26PYHQJ6Ztd1Uvtr/QKH+VC+F1Qu5 5wbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h20-20020a056a001a5400b004fdada2b1d5si15956334pfv.327.2022.05.09.06.23.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:23:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2A2912B031C; Mon, 9 May 2022 06:15:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235633AbiEINSz (ORCPT + 99 others); Mon, 9 May 2022 09:18:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235358AbiEINSH (ORCPT ); Mon, 9 May 2022 09:18:07 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBE9E2A9741 for ; Mon, 9 May 2022 06:14:13 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KxhSn4NNXzhYvd; Mon, 9 May 2022 21:13:45 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 9 May 2022 21:14:05 +0800 From: Miaohe Lin To: CC: , , , , , , , , , , , Subject: [PATCH 10/15] mm/swap: break the loop if matching device is found Date: Mon, 9 May 2022 21:14:11 +0800 Message-ID: <20220509131416.17553-11-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220509131416.17553-1-linmiaohe@huawei.com> References: <20220509131416.17553-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 We can break the loop if matching device is found to save some possible cpu cycles because there should be only one matching device and there is no need to continue if the matching one is already found. Signed-off-by: Miaohe Lin --- mm/swapfile.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/swapfile.c b/mm/swapfile.c index 133e03fea104..c90298a0561a 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1692,6 +1692,8 @@ int swap_type_of(dev_t device, sector_t offset) spin_unlock(&swap_lock); return type; } + + break; } } spin_unlock(&swap_lock); -- 2.23.0