From patchwork Wed Mar 20 23:48:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 10862685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 64A9317EF for ; Wed, 20 Mar 2019 23:48:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3728A29ECD for ; Wed, 20 Mar 2019 23:48:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2ADE129EF6; Wed, 20 Mar 2019 23:48:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 78B2B29ECD for ; Wed, 20 Mar 2019 23:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MhlFd0yotm/uYnNTXi5xZ9I77Y8TWuBcb3gfiFMHV24=; b=iPgEf69SJ1W/c4 spa70GEbqBX2c2dZ3mRlq4X7a2McTTPVX2qAQZDr04eobK23V9yJ9vTEx1lBKnZn7msdIlTcdaSwB RYBt88TtWhBXOnR1tfMQuJH92x2Vs9n50Cc0CZ7CU2LTdIf8bLsCE7lHBAquUivzg9OZTEB2qxHSL ydwttPq27dbUWVqe7oqb07FFQHPPNf9On6/ExNcENIwDWDPnI9kt2zGdXly+f2vbWGDCpZmQGQ9ji yZbTwDUWNDiWFJQqZHZOJGLnuA/F3pezzTyBZ+hOR7fs0adTOIbnLnW5wWkIun1R9TBh63AocsCkY wLQlgMrqSmGqF3T7UU6A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6kwV-0001Qi-RG; Wed, 20 Mar 2019 23:48:19 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6kwT-0001ON-4J for linux-riscv@lists.infradead.org; Wed, 20 Mar 2019 23:48:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1553125697; x=1584661697; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VuMxbdDRBNStadvV9SEfpyan+V5rH2K9LRlJxGawap0=; b=hD66tigXESfqkuWJSNupox0DjW6DYLfNCTj/W2WHA+DP5o235JF42u+x FyRtoXMVWADTHMLAJMG/Dbi68VFbss4vXHg/3TVgWfIaQ/7FeqABKHWnU 22lziURZ7acaP46qpjzui1H+WpyCeovFxr6L++n/zWEjtW7zt5cTdaVn1 frxW3g15bs5Dlpkqk2S9oSzScqpWtUhSpTQCvSyE/bd+AvXYF2EV5lK7W c6bV1KHyGeocoiXWv7NT5r6+0jf7VHd3NAtaxbQMkahRYFcjPT1Pwi64F /IgFN3YwXbe0NzhAU24SRHBbVNveC0TcU0hbLa1HqHW428jxJ4KvoR2wn Q==; X-IronPort-AV: E=Sophos;i="5.58,498,1544457600"; d="scan'208";a="209432739" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Mar 2019 07:48:14 +0800 IronPort-SDR: sxRe7y+eFaTEAmqswrbGfNmAIVRNpCsoivmtcEOIygt4EyeIhyeBlNUfzjX8R8s+93uL4qhZOc YTdQabP1YgAbrnxyXLr1fD7ZVbaBlh+1VrqNA3NQrZ5LOdmgY1mqm7GsXyLjgKXJ7wQJjZVoxU WY5AXnQvMq8wpqL1Zo3Vhw5rK7idmfAGm5I05Ps1v9hBGuz+9IBGyOeQ7yhU5apBGRmBlEwr7U Gq6DAxCcRr6Yl+QdtOFI0/wPl1OyRdxdzCBdSh33j+11cLOVjw/Rpn5We/3/lHBmCoxKEh557+ BmzWGCb8fICIy1Z0ug0Mwj8r Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 20 Mar 2019 16:27:51 -0700 IronPort-SDR: a6Gg7YRgL6KcYjbG8l2eQ4h+5JXHqtrNrHX7zi+nMjzNg/QGYu/LidOjsdIEJDDeO/A+2ox0R2 S3X/pQ3Yy6CY3YL1FBvAlrLW0TxDCxcmBosp8eLP+U+ARUOZGHUolNmmTCuectQZ4K1IIyrZs1 1Rr3xetFmzyLgmyL7tE53SAxh7Viy/iFaGidS+WrUCcvhCBl7EQ6SIfos+cRvl5EpH7SYczSnz +89ENr5nDKY72dZ3uS76yvrgAqOT5pyY/X2/CmFl3rTccQbcmAvJzU0u6EKxtFUL218Vrf+ulU VaE= Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip01.wdc.com with ESMTP; 20 Mar 2019 16:48:14 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [RFT/RFC PATCH v3 1/5] Documentation: DT: arm: add support for sockets defining package boundaries Date: Wed, 20 Mar 2019 16:48:02 -0700 Message-Id: <20190320234806.19748-2-atish.patra@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190320234806.19748-1-atish.patra@wdc.com> References: <20190320234806.19748-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190320_164817_288982_FF2E4EFC X-CRM114-Status: GOOD ( 15.62 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "Rafael J. Wysocki" , "Peter Zijlstra \(Intel\)" , Catalin Marinas , Palmer Dabbelt , Will Deacon , Atish Patra , linux-riscv@lists.infradead.org, Ingo Molnar , Rob Herring , Dmitriy Cherkasov , Anup Patel , Morten Rasmussen , devicetree@vger.kernel.org, Albert Ou , Johan Hovold , Rob Herring , Paul Walmsley , Ard Biesheuvel , Greg Kroah-Hartman , Jeremy Linton , Otto Sabart , Sudeep Holla Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sudeep Holla The current ARM DT topology description provides the operating system with a topological view of the system that is based on leaf nodes representing either cores or threads (in an SMT system) and a hierarchical set of cluster nodes that creates a hierarchical topology view of how those cores and threads are grouped. However this hierarchical representation of clusters does not allow to describe what topology level actually represents the physical package or the socket boundary, which is a key piece of information to be used by an operating system to optimize resource allocation and scheduling. Lets add a new "socket" node type in the cpu-map node to describe the same. Signed-off-by: Sudeep Holla Reviewed-by: Rob Herring --- .../devicetree/bindings/arm/topology.txt | 52 ++++++++++++++----- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/topology.txt b/Documentation/devicetree/bindings/arm/topology.txt index b0d80c0f..3b8febb4 100644 --- a/Documentation/devicetree/bindings/arm/topology.txt +++ b/Documentation/devicetree/bindings/arm/topology.txt @@ -9,6 +9,7 @@ ARM topology binding description In an ARM system, the hierarchy of CPUs is defined through three entities that are used to describe the layout of physical CPUs in the system: +- socket - cluster - core - thread @@ -63,21 +64,23 @@ nodes are listed. The cpu-map node's child nodes can be: - - one or more cluster nodes + - one or more cluster nodes or + - one or more socket nodes in a multi-socket system Any other configuration is considered invalid. -The cpu-map node can only contain three types of child nodes: +The cpu-map node can only contain 4 types of child nodes: +- socket node - cluster node - core node - thread node whose bindings are described in paragraph 3. -The nodes describing the CPU topology (cluster/core/thread) can only -be defined within the cpu-map node and every core/thread in the system -must be defined within the topology. Any other configuration is +The nodes describing the CPU topology (socket/cluster/core/thread) can +only be defined within the cpu-map node and every core/thread in the +system must be defined within the topology. Any other configuration is invalid and therefore must be ignored. =========================================== @@ -85,26 +88,44 @@ invalid and therefore must be ignored. =========================================== cpu-map child nodes must follow a naming convention where the node name -must be "clusterN", "coreN", "threadN" depending on the node type (ie -cluster/core/thread) (where N = {0, 1, ...} is the node number; nodes which -are siblings within a single common parent node must be given a unique and +must be "socketN", "clusterN", "coreN", "threadN" depending on the node type +(ie socket/cluster/core/thread) (where N = {0, 1, ...} is the node number; nodes +which are siblings within a single common parent node must be given a unique and sequential N value, starting from 0). cpu-map child nodes which do not share a common parent node can have the same name (ie same number N as other cpu-map child nodes at different device tree levels) since name uniqueness will be guaranteed by the device tree hierarchy. =========================================== -3 - cluster/core/thread node bindings +3 - socket/cluster/core/thread node bindings =========================================== -Bindings for cluster/cpu/thread nodes are defined as follows: +Bindings for socket/cluster/cpu/thread nodes are defined as follows: + +- socket node + + Description: must be declared within a cpu-map node, one node + per physical socket in the system. A system can + contain single or multiple physical socket. + The association of sockets and NUMA nodes is beyond + the scope of this bindings, please refer [2] for + NUMA bindings. + + This node is optional for a single socket system. + + The socket node name must be "socketN" as described in 2.1 above. + A socket node can not be a leaf node. + + A socket node's child nodes must be one or more cluster nodes. + + Any other configuration is considered invalid. - cluster node Description: must be declared within a cpu-map node, one node per cluster. A system can contain several layers of - clustering and cluster nodes can be contained in parent - cluster nodes. + clustering within a single physical socket and cluster + nodes can be contained in parent cluster nodes. The cluster node name must be "clusterN" as described in 2.1 above. A cluster node can not be a leaf node. @@ -164,13 +185,15 @@ Bindings for cluster/cpu/thread nodes are defined as follows: 4 - Example dts =========================================== -Example 1 (ARM 64-bit, 16-cpu system, two clusters of clusters): +Example 1 (ARM 64-bit, 16-cpu system, two clusters of clusters in a single +physical socket): cpus { #size-cells = <0>; #address-cells = <2>; cpu-map { + socket0 { cluster0 { cluster0 { core0 { @@ -253,6 +276,7 @@ cpus { }; }; }; + }; CPU0: cpu@0 { device_type = "cpu"; @@ -473,3 +497,5 @@ cpus { =============================================================================== [1] ARM Linux kernel documentation Documentation/devicetree/bindings/arm/cpus.yaml +[2] Devicetree NUMA binding description + Documentation/devicetree/bindings/numa.txt From patchwork Wed Mar 20 23:48:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 10862687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDD1A1515 for ; Wed, 20 Mar 2019 23:48:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8DAD29ECD for ; Wed, 20 Mar 2019 23:48:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACF2229ED1; Wed, 20 Mar 2019 23:48:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9DD4829ED0 for ; Wed, 20 Mar 2019 23:48:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=N4uZm1FgKLGZB7Io+IpKeNqmONWxcS87Q4ofJDmnBpQ=; b=mscgdkt8GtOcqA ta0At+vU7+wxcW/Ath7B2dVcr9HmNt3QLwtFOfhMn4+KridEBRVVBTp/jBCLBpLF59Oc9J67OijOV ZgSknnJie/mxkCfGDD1+7faMhrcgVx0gjBMcdj4+IPDuJGUQ40Vn4sPp85+SOX4crmrldHKYApTPS f3au3ppjrPnMsVTtYK7/7VSRpvOPzxKSl7r2eNYM0RArjuhHenGjZ9E1j6x3ZnE+gvNR9ct7BpaJG HPj5zoGxiWlPmBwxDTvVN5edE9WrUdJDA3lfbUm1dj13B21gFu+stpi31YvnYstWjRqA8oMTUMzBW 59bwkcgze8qGQmj1jEnQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6kwY-0001UE-Qz; Wed, 20 Mar 2019 23:48:22 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6kwU-0001OM-Ee for linux-riscv@lists.infradead.org; Wed, 20 Mar 2019 23:48:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1553125698; x=1584661698; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8+GS09e2kuxAm41XWJLYt8y5cTm3Ai/BqW043K5L6o4=; b=QdPA4wqjIsZ4lSlNCJPUbQcf9slMMSGJTsKjixHSp1OZu8H8P/ih+cZ5 8YRUNnWo+EXNKvTtjiG/GVuUW/AaFUtO2Z9n840GSXlS6XA+ajdoJALTv vtPhUnXIkSdvdsomCr2Soyp8KmNFGuP2zcfidP/EDuUkbVVvOFmf4fFNO cP+oa+HPbiiZOGkNR1LzvXaAH0Ji/BLriHuMfJM/BVfqQor4S+p4AlhLV AUOFuE+AV6W08NYkxUZj+6vOn0j6otdEXsLE2+iQyHk+kfbwgMGP1r05U 5NjKSO8Lb3DB70v365K1i01fNNfx2BSfvivZs18WWFpkMAE59pEnroiE5 w==; X-IronPort-AV: E=Sophos;i="5.58,498,1544457600"; d="scan'208";a="209432741" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Mar 2019 07:48:15 +0800 IronPort-SDR: Az4HOiUA2zPAZ1gYcMageIa+a/NTM921h6SbJH9FNyTeoXJvwamwKv8CgLfkpOqNZ8xYZYlYU2 oywldgA2GxB4grlq2x+/8tcKTQ9pO2PLMbhhqJpVNlWRD2iKMax+ZI4tY6AxAZhVE4G7yO5uSe 5yNS1zwwtDxGcg8lV8XH8J9fW5OSDk7pUiMV3t7OnMMaEAIqx3/m0gNc3UpBCajRqUcOtCdj1i YNIJK18HfExzsBjLGRiNvVdnOhmxffWDzrXTaknuQDX6fjm+ptI+vqOhA/Klbg/C5NFt9iWWM2 Fr4Ka6vOxJGHkdg7/HcAh8Cr Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 20 Mar 2019 16:27:52 -0700 IronPort-SDR: Lzd9zrpBxuvOxN6UBKKq8X/tVYNVlG7Ll9jP+kayjJZ+zTZmiDXWlHXB7ErYVYouYINWVkqXWn E1ME3G9uZnXmVc+ibzLqXuJye1s8omY9roT4jxZ+VWbm1/TmtWTd5vlnMI3B9bXrSJhpgrNbtS Mf47+JOWvDzu1PRfMLkDf1PuYMv/29duqltRdzxXpH1M4oZ3ioD0Rv5JppuJTzBUuekZ8FvF5C YEUBQ/MgqO8vJsO0M/fp41GlMZXwwTEqQ0fs1tTGx2b1EFU6EqiDyQSCt6tZFkc5j2KbtbPmuG I08= Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip01.wdc.com with ESMTP; 20 Mar 2019 16:48:15 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [RFT/RFC PATCH v3 2/5] dt-binding: cpu-topology: Move cpu-map to a common binding. Date: Wed, 20 Mar 2019 16:48:03 -0700 Message-Id: <20190320234806.19748-3-atish.patra@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190320234806.19748-1-atish.patra@wdc.com> References: <20190320234806.19748-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190320_164818_727076_2D17CF5E X-CRM114-Status: GOOD ( 13.92 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "Rafael J. Wysocki" , "Peter Zijlstra \(Intel\)" , Catalin Marinas , Palmer Dabbelt , Will Deacon , Atish Patra , linux-riscv@lists.infradead.org, Ingo Molnar , Dmitriy Cherkasov , Anup Patel , Morten Rasmussen , devicetree@vger.kernel.org, Albert Ou , Johan Hovold , Rob Herring , Paul Walmsley , Ard Biesheuvel , Greg Kroah-Hartman , Jeremy Linton , Otto Sabart , Sudeep Holla Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP cpu-map binding can be used to described cpu topology for both RISC-V & ARM. It makes more sense to move the binding to document to a common place. The relevant discussion can be found here. https://lkml.org/lkml/2018/11/6/19 Signed-off-by: Atish Patra Reviewed-by: Sudeep Holla Reviewed-by: Rob Herring --- .../topology.txt => cpu/cpu-topology.txt} | 82 +++++++++++++++---- 1 file changed, 66 insertions(+), 16 deletions(-) rename Documentation/devicetree/bindings/{arm/topology.txt => cpu/cpu-topology.txt} (86%) diff --git a/Documentation/devicetree/bindings/arm/topology.txt b/Documentation/devicetree/bindings/cpu/cpu-topology.txt similarity index 86% rename from Documentation/devicetree/bindings/arm/topology.txt rename to Documentation/devicetree/bindings/cpu/cpu-topology.txt index 3b8febb4..069addcc 100644 --- a/Documentation/devicetree/bindings/arm/topology.txt +++ b/Documentation/devicetree/bindings/cpu/cpu-topology.txt @@ -1,12 +1,12 @@ =========================================== -ARM topology binding description +CPU topology binding description =========================================== =========================================== 1 - Introduction =========================================== -In an ARM system, the hierarchy of CPUs is defined through three entities that +In a SMP system, the hierarchy of CPUs is defined through three entities that are used to describe the layout of physical CPUs in the system: - socket @@ -14,9 +14,6 @@ are used to describe the layout of physical CPUs in the system: - core - thread -The cpu nodes (bindings defined in [1]) represent the devices that -correspond to physical CPUs and are to be mapped to the hierarchy levels. - The bottom hierarchy level sits at core or thread level depending on whether symmetric multi-threading (SMT) is supported or not. @@ -25,33 +22,31 @@ threads existing in the system and map to the hierarchy level "thread" above. In systems where SMT is not supported "cpu" nodes represent all cores present in the system and map to the hierarchy level "core" above. -ARM topology bindings allow one to associate cpu nodes with hierarchical groups +CPU topology bindings allow one to associate cpu nodes with hierarchical groups corresponding to the system hierarchy; syntactically they are defined as device tree nodes. -The remainder of this document provides the topology bindings for ARM, based -on the Devicetree Specification, available from: +Currently, only ARM/RISC-V intend to use this cpu topology binding but it may be +used for any other architecture as well. -https://www.devicetree.org/specifications/ +The cpu nodes, as per bindings defined in [4], represent the devices that +correspond to physical CPUs and are to be mapped to the hierarchy levels. -If not stated otherwise, whenever a reference to a cpu node phandle is made its -value must point to a cpu node compliant with the cpu node bindings as -documented in [1]. A topology description containing phandles to cpu nodes that are not compliant -with bindings standardized in [1] is therefore considered invalid. +with bindings standardized in [4] is therefore considered invalid. =========================================== 2 - cpu-map node =========================================== -The ARM CPU topology is defined within the cpu-map node, which is a direct +The ARM/RISC-V CPU topology is defined within the cpu-map node, which is a direct child of the cpus node and provides a container where the actual topology nodes are listed. - cpu-map node - Usage: Optional - On ARM SMP systems provide CPUs topology to the OS. - ARM uniprocessor systems do not require a topology + Usage: Optional - On SMP systems provide CPUs topology to the OS. + Uniprocessor systems do not require a topology description and therefore should not define a cpu-map node. @@ -494,8 +489,63 @@ cpus { }; }; +Example 3: HiFive Unleashed (RISC-V 64 bit, 4 core system) + +{ + #address-cells = <2>; + #size-cells = <2>; + compatible = "sifive,fu540g", "sifive,fu500"; + model = "sifive,hifive-unleashed-a00"; + + ... + cpus { + #address-cells = <1>; + #size-cells = <0>; + cpu-map { + cluster0 { + core0 { + cpu = <&CPU1>; + }; + core1 { + cpu = <&CPU2>; + }; + core2 { + cpu0 = <&CPU2>; + }; + core3 { + cpu0 = <&CPU3>; + }; + }; + }; + + CPU1: cpu@1 { + device_type = "cpu"; + compatible = "sifive,rocket0", "riscv"; + reg = <0x1>; + } + + CPU2: cpu@2 { + device_type = "cpu"; + compatible = "sifive,rocket0", "riscv"; + reg = <0x2>; + } + CPU3: cpu@3 { + device_type = "cpu"; + compatible = "sifive,rocket0", "riscv"; + reg = <0x3>; + } + CPU4: cpu@4 { + device_type = "cpu"; + compatible = "sifive,rocket0", "riscv"; + reg = <0x4>; + } + } +}; =============================================================================== [1] ARM Linux kernel documentation Documentation/devicetree/bindings/arm/cpus.yaml [2] Devicetree NUMA binding description Documentation/devicetree/bindings/numa.txt +[3] RISC-V Linux kernel documentation + Documentation/devicetree/bindings/riscv/cpus.txt +[4] https://www.devicetree.org/specifications/ From patchwork Wed Mar 20 23:48:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 10862691 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6947C17EF for ; Wed, 20 Mar 2019 23:48:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FC2229ECD for ; Wed, 20 Mar 2019 23:48:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33DDF29EF6; Wed, 20 Mar 2019 23:48:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1360929ECD for ; Wed, 20 Mar 2019 23:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dkA6e0yTjpgvz9Mc7UCz55qsy+GBSFwwQ6meVrJYsWo=; b=uu/rkgheoWbCY3 9aOE5IIlCBAJW79PEJ1ZF7o1yhJUK8S29oVNXXWB5pUlPFvdQ/4Palsf8FJ9BgNEOMhsXNS6vSuYM f8LssG1wMEVGFf+AKpbt1TX+RrIMMy2ijII50esTSFW+CZpZ9Wzaw8GAOa+C8O/cUXhOof2ocPXv7 1hhYioGfXdKazqV/wNpu5ujv4K+YOHX0uLpp5QdcJqrlqkdhG9Pm+kI1t+Ciq+wU8I2zSVlUPB9Li 4O70BDPG7Z85NzFuMNbDo0jlX1FMu6XytwA61H/IPDeSfKvR9O1gjn+JAZXP+ainb2i5+xMF/BMoH T7T272iuGjyPpZcRWyIw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6kwZ-0001VL-MZ; Wed, 20 Mar 2019 23:48:23 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6kwU-0001ON-Is for linux-riscv@lists.infradead.org; Wed, 20 Mar 2019 23:48:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1553125698; x=1584661698; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=amqP89gwPQFN9Tqm3LdMzVULIBgJF8Mj4/6iEK50OhA=; b=BQvSL4JzLZOh+hx4x8nDgZRWujouV/1JB8+oc08fCRkDtIRf5GtdXXnj DivDUeFeYjNSWFt3ZQxc6Y0M+ges6B0aNjNypfmZX7bY4QjgMb3jOKboF qV2ayyVoCTjfNHYxTy36O1Jd/QbW0JMmB42fn76Ex1oTFWWGK05t4FmGt n+R1GmwnQyqHTfwayFFh/oUgzzihEQN8/KZFSasB4kCipOMceQrWjD45c gOIAuHS9Bpa/BNuAf9wc/nEcr9NJc265ADekvx1a507blVNV+CV+qkKZ2 mHcrhaKWL0rA5u2LUmQ2AARHvruzhw70nifmBtpHa9YdOtTfWt15zzSEa Q==; X-IronPort-AV: E=Sophos;i="5.58,498,1544457600"; d="scan'208";a="209432743" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Mar 2019 07:48:15 +0800 IronPort-SDR: 1jOcBP5rAhhogQqnvB06vBGXdv7RTzAadgXI1/m9HPNHxaadLDuX2J/QpUw0F+eNTuIq2eH8np /qqTOTD/t71iUJ4XxL3eL7iwjVns+4P67uZmr5kMXVsADH8zvvyKuokPU31yp2ebJDCCN1Da0V al0Nmw3ZTDJ9nMc1fFbI8pcTLkLxSaCCzmMM4i/I0VwpoSfG/tkf5LpBI9LaVK17FR4siBntV4 yFgXMukZTPDLxgzdlWlEuyn6M8qKcS9ZEk63tlXruV0NqzPLbHUoURAMQVYe/x9VQtkltQrE/F 960dV8gvI/WJo1WbOXmtzZ0l Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 20 Mar 2019 16:27:52 -0700 IronPort-SDR: 1M9uqKX9qOmXJiD6XtCNQgIEsMZLTK6UoMBx/th0jCeupbdjaF0aHF2wUq5qnVioVNiX8ZtYAp psL43Z/nyx/0BznAMJg7UWMkvPsiXSl36Vx9pqfiYHv9s8THdgGm/TQQPx56V7I9JqTuQ11BR+ mPqT8hj6SbO0O0klJ3s7NRgI9nviZi8w25/L7vs2n65tJ1ODrsYloPyrnp+E1cdAZv9CYVyGhw MpIq9wEjphs+MD2uVbS8yyk6VuOXrLZkPiRtjdHR1E1/MFm4cuHFMRQmmRzjr9HLFUpjSnMf5z yLE= Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip01.wdc.com with ESMTP; 20 Mar 2019 16:48:15 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [RFT/RFC PATCH v3 3/5] cpu-topology: Move cpu topology code to common code. Date: Wed, 20 Mar 2019 16:48:04 -0700 Message-Id: <20190320234806.19748-4-atish.patra@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190320234806.19748-1-atish.patra@wdc.com> References: <20190320234806.19748-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190320_164818_829416_995BF1DF X-CRM114-Status: GOOD ( 22.18 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "Rafael J. Wysocki" , "Peter Zijlstra \(Intel\)" , Catalin Marinas , Palmer Dabbelt , Will Deacon , Atish Patra , linux-riscv@lists.infradead.org, Ingo Molnar , Jeffrey Hugo , Anup Patel , Morten Rasmussen , devicetree@vger.kernel.org, Albert Ou , Johan Hovold , Rob Herring , Paul Walmsley , Ard Biesheuvel , Greg Kroah-Hartman , Jeremy Linton , Dmitriy Cherkasov , Otto Sabart , Sudeep Holla Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Both RISC-V & ARM64 are using cpu-map device tree to describe their cpu topology. It's better to move the relevant code to a common place instead of duplicate code. Signed-off-by: Atish Patra Tested-by: Jeffrey Hugo --- arch/arm64/include/asm/topology.h | 23 --- arch/arm64/kernel/topology.c | 303 +----------------------------- drivers/base/arch_topology.c | 298 ++++++++++++++++++++++++++++- drivers/base/topology.c | 1 + include/linux/arch_topology.h | 28 +++ 5 files changed, 330 insertions(+), 323 deletions(-) diff --git a/arch/arm64/include/asm/topology.h b/arch/arm64/include/asm/topology.h index 0524f243..a4d945db 100644 --- a/arch/arm64/include/asm/topology.h +++ b/arch/arm64/include/asm/topology.h @@ -4,29 +4,6 @@ #include -struct cpu_topology { - int thread_id; - int core_id; - int package_id; - int llc_id; - cpumask_t thread_sibling; - cpumask_t core_sibling; - cpumask_t llc_sibling; -}; - -extern struct cpu_topology cpu_topology[NR_CPUS]; - -#define topology_physical_package_id(cpu) (cpu_topology[cpu].package_id) -#define topology_core_id(cpu) (cpu_topology[cpu].core_id) -#define topology_core_cpumask(cpu) (&cpu_topology[cpu].core_sibling) -#define topology_sibling_cpumask(cpu) (&cpu_topology[cpu].thread_sibling) -#define topology_llc_cpumask(cpu) (&cpu_topology[cpu].llc_sibling) - -void init_cpu_topology(void); -void store_cpu_topology(unsigned int cpuid); -void remove_cpu_topology(unsigned int cpuid); -const struct cpumask *cpu_coregroup_mask(int cpu); - #ifdef CONFIG_NUMA struct pci_bus; diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 0825c4a8..6b95c91e 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -14,250 +14,13 @@ #include #include #include -#include -#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include -static int __init get_cpu_for_node(struct device_node *node) -{ - struct device_node *cpu_node; - int cpu; - - cpu_node = of_parse_phandle(node, "cpu", 0); - if (!cpu_node) - return -1; - - cpu = of_cpu_node_to_id(cpu_node); - if (cpu >= 0) - topology_parse_cpu_capacity(cpu_node, cpu); - else - pr_crit("Unable to find CPU node for %pOF\n", cpu_node); - - of_node_put(cpu_node); - return cpu; -} - -static int __init parse_core(struct device_node *core, int package_id, - int core_id) -{ - char name[10]; - bool leaf = true; - int i = 0; - int cpu; - struct device_node *t; - - do { - snprintf(name, sizeof(name), "thread%d", i); - t = of_get_child_by_name(core, name); - if (t) { - leaf = false; - cpu = get_cpu_for_node(t); - if (cpu >= 0) { - cpu_topology[cpu].package_id = package_id; - cpu_topology[cpu].core_id = core_id; - cpu_topology[cpu].thread_id = i; - } else { - pr_err("%pOF: Can't get CPU for thread\n", - t); - of_node_put(t); - return -EINVAL; - } - of_node_put(t); - } - i++; - } while (t); - - cpu = get_cpu_for_node(core); - if (cpu >= 0) { - if (!leaf) { - pr_err("%pOF: Core has both threads and CPU\n", - core); - return -EINVAL; - } - - cpu_topology[cpu].package_id = package_id; - cpu_topology[cpu].core_id = core_id; - } else if (leaf) { - pr_err("%pOF: Can't get CPU for leaf core\n", core); - return -EINVAL; - } - - return 0; -} - -static int __init parse_cluster(struct device_node *cluster, int depth) -{ - char name[10]; - bool leaf = true; - bool has_cores = false; - struct device_node *c; - static int package_id __initdata; - int core_id = 0; - int i, ret; - - /* - * First check for child clusters; we currently ignore any - * information about the nesting of clusters and present the - * scheduler with a flat list of them. - */ - i = 0; - do { - snprintf(name, sizeof(name), "cluster%d", i); - c = of_get_child_by_name(cluster, name); - if (c) { - leaf = false; - ret = parse_cluster(c, depth + 1); - of_node_put(c); - if (ret != 0) - return ret; - } - i++; - } while (c); - - /* Now check for cores */ - i = 0; - do { - snprintf(name, sizeof(name), "core%d", i); - c = of_get_child_by_name(cluster, name); - if (c) { - has_cores = true; - - if (depth == 0) { - pr_err("%pOF: cpu-map children should be clusters\n", - c); - of_node_put(c); - return -EINVAL; - } - - if (leaf) { - ret = parse_core(c, package_id, core_id++); - } else { - pr_err("%pOF: Non-leaf cluster with core %s\n", - cluster, name); - ret = -EINVAL; - } - - of_node_put(c); - if (ret != 0) - return ret; - } - i++; - } while (c); - - if (leaf && !has_cores) - pr_warn("%pOF: empty cluster\n", cluster); - - if (leaf) - package_id++; - - return 0; -} - -static int __init parse_dt_topology(void) -{ - struct device_node *cn, *map; - int ret = 0; - int cpu; - - cn = of_find_node_by_path("/cpus"); - if (!cn) { - pr_err("No CPU information found in DT\n"); - return 0; - } - - /* - * When topology is provided cpu-map is essentially a root - * cluster with restricted subnodes. - */ - map = of_get_child_by_name(cn, "cpu-map"); - if (!map) - goto out; - - ret = parse_cluster(map, 0); - if (ret != 0) - goto out_map; - - topology_normalize_cpu_scale(); - - /* - * Check that all cores are in the topology; the SMP code will - * only mark cores described in the DT as possible. - */ - for_each_possible_cpu(cpu) - if (cpu_topology[cpu].package_id == -1) - ret = -EINVAL; - -out_map: - of_node_put(map); -out: - of_node_put(cn); - return ret; -} - -/* - * cpu topology table - */ -struct cpu_topology cpu_topology[NR_CPUS]; -EXPORT_SYMBOL_GPL(cpu_topology); - -const struct cpumask *cpu_coregroup_mask(int cpu) -{ - const cpumask_t *core_mask = cpumask_of_node(cpu_to_node(cpu)); - - /* Find the smaller of NUMA, core or LLC siblings */ - if (cpumask_subset(&cpu_topology[cpu].core_sibling, core_mask)) { - /* not numa in package, lets use the package siblings */ - core_mask = &cpu_topology[cpu].core_sibling; - } - if (cpu_topology[cpu].llc_id != -1) { - if (cpumask_subset(&cpu_topology[cpu].llc_sibling, core_mask)) - core_mask = &cpu_topology[cpu].llc_sibling; - } - - return core_mask; -} - -static void update_siblings_masks(unsigned int cpuid) -{ - struct cpu_topology *cpu_topo, *cpuid_topo = &cpu_topology[cpuid]; - int cpu; - - /* update core and thread sibling masks */ - for_each_online_cpu(cpu) { - cpu_topo = &cpu_topology[cpu]; - - if (cpuid_topo->llc_id == cpu_topo->llc_id) { - cpumask_set_cpu(cpu, &cpuid_topo->llc_sibling); - cpumask_set_cpu(cpuid, &cpu_topo->llc_sibling); - } - - if (cpuid_topo->package_id != cpu_topo->package_id) - continue; - - cpumask_set_cpu(cpuid, &cpu_topo->core_sibling); - cpumask_set_cpu(cpu, &cpuid_topo->core_sibling); - - if (cpuid_topo->core_id != cpu_topo->core_id) - continue; - - cpumask_set_cpu(cpuid, &cpu_topo->thread_sibling); - cpumask_set_cpu(cpu, &cpuid_topo->thread_sibling); - } -} - void store_cpu_topology(unsigned int cpuid) { struct cpu_topology *cpuid_topo = &cpu_topology[cpuid]; @@ -296,59 +59,19 @@ void store_cpu_topology(unsigned int cpuid) update_siblings_masks(cpuid); } -static void clear_cpu_topology(int cpu) -{ - struct cpu_topology *cpu_topo = &cpu_topology[cpu]; - - cpumask_clear(&cpu_topo->llc_sibling); - cpumask_set_cpu(cpu, &cpu_topo->llc_sibling); - - cpumask_clear(&cpu_topo->core_sibling); - cpumask_set_cpu(cpu, &cpu_topo->core_sibling); - cpumask_clear(&cpu_topo->thread_sibling); - cpumask_set_cpu(cpu, &cpu_topo->thread_sibling); -} - -static void __init reset_cpu_topology(void) -{ - unsigned int cpu; - - for_each_possible_cpu(cpu) { - struct cpu_topology *cpu_topo = &cpu_topology[cpu]; - - cpu_topo->thread_id = -1; - cpu_topo->core_id = 0; - cpu_topo->package_id = -1; - cpu_topo->llc_id = -1; - - clear_cpu_topology(cpu); - } -} - -void remove_cpu_topology(unsigned int cpu) -{ - int sibling; - - for_each_cpu(sibling, topology_core_cpumask(cpu)) - cpumask_clear_cpu(cpu, topology_core_cpumask(sibling)); - for_each_cpu(sibling, topology_sibling_cpumask(cpu)) - cpumask_clear_cpu(cpu, topology_sibling_cpumask(sibling)); - for_each_cpu(sibling, topology_llc_cpumask(cpu)) - cpumask_clear_cpu(cpu, topology_llc_cpumask(sibling)); - - clear_cpu_topology(cpu); -} - #ifdef CONFIG_ACPI /* * Propagate the topology information of the processor_topology_node tree to the * cpu_topology array. */ -static int __init parse_acpi_topology(void) +int __init parse_acpi_topology(void) { bool is_threaded; int cpu, topology_id; + if (acpi_disabled) + return 0; + is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK; for_each_possible_cpu(cpu) { @@ -384,24 +107,6 @@ static int __init parse_acpi_topology(void) return 0; } - -#else -static inline int __init parse_acpi_topology(void) -{ - return -EINVAL; -} #endif -void __init init_cpu_topology(void) -{ - reset_cpu_topology(); - /* - * Discard anything that was parsed if we hit an error so we - * don't use partial information. - */ - if (!acpi_disabled && parse_acpi_topology()) - reset_cpu_topology(); - else if (of_have_populated_dt() && parse_dt_topology()) - reset_cpu_topology(); -} diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index edfcf8d9..6cc6a860 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -6,8 +6,8 @@ * Written by: Juri Lelli, ARM Ltd. */ -#include #include +#include #include #include #include @@ -16,6 +16,11 @@ #include #include #include +#include +#include +#include +#include +#include DEFINE_PER_CPU(unsigned long, freq_scale) = SCHED_CAPACITY_SCALE; @@ -278,3 +283,294 @@ static void parsing_done_workfn(struct work_struct *work) #else core_initcall(free_raw_capacity); #endif + +#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV) +static int __init get_cpu_for_node(struct device_node *node) +{ + struct device_node *cpu_node; + int cpu; + + cpu_node = of_parse_phandle(node, "cpu", 0); + if (!cpu_node) + return -1; + + cpu = of_cpu_node_to_id(cpu_node); + if (cpu >= 0) + topology_parse_cpu_capacity(cpu_node, cpu); + else + pr_crit("Unable to find CPU node for %pOF\n", cpu_node); + + of_node_put(cpu_node); + return cpu; +} + +static int __init parse_core(struct device_node *core, int package_id, + int core_id) +{ + char name[10]; + bool leaf = true; + int i = 0; + int cpu; + struct device_node *t; + + do { + snprintf(name, sizeof(name), "thread%d", i); + t = of_get_child_by_name(core, name); + if (t) { + leaf = false; + cpu = get_cpu_for_node(t); + if (cpu >= 0) { + cpu_topology[cpu].package_id = package_id; + cpu_topology[cpu].core_id = core_id; + cpu_topology[cpu].thread_id = i; + } else { + pr_err("%pOF: Can't get CPU for thread\n", + t); + of_node_put(t); + return -EINVAL; + } + of_node_put(t); + } + i++; + } while (t); + + cpu = get_cpu_for_node(core); + if (cpu >= 0) { + if (!leaf) { + pr_err("%pOF: Core has both threads and CPU\n", + core); + return -EINVAL; + } + + cpu_topology[cpu].package_id = package_id; + cpu_topology[cpu].core_id = core_id; + } else if (leaf) { + pr_err("%pOF: Can't get CPU for leaf core\n", core); + return -EINVAL; + } + + return 0; +} + +static int __init parse_cluster(struct device_node *cluster, int depth) +{ + char name[10]; + bool leaf = true; + bool has_cores = false; + struct device_node *c; + static int package_id __initdata; + int core_id = 0; + int i, ret; + + /* + * First check for child clusters; we currently ignore any + * information about the nesting of clusters and present the + * scheduler with a flat list of them. + */ + i = 0; + do { + snprintf(name, sizeof(name), "cluster%d", i); + c = of_get_child_by_name(cluster, name); + if (c) { + leaf = false; + ret = parse_cluster(c, depth + 1); + of_node_put(c); + if (ret != 0) + return ret; + } + i++; + } while (c); + + /* Now check for cores */ + i = 0; + do { + snprintf(name, sizeof(name), "core%d", i); + c = of_get_child_by_name(cluster, name); + if (c) { + has_cores = true; + + if (depth == 0) { + pr_err("%pOF: cpu-map children should be clusters\n", + c); + of_node_put(c); + return -EINVAL; + } + + if (leaf) { + ret = parse_core(c, package_id, core_id++); + } else { + pr_err("%pOF: Non-leaf cluster with core %s\n", + cluster, name); + ret = -EINVAL; + } + + of_node_put(c); + if (ret != 0) + return ret; + } + i++; + } while (c); + + if (leaf && !has_cores) + pr_warn("%pOF: empty cluster\n", cluster); + + if (leaf) + package_id++; + + return 0; +} + +static int __init parse_dt_topology(void) +{ + struct device_node *cn, *map; + int ret = 0; + int cpu; + + cn = of_find_node_by_path("/cpus"); + if (!cn) { + pr_err("No CPU information found in DT\n"); + return 0; + } + + /* + * When topology is provided cpu-map is essentially a root + * cluster with restricted subnodes. + */ + map = of_get_child_by_name(cn, "cpu-map"); + if (!map) + goto out; + + ret = parse_cluster(map, 0); + if (ret != 0) + goto out_map; + + topology_normalize_cpu_scale(); + + /* + * Check that all cores are in the topology; the SMP code will + * only mark cores described in the DT as possible. + */ + for_each_possible_cpu(cpu) + if (cpu_topology[cpu].package_id == -1) + ret = -EINVAL; + +out_map: + of_node_put(map); +out: + of_node_put(cn); + return ret; +} + +/* + * cpu topology table + */ +struct cpu_topology cpu_topology[NR_CPUS]; +EXPORT_SYMBOL_GPL(cpu_topology); + +const struct cpumask *cpu_coregroup_mask(int cpu) +{ + const cpumask_t *core_mask = cpumask_of_node(cpu_to_node(cpu)); + + /* Find the smaller of NUMA, core or LLC siblings */ + if (cpumask_subset(&cpu_topology[cpu].core_sibling, core_mask)) { + /* not numa in package, lets use the package siblings */ + core_mask = &cpu_topology[cpu].core_sibling; + } + if (cpu_topology[cpu].llc_id != -1) { + if (cpumask_subset(&cpu_topology[cpu].llc_sibling, core_mask)) + core_mask = &cpu_topology[cpu].llc_sibling; + } + + return core_mask; +} + +void update_siblings_masks(unsigned int cpuid) +{ + struct cpu_topology *cpu_topo, *cpuid_topo = &cpu_topology[cpuid]; + int cpu; + + /* update core and thread sibling masks */ + for_each_online_cpu(cpu) { + cpu_topo = &cpu_topology[cpu]; + + if (cpuid_topo->llc_id == cpu_topo->llc_id) { + cpumask_set_cpu(cpu, &cpuid_topo->llc_sibling); + cpumask_set_cpu(cpuid, &cpu_topo->llc_sibling); + } + + if (cpuid_topo->package_id != cpu_topo->package_id) + continue; + + cpumask_set_cpu(cpuid, &cpu_topo->core_sibling); + cpumask_set_cpu(cpu, &cpuid_topo->core_sibling); + + if (cpuid_topo->core_id != cpu_topo->core_id) + continue; + + cpumask_set_cpu(cpuid, &cpu_topo->thread_sibling); + cpumask_set_cpu(cpu, &cpuid_topo->thread_sibling); + } +} + +static void clear_cpu_topology(int cpu) +{ + struct cpu_topology *cpu_topo = &cpu_topology[cpu]; + + cpumask_clear(&cpu_topo->llc_sibling); + cpumask_set_cpu(cpu, &cpu_topo->llc_sibling); + + cpumask_clear(&cpu_topo->core_sibling); + cpumask_set_cpu(cpu, &cpu_topo->core_sibling); + cpumask_clear(&cpu_topo->thread_sibling); + cpumask_set_cpu(cpu, &cpu_topo->thread_sibling); +} + +static void __init reset_cpu_topology(void) +{ + unsigned int cpu; + + for_each_possible_cpu(cpu) { + struct cpu_topology *cpu_topo = &cpu_topology[cpu]; + + cpu_topo->thread_id = -1; + cpu_topo->core_id = 0; + cpu_topo->package_id = -1; + cpu_topo->llc_id = -1; + + clear_cpu_topology(cpu); + } +} + +void remove_cpu_topology(unsigned int cpu) +{ + int sibling; + + for_each_cpu(sibling, topology_core_cpumask(cpu)) + cpumask_clear_cpu(cpu, topology_core_cpumask(sibling)); + for_each_cpu(sibling, topology_sibling_cpumask(cpu)) + cpumask_clear_cpu(cpu, topology_sibling_cpumask(sibling)); + for_each_cpu(sibling, topology_llc_cpumask(cpu)) + cpumask_clear_cpu(cpu, topology_llc_cpumask(sibling)); + + clear_cpu_topology(cpu); +} + +__weak int __init parse_acpi_topology(void) +{ + return 0; +} + +void __init init_cpu_topology(void) +{ + reset_cpu_topology(); + + /* + * Discard anything that was parsed if we hit an error so we + * don't use partial information. + */ + if (parse_acpi_topology()) + reset_cpu_topology(); + else if (of_have_populated_dt() && parse_dt_topology()) + reset_cpu_topology(); +} +#endif diff --git a/drivers/base/topology.c b/drivers/base/topology.c index 5fd9f167..c17d5434 100644 --- a/drivers/base/topology.c +++ b/drivers/base/topology.c @@ -8,6 +8,7 @@ * * All rights reserved. */ +#include #include #include #include diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h index d9bdc1a7..d4e76e0a 100644 --- a/include/linux/arch_topology.h +++ b/include/linux/arch_topology.h @@ -33,4 +33,32 @@ unsigned long topology_get_freq_scale(int cpu) return per_cpu(freq_scale, cpu); } +struct cpu_topology { + int thread_id; + int core_id; + int package_id; + int llc_id; + cpumask_t thread_sibling; + cpumask_t core_sibling; + cpumask_t llc_sibling; +}; + +#ifdef CONFIG_GENERIC_ARCH_TOPOLOGY +extern struct cpu_topology cpu_topology[NR_CPUS]; + +#define topology_physical_package_id(cpu) (cpu_topology[cpu].package_id) +#define topology_core_id(cpu) (cpu_topology[cpu].core_id) +#define topology_core_cpumask(cpu) (&cpu_topology[cpu].core_sibling) +#define topology_sibling_cpumask(cpu) (&cpu_topology[cpu].thread_sibling) +#define topology_llc_cpumask(cpu) (&cpu_topology[cpu].llc_sibling) +void init_cpu_topology(void); +void store_cpu_topology(unsigned int cpuid); +const struct cpumask *cpu_coregroup_mask(int cpu); +#endif + +#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV) +void update_siblings_masks(unsigned int cpu); +#endif +void remove_cpu_topology(unsigned int cpuid); + #endif /* _LINUX_ARCH_TOPOLOGY_H_ */ From patchwork Wed Mar 20 23:48:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 10862689 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 490361575 for ; Wed, 20 Mar 2019 23:48:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25A1129ED0 for ; Wed, 20 Mar 2019 23:48:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19AF029EDB; Wed, 20 Mar 2019 23:48:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A0BC229ED0 for ; Wed, 20 Mar 2019 23:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WCc0Bc/d8qAB5G0uBg2u20mNbhv5Hkli8whZ8T/TuFI=; b=UAQa79JaEOUusq ADB9INEm/1T4DzSDgD3TUAZ3PrnFyMrHMzwJkE3coVYZzptwzuu4EYvzhKD1tLcoQ6t/EU9IJE9lt ooYc4Z3q9YsDMccNjdAoEZIm3D4IyEc/BE6qOkt6vBhk8D5jtdw7gTZhE0XeWotsJKd/YuYzcVZRc PGD9FtLOpV7ZhGXimVqZFN0MtvUGNeAv3anh0Qk+8VsPpKCcAp68Mm99v04+QPeKqDj2P9ip1tsbU 3M0Q+YKyB6edQf9nyIUbYmNfiJxlENJsipmFxLRBPq8BMG8tVd2hk/N67MUQ2XkQY0U5kZtvcBR7m 9afbMjVUKon8zNwEdXTg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6kwa-0001Wu-QC; Wed, 20 Mar 2019 23:48:24 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6kwU-0001P3-Ue for linux-riscv@lists.infradead.org; Wed, 20 Mar 2019 23:48:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1553125698; x=1584661698; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=clP6NMFQMwOD3n54p6gFwQhrqNU04Jf2cfalAdxHECo=; b=EXCRSH6M95NH5rSQ5VPlUyQ3Z97w3Jj8ki5tj5lMrTiy34qM/TbTtT6Q 2AYkJrbs7RLhdWrR9ofkkX40bnLf/BqJ4Ro3ngpY4VGYkrEZqTuQLdO8L sMEhq1aQ9S533ICxqKXSGl9sruI1h45kLZcc3xrgM5vl1Hdew6iGv4J0A zaS0fM14vMN4bY7NYwJIy187cBFNPPLDHSouwQJF0mLp2cmLlSks4EmwO P5HBVPQhD6nQvtgL0YUuORRNaBF4Ar+7fsthAnIy2v2d6vJBCp+COlTAI otuoDjP9O5YOWJ4j5AISBozxxYaFAtYsyOcvp942K3+JM44s/1Dz+0ds+ w==; X-IronPort-AV: E=Sophos;i="5.58,498,1544457600"; d="scan'208";a="209432745" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Mar 2019 07:48:16 +0800 IronPort-SDR: GiRdY+UnApTGV+APexLiuq3lsZ7eI5/LMfX/mEFnAl+IllUOXOJJJMaj9qk1EaCYx2+BqW9xJ7 Hgu7oTiBmeqDyCwMwX0lnXM8Sa3NO62Irf112AF818QTP80ZmGNUfRNkvqgsdYSFlLh3JFfRPa kAhf/Ql8RzSM3093xh2gFUytHYEFClvwYhY5qTEyET04yjFHNiU3FkNHUeHZRrsZ7lTjBVAL9z Aa/jTWm7ibJkbgqUhVNQct6RAGlbKGi97OnwlXX+gDntyJsVJMAPAS2PiVEbdTVjMTGQpkJ+YD Pipn3HKw1AzqW66PnIqvRn9s Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 20 Mar 2019 16:27:53 -0700 IronPort-SDR: /1pYslUX5TWJJ4C/tLDjSgJrKkGzmhVYGb+STzhMnVSd782VWNJaIqLSzzK3O2t1mZ9460YR5O Tk70+87aq32vJCBZ+uyObTfeaJwfG5RPWcf5Sit8WkHkNjUqegyMsgDioCyApcrCMMkJSKAx3A +fjtrzVFHjMsFeUJvY2PdBkkHua84WmCaofCHM+pFnIxOHEfUvtc1q9F/zcTHVLlK9pIQF0Hoi m8ulEDu8m85a930yWJy+sh5f3yLp8XkudMe8TIDJcP/xBknERMQ1ccK7IzM5cQbZpRmqlRbO1i O2E= Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip01.wdc.com with ESMTP; 20 Mar 2019 16:48:16 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [RFT/RFC PATCH v3 4/5] arm: Use common cpu_topology Date: Wed, 20 Mar 2019 16:48:05 -0700 Message-Id: <20190320234806.19748-5-atish.patra@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190320234806.19748-1-atish.patra@wdc.com> References: <20190320234806.19748-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190320_164819_221377_3928BF0B X-CRM114-Status: GOOD ( 12.69 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "Rafael J. Wysocki" , "Peter Zijlstra \(Intel\)" , Catalin Marinas , Palmer Dabbelt , Will Deacon , Atish Patra , linux-riscv@lists.infradead.org, Ingo Molnar , Dmitriy Cherkasov , Anup Patel , Morten Rasmussen , devicetree@vger.kernel.org, Albert Ou , Johan Hovold , Rob Herring , Paul Walmsley , Ard Biesheuvel , Greg Kroah-Hartman , Jeremy Linton , Otto Sabart , Sudeep Holla Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, ARM32 and ARM64 uses different data structures to represent their cpu toplogies. Since, we are moving the ARM64 topology to common code to be used by other architectures, we can reuse that for ARM32 as well. Signed-off-by: Atish Patra --- arch/arm/include/asm/topology.h | 22 +--------------------- arch/arm/kernel/topology.c | 10 +++++----- include/linux/arch_topology.h | 10 +++++++++- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/arch/arm/include/asm/topology.h b/arch/arm/include/asm/topology.h index 2a786f54..52f99ec8 100644 --- a/arch/arm/include/asm/topology.h +++ b/arch/arm/include/asm/topology.h @@ -5,26 +5,6 @@ #ifdef CONFIG_ARM_CPU_TOPOLOGY #include - -struct cputopo_arm { - int thread_id; - int core_id; - int socket_id; - cpumask_t thread_sibling; - cpumask_t core_sibling; -}; - -extern struct cputopo_arm cpu_topology[NR_CPUS]; - -#define topology_physical_package_id(cpu) (cpu_topology[cpu].socket_id) -#define topology_core_id(cpu) (cpu_topology[cpu].core_id) -#define topology_core_cpumask(cpu) (&cpu_topology[cpu].core_sibling) -#define topology_sibling_cpumask(cpu) (&cpu_topology[cpu].thread_sibling) - -void init_cpu_topology(void); -void store_cpu_topology(unsigned int cpuid); -const struct cpumask *cpu_coregroup_mask(int cpu); - #include /* Replace task scheduler's default frequency-invariant accounting */ @@ -38,7 +18,7 @@ const struct cpumask *cpu_coregroup_mask(int cpu); #else -static inline void init_cpu_topology(void) { } +static inline void init_cpu_topology(void) {} static inline void store_cpu_topology(unsigned int cpuid) { } #endif diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index 60e375ce..0ddb24c7 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -180,7 +180,7 @@ static inline void update_cpu_capacity(unsigned int cpuid) {} /* * cpu topology table */ -struct cputopo_arm cpu_topology[NR_CPUS]; +struct cpu_topology cpu_topology[NR_CPUS]; EXPORT_SYMBOL_GPL(cpu_topology); const struct cpumask *cpu_coregroup_mask(int cpu) @@ -197,9 +197,9 @@ const struct cpumask *cpu_corepower_mask(int cpu) return &cpu_topology[cpu].thread_sibling; } -static void update_siblings_masks(unsigned int cpuid) +void update_siblings_masks(unsigned int cpuid) { - struct cputopo_arm *cpu_topo, *cpuid_topo = &cpu_topology[cpuid]; + struct cpu_topology *cpu_topo, *cpuid_topo = &cpu_topology[cpuid]; int cpu; /* update core and thread sibling masks */ @@ -230,7 +230,7 @@ static void update_siblings_masks(unsigned int cpuid) */ void store_cpu_topology(unsigned int cpuid) { - struct cputopo_arm *cpuid_topo = &cpu_topology[cpuid]; + struct cpu_topology *cpuid_topo = &cpu_topology[cpuid]; unsigned int mpidr; /* If the cpu topology has been already set, just return */ @@ -302,7 +302,7 @@ void __init init_cpu_topology(void) /* init core mask and capacity */ for_each_possible_cpu(cpu) { - struct cputopo_arm *cpu_topo = &(cpu_topology[cpu]); + struct cpu_topology *cpu_topo = &(cpu_topology[cpu]); cpu_topo->thread_id = -1; cpu_topo->core_id = -1; diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h index d4e76e0a..7c850611 100644 --- a/include/linux/arch_topology.h +++ b/include/linux/arch_topology.h @@ -36,17 +36,25 @@ unsigned long topology_get_freq_scale(int cpu) struct cpu_topology { int thread_id; int core_id; +#ifdef CONFIG_ARM_CPU_TOPOLOGY + int socket_id; +#else int package_id; int llc_id; + cpumask_t llc_sibling; +#endif cpumask_t thread_sibling; cpumask_t core_sibling; - cpumask_t llc_sibling; }; #ifdef CONFIG_GENERIC_ARCH_TOPOLOGY extern struct cpu_topology cpu_topology[NR_CPUS]; +#ifdef CONFIG_ARM_CPU_TOPOLOGY +#define topology_physical_package_id(cpu) (cpu_topology[cpu].socket_id) +#else #define topology_physical_package_id(cpu) (cpu_topology[cpu].package_id) +#endif #define topology_core_id(cpu) (cpu_topology[cpu].core_id) #define topology_core_cpumask(cpu) (&cpu_topology[cpu].core_sibling) #define topology_sibling_cpumask(cpu) (&cpu_topology[cpu].thread_sibling) From patchwork Wed Mar 20 23:48:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 10862693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F76B1515 for ; Wed, 20 Mar 2019 23:48:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BD9F29ED0 for ; Wed, 20 Mar 2019 23:48:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FED029ED1; Wed, 20 Mar 2019 23:48:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EFC5329ECD for ; Wed, 20 Mar 2019 23:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eVXE88azgfj6OlRN8DClrcFcPYrRRoHDVJudvDZAYlA=; b=QVbbUM8a+9erLL NzUib5Tm3t4NFKeBRb0hiVp/SUmhLm2hfUbNnFByVhPnB8AuSdPoVEAFDZcJw9UHGPzLqWIxsZefX 2qfAyoDDDYadhecoRpT+QniX7WPaCV/uk3AuLf6kpGIr9D3ZH0qycyZZJmfbXOE9Olct2UFuvz2bn hpACOSA+9N8Czd4HmKxLwMSWuEHzcupwr+ylfEGoQ/oheEWoH7YFXbPByY6TeHGa1LBZyDil0gAyE GQdTS7oSUXTOig0B9dHJL2v15ZhT50OobC4sK9RjxrGDIMNadmXAQS2M2NV09Ms+9HXS1KgxFiceM Bb13dXKmTJnZy1q4o1vg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6kwb-0001Yj-T8; Wed, 20 Mar 2019 23:48:25 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6kwW-0001OM-BV for linux-riscv@lists.infradead.org; Wed, 20 Mar 2019 23:48:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1553125700; x=1584661700; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s8sajK0+Y5Qxk3l9f3FRoReqL4ztyr9hMhYSgl8VlYs=; b=HgOrsZeFDIHo5DqrM/1I1Yl7p753G2eoNurOk0GvtLJKthDxKygPop/B yLaW/FKf3EU84BW1/XAoFgIVyxQhllHAgwiBn8Sv1TIiyJLF0E57nrhJG xLU+OzpQJHxbH1zobKC6JF8HmiKdGeI6YV7/HZaXqq27E/PVhS8x0StbM TJL/asnjq/fMZ8mE45Y1aPbPjVfL6hidOb0sfldzVyAqMBt8jBtb07Ocl FLcwIvk63L1+I50oyKxJCXnzGlwOiv4w3YqaDkaIUZ0thkheZR1KP6BcV qyrR2bQcc693nDVfrpGD4Xnqzw+umkNWXenHncpEd35htuBVISuBQVIbU g==; X-IronPort-AV: E=Sophos;i="5.58,498,1544457600"; d="scan'208";a="209432747" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Mar 2019 07:48:16 +0800 IronPort-SDR: 4fMxm+0f7kjpdl7GagncgJ8qpnZg2h7ZEksRYOFZ+GOTN0LBRGPgq4Zcwh0QwgvA+nC6Yx7SFS fo7x4yBzGgpIlE0ChcGDuarhYpurISAF8hVQbuRBLx83To3BI4zWCuauARtnD/1UVs6lFTeJQg 1eI8XrcpeG1MAmwLVijAr/WdbHDvAN5rLvjeQ3TMVx/HZ/2jgH/plP798Yo4nr1O1Qq9laGx8j O3a2klZ6A4YtA6xDGBthI/b2lMgNgVifSqlPI50U7r7gLItMRCsyDlPcKw7+xQ5vaJR1AIVt9T 6Pi7/VyZyxWyqN4rvYHzcPos Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 20 Mar 2019 16:27:53 -0700 IronPort-SDR: TW5Zbmthhyvkzhd46KZtqxhnd3w3JqrSsH2O3cUfBjyhO4AXA57gWdo9glBSf+uwzzoLK2yzLl z12Xk/ez4h0xYkTJ32lZw3aSYGB0uTonvch+xr+YQdqMqX7b9C8WluoF+iUT8HtbNhI9MEMmg4 rh7dRLVHbn2lFfALzYLMVD5mxh6iGKTjcPzWGhiifGOn6eUu6FwvJtBZdtqrlTPgouytBFkx1B xsKVxXh0sQQ6+3vWQ0QcVkantcZSgBw+yGqBrmAMtJKJdlhvH5mPb5R6G0Es7BdUhOQ1RHP7iQ uco= Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip01.wdc.com with ESMTP; 20 Mar 2019 16:48:16 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [RFT/RFC PATCH v3 5/5] RISC-V: Parse cpu topology during boot. Date: Wed, 20 Mar 2019 16:48:06 -0700 Message-Id: <20190320234806.19748-6-atish.patra@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190320234806.19748-1-atish.patra@wdc.com> References: <20190320234806.19748-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190320_164820_745790_68F391E4 X-CRM114-Status: GOOD ( 10.59 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "Rafael J. Wysocki" , "Peter Zijlstra \(Intel\)" , Catalin Marinas , Palmer Dabbelt , Will Deacon , Atish Patra , linux-riscv@lists.infradead.org, Ingo Molnar , Dmitriy Cherkasov , Anup Patel , Morten Rasmussen , devicetree@vger.kernel.org, Albert Ou , Johan Hovold , Rob Herring , Paul Walmsley , Ard Biesheuvel , Greg Kroah-Hartman , Jeremy Linton , Otto Sabart , Sudeep Holla Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, there are no topology defined for RISC-V. Parse the cpu-map node from device tree and setup the cpu topology. CPU topology after applying the patch. $cat /sys/devices/system/cpu/cpu2/topology/core_siblings_list 0-3 $cat /sys/devices/system/cpu/cpu3/topology/core_siblings_list 0-3 $cat /sys/devices/system/cpu/cpu3/topology/physical_package_id 0 $cat /sys/devices/system/cpu/cpu3/topology/core_id 3 Signed-off-by: Atish Patra --- arch/riscv/Kconfig | 1 + arch/riscv/kernel/smpboot.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index eb56c82d..ac87a0ec 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -47,6 +47,7 @@ config RISCV select PCI_MSI if PCI select RISCV_TIMER select GENERIC_IRQ_MULTI_HANDLER + select GENERIC_ARCH_TOPOLOGY if SMP select ARCH_HAS_PTE_SPECIAL select HAVE_EBPF_JIT if 64BIT diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index f41eb193..a8fe590c 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -16,6 +16,7 @@ * GNU General Public License for more details. */ +#include #include #include #include @@ -43,6 +44,7 @@ static DECLARE_COMPLETION(cpu_running); void __init smp_prepare_boot_cpu(void) { + init_cpu_topology(); } void __init smp_prepare_cpus(unsigned int max_cpus) @@ -146,6 +148,7 @@ asmlinkage void __init smp_callin(void) trap_init(); notify_cpu_starting(smp_processor_id()); + update_siblings_masks(smp_processor_id()); set_cpu_online(smp_processor_id(), 1); /* * Remote TLB flushes are ignored while the CPU is offline, so emit