Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7963744imm; Thu, 28 Jun 2018 12:09:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcHLQoURYK/2EpLUaqTRHCUaZmtotN5gGCPcFJxTNxy2oTv+UvdQ1qk0xvllaasOlp+WMgg X-Received: by 2002:a65:64c8:: with SMTP id t8-v6mr1416808pgv.110.1530212967360; Thu, 28 Jun 2018 12:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530212967; cv=none; d=google.com; s=arc-20160816; b=XmcSKxD+OsorynLFeYsY+lHAQTfuxHNoF0q1i3wx69ba7gvH47s02nuFzWIoBSQ2bC 4qU/qr+P3RkYEbvm5cufumMVgSlxrKUyeIJ/a58BDjCLJ1cwgzlnV6NYTurZ0NyC2mRy dlPzfgoCJThXClhK+jJgjYQhmPnnsW9pZTe8Y7odTTbg7SNjLQBoZqqGdkVM2sXGM710 sQH+LXQoBWvndZ+yPa8zMBqpMgK3jq1bWvDeS/9GPxlq+YbETaw5eU24xd0huQ4LdBAn 8STNBAizDja4KeAWdq+2O4Zt2GDaNkMahW1K2S+0Vk8IwGFOTuviwUa19h2AlCPZ8ZZ8 qekw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=3UQAi93wUEpIly23LwGN+PrWJ/TuYNXXrtlZeNJJj3U=; b=SW/0h+3HwCKGk02BdKVsO6v0uqSnpmE7BKz7FOep5Gc9i2kYlKqjLzM4cZOi1fZCgT 2qRhArOLXTqa2qE9t0BRgdb1WGTQ+fLjQ+fJyYl5aj0+BuF8ct0bkrDKXz0IRcXHitfp cJepqttFECdhUKpIST4c9B/GnYtYRtwFh+62GGdIXRJTBL+5ShwdTVfj9n7+GlgbHs0s 6nd6YtbPQ7dWUQHUMPBOXUmjw6TdmbbrKrKK/Iw3KJ4U0Eyt4LCQ3NQgRUUOPJ0U8g7G Jsmp9XPvGTgN/EBjD5/xv7DHXitB4D5GoxQqzQwoG+iKnEWIEXwCWztaqQZ/OxGFpOg3 iILA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l196-v6si5506799pga.38.2018.06.28.12.09.12; Thu, 28 Jun 2018 12:09:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935541AbeF1Prg convert rfc822-to-8bit (ORCPT + 99 others); Thu, 28 Jun 2018 11:47:36 -0400 Received: from mx01.hxt-semitech.com.96.203.223.in-addr.arpa ([223.203.96.7]:34790 "EHLO barracuda.hxt-semitech.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S966965AbeF1Pp2 (ORCPT ); Thu, 28 Jun 2018 11:45:28 -0400 X-ASG-Debug-ID: 1530200670-093b7e43b2a9fe0001-xx1T2L Received: from HXTBJIDCEMVIW01.hxtcorp.net (localhost [10.128.0.14]) by barracuda.hxt-semitech.com with ESMTP id bCfyYoARDnZtbTms (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 28 Jun 2018 23:44:30 +0800 (CST) X-Barracuda-Envelope-From: shunyong.yang@hxt-semitech.com Received: from HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) by HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) with Microsoft SMTP Server (TLS) id 15.0.847.32; Thu, 28 Jun 2018 23:44:33 +0800 Received: from HXTBJIDCEMVIW01.hxtcorp.net ([fe80::f451:a443:c0b5:87d1]) by HXTBJIDCEMVIW01.hxtcorp.net ([fe80::f451:a443:c0b5:87d1%12]) with mapi id 15.00.0847.030; Thu, 28 Jun 2018 23:44:33 +0800 From: "Yang, Shunyong" To: Andrew Jones CC: Sudeep Holla , Jeremy Linton , "catalin.marinas@arm.com" , "will.deacon@arm.com" , "linux-kernel@vger.kernel.org" , "Zheng, Joey" Subject: Re: [RFC PATCH] arm64: topology: Map PPTT node offset to logic physical package id Thread-Topic: [RFC PATCH] arm64: topology: Map PPTT node offset to logic physical package id X-ASG-Orig-Subj: Re: [RFC PATCH] arm64: topology: Map PPTT node offset to logic physical package id Thread-Index: AQHUDsGU1koi4KlNakibmAYxryVeeqR04+QAgAAm8wCAAAQNAIAAEsIAgAAN8ICAAAvDgIAAlPT9 Date: Thu, 28 Jun 2018 15:44:32 +0000 Message-ID: References: <1530177508-15298-1-git-send-email-shunyong.yang@hxt-semitech.com> <20180628115748.kprobde6c3joc6ll@kamzik.brq.redhat.com> ,<20180628145125.2psdmymtuueiv4xn@kamzik.brq.redhat.com> In-Reply-To: <20180628145125.2psdmymtuueiv4xn@kamzik.brq.redhat.com> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Barracuda-Connect: localhost[10.128.0.14] X-Barracuda-Start-Time: 1530200670 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA X-Barracuda-URL: https://192.168.50.101:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at hxt-semitech.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.7616 1.0000 1.8731 X-Barracuda-Spam-Score: 1.87 X-Barracuda-Spam-Status: No, SCORE=1.87 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.52522 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, All > On Jun 28, 2018, at 22:51, Andrew Jones wrote: > >> On Thu, Jun 28, 2018 at 03:09:19PM +0100, Sudeep Holla wrote: >> >> >>> On 28/06/18 14:19, Jeremy Linton wrote: >>> Hi, >>> >>> On 06/28/2018 07:12 AM, Sudeep Holla wrote: >> >> [...] >> >>>> >>>> OK sure. I liked the approach in Shunyong's patch. I was thinking if we >>>> can avoid the list and dynamic allocation on each addition and make it >>>> more simpler. >>>> >>> >>> This one reads simpler, but yes I agree we should try to avoid the >>> dynamic allocation. >>> >>> OTOH, I think that dropping the dynamic allocation leads to an algorithm >>> that picks a value and replaces all the matches. Which of course is >>> Andrew's patch, although I did have to read it a couple times to get a >>> grasp how it works. I'm guessing that is due to the fact that he seems >>> to have optimized 3 double loops into a single loop with two individual >>> nested loops. AKA its probably more efficient than the naive >>> implementation, but readability seems to have suffered a bit in the >>> initial version he posted. I'm not sure the optimization is worth it, >>> but I'm guessing there is a middle ground which makes it more readable. >>> >> >> Completely agree. RFC from Andrew is not so readable and easy to understand. > > Middle ground coming up. At the expense of a triple-nested loop (which > will never be N^3 iterations due to conditions at the start of each loop), > we can avoid dynamic allocations and list iterations and still gain > readability. > > Thanks, > drew I have a new approach. As we've already got the offset of the node with physical package bit set, which is the parent of the cpu we are querying. We can iterate from the begining of PPTT to count the nodes with physical package bit set till we reach the offset we've got. Then, the count value is the package id. This avoid list and dynamic allocation. And PPTT provides length for each node, iteration should be easy. I think this may implemented in pptt.c. I am writing this mail on my phone. Maybe I should try to write a patch to test in office tomorrow if you think it's feasible. Thanks. Shunyong.