Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5612938imm; Wed, 12 Sep 2018 08:30:35 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbESwr7xm6qUeOxe2CdQMN+t4S/eLVDEVVuYxS1NhoKSOd0ElWnDlhBg0lcAFqez9TfFSLo X-Received: by 2002:a62:438f:: with SMTP id l15-v6mr3042493pfi.196.1536766235751; Wed, 12 Sep 2018 08:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536766235; cv=none; d=google.com; s=arc-20160816; b=egBwm0m0DT/QjuW+uZrCIi49Ng1MR09JTGueJDAlsepjThMQhJvreWGwy/I8u/yGBE tjMCzW9wi4QWdkO3i2ctsxYQKgqvOfvpbzx4gYLFjx+nhsjqJZ9/0yhz4NINuG6Jp0d/ zubU6sZIeA9N4+K0CE9+T7dCWkLe5JpeXueJGiDmAnZbcFbrLkbxEAdhHY/fMJQEqHn1 gEqahdAPX84OlrVJE9K+xVmBePQ/DvvWvDX5DkV6WgttmpkTBq8ouqwiBapyNZTSTpYA hahnGDihTDcC9L/0rgt6sf3gpzGo+yXrzCafQqPqF86ZrmczDaWqi1zexhcBaCKClKQa tOxw== 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:organization:from:references:to:subject:cc; bh=pL2Y+C24nrbHBDm83OBtdbjm5O49LBbBFx9Sd7ssqH8=; b=dJJDpt9UjV2rI+6QZDVmYQ9lr78JOeVatljL7wFCyaf62L8ZnFqhLVdJNq7B2Z7Rsx 87EmQw/djhJkuOrcuq01c0V2SH+sfRwXmmtk1qoAjEK5YjZbsoclLJET2Lwj40xHA9GO GCgySylXEomo6ediNWq9I77jkBpcn0FOlMSGJlGuZ6pWiOgSff9aeLZ1uoTncEFIRjJ1 h4sciO238c7c5GIZl7Zb9b9PG/DBbexZCl6FN9D8DKsD8bB38V5JWPrFO/Qtgiw5EGEk kZXrXXEczZCAZ+86oiVKzXScHmnHL9JdIzrP5VodriUIYWgsqJwdyDcuF2P8Xh1GzkgD oPpw== 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 i7-v6si1247451pfk.146.2018.09.12.08.29.34; Wed, 12 Sep 2018 08:30:35 -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 S1727044AbeILUdC (ORCPT + 99 others); Wed, 12 Sep 2018 16:33:02 -0400 Received: from foss.arm.com ([217.140.101.70]:33732 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726677AbeILUdC (ORCPT ); Wed, 12 Sep 2018 16:33:02 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8A99C7A9; Wed, 12 Sep 2018 08:28:01 -0700 (PDT) Received: from [10.4.12.116] (e107155-lin.emea.arm.com [10.4.12.116]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 51B953F5C0; Wed, 12 Sep 2018 08:28:00 -0700 (PDT) Cc: Sudeep Holla , linux-kernel@vger.kernel.org, vkilari@codeaurora.org Subject: Re: [PATCH] ACPI/PPTT: Handle architecturally unknown cache types To: Jeffrey Hugo , Jeremy Linton , rjw@rjwysocki.net, linux-acpi@vger.kernel.org References: <1536694334-5811-1-git-send-email-jhugo@codeaurora.org> <98e2e6fa-7256-b5ac-7d2e-42c858c6e57c@codeaurora.org> From: Sudeep Holla Organization: ARM Message-ID: Date: Wed, 12 Sep 2018 16:27:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <98e2e6fa-7256-b5ac-7d2e-42c858c6e57c@codeaurora.org> Content-Type: text/plain; charset=utf-8 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 12/09/18 15:41, Jeffrey Hugo wrote: > 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. > Yes, we have other issues if the architecturally not specified cache is not unified irrespective of what PPTT says. So we may need to review and see if that assumption is removed everywhere. Until then why can't a simple change fix the issue you have: -->8 diff --git i/drivers/acpi/pptt.c w/drivers/acpi/pptt.c index d1e26cb599bf..f74131201f5e 100644 --- i/drivers/acpi/pptt.c +++ w/drivers/acpi/pptt.c @@ -406,7 +406,8 @@ static void update_cache_properties(struct cacheinfo *this_leaf, * update the cache type as well. */ if (this_leaf->type == CACHE_TYPE_NOCACHE && - valid_flags == PPTT_CHECKED_ATTRIBUTES) + (valid_flags == PPTT_CHECKED_ATTRIBUTES || + found_cache->flags & ACPI_PPTT_CACHE_TYPE_VALID)) this_leaf->type = CACHE_TYPE_UNIFIED; } [...] >>> >>> 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. The above issues is purely lscpu to blame and nothing to do with kernel change. If kernel doesn't report level 3 cache info and lscpu fails to report level 1/2 cache info and kernel is to blame here ? That's unfair. >>> With this change, we get what we expect >>> out of lscpu (and also lstopo) including the cache(s) which are not >>> architecturally specified. Ofcourse, but we can't attribute that as kernel bug. I agree we should not show incorrect info for cache type and that needs to be fixed but disagree with lscpu issue as kernel issue. Kernel is not breaking any ABI as cacheinfo itself is optional and the absence of it needs to be dealt with. >> 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). > Yes it should be that way for above mentioned reasons. You need to fix other things if you want to support separate data and inst cache for architecturally unspecified cache. [...] > > 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. > Fair enough. > 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. > Again agreed. -- Regards, Sudeep