Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3819046ybi; Mon, 29 Jul 2019 13:14:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+ixggbg2wlunMYBXBQqWcuNxPk+f/5m0NTN2ml7oXoNc4/SeQDYNCgAyfH339Iv90DJod X-Received: by 2002:aa7:8641:: with SMTP id a1mr38516193pfo.177.1564431262909; Mon, 29 Jul 2019 13:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431262; cv=none; d=google.com; s=arc-20160816; b=rhytQQ9tFREdNvh41TUAFMbHcEIcHH6Saj7a41DQE0MCPTyDFay2xP63XorjWhBKLA ek5bERn6sN5hvFXMdyeZux4KWRwEPmADCinT0tXWxoYdO/5iXvSVNXF11PZntYvlN4Dp UQ67sJennGjEGzxyZ8BVoc8Qdb8QFZ2lqJtgpN7xQdjS1ix10MwiBVdyVEbHC1aLvo3U YigzfUw8qQBP6d5n/J2++m06oNZyknHDOU/Jbpeos0eNwCO+Qq3KTlrPHZ1Ue58GIPCn 44Ly1kuoXNj25eHSYkjHBI/8zn+JsIOmFzBP8g35xVZGyUkFp3sf+LydOzqFIr8t+iE2 cB/g== 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=LZFNBVH8KbTd1eBDyfPVXKxBqHYL+jY9UMtgzi8jsGI=; b=SDntiL033fV9re2C1rWZ7Hmq77xxRCmUgHGn447M2QTpn46kc9fJUPvqtFTKYSALeD zvvq0nRh8AX2QJRQTYdlj7wo+adwJc6EQce45LJYWBbFv+Bb68X9gwS2yx14M9lYHbbz 94rbPmx9C2jfSc09nx2MTE6YhPRa+qwIxTHodG5Hqbp6OSJOeRBslOF3bVLRRrMZCRUA 0w33ZJhhE9It2ctqamqTMaCuTb9JUVtKoF0NBoVCa+ang0RXGjsy02u6FLEUIC54RRqK l167FH68yVIJblXiCk2z2jVYlVHEpuLDWVlPQ5qUatq1tpqc4HKzjJ4li+k+4KoxuKGa sL+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="GPw/LHcP"; 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 c25si28969818pgm.73.2019.07.29.13.14.08; Mon, 29 Jul 2019 13:14:22 -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=@kernel.org header.s=default header.b="GPw/LHcP"; 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 S1730152AbfG2TbY (ORCPT + 99 others); Mon, 29 Jul 2019 15:31:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:44200 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbfG2TbX (ORCPT ); Mon, 29 Jul 2019 15:31:23 -0400 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 D0D4F217D7; Mon, 29 Jul 2019 19:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428682; bh=l812z+GzbP3jprn8JXbAjwaxXbwOpuC4ieMSHNfzk00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GPw/LHcP1HnqyKdQHLMQq0GXJonlcI3z9xPk5uNZ1r2RZ4A6/y44t3I1EFtUyUsCE vM/JSeDcm8LPrtZxvKZVQUJEyGSy6LSuJSjHIiMUrWKM/hs4qfz/untN9Gn4247OCq JjlrfSLRw4wVKKBW+N9x1g8XYeIEixjQvVWXleRQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kim Phillips , "Peter Zijlstra (Intel)" , Alexander Shishkin , Arnaldo Carvalho de Melo , Borislav Petkov , Gary Hook , "H. Peter Anvin" , Janakarajan Natarajan , Jiri Olsa , Linus Torvalds , Martin Liska , Namhyung Kim , Pu Wen , Stephane Eranian , Suravee Suthikulpanit , Thomas Gleixner , Vince Weaver , Ingo Molnar Subject: [PATCH 4.14 154/293] perf/x86/amd/uncore: Set the thread mask for F17h L3 PMCs Date: Mon, 29 Jul 2019 21:20:45 +0200 Message-Id: <20190729190836.373562399@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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: Kim Phillips commit 2f217d58a8a086d3399fecce39fb358848e799c4 upstream. Fill in the L3 performance event select register ThreadMask bitfield, to enable per hardware thread accounting. Signed-off-by: Kim Phillips Signed-off-by: Peter Zijlstra (Intel) Cc: Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Borislav Petkov Cc: Gary Hook Cc: H. Peter Anvin Cc: Janakarajan Natarajan Cc: Jiri Olsa Cc: Linus Torvalds Cc: Martin Liska Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Pu Wen Cc: Stephane Eranian Cc: Suravee Suthikulpanit Cc: Thomas Gleixner Cc: Vince Weaver Link: https://lkml.kernel.org/r/20190628215906.4276-2-kim.phillips@amd.com Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/events/amd/uncore.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c @@ -209,15 +209,22 @@ static int amd_uncore_event_init(struct hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB; hwc->idx = -1; + if (event->cpu < 0) + return -EINVAL; + /* * SliceMask and ThreadMask need to be set for certain L3 events in * Family 17h. For other events, the two fields do not affect the count. */ - if (l3_mask && is_llc_event(event)) - hwc->config |= (AMD64_L3_SLICE_MASK | AMD64_L3_THREAD_MASK); + if (l3_mask && is_llc_event(event)) { + int thread = 2 * (cpu_data(event->cpu).cpu_core_id % 4); - if (event->cpu < 0) - return -EINVAL; + if (smp_num_siblings > 1) + thread += cpu_data(event->cpu).apicid & 1; + + hwc->config |= (1ULL << (AMD64_L3_THREAD_SHIFT + thread) & + AMD64_L3_THREAD_MASK) | AMD64_L3_SLICE_MASK; + } uncore = event_to_amd_uncore(event); if (!uncore)