Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2683740rdg; Mon, 16 Oct 2023 11:28:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHKN4yVzMFZ6C1sGjnrRdo3Ltt6eKkyagLb2mpIqdFtwYDm6OAl9yF2oF3bGxMqXbP4qiO5 X-Received: by 2002:a05:6a20:1593:b0:155:5c28:ea74 with SMTP id h19-20020a056a20159300b001555c28ea74mr35217884pzj.12.1697480900954; Mon, 16 Oct 2023 11:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697480900; cv=none; d=google.com; s=arc-20160816; b=Mfl3UYrLnw+74u0FFTk/uqqvTb8zEAZ0VSH90rKIUCPb+w6yK7z0hVuVYm0TNqpSmO UwhUhQLFdIern4QTB78VAlRxXhhw+0grL9zcUURp39+aUN6vAAucRHZhdbnVsScCVOfo ftIqxqJnnP+haqa3x19tyNlZG8gXFVJUrFjDDrGMXQPbBifqv6Qft58acj3cVExTS47P jxsxi/sT6bgzzpjB8VvJeWx50gjzZc/ledxrT04v8BIj2VL+FROrUYxL1RkVa43+POXf oMLDGoyPBpm14ePY4g+ztFGlzvS/4Zad1xxuj4albtqP+RJz/MZ4AflDBaoD9vbTNJIU MTvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bm51Bwy2SpdgE6SyKdoP36JXJJ8T1AHayysY044xqt4=; fh=7SodUo6c8+FPMpxOdIyAqlelpEc+y8+H5ogfKfSslhM=; b=iQG7cgSjjSNOk7DnYY6Cn7cvgRF7AH6Gvc9K4Zn8zEKsXy4vEtyXcDBr+Osf8D/YIa Q0861TNkdJgJEHk/n6aDN++EKkJoJVH0B1PblAgNFc9srMEyxTp9t1o6xdpW5ekNPjqn 1gN28QBQpl/UpB8t5Z8NThszmtumVXyfTrb9JGp8cBkuk1LkZvSi9nY6xQQ3ABNBihp1 SwYGuTvmBVteehwUsmUPr+fu9Hu7brjz705eHoH31KdlLxGL+DINALwjlnyCbHXsunKj niOXt9kVSuzKq6sRc1YyMVT1WRTpiEpBiktDlKQz7x4YsJ9eFskXumsrXfwiaFoX2a75 p/XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=FLIplMzc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id z7-20020a633307000000b005aa4888b9bfsi8608869pgz.629.2023.10.16.11.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 11:28:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=FLIplMzc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 76B3A8044776; Mon, 16 Oct 2023 11:28:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233956AbjJPS2I (ORCPT + 99 others); Mon, 16 Oct 2023 14:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233820AbjJPS2G (ORCPT ); Mon, 16 Oct 2023 14:28:06 -0400 Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1950AF0 for ; Mon, 16 Oct 2023 11:28:04 -0700 (PDT) Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-1ea4a3d0a44so783225fac.1 for ; Mon, 16 Oct 2023 11:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1697480883; x=1698085683; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=bm51Bwy2SpdgE6SyKdoP36JXJJ8T1AHayysY044xqt4=; b=FLIplMzcfLk8EUEDpYJJGXVzt83IfMpgjDqPezVP74Ml0ni5HtU9m160CngcNFShrY TpopDP5PlplCI44xhq2vOiZsgZavZg0A/1DY7YZm0Pz73PppG/OjY4haCky/NdWdvzr6 z2gXWt8RWyXI80KvRsnF2edxa21FpGlwwGGEiIoUlZJqw0G6+JpPVrbGG6mSxFlsQ/J5 ijLOaVGmQb/rTYL4GxSoogIOQzgmHUOSl0B+uLs8lHTfk1ZwUi79tt9vT/xE9a6Ow5Pi cIgPD/F20y3KnkNbtQd9Ul0RkWX918UmbPhKJi972YjKMlVOwsyk2U03lHfHPg6dpb0y Pjaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697480883; x=1698085683; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bm51Bwy2SpdgE6SyKdoP36JXJJ8T1AHayysY044xqt4=; b=aVP7a6k78CobX6BVIfkvBGzo+6mdABzUaM/DG1MWteYbd9xAj2uIcrbwzP+UXyp6xR KlsVaTiw+Dki/o2ZJrgFn04qwwID++uildSd/zIBfXgzrObvU3NL+iOcp37IsHDac5Dj kh5V4ZxontAnsylMB8Y/QQPg2P93L2/1HmSnU5bmemICRX9W0/CKVPZJYOIFhXLzvgGC AfJlE0BZm2CzxBSTuxSdbgbtIlTItKkwwv4dr0GKUHPxrzwBV5oZwREjK6vuYYzkpyea VwpHPv25MHoouoEvLKmNalNVPk56JOPdB5nfaHCpf4z6fSF2r4rTWX/rafx+Y9PysMyg 7tBg== X-Gm-Message-State: AOJu0Yx3zoA+nFV1NhvKraDh+cjCqIyVN0Q/eFDBGkAoONAW/Jjdz1pH ifeNhbxRUp9iR/rj75aTK/bkH8ts6taezzX9TFX10g== X-Received: by 2002:a05:6871:e46:b0:1e9:90ec:140 with SMTP id vk6-20020a0568710e4600b001e990ec0140mr13011252oab.58.1697480883424; Mon, 16 Oct 2023 11:28:03 -0700 (PDT) MIME-Version: 1.0 References: <65e98129-0617-49ca-9802-8e3a46d58d29@efficios.com> In-Reply-To: <65e98129-0617-49ca-9802-8e3a46d58d29@efficios.com> From: Robbin Ehn Date: Mon, 16 Oct 2023 20:27:52 +0200 Message-ID: Subject: Re: [RFC PATCH] membarrier: riscv: Provide core serializing command To: Mathieu Desnoyers Cc: Palmer Dabbelt , parri.andrea@gmail.com, charlie@rivosinc.com, paulmck@kernel.org, Paul Walmsley , aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, mmaas@google.com, hboehm@google.com, striker@us.ibm.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 16 Oct 2023 11:28:18 -0700 (PDT) > But fence.i would only have effects on the hart it is being called from, right ? > What is the use-case for allowing user-space to issue this instruction ? Right now openjdk uses flush_icache for every cmodx write. And it does a lot of cmodx. If the hardware does not require an IPI/icache flushing we still need to serialize the reader. (locally stopping out-of-order execution/speculation at least) And in some cases the reader knows the code stream has been changed and can emit fence.i itself instead. So we want the option to emit fence.i directly into the code stream. As fence.i is an unpriv instruction there is no issue with emitting it. But we need the assurance that context switching to a new hart does not eliminate the effects of the fence.i. /Robbin > > One more thing: membarrier(2) sync_core only issues things like "fence.i" on > the various cores in the system running threads belonging to the process, but > does not intend to take care of doing any kind of cache invalidation per se > (e.g. invalidating an address range worth of cache). On ARM, this is done by a > separate system call (e.g. cacheflush(2)), or can be done by instructions > available from userspace in some cases. > > Do you expect to have a need for flushing only specific icache lines, or is > the intent to always flush the entire icache ? > > > > > Charlie is volunteering to do the work here, so hopefully we'll have > > something moving forward. > > That's great! I hope my feedback will help. > > Thanks, > > Mathieu > > > > >> > >> Andrea > > -- > Mathieu Desnoyers > EfficiOS Inc. > https://www.efficios.com >