From nobody Fri Nov 22 01:14:03 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC4E31E907B for ; Mon, 18 Nov 2024 22:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970463; cv=none; b=bqTNBAiEP/dkn2fKe06rube0Bwy2AM1Msrfcr/JE+eLk4XgPmbf3fk87PIKfZx7I6V988wG4bQrU1NOjPT7cFzG0b/9UDdwbviyDesrFaSK5z4xpa/+qPDWDZw3BkJ8noqjd6kLoy+DucG/RrQSW16F2B//wVP6U0HHr4Xk91v8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970463; c=relaxed/simple; bh=HXojo0/fTP/zExJdIYj45kNltzewwVI4CI/1w1068zE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=NsBeL39l/uuE8i389PKxMOCpAvPkl6QLwYPxwVTYojYZBipP8u3Ru0nbQsZjngjK8RwbqcwrJeaVUTFGdF5G7ymERa4zz7/in5IG3HH3TzjFoCov2bVSbr6igJrLrqjbPQlo85R+bUngZGp0GuRpRP2fzlrKTXhQWVf7gZTSz/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=etIWfmx/; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="etIWfmx/" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6ee51558e90so65567767b3.1 for ; Mon, 18 Nov 2024 14:54:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731970461; x=1732575261; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=wcPgicYw7lNCwZ4lAX6Rp3LicdE0a0SwYEgY1Pd6MHA=; b=etIWfmx/7Ui/YXmuyzC2Ajhf4eUTjT+ZM1rVZBULXdnvMhQqeFnbuv2gmcYY4unqPy AoEPfloENysARJLvCwapik2LLadhNJ2uHxfnmduBOygzw1UMGNqsGEHUDPXEgRxj6TGR oTIFJlD14YVpT8a90BJ7Kg8PWVmiBTaTtKxQG/tkhItGrjWC1JN4dxTI4LzFHCcUj/52 95z+BjJWKs73HW91+zUNdTOpu5FXxqQ0vrHsFerQnbxY+xP3iI6hc19tdWYEC/p2hZO1 3yV81antg5Wh4JlvU5nTmgLrTPNCljq0Xl2tqgt/0egHsWlXbMCIo7LbICQYzjcuPdf1 zWWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731970461; x=1732575261; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wcPgicYw7lNCwZ4lAX6Rp3LicdE0a0SwYEgY1Pd6MHA=; b=gUxsDUNO06Q/doSfHuLtdGgSCivp+i9g26aJFj5r3Kevzsv6DWTg3XQtusYGgytGL7 SCk1K0t8A57MQKFcjG7rZAticZ0t9nFO9X8q1aYTJgtE1hRXvsBZUQZvQ0Dq964xq82X IfESRmw5im21qbFmJBUPtsSDNrXN3E1m5Bqg3bmwYB66WDD+M+YP8i7E1d2pUSwAaFJO vm0qtpB83sm/br7EFuDx+CYzYK7yGOLA8mIj8ntk+aCCPrcSSJAjAwXbGHNAs+haixjK 5vlvbBc91T0m8pqclCGB4fjZ16yP7bwuqs9znFh80r8xCDuWNZMcXt62fk1laE/hk8Xg vTjQ== X-Forwarded-Encrypted: i=1; AJvYcCW6tvJalYHDhv4A+/LOQH9VV+NGXc98C5mSWrAFCMWD5d0Zq20IspcrVMis1W6zzNdTyB3YByUNaXh4Z/I=@vger.kernel.org X-Gm-Message-State: AOJu0YyqA5VvvRMjzP5BUdjqv8O3vjJQc0YcHFeTQlciHJBGTKD0q7C4 J4lkEYxHBSwz/FRuh+Lw94BpE5hmC2w/J+Y6wfDUgaaxyt0+GDvx/H1IR4THcEZ7WA8UknySWtO sDl//ow== X-Google-Smtp-Source: AGHT+IGPv4JaCyn7zRXGpIzy8isHlbIcxqrVk715hTkaLLRFHcVSEMYfjdPn9FY18xv6x3jHLXZWo0bjlfhy X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:22a4:ded5:5c37:fcc7]) (user=irogers job=sendgmr) by 2002:a05:690c:6585:b0:6e2:371f:4aef with SMTP id 00721157ae682-6ee55c95c78mr1282587b3.3.1731970460841; Mon, 18 Nov 2024 14:54:20 -0800 (PST) Date: Mon, 18 Nov 2024 14:53:39 -0800 In-Reply-To: <20241118225345.889810-1-irogers@google.com> Message-Id: <20241118225345.889810-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241118225345.889810-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Subject: [PATCH v5 1/7] perf env: Ensure failure broken topology file reads are always -1 encoded From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Athira Jajeev , James Clark , Dominique Martinet , Yang Li , Colin Ian King , Yang Jihong , "Steinar H. Gunderson" , Oliver Upton , Ilkka Koskinen , Ze Gao , Weilin Wang , Ben Gainey , zhaimingbing , Zixian Cai , Andi Kleen , Paran Lee , Thomas Falcon , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, "Steven Rostedt (Google)" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" get_core_id returns 0 on success and a negative errno value on error. Currently the error can only be -1, but fixing this to be any errno value breaks perf: https://lore.kernel.org/lkml/Zzu4Sdebve-NXEMX@google.com/ To avoid this, make sure all error values are written as -1. Signed-off-by: Ian Rogers --- tools/perf/util/env.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index e2843ca2edd9..e890a52e01a6 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -326,10 +326,13 @@ int perf_env__read_cpu_topology_map(struct perf_env *= env) =20 for (idx =3D 0; idx < nr_cpus; ++idx) { struct perf_cpu cpu =3D { .cpu =3D idx }; + int core_id =3D cpu__get_core_id(cpu); + int socket_id =3D cpu__get_socket_id(cpu); + int die_id =3D cpu__get_die_id(cpu); =20 - env->cpu[idx].core_id =3D cpu__get_core_id(cpu); - env->cpu[idx].socket_id =3D cpu__get_socket_id(cpu); - env->cpu[idx].die_id =3D cpu__get_die_id(cpu); + env->cpu[idx].core_id =3D core_id >=3D 0 ? core_id : -1; + env->cpu[idx].socket_id =3D socket_id >=3D 0 ? socket_id : -1; + env->cpu[idx].die_id =3D die_id >=3D 0 ? die_id : -1; } =20 env->nr_cpus_avail =3D nr_cpus; --=20 2.47.0.338.g60cca15819-goog