From patchwork Sat Mar 11 00:06:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 67876 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp43021wrd; Fri, 10 Mar 2023 16:23:15 -0800 (PST) X-Google-Smtp-Source: AK7set+euFp2wdJPcenEFj7dYjnCMvjJDN6YsCOlxwrtfa/sHnNJTp5NUzJdo4SiclqOken/YzAP X-Received: by 2002:a17:902:d54f:b0:19e:73a9:c21b with SMTP id z15-20020a170902d54f00b0019e73a9c21bmr25715114plf.45.1678494194962; Fri, 10 Mar 2023 16:23:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678494194; cv=none; d=google.com; s=arc-20160816; b=ZjJ8d0SprvtwWVQmCTlFk7VgR0JQg/l6XAohEAUHNTR/VJ+i0lArXkUekz/tD26CW7 1TNqeiEfdneZTfKUR/FpmYaa1sx6v1mABUn/XOiqq7N+HrWADnz9vPFN3cCCL3UK0c/h h8CKPkOmW4t1/aWVVfweoqkPM6yRBNRTJ7GLw8LJJKFmdEcHDSXH9h0qQqjwf2h06tZ3 fLVFWzyDqTIflF3XYdHDqGqczcf8A4wavfGJW/CN+Fnf5nPX1KXP6ySPOK0Ph9mqFgwS xNwwHLUDgQOlvZ7xgmISGz0AsjqhviTJw5xrUvpmeRbX8dMyJ80anpaNWjcY3OKPv0ze PBNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=B7QL62ne7xspG8r+3tPhE63tmfSAaS1hXK7nOe5vD3E=; b=zphLEgioeHMHr+7w/lpV++EMhANi3YvIX7E61fM9eNzCm13grl3nbe4OkWeoXtau5W 2XvKJX1lzDF7UTkBWPmrmeYHkQ4CaBokhQFXkReZcyFNuzRVgNgPvXSFZ5DxwwRh/okd SWsYa7dswzUqHcqlDQEx5itDc+qmUwLWB0klysbDrm1fV5YX3PhqNhxReRh/sRbh6++B gXN1nWUXtJW6GaJBEzJ8nQFs6LMfbigOUofX+Ec0ZhExSUA9teKVnXH5iCJQT4Ri4APB DmCdz5TwyEyGyTKbRcDyxVLCYEYwgEMgi/mW0qh0UxA1VeNSeu+TIIgu3IfqU0h+2BQ+ rVzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=n0xTQPTe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 2-20020a170902c10200b0019e3728f17csi1114977pli.209.2023.03.10.16.23.02; Fri, 10 Mar 2023 16:23:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=n0xTQPTe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230001AbjCKAHG (ORCPT + 99 others); Fri, 10 Mar 2023 19:07:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbjCKAGx (ORCPT ); Fri, 10 Mar 2023 19:06:53 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE5A413E51C for ; Fri, 10 Mar 2023 16:06:45 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id x34so6888042pjj.0 for ; Fri, 10 Mar 2023 16:06:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678493205; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=B7QL62ne7xspG8r+3tPhE63tmfSAaS1hXK7nOe5vD3E=; b=n0xTQPTe8pqES0vIKyOOdIgJuU1v7f0nTP9ox96dIsL9yxnzB2O70ZPtacZWQ7IvPr WERUt3uCAASQqVKnw0sfH64d3t4TqNkRfzuygF0x3qCS3TVio43ikRYPe8fxyUmKsREy gx0s3H7eAsiCnYGcQyGu3NeDRf+XHkSxJ87YRY13NJQPj3sP1O4WpCI5DkVaLwliYu/a k3DBlAmiDKEt//asGCq4O4rTHvckP7cpMTverCNh7PPpZHZNbPhxkXesbzdvYvYo4DrB bT9DA0eOhxdv02KsKnFwFejZLiDphFQf0kH405GQb6pqjCrFOVVYJABr+6etgqUKbSi2 YlYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678493205; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=B7QL62ne7xspG8r+3tPhE63tmfSAaS1hXK7nOe5vD3E=; b=sMoCNi6uDtIZVow5Z02bwURgc4WU2AcVxPr2BbBxhGy01DQvraDV8j2V/keZxTtRgj klmFSCqEpsNQVvbwPOp6OzbkvAXySfWmO8SGrvUjjO0441lsTgEN05n2UwOEXgd5slTz FXBeKXDJyh35afmZLUqRaQ5V5DDU7eU/xRwC3Xc0ABQgi8oJHieWKCvDJFlD8T/8Fm4Q huYTZyVsL+eug+qxCFdh9DIb9FCKBXaCEoxhJ8bpSetQY6y3wmhiceBvw/p6YIkK2NQr 0+zcFqmUOCCmLVDFQ5JR0ji05nVorXkngsWOLLQSOdU5BLkpoaAMcIs6RD+eMnM8xreN un+g== X-Gm-Message-State: AO0yUKWjp01/YpqCU88+1W7uDpPeEr4dGnblxGnKFuUiobsHLsYkXTSN l1Py8Xw24dCTVSAa5ZJzov4= X-Received: by 2002:a17:902:f54c:b0:19c:a9b8:4349 with SMTP id h12-20020a170902f54c00b0019ca9b84349mr32754383plf.32.1678493205162; Fri, 10 Mar 2023 16:06:45 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:44b0:e32f:ca65:5413:8ef7]) by smtp.gmail.com with ESMTPSA id lk15-20020a17090308cf00b0019b0937003esm505421plb.150.2023.03.10.16.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 16:06:44 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra , Ingo Molnar Cc: Ravi Bangoria , Arnaldo Carvalho de Melo , Stephane Eranian , Kan Liang , LKML Subject: [PATCH] perf/x86/ibs: Set data_src.mem_lvl_num as well Date: Fri, 10 Mar 2023 16:06:42 -0800 Message-Id: <20230311000642.1270971-1-namhyung@kernel.org> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760028728904071660?= X-GMAIL-MSGID: =?utf-8?q?1760028728904071660?= The IBS PMU driver sets data source of memory operations but it missed mem_lvl_num field. So I'm adding them here. Most cases are straight-forward but please check if MEM_LVLNUM_ANY_CACHE for peer cache hits is ok. Also I wonder we can add MEM_REMOTE_REMOTE for peer cache hits in a far CCX. Signed-off-by: Namhyung Kim --- arch/x86/events/amd/ibs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index 64582954b5f6..819869fc2dc7 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -724,6 +724,7 @@ static void perf_ibs_get_mem_lvl(union ibs_op_data2 *op_data2, /* L1 Hit */ if (op_data3->dc_miss == 0) { data_src->mem_lvl = PERF_MEM_LVL_L1 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_L1; return; } @@ -733,6 +734,7 @@ static void perf_ibs_get_mem_lvl(union ibs_op_data2 *op_data2, if (boot_cpu_data.x86 != 0x19 || boot_cpu_data.x86_model > 0xF || !(op_data3->sw_pf || op_data3->dc_miss_no_mab_alloc)) { data_src->mem_lvl = PERF_MEM_LVL_L2 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_L2; return; } } @@ -748,12 +750,14 @@ static void perf_ibs_get_mem_lvl(union ibs_op_data2 *op_data2, if (ibs_caps & IBS_CAPS_ZEN4) { if (ibs_data_src == IBS_DATA_SRC_EXT_LOC_CACHE) { data_src->mem_lvl = PERF_MEM_LVL_L3 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_L3; return; } } else { if (ibs_data_src == IBS_DATA_SRC_LOC_CACHE) { data_src->mem_lvl = PERF_MEM_LVL_L3 | PERF_MEM_LVL_REM_CCE1 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_L3; return; } } @@ -762,6 +766,7 @@ static void perf_ibs_get_mem_lvl(union ibs_op_data2 *op_data2, if (ibs_caps & IBS_CAPS_ZEN4 && ibs_data_src == IBS_DATA_SRC_EXT_NEAR_CCX_CACHE) { data_src->mem_lvl = PERF_MEM_LVL_REM_CCE1 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_ANY_CACHE; return; } @@ -769,11 +774,13 @@ static void perf_ibs_get_mem_lvl(union ibs_op_data2 *op_data2, if (ibs_caps & IBS_CAPS_ZEN4) { if (ibs_data_src == IBS_DATA_SRC_EXT_FAR_CCX_CACHE) { data_src->mem_lvl = PERF_MEM_LVL_REM_CCE2 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_ANY_CACHE; return; } } else { if (ibs_data_src == IBS_DATA_SRC_REM_CACHE) { data_src->mem_lvl = PERF_MEM_LVL_REM_CCE2 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_ANY_CACHE; return; } } @@ -784,6 +791,7 @@ static void perf_ibs_get_mem_lvl(union ibs_op_data2 *op_data2, data_src->mem_lvl = PERF_MEM_LVL_LOC_RAM | PERF_MEM_LVL_HIT; else data_src->mem_lvl = PERF_MEM_LVL_REM_RAM1 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_RAM; return; } @@ -832,10 +840,12 @@ static void perf_ibs_get_mem_lvl(union ibs_op_data2 *op_data2, */ if (op_data3->dc_miss_no_mab_alloc) { data_src->mem_lvl = PERF_MEM_LVL_LFB | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_LFB; return; } data_src->mem_lvl = PERF_MEM_LVL_NA; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_NA; } static bool perf_ibs_cache_hit_st_valid(void)