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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0303C433EF for ; Tue, 26 Apr 2022 13:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W0KNX3nirSpBssc+rXZdB8e7oXdZYXqDdc24RMf64NE=; b=iHIczmTVoOSllr o26EiQDb7czdxHuVsMjobauo/L9GbU4sRTJtY3A8HD/YJJc0DTJVba/qr/ENd5UrYOZN1JHYDZWEy gaY/MXfEa6yk1f988fGqfkIPCJXE2pR5vAWlA6KlQFFI6dmoytjcK0Ut1tKB0qPq53iNWhHkS24I/ hcsUarI7WbZysawRyW+gS+kV8ivDkhxVtfHGENp41SqokUILAYIWwYmX68/p+jNKK3slwzIJXh9Ks U1m4rFTKJQgg+7GNdwn+Y1lLKWF2cT6Cj4ehHijzVvnyL8EPvUVFoL+LM15QQzUw4mUM6HH5NpThF TYFKMvl7oaB6Am9LDweQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1njL6u-00EXVA-HE; Tue, 26 Apr 2022 13:20:08 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1njL6q-00EXTN-RJ for linux-arm-kernel@lists.infradead.org; Tue, 26 Apr 2022 13:20:06 +0000 Received: by mail-pf1-x42e.google.com with SMTP id z16so17942165pfh.3 for ; Tue, 26 Apr 2022 06:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=HLmgdCeRQnlZPI0jqFO8y9T2xXc5m6qGLiOpaSM2FSM=; b=jPCQfFTpQpV7n7pB7rQDJt9sEnkgB4WREXGbL8Dv7b1F2XbxwlGG9CjunEgd52tZNh f7b7jRWcHwxnBXWkjhTIo5RsaLGht6e7tCbque3ut0TGd+K/JWFdBL3RoZ66gTg6AWOr tt/4wyon5tX9Fj2AvW12rYJSMG5VjtoOlW++QPT8nwJk7gFXCOX3SrHat2epwpEjI8ww AFCQ8Rn77o0zNND5MQZv31aCz2DUeV3FK9hPagKRgqmRKXpwU/XnLSgFUbHZhkfSHEkJ o1Ok5lmOEVM5/v+cSqBQdoCuC+HiqBJ64GblVLjeciEYYmiEZfTWUZcMQfwIiTVE6i/p J72w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HLmgdCeRQnlZPI0jqFO8y9T2xXc5m6qGLiOpaSM2FSM=; b=KgDQAxkONjZzat2BdfER2vFg79Gb2rS8OjbhlS7mynbUXZX7UhAZ8F3AqAnXFv8svV mMOsMZm5p9UBug34uRxLl6s8JWtVirmJwOFb06pCcJKGO8ayUog982VKKZI1GirHBk/0 NS4HBENXyKPWgtVkxkvtdxkqogfAxN4hxg+rIAl0Pu5JfzOwKyNjEQK2cZg71Bh2xtKl Q3SeuFplHacvSnVOXJjU7+5xmLJ2b652eRP6GiHaC3dxFl6dZDpONaN7++VNLTfyxb/Q QQxSKAexUg+KAtByu4ODNd1RV8p3kK9qyc+O7FpF4N+BkaMar3lqh+WWrfXX7VW/IzHJ xwfQ== X-Gm-Message-State: AOAM5338t1GQk2xopdesAi+E2+G0LppWkQ3F44HRC1vQ+nnbvLoDC9t9 WhTeVldqnVLamu1G96xWgWhEjQ== X-Google-Smtp-Source: ABdhPJywU6zSNw8eC6iZB0lW4cMNYVRUgoT39LY8hW7zbfiZnYq6dVsSlFGb05d66NZD5nCNmqfhWQ== X-Received: by 2002:a63:86c8:0:b0:3aa:fa50:b002 with SMTP id x191-20020a6386c8000000b003aafa50b002mr13427236pgd.570.1650979199932; Tue, 26 Apr 2022 06:19:59 -0700 (PDT) Received: from leoy-ThinkPad-X240s (216.24.179.102.16clouds.com. [216.24.179.102]) by smtp.gmail.com with ESMTPSA id x22-20020a17090aa39600b001d95c09f877sm3120923pjp.35.2022.04.26.06.19.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 06:19:59 -0700 (PDT) Date: Tue, 26 Apr 2022 21:19:52 +0800 From: Leo Yan To: James Clark Cc: Timothy Hayes , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org, John Garry , Will Deacon , Mathieu Poirier , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH 2/3] perf: arm-spe: Fix SPE events with phys addresses Message-ID: <20220426131952.GA1923836@leoy-ThinkPad-X240s> References: <20220421165205.117662-1-timothy.hayes@arm.com> <20220421165205.117662-3-timothy.hayes@arm.com> <20220424125951.GD978927@leoy-ThinkPad-X240s> <322009d2-330c-22d4-4075-eca2042f64e1@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <322009d2-330c-22d4-4075-eca2042f64e1@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220426_062004_997935_64A788E8 X-CRM114-Status: GOOD ( 30.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Apr 25, 2022 at 10:12:36AM +0100, James Clark wrote: [...] > >> diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c > >> index 151cc38a171c..1a80151baed9 100644 > >> --- a/tools/perf/util/arm-spe.c > >> +++ b/tools/perf/util/arm-spe.c > >> @@ -1033,7 +1033,8 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) > >> memset(&attr, 0, sizeof(struct perf_event_attr)); > >> attr.size = sizeof(struct perf_event_attr); > >> attr.type = PERF_TYPE_HARDWARE; > >> - attr.sample_type = evsel->core.attr.sample_type & PERF_SAMPLE_MASK; > >> + attr.sample_type = evsel->core.attr.sample_type & > >> + (PERF_SAMPLE_MASK | PERF_SAMPLE_PHYS_ADDR); > > > > I verified this patch and I can confirm the physical address can be > > dumped successfully. > > > > I have a more general question, seems to me, we need to change the > > macro PERF_SAMPLE_MASK in the file util/event.h as below, so > > here doesn't need to 'or' the flag PERF_SAMPLE_PHYS_ADDR anymore. > > > > @Arnaldo, @Jiri, could you confirm if this is the right way to move > > forward? I am not sure why PERF_SAMPLE_MASK doesn't contain the bit > > PERF_SAMPLE_PHYS_ADDR in current code. > > I think there is a reason that PERF_SAMPLE_MASK is a subset of all the > bits. This comment below suggests it. Is it so the mask only includes fields > that are 64bits? That makes the __evsel__sample_size() function a simple > multiplication of a count of all the fields that are 64bits. After reading code, seems the conclusion "a count of all the fields that are 64bits" is not valid. PERF_SAMPLE_MASK contains bits PERF_SAMPLE_IP and PERF_SAMPLE_TID, the corresponding fields 'pid' and 'tid' in the structure perf_sample are u32 type. > static int > perf_event__check_size(union perf_event *event, unsigned int sample_size) > { > /* > * The evsel's sample_size is based on PERF_SAMPLE_MASK which includes > * up to PERF_SAMPLE_PERIOD. After that overflow() must be used to > * check the format does not go past the end of the event. > */ > if (sample_size + sizeof(event->header) > event->header.size) > return -EFAULT; Okay, thanks for sharing the info, it does show that it's deliberately to not contain all fields in PERF_SAMPLE_MASK. If so, this patch is fine for me: Reviewed-by: Leo Yan > return 0; > } > > Having said that, the mask was updated once to add PERF_SAMPLE_IDENTIFIER to > it, so that comment is slightly out of date now. > > > > > > diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h > > index cdd72e05fd28..c905ac32ebad 100644 > > --- a/tools/perf/util/event.h > > +++ b/tools/perf/util/event.h > > @@ -39,7 +39,7 @@ struct perf_event_attr; > > PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \ > > PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID | \ > > PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD | \ > > - PERF_SAMPLE_IDENTIFIER) > > + PERF_SAMPLE_IDENTIFIER | PERF_SAMPLE_PHYS_ADDR) > > > > Thanks, > > Leo > > > >> attr.sample_type |= PERF_SAMPLE_IP | PERF_SAMPLE_TID | > >> PERF_SAMPLE_PERIOD | PERF_SAMPLE_DATA_SRC | > >> PERF_SAMPLE_WEIGHT | PERF_SAMPLE_ADDR; > >> -- > >> 2.25.1 > >> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel