Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3270792pxb; Sun, 29 Aug 2021 20:09:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0m7mV4Ebw6pAr8gjqC/ImlUPHa1srRTl3L63wYwBKMoB085qKPPU6qZ5rd33u63NEEL7u X-Received: by 2002:a92:c90a:: with SMTP id t10mr15356101ilp.188.1630292958526; Sun, 29 Aug 2021 20:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630292958; cv=none; d=google.com; s=arc-20160816; b=d3mHBMZqP+M/rO2MN9uE9FTPwUTGXIVno3t428q14AgA/UUIkAsT0WTTTDLmhOnFyt u30X41Rkt6PdHEzFcsQYNcYV0V3kvuGo3fnweJqIDoODxWniOlWFkosJWjiA/bxI8vcI PrE7H+6e34fNse86VRarbpzNNMIOYpi7nK5DsapHzzh/UV4mwvwJbCwv08cOP65vMo1p U3+8jwAHmkTxl72PCSUCEs/t6c6dVR1sAMmNiZtG/Obc4S/1P8vr4tddepG/VzfBejBJ souMsXxCajO1zsVjmETlHRf+5e7amutoN7UA4IdAfLiGqEYA0zkgXE4lAQXbcB0VLRe6 DyYg== 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=XyC3eMjyvzy2h5NQGE3juzyJQqXKCxwrrVIRyLgJvIY=; b=EiZVzHaRFbG5FE0ZgUpumLyuvkCQzYENqI3xFRjySW86pplg58BvON6/DiCOF3Isrn wPV4ySh0V4JXlfLEFA6igSq36Or0nkRnong+iOgON3cfxkklhIVP4AMD2B+86NC/AgUa RVywekRLZnW+N7ogtSR8zj2YGjkl6Q6kUAvTXLQjPFC8kcxT/dn9ulIrIksuxVcqxYII eEZCXIhvE10msrgfezharmkecSemVgKFUFbuPWLuerd2TeNTXZN7+Nk/aZbX4zWPLS4e 081RVW/oCZpJZkX6oQwImeCkrqe8n8hNxOUK0kZM4xsdfcZ8XfknQXuRax/wtNOVyU2E kiZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@maine.edu header.s=google header.b=eKpoBqxU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q14si13046665ilm.44.2021.08.29.20.08.53; Sun, 29 Aug 2021 20:09:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@maine.edu header.s=google header.b=eKpoBqxU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233910AbhH3DIV (ORCPT + 99 others); Sun, 29 Aug 2021 23:08:21 -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-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--