From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CB65C43334 for ; Wed, 20 Jul 2022 00:43:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238246AbiGTAn0 (ORCPT ); Tue, 19 Jul 2022 20:43:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237934AbiGTAnY (ORCPT ); Tue, 19 Jul 2022 20:43:24 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D2E55A158 for ; Tue, 19 Jul 2022 17:43:23 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id v5so1166943wmj.0 for ; Tue, 19 Jul 2022 17:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QWg+c8mfSLpGnrIT5cTIiGQG7DyX5JzzwtgyUHZpsy4=; b=jqtQdn1tESs6xSio7z1YjSW/26bIfOaw5z7wHZpj+pdT81Ta/UTHGpbVlEs9Sq2zLn B2mLSmXn3C/RRz+2cbFEI9l1XjxGUTQJte4YtgctvHz61g6jkQsNu7FmBmXHF/gCFSH2 rVFK7tiNdVQo1RRKLuStKCOoADITERFNi096XBVf67ZHzqmvOkubnhMJklhmRhV4BjoM ZSv9Tvp/W7GMgxnPGazX3UUOUAZ8zOjzt71LU4Fir5X0lV/QtEJWlN24s66bHrBt2XUi tS/ZbnfrFkwAjvb6INA84ktcKviA5phfnHAHbUx7fg3D13H1QmBgknoU8WGuA2zfe89d gyhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QWg+c8mfSLpGnrIT5cTIiGQG7DyX5JzzwtgyUHZpsy4=; b=xCNDsSFMeOy4IjDjXgiryUc1Mp/t3CPuxYJQKYQIoFzN+a00hoCshexT3Ra9KBmA7q vaX6GivXpx4+Ic4MbvThy4pzOEwO0yjmP/4dD6p5V9G/tW26eMoAuEkluI2sibsbjT2z pl9HEb0Rbvb/TBVMDBKNaYYAShUT6pvbt3EGj+mZ2IBtfqMxbhtmdAtKb8QSDAJGOszp pOPdi2YzUrZ1V3nwvvbq4awId2MDtXrE5rR2dVA8K/C1yMyRmraeuMQf/R6Mi/hFPWg/ CBjBdNrgE/7burHG+I52vy3WM06YayoVaC4EBumJ0FtVlQVSMMTVK+iMEeLwfSx6RUjP posA== X-Gm-Message-State: AJIora8IX3Y2wm0IaSpBlWJIBUsvA+nbJpEnU5VaWUR4Eh1/lPc/kY29 yVoJL6t7vzEZ7VFXjsosR1nwJjGryTd31Lah08bfvA== X-Google-Smtp-Source: AGRyM1sAdelFgehnBB1OSIKPRvDpxwzFcPb5n9IG7FURM14GgRWav0ZHhwP05+SXl2PlR933ubt3y/muVSJeoxpLRXE= X-Received: by 2002:a7b:c8d3:0:b0:3a2:fe0d:ba2e with SMTP id f19-20020a7bc8d3000000b003a2fe0dba2emr1465659wml.115.1658277801389; Tue, 19 Jul 2022 17:43:21 -0700 (PDT) MIME-Version: 1.0 References: <20220711093218.10967-1-adrian.hunter@intel.com> <20220711093218.10967-18-adrian.hunter@intel.com> In-Reply-To: <20220711093218.10967-18-adrian.hunter@intel.com> From: Ian Rogers Date: Tue, 19 Jul 2022 17:43:09 -0700 Message-ID: Subject: Re: [PATCH 17/35] perf auxtrace: Add machine_pid and vcpu to auxtrace_error To: Adrian Hunter Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Andi Kleen , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 11, 2022 at 2:33 AM Adrian Hunter wrote: > > Add machine_pid and vcpu to struct perf_record_auxtrace_error. The existing > fmt member is used to identify the new format. > > The new members make it possible to easily differentiate errors from guest > machines. > > Signed-off-by: Adrian Hunter Acked-by: Ian Rogers Thanks, Ian > --- > tools/lib/perf/include/perf/event.h | 2 ++ > tools/perf/util/auxtrace.c | 30 +++++++++++++++---- > tools/perf/util/auxtrace.h | 4 +++ > .../scripting-engines/trace-event-python.c | 4 ++- > tools/perf/util/session.c | 4 +++ > 5 files changed, 37 insertions(+), 7 deletions(-) > > diff --git a/tools/lib/perf/include/perf/event.h b/tools/lib/perf/include/perf/event.h > index c2dbd3e88885..556bb06798f2 100644 > --- a/tools/lib/perf/include/perf/event.h > +++ b/tools/lib/perf/include/perf/event.h > @@ -279,6 +279,8 @@ struct perf_record_auxtrace_error { > __u64 ip; > __u64 time; > char msg[MAX_AUXTRACE_ERROR_MSG]; > + __u32 machine_pid; > + __u32 vcpu; > }; > > struct perf_record_aux { > diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c > index 511dd3caa1bc..6edab8a16de6 100644 > --- a/tools/perf/util/auxtrace.c > +++ b/tools/perf/util/auxtrace.c > @@ -1189,9 +1189,10 @@ void auxtrace_buffer__free(struct auxtrace_buffer *buffer) > free(buffer); > } > > -void auxtrace_synth_error(struct perf_record_auxtrace_error *auxtrace_error, int type, > - int code, int cpu, pid_t pid, pid_t tid, u64 ip, > - const char *msg, u64 timestamp) > +void auxtrace_synth_guest_error(struct perf_record_auxtrace_error *auxtrace_error, int type, > + int code, int cpu, pid_t pid, pid_t tid, u64 ip, > + const char *msg, u64 timestamp, > + pid_t machine_pid, int vcpu) > { > size_t size; > > @@ -1207,12 +1208,26 @@ void auxtrace_synth_error(struct perf_record_auxtrace_error *auxtrace_error, int > auxtrace_error->ip = ip; > auxtrace_error->time = timestamp; > strlcpy(auxtrace_error->msg, msg, MAX_AUXTRACE_ERROR_MSG); > - > - size = (void *)auxtrace_error->msg - (void *)auxtrace_error + > - strlen(auxtrace_error->msg) + 1; > + if (machine_pid) { > + auxtrace_error->fmt = 2; > + auxtrace_error->machine_pid = machine_pid; > + auxtrace_error->vcpu = vcpu; > + size = sizeof(*auxtrace_error); > + } else { > + size = (void *)auxtrace_error->msg - (void *)auxtrace_error + > + strlen(auxtrace_error->msg) + 1; > + } > auxtrace_error->header.size = PERF_ALIGN(size, sizeof(u64)); > } > > +void auxtrace_synth_error(struct perf_record_auxtrace_error *auxtrace_error, int type, > + int code, int cpu, pid_t pid, pid_t tid, u64 ip, > + const char *msg, u64 timestamp) > +{ > + auxtrace_synth_guest_error(auxtrace_error, type, code, cpu, pid, tid, > + ip, msg, timestamp, 0, -1); > +} > + > int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, > struct perf_tool *tool, > struct perf_session *session, > @@ -1662,6 +1677,9 @@ size_t perf_event__fprintf_auxtrace_error(union perf_event *event, FILE *fp) > if (!e->fmt) > msg = (const char *)&e->time; > > + if (e->fmt >= 2 && e->machine_pid) > + ret += fprintf(fp, " machine_pid %d vcpu %d", e->machine_pid, e->vcpu); > + > ret += fprintf(fp, " cpu %d pid %d tid %d ip %#"PRI_lx64" code %u: %s\n", > e->cpu, e->pid, e->tid, e->ip, e->code, msg); > return ret; > diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h > index cd0d25c2751c..6a4fbfd34c6b 100644 > --- a/tools/perf/util/auxtrace.h > +++ b/tools/perf/util/auxtrace.h > @@ -595,6 +595,10 @@ int auxtrace_index__process(int fd, u64 size, struct perf_session *session, > bool needs_swap); > void auxtrace_index__free(struct list_head *head); > > +void auxtrace_synth_guest_error(struct perf_record_auxtrace_error *auxtrace_error, int type, > + int code, int cpu, pid_t pid, pid_t tid, u64 ip, > + const char *msg, u64 timestamp, > + pid_t machine_pid, int vcpu); > void auxtrace_synth_error(struct perf_record_auxtrace_error *auxtrace_error, int type, > int code, int cpu, pid_t pid, pid_t tid, u64 ip, > const char *msg, u64 timestamp); > diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c > index adba01b7d9dd..3367c5479199 100644 > --- a/tools/perf/util/scripting-engines/trace-event-python.c > +++ b/tools/perf/util/scripting-engines/trace-event-python.c > @@ -1559,7 +1559,7 @@ static void python_process_auxtrace_error(struct perf_session *session __maybe_u > msg = (const char *)&e->time; > } > > - t = tuple_new(9); > + t = tuple_new(11); > > tuple_set_u32(t, 0, e->type); > tuple_set_u32(t, 1, e->code); > @@ -1570,6 +1570,8 @@ static void python_process_auxtrace_error(struct perf_session *session __maybe_u > tuple_set_u64(t, 6, tm); > tuple_set_string(t, 7, msg); > tuple_set_u32(t, 8, cpumode); > + tuple_set_s32(t, 9, e->machine_pid); > + tuple_set_s32(t, 10, e->vcpu); > > call_object(handler, t, handler_name); > > diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c > index f3e9fa557bc9..7ea0b91013ea 100644 > --- a/tools/perf/util/session.c > +++ b/tools/perf/util/session.c > @@ -895,6 +895,10 @@ static void perf_event__auxtrace_error_swap(union perf_event *event, > event->auxtrace_error.ip = bswap_64(event->auxtrace_error.ip); > if (event->auxtrace_error.fmt) > event->auxtrace_error.time = bswap_64(event->auxtrace_error.time); > + if (event->auxtrace_error.fmt >= 2) { > + event->auxtrace_error.machine_pid = bswap_32(event->auxtrace_error.machine_pid); > + event->auxtrace_error.vcpu = bswap_32(event->auxtrace_error.vcpu); > + } > } > > static void perf_event__thread_map_swap(union perf_event *event, > -- > 2.25.1 >