Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8372538ybl; Thu, 16 Jan 2020 15:33:35 -0800 (PST) X-Google-Smtp-Source: APXvYqx1s4dcIZAASfhtG9v7wdc2LqJUc/70HJDnoL/YBC7d+VazgyMk2C4oN0mdh6zetSRWIcFg X-Received: by 2002:a9d:7410:: with SMTP id n16mr4221696otk.23.1579217615360; Thu, 16 Jan 2020 15:33:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579217615; cv=none; d=google.com; s=arc-20160816; b=hLDF/LudOXwzLOhUsce8I2lY9487XaUrZVEyVMqGIRfBYCicixhuZVWA7pELwWWoxF yzEQ+F5b/T8mCmvVK25Tn1QcotmMuw58Sz25DvdVoqKfnhTNgFiKvPBMdFt5VyeBckva S/Y5FBxrK4uBOgzSSv6ecEuOZ3fkrm71btoEzrlmW2AhlAElHdv1smqentk0AYN047tK lQDuq0TnI140RcGaqOlBhTvcREWr0PjAaeh4FcDYdo120hvQFc3soSH5qSN8Spo7gPfe hmjbzYxa+IKXAu7OgoeJstLLMwfm8QLUJnGIgj+5NGqcfJL/tTDb40/E0FKSa0XS7Y01 spHg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=C72wzlFbus+uVitLXMbGua8vFjVHvXyLBx20iog94MM=; b=UHe75Oy5LwwtB7fPvN3ziiOBX5WlDvkP3ZzEywaoxuCCOcboXrG/pr8Rleo/g7nWYk w5LPVIBZje03xZmWYj7KaqpX5b24NPosq6tLLcB09SzNhzfvm/ejqNQ6hD+v/imu/Gud j6FpjJZenGKir233CPGDWfxaZa1oMADIYCUSD9TpfNk7k5tMr05TShDXlrFBnuo0b58T EWE6GFraJqOryP7TxXA6VIJyKc4BDmDe57TiQUx9BNyXr1bAEFKs0VcuMUXT+uNjr8y9 usy5jKf55DXak0j20j8NW8J74ey0DQu6LBXRMtT16QERMMZXyQ/TyT10tzrFLPuUaUVN lZ8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qglhAIjR; 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 b9si12439953oie.20.2020.01.16.15.33.23; Thu, 16 Jan 2020 15:33:35 -0800 (PST) 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=@kernel.org header.s=default header.b=qglhAIjR; 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 S2391422AbgAPXax (ORCPT + 99 others); Thu, 16 Jan 2020 18:30:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:37240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403886AbgAPXaZ (ORCPT ); Thu, 16 Jan 2020 18:30:25 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 71B9C2087E; Thu, 16 Jan 2020 23:30:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579217424; bh=hNUI5rCXY/JGwB+H+BOV4HGykXp69tf62roWzp9ofdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qglhAIjR9xNwyxaClz1jfrSrb/uUhuR2bLuLvpGHuYBOMGBedCVtW/4RbZf/pAksQ l+3LCsFBexYjml+SxaYQDEl4Mfsj5h/NwbUl24tAFNdd3cf5CGd0PufLU8qAJ/ybp6 MkIc8ZTtrQeOKvykmwQPvP3YLTGyAiY/KC+Behmg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Kondratiev , Paul Burton , Ralf Baechle , James Hogan , linux-mips@vger.kernel.org, Sasha Levin Subject: [PATCH 4.19 77/84] mips: cacheinfo: report shared CPU map Date: Fri, 17 Jan 2020 00:18:51 +0100 Message-Id: <20200116231722.592602605@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231713.087649517@linuxfoundation.org> References: <20200116231713.087649517@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Kondratiev [ Upstream commit 3b1313eb32c499d46dc4c3e896d19d9564c879c4 ] Report L1 caches as shared per core; L2 - per cluster. This fixes "perf" that went crazy if shared_cpu_map attribute not reported on sysfs, in form of /sys/devices/system/cpu/cpu*/cache/index*/shared_cpu_list /sys/devices/system/cpu/cpu*/cache/index*/shared_cpu_map Signed-off-by: Vladimir Kondratiev Signed-off-by: Paul Burton Cc: Ralf Baechle Cc: James Hogan Cc: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Sasha Levin --- arch/mips/kernel/cacheinfo.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/cacheinfo.c b/arch/mips/kernel/cacheinfo.c index 428ef2189203..3ea95568ece4 100644 --- a/arch/mips/kernel/cacheinfo.c +++ b/arch/mips/kernel/cacheinfo.c @@ -61,6 +61,25 @@ static int __init_cache_level(unsigned int cpu) return 0; } +static void fill_cpumask_siblings(int cpu, cpumask_t *cpu_map) +{ + int cpu1; + + for_each_possible_cpu(cpu1) + if (cpus_are_siblings(cpu, cpu1)) + cpumask_set_cpu(cpu1, cpu_map); +} + +static void fill_cpumask_cluster(int cpu, cpumask_t *cpu_map) +{ + int cpu1; + int cluster = cpu_cluster(&cpu_data[cpu]); + + for_each_possible_cpu(cpu1) + if (cpu_cluster(&cpu_data[cpu1]) == cluster) + cpumask_set_cpu(cpu1, cpu_map); +} + static int __populate_cache_leaves(unsigned int cpu) { struct cpuinfo_mips *c = ¤t_cpu_data; @@ -68,14 +87,20 @@ static int __populate_cache_leaves(unsigned int cpu) struct cacheinfo *this_leaf = this_cpu_ci->info_list; if (c->icache.waysize) { + /* L1 caches are per core */ + fill_cpumask_siblings(cpu, &this_leaf->shared_cpu_map); populate_cache(dcache, this_leaf, 1, CACHE_TYPE_DATA); + fill_cpumask_siblings(cpu, &this_leaf->shared_cpu_map); populate_cache(icache, this_leaf, 1, CACHE_TYPE_INST); } else { populate_cache(dcache, this_leaf, 1, CACHE_TYPE_UNIFIED); } - if (c->scache.waysize) + if (c->scache.waysize) { + /* L2 cache is per cluster */ + fill_cpumask_cluster(cpu, &this_leaf->shared_cpu_map); populate_cache(scache, this_leaf, 2, CACHE_TYPE_UNIFIED); + } if (c->tcache.waysize) populate_cache(tcache, this_leaf, 3, CACHE_TYPE_UNIFIED); -- 2.20.1