Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3898004pxb; Mon, 30 Aug 2021 13:23:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDyj2IX0DQ2by1u3GbIKRVCChtix9a6izdtjzNx9YZZmthBWGIvcaTkTNrj6rDs/CGpWym X-Received: by 2002:a17:906:a0c:: with SMTP id w12mr26389886ejf.376.1630355011312; Mon, 30 Aug 2021 13:23:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630355011; cv=none; d=google.com; s=arc-20160816; b=vJhrgavVO4Zto7SNI6N0scGzqMESk9clMpqOhaZGw5cyCLvL3s8dptjvIAKmpxCngn fdSA1UGamkDwo6ty+Up/xBAoUhg0edN/KF7yeU8QNN8+Z20SV1WPTRUmPStPsSK8tnLL VZ8zSQsPfebwp4U7782A7rIi51ZyMPVsee1naK5TmIc/AHRky1ESB1FFnbChZIT4e9Xq V4TEusIkftWt7OlQHIUgfVOe1eGL2+uEaYeybM4wqlW771MQ0IV4dOZUo4Hi21jK9qg3 UPr0nEiDEoy1pwg3v4xLNSQ38pDCA9qHKLIYB9hh+8YLSxYd9aDQbA/MyVpIlIogatIP zm6A== 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=X7a3OV8CJpHOBd/pCAOp/2UFjX6RkqdkX1D3kGcsPcE=; b=WCkmF1VxAlk00tAneg33Ma8uV2CJjV9ae02gboMpEU90I+Wi/MKiAE+KmsArKyMEky JciCnwNC4caiY+sGhDqQ21o0WlxLoGDotaAuISooDq++BHaqT0+hrvD2O+HXoZWec6w1 Dhq8uymo/DwJ+eqFoeUqUwEbnMczGkxiKJFiAfr21j6OSkEgTHG69AihC+5wL+oh939s XAZZtzBFD5lTSOOY4Cg3Iuj4KKlYnM1IA/w+A5EGs8uSN/MsHNqYLvoIaagMHx4Hr+7E /tavSld/phCavMxcFSo43lj/MayjIi442EkUE7HjmoHy8RW4ljYAOXTuKYPAlqP1ss3p 8mjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@maine.edu header.s=google header.b=M+fTkpA4; 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 u19si15520562ejo.211.2021.08.30.13.23.00; Mon, 30 Aug 2021 13:23:31 -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=M+fTkpA4; 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 S232906AbhH3UWR (ORCPT + 99 others); Mon, 30 Aug 2021 16:22:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233129AbhH3UWQ (ORCPT ); Mon, 30 Aug 2021 16:22:16 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AA4BC061575 for ; Mon, 30 Aug 2021 13:21:22 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id 2so8250364qtw.1 for ; Mon, 30 Aug 2021 13:21:22 -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=X7a3OV8CJpHOBd/pCAOp/2UFjX6RkqdkX1D3kGcsPcE=; b=M+fTkpA41Uub+mOaSv7kcWaeQm3vIscRWIMBMqoISpojyDuGEmCULgvUOgsdSLmmxD a9lAGZaWrL3v0Li5+QZkgKWpLT0K75/AZGUzifyvsOaF9WUNY0q5sk/eSpHNanAYRlp+ 532QwkMUbAR+FiPQw0hDi7p415rdQn7h2gspU= 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=X7a3OV8CJpHOBd/pCAOp/2UFjX6RkqdkX1D3kGcsPcE=; b=eaTnbNrtnG+A2Qa/4LD5wAy5bquAiitk93HJYWvCwan5TInZ8CekYDDpsQjERxcLi0 rhgcEZeTBLHVyXgD9D0v2r0MwDqFF4x8JdleuF5d0C5BCsiIcuN6q7pBOnVr3dR5nuRu KUxxfWRSNxqzclHcCaInbJKZnOKqpW3TSffZzWJwbn5d2TMWsFEr8qdOoqWexqce8Nh0 mlDtqe9+O9C0ku+JMQhSizxLEBiYp2gSku3wPr0unGnbrICWYyMnzLGqGJK6AWXcv8hc ugrU9TUO1y1HOmWSFe+b3hqRps9ezX3azk7mNUya0JkuaPZ/ghn6W/P9z+CDTexgHNtd lN3Q== X-Gm-Message-State: AOAM530qFGBgHsqrxSFwBFCxYsqhj4IPDuVB7ETj0C2k9yo2biOBrEV1 HphROrtSJNvqVYIZvXRJt9oSKA== X-Received: by 2002:a05:622a:1888:: with SMTP id v8mr22468747qtc.105.1630354881835; Mon, 30 Aug 2021 13:21:21 -0700 (PDT) Received: from macbook-air.local (weaver.eece.maine.edu. [130.111.218.23]) by smtp.gmail.com with ESMTPSA id s28sm11974306qkm.43.2021.08.30.13.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 13:21:21 -0700 (PDT) From: Vince Weaver X-Google-Original-From: Vince Weaver Date: Mon, 30 Aug 2021 16:21:19 -0400 (EDT) To: Peter Zijlstra cc: Vince Weaver , Andy Lutomirski , Rob Herring , 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: <20210830085106.GF4353@worktop.programming.kicks-ass.net> Message-ID: <0b794c5-5988-c79d-7bb-11533ed92a9@maine.edu> References: <20210728230230.1911468-1-robh@kernel.org> <20210728230230.1911468-3-robh@kernel.org> <43b3a838-da8a-4733-9832-f3d5f990ec13@www.fastmail.com> <20210830085106.GF4353@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 30 Aug 2021, Peter Zijlstra wrote: > There's just not much we can do to validate the usage, fundamentally at > RDPMC time we're not running any kernel code, so we can't validate the > conditions under which we're called. > > I suppose one way would be to create a mode where RDPMC is disabled but > emulated -- which completely voids the reason for using RDPMC in the > first place (performance), but would allow us to validate the usage. > > Fundamentally, we must call RDPMC only for events that are currently > actuve on *this* CPU. Currently we rely on userspace to DTRT and if it > doesn't we have no way of knowing and it gets to keep the pieces. yes, though it would be nice for cases where things will never work (such as process-attach? I think even if pinned to the same CPU that won't work?) Maybe somehow the mmap page could be set in a way to indicate we should fall back to the syscall. Maybe set pc->index to an invalid value so we can use the existing syscall fallback code. We could force every userspace program to know allthe unsupoorted cases but it seems like it could be easier and less failure-prone to centralize this in the kernel. I was looking into maybe creating a patch for this but the magic perf mmap page implementation is complex enough that I'm not sure I'm qualified to mess with it. Vince