Received: by 2002:a05:7208:31d3:b0:81:e143:7c29 with SMTP id v19csp432199rbd; Fri, 5 Apr 2024 08:41:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXSbY4Q95EmsofRCKm9t1X3YK3R59SCw8Nh7lGpnD+411lSDoQqymc6dqCDky2y/jcajWia/BIdLfs3k2MpYzwCuMSHcNcjSNG1mB9lMw== X-Google-Smtp-Source: AGHT+IEhI+HtH1T+hEk+M3U2k04BxVOcW2F9etn7Y98lJNrPqnthHn10JaHXQhwp3ImVSQppZZbS X-Received: by 2002:a05:6e02:156f:b0:366:a7e1:7677 with SMTP id k15-20020a056e02156f00b00366a7e17677mr2147699ilu.3.1712331681668; Fri, 05 Apr 2024 08:41:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712331681; cv=pass; d=google.com; s=arc-20160816; b=maHGXL5YR2+JVdYWRvRWoccARmRj3HAnfkyNkzxuzHdHE4KxOKUHull0v9UTDM36Oj 86c86YR2bWZa7cWnqn7rerArPuwOunrDOen9cJMw5Gjozz8ogc4Y8bWJM4WrDnCpSNHf SRwHwIZLd1z0F+TmQnVuXGDa2euIHR5HFBxAQIOZTNOQOJMHT/LcDMloTUwDCQsQmLeK wRNehGHIpUllHtt/tm37Rn3tOV6CLk4Iz5Bv3/oI6N1elK1h53MaAfqPXeOveI85m1fl qlqpCfIERCHQR+D/1W3BQ8xPAKWeN4ew33LOx4YfmlGO4sjeeFC7Th195ov5botuMuTA LlCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=v6OoXn0uQxIGlkf2RfKosXfhsgFAiem9fpmNkOS6flg=; fh=84+uPXW37fyXmSL2SdIr4iZLpCd3sksj/Rcgwi2erBg=; b=sxmatDJQRv3k6aTuDuWRioXCM7L8btW0qH2rExZUVeOeI8LjHb1lQF3qQrtzRJfBDz 22SrQ6mD+/9IIkQUo6WQROo6EGy0sgsp3k+dhu6M9VYIK4mBadkvn0/j993SaN5LxrFG xrDoIb/uAgEFUEImVPLh+pjDp1/o3MVL8UJP/mEpRQVQtr3Xg1CMsja/RgBnVNJnv5Yx EcgkImWn3Mi/r+L/9Xhh90nuNsel7GGoimDWpZuX/z1FDCPQdUC/BjvuGQLbNxVKqv5M Hy62ze9oa3IlKQlPXM5qHi2yNYazCsLS6d6vPFy4jWVm20n5IJI4wDJ0ITLN707F/dXt KGjA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Jd4JG8EP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-133164-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133164-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 32-20020a631660000000b005dcc035ca8fsi1568005pgw.561.2024.04.05.08.41.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 08:41:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133164-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Jd4JG8EP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-133164-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133164-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D72E4B2381E for ; Fri, 5 Apr 2024 14:32:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24A1216F831; Fri, 5 Apr 2024 14:31:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Jd4JG8EP" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1B2A16F28F; Fri, 5 Apr 2024 14:31:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712327496; cv=none; b=N86aw0/juGhyg26ouclOvLjH3MnRNg4APYoGApwcGzgDFWtqkOanH7zj+OBG2NBmWg+IrJ9sm9+XFD4wukX6BaahCzrBEDISBbHaJT142jsVP8XPMGcOBrogSVKcSGTkRCGVz0vxBse+6FFM6BwY1C8nwa4DKGWZuuzfTpHjvzY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712327496; c=relaxed/simple; bh=REmT479AFnCCcCTlpWSmaYrzgIUHjpteGLS0bjBDaMI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=ZCMgA97hPphSTyKl1o13HGtbRYZJbWACpr+zo2XblBoc82H5/AEPeve1dyOuNCckWXW5pD5b+BVll3xeXiFseYSMqrSZyh4nHkjJOydZvPgqSBhCuqAu7LuptoOmp0qJj9FNAUdii6Msh2yypn9Aurl26Im1wfdBmCkMGuarbpA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Jd4JG8EP; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712327495; x=1743863495; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=REmT479AFnCCcCTlpWSmaYrzgIUHjpteGLS0bjBDaMI=; b=Jd4JG8EP7YHUnLe55tF3hAayLQoqofxADkK7DXC0/9T5TVO2gUtn0iuR 1q9hAwqY8IXxJwVYewf1fmrNsOnvtlHYqHp4rtJr1zJoTGERjAV23hcHk /Ry/R6cfUY/jf762CEoXxM7K47LoPS1gC0NJgMLRA0uH9mF9g2jU3neii KO8FuNEF+1Xxdv4d7yuBLFO6nc+EZGTWFQicRZD3MOj4GP/f5s0kSVhdl x+6asxAuaNMtDMp+dB6caBut/ASwfjCn+NFjO6UWCK38LsSquJNOM2Y1A vOdvV7qRin92XsOpFpAhZSp6cj2RiH/DghAph3J+AydA7pbGTSQOcJywo w==; X-CSE-ConnectionGUID: xZLblvNlRxGeB8zdggtnjA== X-CSE-MsgGUID: RSnP59z6RhC4szRvjBiuKQ== X-IronPort-AV: E=McAfee;i="6600,9927,11035"; a="11476450" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="11476450" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 07:31:34 -0700 X-CSE-ConnectionGUID: hG8APWZARMy+KffIgepD6w== X-CSE-MsgGUID: 7Z8NtXy/R1S6q3/uPejMug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="23817555" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmviesa004.fm.intel.com with ESMTP; 05 Apr 2024 07:31:33 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org Cc: Kan Liang , "Bayduraev, Alexey V" , stable@vger.kernel.org Subject: [PATCH] perf/x86/intel/ds: Fix non 0 retire latency on Raptorlake Date: Fri, 5 Apr 2024 07:30:32 -0700 Message-Id: <20240405143032.1243201-1-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Kan Liang A non-0 retire latency can be observed on a Raptorlake which doesn't support the retire latency feature. By design, the retire latency shares the PERF_SAMPLE_WEIGHT_STRUCT sample type with other types of latency. That could avoid adding too many different sample types to support all kinds of latency. For the machine which doesn't support some kind of latency, 0 should be returned. Perf doesn’t clear/init all the fields of a sample data for the sake of performance. It expects the later perf_{prepare,output}_sample() to update the uninitialized field. However, the current implementation doesn't touch the field of the retire latency if the feature is not supported. The memory garbage is dumped into the perf data. Clear the retire latency if the feature is not supported. Fixes: c87a31093c70 ("perf/x86: Support Retire Latency") Reported-by: "Bayduraev, Alexey V" Tested-by: "Bayduraev, Alexey V" Signed-off-by: Kan Liang Cc: stable@vger.kernel.org --- arch/x86/events/intel/ds.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index f95cca6b632a..838f3e23bce9 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -1989,8 +1989,12 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event, set_linear_ip(regs, basic->ip); regs->flags = PERF_EFLAGS_EXACT; - if ((sample_type & PERF_SAMPLE_WEIGHT_STRUCT) && (x86_pmu.flags & PMU_FL_RETIRE_LATENCY)) - data->weight.var3_w = format_size >> PEBS_RETIRE_LATENCY_OFFSET & PEBS_LATENCY_MASK; + if (sample_type & PERF_SAMPLE_WEIGHT_STRUCT) { + if (x86_pmu.flags & PMU_FL_RETIRE_LATENCY) + data->weight.var3_w = format_size >> PEBS_RETIRE_LATENCY_OFFSET & PEBS_LATENCY_MASK; + else + data->weight.var3_w = 0; + } /* * The record for MEMINFO is in front of GP -- 2.35.1