Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8557917ybl; Thu, 16 Jan 2020 19:33:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxFppxrg8YD2MMEe0rMY+5UFsWxUuWhiLIHHj2NXZQ8AXx/l+kfVUf/Tp1BWOVEEMd1BVZb X-Received: by 2002:aca:b286:: with SMTP id b128mr1960972oif.147.1579231991861; Thu, 16 Jan 2020 19:33:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579231991; cv=none; d=google.com; s=arc-20160816; b=fOXWortqhcRNxk0YLDUBvcx5F/L9wA+xZhCJVfNkvzHjcHVd1Uuidp+wJ32Qj+mgmQ yaUobuMFSygWtVxJKHkiBEdEGAmsgeH2eoMB0eqW3WfMeQtkfZZXVNALG7bi7Z5/Bu8O 7BAZNyKKtlcjLRofQQwqkEL7gIjcSsQLGwQNurHQYUEm2U4rpCHiJ7HkTQlFHQzaQZyj AZVSu1aKkZXuPjyV0psLnYlFBXRBP0RHkX3pDhuIjzC+4j6BvFXmYOv8S9nBTLnRNnxD lmMjZTyEjbF5YX+IMGmJoYBcRwA3gsOnlfv5NSAJz4s+57h9tIlgXBLKucNt4BBFbaSi vxjQ== 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=xx6evfRu7fWY93Z7c81aiyRGk/ndRym6W+uUB4d3Vlk=; b=hPEruOZ6Kry61CIf5mrmv+t4uql81OvEksUatuuMxTKJhXQNcysBbdnI0HgjKfLhsl +tznFC5dIjdGMM6bWZeVZ/sqElAiTJEJScDq/+JIjhCsmBCsXLv9xsW/NriisX7pabXE D7Av4mX64Nu1Z3xFuWLngNIBkGXbbluEcWBhWDfvePihOb0OLKxDIxBuPybZkAgY22H4 g2Ebb2v+kNvbGidT1roEt2CfWhweV0rM03U7IjRjKLhdGGSrK+YNaLB5GPR5ZGCtwIOl tfvAI0kBhUxw12VcdA/679zpZXv/H3xnvDFb/pIOG/RCujghFcmAszGoA5u2sw1H02E0 R6Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E6dG6kMP; 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 k1si12858500oic.245.2020.01.16.19.33.00; Thu, 16 Jan 2020 19:33:11 -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=E6dG6kMP; 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 S2391858AbgAPXlZ (ORCPT + 99 others); Thu, 16 Jan 2020 18:41:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:59002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388327AbgAPX1V (ORCPT ); Thu, 16 Jan 2020 18:27:21 -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 3C32B2072E; Thu, 16 Jan 2020 23:27:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579217240; bh=Jas9M4NC9WttapCSqzQTQUihydt2rWA4eNC4cFlbr/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E6dG6kMPEferV7By1oYWzHYBKqkqpknzGd0KlmkVzqgK0Ir0BcaGS6lh1BNngwYdI cSUFFW+J4XkgHCjmAb8wdq5UpmVBPKdNMdwCq59yTOE2+xztyZi2H3wq+6fkH+s/IY IKCfk0Hb9cE9O7zo0eW5VMC+ZprYbqcSo8zpnHgk= 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 5.4 187/203] mips: cacheinfo: report shared CPU map Date: Fri, 17 Jan 2020 00:18:24 +0100 Message-Id: <20200116231800.650807790@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231745.218684830@linuxfoundation.org> References: <20200116231745.218684830@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 f777e44653d5..47312c529410 100644 --- a/arch/mips/kernel/cacheinfo.c +++ b/arch/mips/kernel/cacheinfo.c @@ -50,6 +50,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; @@ -57,14 +76,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