Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1784204ybc; Sun, 24 Nov 2019 06:10:01 -0800 (PST) X-Google-Smtp-Source: APXvYqz9XpeK5UDhdpHPMzXgA1zTwd3auFYJyMNvR5QNoEbuohJaocvCe4hl5oV1ryxbwhtCnv+Q X-Received: by 2002:a05:6402:158d:: with SMTP id c13mr12793646edv.62.1574604600916; Sun, 24 Nov 2019 06:10:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574604600; cv=none; d=google.com; s=arc-20160816; b=Q12yjZEZketqVBw9iKH/31iYYydBz+on2Dl0cL8e/YZtkWtEZ8xNamjZbNhCfXOPt7 7I9WUp5bKvAduKFTTuvfDhB4czeUdZDPjdHI+VM+KLK4NwyL9mWPKHhTiTc5p698i+nV JBxZRi0D1tqyUCkkVZ39ISdiUJyLsJjF0Tghu/Xv7PvpFXW3F05NHNSVCHWZzraQzacR 4Cx01a5CYL/uVdSisl29clP+yXEtuq/a5cZmAB1M3Et0/UjO65uKnwelD0WPOhM7ZSPK oXnYP5gMWUA7FkNfOI/Cm4f4JZPLYHIfwXGoIIYM7kZNpLBLBeqWAVJ9fnXP5uVK1a36 db8Q== 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 :message-id:date:subject:cc:to:from; bh=z4eRUewUNyD6VO/8YccBeWTDg/nuHpDsPFKBsdeEeWw=; b=vPN1mWMkflqV+OLWEZpyiEi3i84BOHoX9ndN3Q7YWVMga0pbm3V6A+SVW4Bp0sfbZk D5FXKqHUK5VS9FuB1LWgL2rorE1NXjnFh6DFVaziV8eWiH50aS7oQ2KbB+XJ8/4Hgisd JkFoHpIfRIHnuzprqWe8GKjChfgJ/+5rJHFn626hQ7gxQ2JV0d1ok8+qSDZ0qXXzSn16 SjmTlLc95OM26+twk7IBDw1rGSS5BiKbias9aXnS+9W2+x5frtKOr+1vejK6U1Cs5/dD PRtRA3IZyoKPJH3+EMzRxNbhT/R+5Y3K6jjccwQu9ZNs7WdoaxC8dfBrHTGY1w88y1mB b4cQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h49si2993259edh.2.2019.11.24.06.09.25; Sun, 24 Nov 2019 06:10:00 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727006AbfKXOHu (ORCPT + 99 others); Sun, 24 Nov 2019 09:07:50 -0500 Received: from mga04.intel.com ([192.55.52.120]:52659 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726803AbfKXOHt (ORCPT ); Sun, 24 Nov 2019 09:07:49 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Nov 2019 06:07:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,238,1571727600"; d="scan'208";a="408068358" Received: from cvg-ubt08.iil.intel.com ([143.185.152.138]) by fmsmga005.fm.intel.com with ESMTP; 24 Nov 2019 06:07:47 -0800 From: Vladimir Kondratiev To: Ralf Baechle , Paul Burton , James Hogan , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vladimir Kondratiev Subject: [PATCH] mips: cacheinfo: report shared CPU map Date: Sun, 24 Nov 2019 16:07:31 +0200 Message-Id: <20191124140731.24430-1-vladimir.kondratiev@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.