Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5555730imm; Wed, 12 Sep 2018 07:43:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdboRrpaYj194w4uTdT0hgJ916jAuFpUJnUEzQALtxufzznBl/DtN8X3AkjnRZ4We7myhu4p X-Received: by 2002:a63:fb57:: with SMTP id w23-v6mr2671308pgj.441.1536763427347; Wed, 12 Sep 2018 07:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536763427; cv=none; d=google.com; s=arc-20160816; b=GJuLa2Qox0SM7ALbepVsG/rImEltUmXnq56ep9jsIPT9OG10I/tsW3ZtTMPFENcnDO 7OiHZcmO6plL1BZykdMyKzMN4qQmba6g0Nwt8eAFDj7UjlefAtm5NXgSUws8KNX4gO6j DFSRe2Hh6OvdoihSaTNaIt0P0f5OciHMPqZApJ9ShaONE19VpmJ96VxAQsIK5sfHIk2/ hhLl11nwfobEar/1uamHb3Zy8MEQkxc+Eno4bVt7n0fFVnFhyZcLG9dGtuGSvRXWU090 z74z5zzwcU3t0ZPSnW0hNgUxziLfudkKOSyhoDTWsL9lBAT/In+6cV/eRWdqQyoTgCVR E5hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature; bh=Fa8CW+Zveljc2TIFV8eYgJx3Zfnpr7jGIj58T2DzkeU=; b=osMD45ZZq6DFVHC7ORt1HtnRJMueluDQhzJmAP5xDwpEXsHMsjWKXtYym1XwIfVT2g 35hO5d6H4pN2OePI8o6yWHteRelggLwcApSssXGFVCxvMg5h+fn+JRsFUqJ/n28j9+jk a7C4S3g4q9hEmFtJpoQsNz/YXMoyq0E1lq7a2XV+KfiyWFfr0ECXifvYrZB+RLHPBHfQ cDZR6+tIBhZNKxmxGj0Bi3CGdSnVnStJoxkpc1KIQIfZu6UrLmin2Fe6yz3TWSPXUDah dEgXE46c30dSyAu1L/7dUvEq4NHCyFSP68XO69ydm63R4eAplh4FUi+qO+B7yBe7LsNT XQ0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=o65ACWPW; dkim=pass header.i=@codeaurora.org header.s=default header.b=QzCsOufr; 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 184-v6si1150717pgj.421.2018.09.12.07.43.24; Wed, 12 Sep 2018 07:43:47 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=o65ACWPW; dkim=pass header.i=@codeaurora.org header.s=default header.b=QzCsOufr; 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 S1727966AbeILTqh (ORCPT + 99 others); Wed, 12 Sep 2018 15:46:37 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:53406 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726879AbeILTqh (ORCPT ); Wed, 12 Sep 2018 15:46:37 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BFC7F6081C; Wed, 12 Sep 2018 14:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536763307; bh=vK7nzpCGfzabl889LWci/0H7oE+JnLcjbRh9XZ4VZWU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=o65ACWPW8Ow2V+cqabmUjCfyM8eWh/6wnvIx1bfNx928dnGHOaLpjw9r07bxSaC8r MO0tij7u9L3wYmXyt4TPpXb3bDLwrlipp3j8XlmN02C7dHwXl82YED7B226D/N5pGN t9kuELi0kmWYey4DuttJWoHzYfBIrUhBKiK47PXs= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.226.60.81] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jhugo@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 257FE6053B; Wed, 12 Sep 2018 14:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536763306; bh=vK7nzpCGfzabl889LWci/0H7oE+JnLcjbRh9XZ4VZWU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=QzCsOufrv673kgm7vZlrZk0X228MzSMp7SgfUbf0FUu+iTNI5PcWZXmGCKC+USMnD ay9pmJiJA+4b37j+1CVpsS84Vsoctpm+tBTJs2Kzd7K7aV5bcVeWWSH2ZadKVqxsno 6yv5lBAOBITsTAxIR7nN5/ADMScV7turlPRXFlMs= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 257FE6053B Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jhugo@codeaurora.org Subject: Re: [PATCH] ACPI/PPTT: Handle architecturally unknown cache types To: Jeremy Linton , rjw@rjwysocki.net, linux-acpi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, vkilari@codeaurora.org, Sudeep Holla References: <1536694334-5811-1-git-send-email-jhugo@codeaurora.org> From: Jeffrey Hugo Message-ID: <98e2e6fa-7256-b5ac-7d2e-42c858c6e57c@codeaurora.org> Date: Wed, 12 Sep 2018 08:41:45 -0600 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/11/2018 3:25 PM, Jeremy Linton wrote: > Hi, > > On 09/11/2018 03:38 PM, Jeffrey Hugo wrote: >> On 9/11/2018 2:16 PM, Jeremy Linton wrote: >>> Hi Jeffrey, >>> >>> (+Sudeep) >>> >>> On 09/11/2018 02:32 PM, Jeffrey Hugo wrote: >>>> The type of a cache might not be specified by architectural >>>> mechanisms (ie >>>> system registers), but its type might be specified in the PPTT.  In >>>> this >>>> case, following the PPTT specification, we should identify the cache as >>>> the type specified by PPTT. >>>> >>>> This fixes the following lscpu issue where only the cache type sysfs >>>> file >>>> is missing which results in no output providing a poor user >>>> experience in >>>> the above system configuration- >>>> lscpu: cannot open /sys/devices/system/cpu/cpu0/cache/index3/type: >>>> No such >>>> file or directory >>>> >>>> Fixes: 2bd00bcd73e5 (ACPI/PPTT: Add Processor Properties Topology >>>> Table parsing) >>>> Reported-by: Vijaya Kumar K >>>> Signed-off-by: Jeffrey Hugo >>>> --- >>>>   drivers/acpi/pptt.c | 15 +++++++++++++++ >>>>   1 file changed, 15 insertions(+) >>>> >>>> diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c >>>> index d1e26cb..3c6db09 100644 >>>> --- a/drivers/acpi/pptt.c >>>> +++ b/drivers/acpi/pptt.c >>>> @@ -401,6 +401,21 @@ static void update_cache_properties(struct >>>> cacheinfo *this_leaf, >>>>               break; >>>>           } >>>>       } >>>> +    if ((this_leaf->type == CACHE_TYPE_NOCACHE) && >>>> +        (found_cache->flags & ACPI_PPTT_CACHE_TYPE_VALID)) { >>>> +        switch (found_cache->attributes & ACPI_PPTT_MASK_CACHE_TYPE) { >>>> +        case ACPI_PPTT_CACHE_TYPE_DATA: >>>> +            this_leaf->type = CACHE_TYPE_DATA; >>>> +            break; >>>> +        case ACPI_PPTT_CACHE_TYPE_INSTR: >>>> +            this_leaf->type = CACHE_TYPE_INST; >>>> +            break; >>>> +        case ACPI_PPTT_CACHE_TYPE_UNIFIED: >>>> +        case ACPI_PPTT_CACHE_TYPE_UNIFIED_ALT: >>>> +            this_leaf->type = CACHE_TYPE_UNIFIED; >>>> +            break; >>>> +        } >>>> +    } >>>>       /* >>>>        * If the above flags are valid, and the cache type is NOCACHE >>>>        * update the cache type as well. >>>> >>> >>> If you look at the next line of code following this comment its going >>> to update the cache type for fully populated PPTT nodes. Although >>> with the suggested change its only going to activate if someone >>> completely fills out the node and fails to set the valid flag on the >>> cache type. >> >> Yes, however that case doesn't apply to the scenario we are concerned >> about, doesn't seem to be fully following the PPTT spec, and seems odd >> that Linux just assumes that a "fully specified" cache is unified. > > Because, the architecturally specified ones won't be type NOCACHE? Correct. However, what if you have a NOCACHE (not architecturally specified), that is fully described in PPTT, as a non-unified cache (data only)? Unlikely? Maybe. Still seem possible though, therefore I feel this assumption is suspect. > >> >>> What I suspect is happening in the reported case is that the nodes in >>> the PPTT table are missing fields we consider to be important. Since >>> that data isn't being filled out anywhere else, so we leave the cache >>> type alone too. This has the effect of hiding sysfs nodes with >>> incomplete information. >>> >>> Also, the lack of the DATA/INST fields is based on the assumption >>> that the only nodes which need their type field updated are outside >>> of the CPU core itself so they are pretty much guaranteed to be >>> UNIFIED. Are you hitting this case? >>> >> >> Yes.  Without this change, we hit the lscpu error in the commit >> message, and get zero output about the system.  We don't even get >> information about the caches which are architecturally specified or >> how many cpus are present.  With this change, we get what we expect >> out of lscpu (and also lstopo) including the cache(s) which are not >> architecturally specified. > > I'm a bit surprised this changes the behavior of the architecturally > specified ones. As I mentioned above, those shouldn't be NOCACHE. We use > the level/type as a key for matching a PPTT node to an architecturally > described cache. If that is mismatched, something more fundamental is > happening. About the only case I can think of that can cause this is if > the CLIDR type fields are incorrect. > > In which case I might suggest we move your switch() for the INST/DATA > into the check below that comment. This change was not intended to impact architecturally specified ones, however I can see how that is the case. That would be the case if the architecturally specified type is X and PPTT indicates Y. According to the PPTT spec, the cache should be treated as type Y then (ie the contents of the PPTT override the architectural mechanisms). I can move my change below the current NOCACHE handling, which would be valid for my scenario, but it seems odd. If I do that, then the current assumption will take priority. IE, if a cache is "fully specified" in PPTT, but is NOCACHE, then it will be treated as unified, regardless of what PPTT says (maybe instruction, or data only). > >> >> I guess I still don't understand why its important for PPTT to list, >> for example, the sets/ways of a cache in all scenarios.  In the case >> of a "transparent" cache (implementation defined as not reported per >> section D3.4.2 of the ARM ARM where the cache cannot be managed by >> SW), there may not be valid values for sets/ways.  I would argue its >> better to not report that information, rather than provide bogus >> information just to make Linux happy, which may break other OSes and >> provide means for which a user to hang themselves. > > This doesn't really have anything to do with the Arm/ARM's definition of > set/way as it pertains to cache maint. Its more to assist userspace > software with an understanding of the system cache architecture so it > can make intelligent decisions about loop tiling and the like. > > What we want is a consistent dependable view for software to utilize. An > unreliable sysfs field is one that tends not to get used. I guess my argument is this - The cache is not specified architecturally because it cannot be managed by software (see the ARM ARM section I referenced). However, its important that the user be able to "see" it, I'm not a marketing guy, but I assume its going to be listed on the "data sheet". Therefore, the firmware is providing some information about the cache (via SMBIOS tables and PPTT). The HW designers have indicated that there is no sane way to provide sets/ways information to software, even on an informational basis (ie not for cache maintenance, but for performance optimizations). Therefore the firmware will not provide this information because it will be wrong. So, therefore, we should still be able to tell the user that a cache exists at the relevant level, and what size it is. On the concerned system, we cannot do that currently. > >> >> However, in the case of a transparent cache, the size/type/level/write >> policy/etc (whatever the firmware provider deems relevant) might be >> valuable information for the OS to make scheduling decisions, and is >> certainly valuable for user space utilities for cross-machine/data ou >> center level job scheduling. >> -- Jeffrey Hugo Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.