Received: by 10.223.185.116 with SMTP id b49csp6207040wrg; Thu, 8 Mar 2018 03:43:55 -0800 (PST) X-Google-Smtp-Source: AG47ELtl5/gF2JW2hZyOD/z6WDTwIY5+GVPJBuaR6zAtdz0o2v/plAl2Asi9QVTqT8k6Mg+WRCpJ X-Received: by 10.99.125.8 with SMTP id y8mr20851634pgc.241.1520509435818; Thu, 08 Mar 2018 03:43:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520509435; cv=none; d=google.com; s=arc-20160816; b=pDsSsSY29C5e/dLTUFBi5FsTYuIjiVeJl5zIMvdQVqEXqCbNYui4bxAvOrW9YAoh5E kUVwznZATN4o/nYGOxh5CB9Pinubjxsc9JqhJ0AI7qSJUuPO6gabm67m9P8i0Z213YoC xnKKsOx9pePLzuzBykXrhnkz6nlc8D1LobEDSTfish2ySd6xNW6HW4fSaNxr5UqNzWoH uLcJMQYWAOjn18CRFayWm467qmh/KPiNA6K2p6w9D4cvz5Z4lYRTxFE5OLEcN4iHB97N M15cKelHVCqHy37RqsJ9Xm4qTDKMeY6Q1oLDICIlzRtowb/k6/KeCPa9C3OoNTQ0Trch PlXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=1ZodXE5wMxsASA9G0y8L30rIFZzI1cvtsXErlXQBUj0=; b=dsv1YX/MBN2mxl2JrBaAYsyWOtSxlGLiRCZjnWOk/rR2rJIcRJWQ5pCLOIbhA6zQm1 pybRs2ExhuTq8HGTpXZZG+97UJ2p4n/HOrXgnZtJdkbaCDof0Xk3RyScOC2ovJfKRhRT gka4BZkUHpX8RSgzOYbabmJbPouKKfHa9IjyuvHD7HI52nKqNlvdbjibIimmNhkI87mc 2WP6Zj5VFzgQmND7WdbXwjXebNb4frLvvAPakbdrpugdU/VNAZ3dHJ/hFBr6TCbGrJM2 8jKW319g2XCqRfu5kPxJ0C0pAWYS60KTqKcq8uGsAGrMbM8wxMGDN5vJzdjETVEALgBd Xetw== ARC-Authentication-Results: i=1; mx.google.com; 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 u19si12872350pgv.195.2018.03.08.03.43.41; Thu, 08 Mar 2018 03:43:55 -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; 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 S935778AbeCHLmb (ORCPT + 99 others); Thu, 8 Mar 2018 06:42:31 -0500 Received: from foss.arm.com ([217.140.101.70]:36460 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751615AbeCHLm3 (ORCPT ); Thu, 8 Mar 2018 06:42:29 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 79C5C1435; Thu, 8 Mar 2018 03:42:29 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 42DEE3F53D; Thu, 8 Mar 2018 03:42:27 -0800 (PST) Date: Thu, 8 Mar 2018 11:42:24 +0000 From: Mark Rutland To: Saravana Kannan Cc: robh@kernel.org, mathieu.poirier@linaro.org, Suzuki K Poulose , peterz@infradead.org, sudeep.holla@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, marc.zyngier@arm.com, jonathan.cameron@huawei.com, frowand.list@gmail.com, leo.yan@linaro.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v11 8/8] perf: ARM DynamIQ Shared Unit PMU support Message-ID: <20180308114223.fsuwyejw4pb3gyoy@lakrids.cambridge.arm.com> References: <20180102112533.13640-9-suzuki.poulose@arm.com> <5A90B77E.8040105@codeaurora.org> <20180225143653.peb4quk3ha5h3t5x@salmiak> <5A972A7D.9020301@codeaurora.org> <20180301114911.fundyuqxtj5klk4e@lakrids.cambridge.arm.com> <5A986425.9080007@codeaurora.org> <20180302104223.7tpsyhsum7nej237@lakrids.cambridge.arm.com> <5A99A3DC.9020400@codeaurora.org> <20180305105925.4cjiqejfid7rswe6@lakrids.cambridge.arm.com> <5A9DC03B.8020201@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5A9DC03B.8020201@codeaurora.org> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 05, 2018 at 02:10:03PM -0800, Saravana Kannan wrote: > On 03/05/2018 02:59 AM, Mark Rutland wrote: > > On Fri, Mar 02, 2018 at 11:19:56AM -0800, Saravana Kannan wrote: > > > On 03/02/2018 02:42 AM, Mark Rutland wrote: > > > > It's important to note that the DSU PMU's event_init() ensures events > > > > are affine to a single CPU, and the perf core code serializes operations > > > > on those events via the context lock. > > > > > > Ah, I see that now. Thanks! > > > > > > > Therefore, two CPUs *won't* try to access the registers simultaneously. > > > > > > Right, and this driver seems to be going through a lot of work to make sure > > > all events are read in one CPU. > > > > > > Do you even have an upstream target where there are multiple DSU's in a > > > system? > > > > I have no idea, though I do beleive that it's possible for a system to > > have multiple DSUs. > > > > > If not, we can simplify a ton of this code (no hotplug notifiers, no > > > migrating PMUs, no SMP calls, etc) by just adding a spinlock and letting any > > > CPU read these DSU counters. > > > > Regardless of whether we allow arbitrary CPUs to read the counters, > > other logic still needs to be CPU affine, and we'll still need hotplug > > notifiers and event migration. > > If you have to support multiple DSUs in a system, then the need is obvious. > But if you don't have to support multiple DSU, it's not obvious to me on why > you still need CPU affining or hotplug notifiers. Could you please provide > me pointers for general understanding? There are a number of reasons. From the top of my head: * The perf core relies on the interrupt handler being serialised w.r.t. operations on the relevant perf_event_context and perf_event_cpu_context by way of these being affine to the same CPU. For this to be the case, events *must* be managed on the CPU the interrupt handler is affine to. * The perf core rotates events on a per-cpu basis. To keep this fair and reasonable, the perf core needs to manage *all* events for a PMU on the same CPU. * We expose a cpumask to userspace, so that it attempts to open events on a single CPU (and doesn't open redundant events that would result in misleading figures). This must be an online CPU for the perf core to allow events to be created, so this must be updated when assocaited CPUs are hotplugged. We must choose *some* arbitrary associated CPU for this. * If the arbitrarily-chosen CPU is hotplugged out, but other associated CPUs are online, we should keep the events active by choosing another arbitrary associated CPU, and migrating the events (see perf_pmu_migrate_context). Note that we must also fiddle with the interrupt affinity. * If a hotplug event occurs between userspace reading the cpumask and opening an event, it may try to open events on a CPU that is not the currently arbitrarily chosen CPU. To ameliorate this, in pmu::even_init we re-write event->cpu so long as the CPU was *some* valid CPU. There might be some other reasons, too... Thanks, Mark.