Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4908150rwb; Mon, 31 Jul 2023 14:31:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlEDp+gXWgys/ke2T4VIJArRKHb5jPBy3l+noG2pXAPXbtHk60X9i96pQ5JK6lKu4ZIdD7t+ X-Received: by 2002:a17:907:7710:b0:994:3207:cddd with SMTP id kw16-20020a170907771000b009943207cdddmr666310ejc.34.1690839101330; Mon, 31 Jul 2023 14:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690839101; cv=none; d=google.com; s=arc-20160816; b=tRvSyAteu3IZLYGejRiVIzcBSr1Cwfv4O/fjn7m/dKR2pKIubciWz7WK3Hw3q6LTLb QEg/apTC8ep68ba81Dm7/JS31SQxaHYn0jbVBa3bO9B+iGkCTW/z+zBXepxsDKq4kS0k gKxfmrr4nd2e0ymNn9QLyi8jmUvPGVjLnbR/DiD5tqEbvXoEkfut82r4y9tdCg7NCZay 5sfU2O/S/Bnobfg0H8EvZf/kgXGpdKidEvHsjZFI4RTmPBtcPKBir6gywe6y5OitTT5N h3jIreG1COD1Xj+TGEk9p0Npc/cJ1Xucjj4BJB9f3FRRB5xSysjffE0YsXv2I4xJAxpX 5InQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=G10afZyCNiaw2vu2jAC3R9gIyzTLIVHGE2tClR0IBw8=; fh=5fNtl8JS7kDauozGvIy+/tcDnRPQL2ach9QYpOLcARA=; b=t9DnClNONNr9XcAi4gqPrj64ezKLlazFFVwnCUiDj/NbJKIbWIDwR8Skty84qKW8KS 2hSl+Kc9A5Nzpv4bqBctyVHpRzaRzIOuYeiI2eKIvjA+nc+3G54+BpSfIEbXPsvIfo35 kKNzv8sM+ivtRQJVBqdoYpfh5M1kapzKPHHza8qQSeHqs01kWvJYpuUPKKy91b7Eggm4 /jwA+R1GAwPWckB4TeZZcHRWcb8kTWPAOGWf4A3/tvdEA1aDnfhWz8Ytf2hXsXcRrSY9 KegvWBO1NhjUwpzCwRh1tKfzug1yOXGZGOSzwfQv2z7ByMaCjcpScp2AkfFX6QMJuemr g4Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=kBp+2VJp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb21-20020a170906b89500b00992b6f546b1si2694073ejb.77.2023.07.31.14.31.15; Mon, 31 Jul 2023 14:31:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=kBp+2VJp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbjGaTsQ (ORCPT + 99 others); Mon, 31 Jul 2023 15:48:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjGaTsP (ORCPT ); Mon, 31 Jul 2023 15:48:15 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A250A0; Mon, 31 Jul 2023 12:48:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=G10afZyCNiaw2vu2jAC3R9gIyzTLIVHGE2tClR0IBw8=; b=kBp+2VJp5ZkwgOk6UXkI6Hycfa 6kT98WUmhx2HQkhtNUZTNNoe07jkAj4Lz4PjP+7r5FBs15S+dQQb2piYzaUHD0peDdc8WIdLQxMQK DNFi0PDdxcs5CJoEXFHGSc7/TGeaYG1Ke5nrUTGoljolHji24RtvsxqdvE5A7itlLqUScknltKB3Z zWy96M9RwO8SFgNHBjDdAjDnzHwsoV3IjCqVd1ylRCKJHShmoUN00v/rzC7LsqX7U0zpk2QAtFJhj LWnDr4Thcm4PrDlyS5MM6o9h4m4nkIP9/R16jO8Ry8c5m88Uki668qErHNvG+0fkJkOImHmzuHHTb jeL6dO4A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qQYry-003T3N-E9; Mon, 31 Jul 2023 19:47:54 +0000 Date: Mon, 31 Jul 2023 20:47:54 +0100 From: Matthew Wilcox To: Ian Rogers Cc: Alexandre Ghiti , Brendan Sweeney , Palmer Dabbelt , Jonathan Corbet , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Paul Walmsley , Palmer Dabbelt , Albert Ou , Atish Patra , Anup Patel , Will Deacon , Rob Herring , Andrew Jones , =?iso-8859-1?Q?R=E9mi?= Denis-Courmont , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Atish Patra Subject: Re: [PATCH v4 09/10] tools: lib: perf: Implement riscv mmap support Message-ID: References: <20230727141428.962286-1-alexghiti@rivosinc.com> <20230727141428.962286-10-alexghiti@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 31, 2023 at 09:46:07AM -0700, Ian Rogers wrote: > On Mon, Jul 31, 2023 at 9:06 AM Alexandre Ghiti wrote: > > I have just had the answer internally (thanks to @Brendan Sweeney): > > csr modifications can alter how the memory is accessed (satp which > > changes the address space, sum which allows/disallows userspace > > access...), so we need the memory barrier to make sure the compiler > > does not reorder the memory accesses. > > The conditions you mention shouldn't apply here though? Even if you > add a memory barrier for the compiler what is stopping the hardware > reordering loads and stores? If it absolutely has to be there then a > comment something like "There is a bug is riscv where the csrr > instruction can clobber memory breaking future reads and some how this > constraint fixes it by ... ". If the hardware doesn't know that writing to a csr can change how memory accesses are done and reorders memory accesses around that csr write, you've got a really broken piece of hardware on your hands ... I know nothing about risc-v, and maybe the definition says that you need to put a memory barrier before and/or after it in the instruction stream, but on all hardware I'm familiar with, writing to a CSR is an implicitly serialising operation.