Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp938835pxb; Wed, 3 Mar 2021 21:49:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyfg7a9iqEqZeo600TNkDKdTtVvBMhHT74/Po12Kz1yR5jarOZFqUh9jUL1DEwB1rL5fO5 X-Received: by 2002:a17:906:b14b:: with SMTP id bt11mr2520738ejb.162.1614836948903; Wed, 03 Mar 2021 21:49:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614836948; cv=none; d=google.com; s=arc-20160816; b=O6E25w5+fQCRqJyPk+qblhKHCBdCuqAnzxcLLOrHBhzZaHXYTV7ayCWOFslIR8J9Vc kqNmH57DPetcB6msi/wTSp9LHyzpr7DT9M7im4wYZkD6YHRCJdELTrnAdGcPO0AUfnIz I0IOLj2OuAZliWZeRqKhOYv6Y4iI2kWEu+a+aG2NRfT+BLtzc0vci3ZxVfGt1xdSfj77 3pBf4q/6QzVhK3SY9IChZ9gzXsbksJUiFydWtXjx6RU/eDVrTiBmpGtFJf/iMOgb6XCI r5MYLMiR2wxg9OC6SnHpUWmANEJ7GqWuntW3vGwVKt6/QDfjsgKczu8FZCjCq/GAebeO YZ+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:mime-version :dkim-signature; bh=tuNxshL7uUmmItBqTOx/3A5Lp41lnCj/YwZnTkT/mR4=; b=MPuCZeFerMAqZ0N2MrDJD3LtC7aaiOiz1SgtytEo38rGHL6r4Q1L3SJUFOaEkOsMh0 VfD9QTdZHtb6JzMZLpQw6OBoK8YRGaq1Gf+iFJKucqVTrMWIZWyDIpvBCtfrZFU5cofR KA8kci5yzezEgXEJr/DAUX2IVCVHAG2eJ6CwXN0bxTl1BPLaHtljkzpPvgnfhMOzTpnV NLtgdLYg2u6IDg692lpGtQpk0x7ZueklxO9XwNchZ0Gx2Ayu5z4/IgV7HttDGzPNufqI P5Q0krG1Nl4VJH5zLPhBMLZ0lXC5X0fX/VENM0YMyjdLM2BLgd0IYeQDdIbvv75gev1z 4imA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XPD0Fyt1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a14si12819380ejk.698.2021.03.03.21.48.46; Wed, 03 Mar 2021 21:49:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XPD0Fyt1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1836332AbhCBHAs (ORCPT + 99 others); Tue, 2 Mar 2021 02:00:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347668AbhCBFws (ORCPT ); Tue, 2 Mar 2021 00:52:48 -0500 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6832DC06178C; Mon, 1 Mar 2021 21:51:53 -0800 (PST) Received: by mail-io1-xd35.google.com with SMTP id u8so20449552ior.13; Mon, 01 Mar 2021 21:51:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=tuNxshL7uUmmItBqTOx/3A5Lp41lnCj/YwZnTkT/mR4=; b=XPD0Fyt1NQVUlQltmLLtjlPLCWDieEczpPB3fpXxGBUq3/evqaRgZtzaXUsfJbdEdl Y6lT3FW0I2ha9dgv4w6+pS5WUnXrufzn8Ur2FKL8UXurggn2dge+YIHp5u/10pguyVlq tVnh8YtvBLjRH3Tub1Yff+OUQSdwwWDkKt7nGIDKk7jc4jTHCOYZmPlBIXQvxIY69N3K SjeIjlu4J8YZf+W9BSndlUi0qD75dhw84h/BiRsfoQK+rukqxg5F33wpGiVuBF4fPQnc WHqr75yLVsiRcTNYIzLelEpTA56XLe5NNjr7nWv7xbKt1vFHI2D0lbKMHIsc7FPZfL4B fRdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=tuNxshL7uUmmItBqTOx/3A5Lp41lnCj/YwZnTkT/mR4=; b=enC/1CyY/xpYu3veR1TS4pNvLdPrd1gLBxzjRm7L8WbHtL1hRleyrlfNgw3rJwkDin cMcbon1GJSEM90/Cx1tbaVfKqOPIIDNdFqb/AqRXzgmQu53t5Ouiu3HxPcnoK/g0G+2q 56UOocOoj0n7BkL1d6eexTYRiBH2Wtfb8SbVsfm+c19W4ztP3Vu7x7XrgOJVYI6Z/2fR 4ZbUaYas4uhLpOjkpaWY/EQfJRS8ExWw0dItzUh4YTlgGmzq+bWkrf3jH9aOFcjVEQk5 Ee4eOzgob/NOQLxjFAuimgoAI2qE/RCC0Otez3/vuBitY9B7qKR6CcpkVkUUG4TGFdfP hpAw== X-Gm-Message-State: AOAM533fACvu847hYm+Q4P6udqmnSPea2gEX2EyyXPgn3zKtoHCPs2WL RsWHWw4oPgCQheHbc2gpVXBtgVSOjWvNTKejXKeDrpifo/x3FA== X-Received: by 2002:a5e:cb4d:: with SMTP id h13mr10886486iok.68.1614664312602; Mon, 01 Mar 2021 21:51:52 -0800 (PST) MIME-Version: 1.0 From: DENG Qingfang Date: Tue, 2 Mar 2021 13:51:42 +0800 Message-ID: Subject: dsa_master_find_slave()'s time complexity and potential performance hit To: netdev , Andrew Lunn , Jakub Kicinski , David Miller , Florian Fainelli , Vivien Didelot , Vladimir Oltean , linux-kernel@vger.kernel.org, Russell King - ARM Linux admin Cc: Birger Koblitz , =?UTF-8?Q?Bj=C3=B8rn_Mork?= , Stijn Segers Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit 7b9a2f4bac68 ("net: dsa: use ports list to find slave"), dsa_master_find_slave() has been iterating over a linked list instead of accessing arrays, making its time complexity O(n). The said function is called frequently in DSA RX path, so it may cause a performance hit, especially for switches that have many ports (20+) such as RTL8380/8390/9300 (There is a downstream DSA driver for it, see https://github.com/openwrt/openwrt/tree/openwrt-21.02/target/linux/realtek/files-5.4/drivers/net/dsa/rtl83xx). I don't have one of those switches, so I can't test if the performance impact is huge or not.