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.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 EF7ECC433E7 for ; Mon, 19 Oct 2020 13:03:06 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 635E521D7B for ; Mon, 19 Oct 2020 13:03:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qUD3o6aE"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="du4KWCHj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 635E521D7B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=F2iCQaekKzhDI9p3tCnPawZztZHXTRkiH7Zp5CAmMRE=; b=qUD3o6aExH6ovnPf+/LPs9S6X Z15Mtb+y2FbzoMWlgWKCkI0DkjZTChGOP2rnG/Njz/DOjrzR846Q8Vdx87Pa/t5N6Qa4VNPa9le0L HBYwv27HHHLP5FS7nbEDfQ3gThki5dCyuhJsgDwvNtbs+5iaR0tXha2Mfo9OqO9stDbMaz++Bs1o3 XA1wsHvV8fgoOsq9m5L5pxdfSov8a92RC3xDKH8fSZMVy8ru6G0bM2HbTRk0L00P48xmzrdQPpvUO gFSddsyAnd4a8LiwNoPlEjD+UQY/jLKK8lcvXV6MYC8ZaDQdLqdbbrX+94bY8FMPK9oBcYN07E0lZ Sc6BURPUQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUUmy-00065v-9j; Mon, 19 Oct 2020 13:01:24 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUUmv-000659-3n for linux-arm-kernel@lists.infradead.org; Mon, 19 Oct 2020 13:01:22 +0000 Received: from willie-the-truck (unknown [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DDA90222BA; Mon, 19 Oct 2020 13:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603112478; bh=GgGkZAaRlizj7Hi/+mHqvSgG6p+ntVUBjwnOiM3XDlQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=du4KWCHjBVYLKJUft5CYwfv20d0edDysVSZ9+SoMX4DD+4Gz7SVW9I/f+e/rIz//U FhypW6Tk5/M7jl1s2Suca4/aKJsYvSrGKolGLHHTtrByhSHzXsaiaoQCwsB7ZBnTq6 O8ninp9XeA7zPWR9okz/UOXqYycVCi40Fmmbhn/U= Date: Mon, 19 Oct 2020 14:01:09 +0100 From: Will Deacon To: Mark Rutland Subject: Re: [PATCH] perf: arm_spe: Use Inner Shareable DSB when draining the buffer Message-ID: <20201019130109.GA14994@willie-the-truck> References: <20201006150520.161985-1-alexandru.elisei@arm.com> <87ft6r4bgd.wl-maz@kernel.org> <8fa8af94-ab08-b43a-95e4-55a13de09efe@arm.com> <20201019122455.GD34028@C02TD0UTHF1T.local> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201019122455.GD34028@C02TD0UTHF1T.local> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201019_090121_312222_62B3ABDB X-CRM114-Status: GOOD ( 32.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: suzuki.poulose@arm.com, Marc Zyngier , linux-kernel@vger.kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, catalin.marinas@arm.com, Alexandru Elisei , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Oct 19, 2020 at 01:24:55PM +0100, Mark Rutland wrote: > On Tue, Oct 06, 2020 at 05:13:31PM +0100, Alexandru Elisei wrote: > > On 10/6/20 4:32 PM, Marc Zyngier wrote: > > > On Tue, 06 Oct 2020 16:05:20 +0100, > > > Alexandru Elisei wrote: > > >> From ARM DDI 0487F.b, page D9-2807: > > >> > > >> "Although the Statistical Profiling Extension acts as another observer in > > >> the system, for determining the Shareability domain of the DSB > > >> instructions, the writes of sample records are treated as coming from the > > >> PE that is being profiled." > > >> > > >> Similarly, on page D9-2801: > > >> > > >> "The memory type and attributes that are used for a write by the > > >> Statistical Profiling Extension to the Profiling Buffer is taken from the > > >> translation table entries for the virtual address being written to. That > > >> is: > > >> - The writes are treated as coming from an observer that is coherent with > > >> all observers in the Shareability domain that is defined by the > > >> translation tables." > > >> > > >> All the PEs are in the Inner Shareable domain, use a DSB ISH to make sure > > >> writes to the profiling buffer have completed. > > > I'm a bit sceptical of this change. The SPE writes are per-CPU, and > > > all we are trying to ensure is that the CPU we are running on has > > > drained its own queue of accesses. > > > > > > The accesses being made within the IS domain doesn't invalidate the > > > fact that they are still per-CPU, because "the writes of sample > > > records are treated as coming from the PE that is being profiled.". > > > > > > So why should we have an IS-wide synchronisation for accesses that are > > > purely local? > > > > I think I might have misunderstood how perf spe works. Below is my original train > > of thought. > > > > In the buffer management event interrupt we drain the buffer, and if the buffer is > > full, we call arm_spe_perf_aux_output_end() -> perf_aux_output_end(). The comment > > for perf_aux_output_end() says "Commit the data written by hardware into the ring > > buffer by adjusting aux_head and posting a PERF_RECORD_AUX into the perf buffer. > > It is the pmu driver's responsibility to observe ordering rules of the hardware, > > so that all the data is externally visible before this is called." My conclusion > > was that after we drain the buffer, the data must be visible to all CPUs. > > FWIW, this reasoning sounds correct to me. The DSB NSH will be > sufficient to drain the buffer, but we need the DSB ISH to ensure that > it's visbile to other CPUs at the instant we call perf_aux_output_end(). > > Otherwise, if CPU x is reading the ring-buffer written by CPU y, it > might see the aux buffer pointers updated before the samples are > viisble, and hence read junk from the buffer. > > We can add a comment to that effect (or rework perf_aux_output_end() > somehow to handle that ordering). Given that DSB is about completion rather than ordering, completion only matters for endpoints and the endpoint in this scenarion is part of the same observer, DSB NSH should be sufficient. Ordering of accesses as observed by other CPUs should be handled with DMB or acquire/release. So if the aux buffer code is missing barriers, we should add them there, like you proposed before: https://lore.kernel.org/lkml/20180510130632.34497-1-mark.rutland@arm.com/ What happened to that? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel