Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5603008imw; Wed, 20 Jul 2022 08:45:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v+3bZaVkzj49fw5Ql94PQc6OJwaJYztX537FRSwd7pq1HJb7iMdHCAej/mv3d+v/RibO1T X-Received: by 2002:a17:907:8690:b0:72b:552e:67c0 with SMTP id qa16-20020a170907869000b0072b552e67c0mr35101106ejc.600.1658331939838; Wed, 20 Jul 2022 08:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658331939; cv=none; d=google.com; s=arc-20160816; b=nEXudCaHfTDeAsE+Tz3D7kio7sqQtk2lEyKbK7vRNETVr9er+8zYTesYJkslXGXyV1 2M3KFJsbj3wMjSYoF7fhDI7iIX8jwB+LiacxzDiVmY3Gdpid5NoF+lJv7OUJKiIlEGeO oWY0ieBue8Ud74J6YvRU0jwWPe6ZoNZGM2MILOgp5dAXLIVzs/QSfaahnuTDesQeKqen FOONCSuFY86erM1jD5rrk0cVhqyEuUV6u0Ddk5+2wDFDDlFC4hCzGR3Q/PWSNgDDK2jN e6KisMforjAUFUkgnfBzh5DHZMlEK/HWJvCXCT5xLwJC4p21GKzD8NPnGbND+N+hy9Dl wrkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:date:from:dkim-signature; bh=peWRstM5WJ1uEJGZkmycSQe/OQeWUfZo2X2E/jtgHIE=; b=BENI38sv763Nr6cHb9yik/sLjTH1wc6L2YdOLr5KJfxyFM3idP3BfhzBrIrAmYhFlW UTTsfPp6xoZErPpZOJRiKg4ZFAbxxG4kwK4fjjjfZQVtYkD/v5yN7HkpZqBO691bRy0L XPOpJXLiBST7Wyh7l3B/4XvyGD2jLLdNWPajxdnnxrBirnKPZZXSimplskhEgvFQ/OOl FBn9pHJJq/uqpoesdy7NKfOHz8wyA9ALSltCRo5VTlHPou1/Bz+0zG0drtg2FirsYwgx 2nLgZWLlDjoFB/7e9xXb1rO7ojwDvoSHCFpp+xJZGmL92uR3vcIPIEHivKySw6y64zhf /Ihw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@maine.edu header.s=google header.b=B3nCvg0T; 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=maine.edu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i16-20020a1709064fd000b006feba25b350si24289452ejw.106.2022.07.20.08.45.13; Wed, 20 Jul 2022 08:45:39 -0700 (PDT) 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=@maine.edu header.s=google header.b=B3nCvg0T; 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=maine.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239036AbiGTPGO (ORCPT + 99 others); Wed, 20 Jul 2022 11:06:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232429AbiGTPGM (ORCPT ); Wed, 20 Jul 2022 11:06:12 -0400 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9AD2237D6 for ; Wed, 20 Jul 2022 08:06:11 -0700 (PDT) Received: by mail-qv1-xf34.google.com with SMTP id y18so2414323qvo.11 for ; Wed, 20 Jul 2022 08:06:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maine.edu; s=google; h=from:date:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=peWRstM5WJ1uEJGZkmycSQe/OQeWUfZo2X2E/jtgHIE=; b=B3nCvg0TJPJ01xPscNBbG9bJvIwTSED8ChRDHzsDnzpHrpkq5kI6I0WYnwrCe/rlf/ UGBnc6YMPm7VCfPkRE+35isAWs7EQSPjpKf6plM6/KET6FqzblisuAVvOmkYMOTRqv7D yT/V5LSFdLaH4VlUen6ySWsnZ9kRHclo6nJ48= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=peWRstM5WJ1uEJGZkmycSQe/OQeWUfZo2X2E/jtgHIE=; b=tZy9CGRi6pWIWFZRoonBCaWMEYFFaltBvIShDIYUGmoe+Wzp3r+jm2BCuRTVENHwwY QdDGn9ua8sdFBiGrkV3H1rJLhs1NaHj4NoVBTruMkci9VEiCraSMdea8AFxreY2SbKYj 1qxbCphwNMG+mKdlMO/Oi5hexgdeWitA/s7cJX0jeI+Sjb/9OzxKJpvz43Sb5MhtcKm1 wKp23oGcInmwUXd0CLrnlO8apwQu8nGZSg00JaIg6h7jVQ0ySCucFQNzWIS2F2c+hSHi sEAm5tdFxcr20WWGnS56relYyC09rgkp+mjwWon80pl+aMr62BB3AF2CoQQbxHO2a0vR ydmw== X-Gm-Message-State: AJIora/J9WeM2AQv7+OZl8mbMWxOhyt2rVlshyjfOWSAhQzhBEIFA1tt 7yBLyFLMfhnkXnCbIcilogI4lA== X-Received: by 2002:a05:6214:2588:b0:474:4cd:43b1 with SMTP id fq8-20020a056214258800b0047404cd43b1mr2702376qvb.45.1658329570359; Wed, 20 Jul 2022 08:06:10 -0700 (PDT) Received: from macbook-air.local (weaver.eece.maine.edu. [130.111.218.23]) by smtp.gmail.com with ESMTPSA id bm35-20020a05620a19a300b006b61b2cb1d2sm35654qkb.46.2022.07.20.08.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 08:06:09 -0700 (PDT) From: Vince Weaver X-Google-Original-From: Vince Weaver Date: Wed, 20 Jul 2022 11:06:08 -0400 (EDT) To: Ian Rogers cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Kajol Jain , Andi Kleen , Adrian Hunter , Anshuman Khandual , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Rob Herring , Stephane Eranian Subject: Re: [PATCH v3 1/3] perf: Align user space counter reading with code In-Reply-To: <20220719223946.176299-2-irogers@google.com> Message-ID: References: <20220719223946.176299-1-irogers@google.com> <20220719223946.176299-2-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Tue, 19 Jul 2022, Ian Rogers wrote: > Align the user space counter reading documentation with the code in > perf_mmap__read_self. Previously the documentation was based on the perf > rdpmc test, but now general purpose code is provided by libperf. > > Signed-off-by: Ian Rogers > --- > include/uapi/linux/perf_event.h | 35 +++++++++++++++++---------- > tools/include/uapi/linux/perf_event.h | 35 +++++++++++++++++---------- > 2 files changed, 44 insertions(+), 26 deletions(-) > > diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h > index d37629dbad72..6826dabb7e03 100644 > --- a/include/uapi/linux/perf_event.h > +++ b/include/uapi/linux/perf_event.h > @@ -538,9 +538,13 @@ struct perf_event_mmap_page { > * > * if (pc->cap_usr_time && enabled != running) { > * cyc = rdtsc(); > - * time_offset = pc->time_offset; > * time_mult = pc->time_mult; > * time_shift = pc->time_shift; > + * time_offset = pc->time_offset; > + * if (pc->cap_user_time_short) { > + * time_cycles = pc->time_cycles; > + * time_mask = pc->time_mask; > + * } From what I've been told, and from what perf_mmap__read_self() actually does, many of these MMAP fields need to be accessed by READ_ONCE() (a GPLv2 only interface) to be correct. Should we update perf_event.h to reflect this? Otherwise it's confusing when the actual code and the documentation in the header don't match like this. As an example, see the actual code snippets from perf_mmap__read_self() seq = READ_ONCE(pc->lock); barrier(); count->ena = READ_ONCE(pc->time_enabled); count->run = READ_ONCE(pc->time_running); if (pc->cap_user_time && count->ena != count->run) { cyc = read_timestamp(); time_mult = READ_ONCE(pc->time_mult); time_shift = READ_ONCE(pc->time_shift); time_offset = READ_ONCE(pc->time_offset); if (pc->cap_user_time_short) { time_cycles = READ_ONCE(pc->time_cycles); time_mask = READ_ONCE(pc->time_mask); } } idx = READ_ONCE(pc->index); cnt = READ_ONCE(pc->offset); ... Vince