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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62569C4320A for ; Mon, 30 Aug 2021 03:07:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45E7A60F5C for ; Mon, 30 Aug 2021 03:07:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236180AbhH3DIX (ORCPT ); Sun, 29 Aug 2021 23:08:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234591AbhH3DGy (ORCPT ); Sun, 29 Aug 2021 23:06:54 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B01C2C061575 for ; Sun, 29 Aug 2021 20:06:01 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id t4so14156011qkb.9 for ; Sun, 29 Aug 2021 20:06:01 -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=XyC3eMjyvzy2h5NQGE3juzyJQqXKCxwrrVIRyLgJvIY=; b=eKpoBqxUECQpQuZb+Bv1OimWe3irD0+Kev7GuuwE0HUmvH15iHKWOMhUCC+r9252Ns GLZJaF+1Qf/jvevCJpYrsmAgZw+S2IE2r19DV5eNdubyJWl+yfRXMsZuXuTZI47QdVLX AAfHvU+yNqjVxQUagePECrjV60CIaH5bZb4+c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=XyC3eMjyvzy2h5NQGE3juzyJQqXKCxwrrVIRyLgJvIY=; b=bOuB41RYI+xQYpJ5zvAHlJDJ7DLBRaTTnmIX7vEZDjg5uKurDQZzh3sOc91yAiTRpS pCXe9m4WKDMnhMbvrzyUO4AMbUm3KgTptAiJ8omUEPTc4SJ/tTLYULey6VhGK9nzLMDq c/X/4tav1Y8Qx9Vk7Dt+kKqk5Qzs4hhnQNmS2dIkNLlMhVVUZH4DvdcM9k25kqbn4tfP yQ2mwE7LWkZ+HirC347J0Kvz2i/Js2bbdO8mEy+rjzWNB7wXdO2pEKAWbvlk40Ak8CJL NL0X4U7UVq6S+SOWR/V4yHHQst5OCVhx85XnEWk1JHfIcbS58fUqCgFeaqlvSbAUQLuY qCMg== X-Gm-Message-State: AOAM53285MWTgCjrXdKbKVQqtR4cG7Y8NSgUs8nUBgk5wGt4OV+gjLvl F7ofOJYXlDiaj8U4/MjRlB+Aag== X-Google-Smtp-Source: ABdhPJyE4cvBoiTsM+hBXavMpRxyUsm9/d41wR+wBWfKIs4lkvJamE9UWEpJnUdOsAHJucw1a63RKA== X-Received: by 2002:a05:620a:4106:: with SMTP id j6mr20608763qko.392.1630292760363; Sun, 29 Aug 2021 20:06:00 -0700 (PDT) Received: from macbook-air.local (weaver.eece.maine.edu. [130.111.218.23]) by smtp.gmail.com with ESMTPSA id g2sm9994223qki.42.2021.08.29.20.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Aug 2021 20:05:59 -0700 (PDT) From: Vince Weaver X-Google-Original-From: Vince Weaver Date: Sun, 29 Aug 2021 23:05:55 -0400 (EDT) To: Andy Lutomirski cc: Rob Herring , "Peter Zijlstra (Intel)" , Mark Rutland , Will Deacon , Kan Liang , Linux Kernel Mailing List , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Borislav Petkov , the arch/x86 maintainers , "H. Peter Anvin" , Dave Hansen , linux-perf-users@vger.kernel.org Subject: Re: [RFC 2/3] perf/x86: Control RDPMC access from .enable() hook In-Reply-To: <43b3a838-da8a-4733-9832-f3d5f990ec13@www.fastmail.com> Message-ID: References: <20210728230230.1911468-1-robh@kernel.org> <20210728230230.1911468-3-robh@kernel.org> <43b3a838-da8a-4733-9832-f3d5f990ec13@www.fastmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="-1463802360-918619477-1630292759=:154341" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1463802360-918619477-1630292759=:154341 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Fri, 27 Aug 2021, Andy Lutomirski wrote: > On Thu, Aug 26, 2021, at 12:09 PM, Rob Herring wrote: > > After testing some scenarios and finding perf_event_tests[1], this > > series isn't going to work for x86 unless rdpmc is restricted to task > > events only or allowed to segfault on CPU events when read on the > > wrong CPU rather than just returning garbage. It's been discussed > > before here[2]. > > > > Ultimately, I'm just trying to define the behavior for arm64 where we > > don't have an existing ABI to maintain and don't have to recreate the > > mistakes of x86 rdpmc ABI. Tying the access to mmap is messy. As we > > explicitly request user access on perf_event_open(), I think it may be > > better to just enable access when the event's context is active and > > ignore mmap(). Maybe you have an opinion there since you added the > > mmap() part? > > That makes sense to me. The mmap() part was always a giant kludge. > > There is fundamentally a race, at least if rseq isn’t used: if you check > that you’re on the right CPU, do RDPMC, and throw out the result if you > were on the wrong CPU (determined by looking at the mmap), you still > would very much prefer not to fault. > > Maybe rseq or a vDSO helper is the right solution for ARM. as the author of those perf_event tests for rdpmc, I have to say if ARM comes up with a cleaner implementation I'd be glad to have x86 transition to something better. The rdpmc code is a huge mess and has all kinds of corner cases. I'm not sure anyone besides the PAPI library tries to use it, and while it's a nice performance improvement to use rdpmc it is really hard to get things working right. As a PAPI developer we actually have run into the issue where the CPU switches and we were reporting the wrong results. Also if I recall (it's been a while) we were having issues where the setup lets you attach to a process on another CPU for monitoring using the rdpmc interface and it returns results even though I think that will rarely ever work in practice. Vince ---1463802360-918619477-1630292759=:154341--