Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3383329imu; Fri, 18 Jan 2019 09:26:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN4SzAQTDzYTxs0a4W9Ld8n7Zt4dyVuDDdqY9SuWSZZYFU6aNsFDWgqpCHbMWg1OVNvfiO57 X-Received: by 2002:a62:6799:: with SMTP id t25mr20167675pfj.139.1547832373884; Fri, 18 Jan 2019 09:26:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547832373; cv=none; d=google.com; s=arc-20160816; b=Ns0pp55w0wCyGJnyItEmpyKbn8ttegaIGJWf8b6937X4PZH/qwnv+Lq6OOLGcTijGu nGXb4uSFoLDaupeq2GTHGR7LkM77bJp7rzNZLnRADipQ22EO1KsYdtntHWyUwoThPMvZ Kjlfe4JrRDKmyQeJjxCuOW8dmQDLc5n7fM8M8hF0GjN/lbWqu7IhLSNnL6nqjkbXBgz5 gthsTeNJkbHwzVheOVFOYC/hr7cSAxpkduq9dK1sOLAwlc1MCQs2Sw5i1PDu1QTdjfg6 f4I3xp8E6zt32z92VHLC9DMjWiadyC4k3HFPDLIW9DxXPVsUnTOz1cijolg/L+chQ43s isxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:date:from:dkim-signature; bh=lZ87AmTI1oQJ5sXff1dsD162tkB2dFUbVTnQFxv3BtQ=; b=STTgYotUF8DwFVfXVi+zVA1c2e0Ux1NGCsavPEOZA4nSfOqK1MHNzPimtdi6q/IilP yhUeYFLgRToDemWU5KhOXHxOBwsewlJ6GAgFs4mCRk6M3cHWbNBvc9l5UAuG352lrXnd iz8OwgI6LqscCq5mm9HHkMOZiH7UpGIFEuc4QK7J3k8q6OKJvYMwDyFV5CO50kUnCy2N sbOTuqMh5zCSL8ZgYKxDDLYW1AS9kniHkxm+itTvAekzbLvkoLg0PaTbrQzxHI5Fj6JQ I6XiKiG8p3NdykQYvTDF9pCRlnkSsEfxH6yVVWda6BJZITK6Af7pSzlRcsuGct/69LtU rS5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@maine.edu header.s=google header.b=TbShEl9B; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y26si1330649pfd.25.2019.01.18.09.25.54; Fri, 18 Jan 2019 09:26:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@maine.edu header.s=google header.b=TbShEl9B; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728382AbfARRY0 (ORCPT + 99 others); Fri, 18 Jan 2019 12:24:26 -0500 Received: from mail-qt1-f177.google.com ([209.85.160.177]:46429 "EHLO mail-qt1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727448AbfARRYY (ORCPT ); Fri, 18 Jan 2019 12:24:24 -0500 Received: by mail-qt1-f177.google.com with SMTP id y20so15965207qtm.13 for ; Fri, 18 Jan 2019 09:24:23 -0800 (PST) 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 :user-agent:mime-version; bh=lZ87AmTI1oQJ5sXff1dsD162tkB2dFUbVTnQFxv3BtQ=; b=TbShEl9BC80tqkxWYSFwCY2ufjK+Civ0MP5jcClAH9JxgogYSBAsulNqmrKq7qLuRf Qok+y+ma78lXAXtdorJHvqHZrgTnucXXX49E6gwY/cNC2+u/lmGD8jhTeWF/kvYSppUc c5ClMr7OGS5el1eeKJQd2tEDwVy2qpJoIzUmI= 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:user-agent:mime-version; bh=lZ87AmTI1oQJ5sXff1dsD162tkB2dFUbVTnQFxv3BtQ=; b=Iut2mEOt+l7Z4mLnYdJAZ0jui1vSJt5eLZBwxUMF/zryl5ZWmVCKeUoTdGq+v4E6hB Av256o/SguqFYoz80TPKOXuCGuwFf2hRyy1zngh/VepEWH4mSIa1OGgagGQ8187bVIF5 j8s2gWxVEApdmio4da3wSq/WW9tkXaBrDiEk0eLybEpu7YvMOnKzGpD3o5wMa9+qKe8O ZcM6VgK4fjAAZ7oqhQzZT5d+naf1W/BObEvWHh/UJ3/euQfYj8mgmoDMATg3B78Az7/X m7HJ8g8yc0aURWQn0EygSya+l17oOx11jjolo6rVcgonUfi0zwSHvWx3B5v9/zG7gIEd 89Yw== X-Gm-Message-State: AJcUukdJRIqOp/jfkW2l4LGhrIaHWKuByRvNJFiJK8eAX/fxB2T0Qgz1 FmpPHq+F18ptBatntyXSOy9AyA== X-Received: by 2002:aed:3781:: with SMTP id j1mr16912136qtb.315.1547832262988; Fri, 18 Jan 2019 09:24:22 -0800 (PST) Received: from macbook-air (weaver.eece.maine.edu. [130.111.218.23]) by smtp.gmail.com with ESMTPSA id w184sm68657577qkw.90.2019.01.18.09.24.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 09:24:21 -0800 (PST) From: Vince Weaver X-Google-Original-From: Vince Weaver Date: Fri, 18 Jan 2019 12:24:20 -0500 (EST) X-X-Sender: vince@macbook-air To: Peter Zijlstra cc: linux-kernel@vger.kernel.org, Ingo Molnar , Arnaldo Carvalho de Melo Subject: Re: perf: rdpmc bug when viewing all procs on remote cpu In-Reply-To: <20190118155814.GC14054@worktop.programming.kicks-ass.net> Message-ID: References: <20190118120149.GC27931@hirez.programming.kicks-ass.net> <20190118155814.GC14054@worktop.programming.kicks-ass.net> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 18 Jan 2019, Peter Zijlstra wrote: > > You can actually use rdpmc when you attach to a CPU, but you have to > ensure that the userspace component is guaranteed to run on that very > CPU (sched_setaffinity(2) comes to mind). unfortunately the HPC people using PAPI would probably be annoyed if we started binding their threads to cores out from under them. > The best we could possibly do is put the (target, not current) cpu > number in the mmap page; but userspace should already know this, for it > created the event and therefore knows this already. one other thing the kernel would do is just disable rdpmc (setting index to 0) in the case where the original perf_event_open() cpu paramater!=0 though that would stop the case where we were on the same CPU from working. The issue is currently if you're not careful the rdpmc() interface will sometimes return plausible (but wrong) results for a cross-CPU rdpmc() call, even if you are properly falling back to read() on ->index being 0. It's a bit surprising and it looks like it will take a decent amount of userspace code to work around the issue, which cuts into the low-overhead nature of rdpmc. If the answer is simply this is the way the kernel is going to do it, that's fine, I just have to add workarounds to PAPI and then get the perf_even_open() manpage updated to make sure people are aware of the issue. Vince