Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1234689rwn; Thu, 8 Sep 2022 16:02:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Gr1cj6dMN0g/5zrwVgZEg+3G0HXfXpNVNPEKqC3H1Bko1/HCVMfRnX1FqvckkiL999I34 X-Received: by 2002:a17:902:ba8e:b0:172:ddb9:fe45 with SMTP id k14-20020a170902ba8e00b00172ddb9fe45mr11085512pls.86.1662678161405; Thu, 08 Sep 2022 16:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662678161; cv=none; d=google.com; s=arc-20160816; b=JHBATtFBTjE7EqheBIsiUy6z4G1CY+m9xY0DH7EJrlz1DSFFVKIH+EzEoK7/hiYZ6p IGJjGw3pn2fLfgs/i1R3uet5iNz7VGnrBoGEpNhggj1yG/iICoXg+LD5kaq/aqgLrmFN WYFTqHhRh0W0qQ0YlVMMz2/vYpFOF1T1zTWOg+4D7btYHRniwSAFdobGH3t7pvBYZh9D XNsxJodyqzmd5NXIsAqsy63j20Y/bdYFehEbv/oNvAv8yQMAUHRU2Zy8MtRu9suzIJY8 JK0gtANISlwQxWmFqNQLK2fon2GrkzM9obi++9hGydwb3YVxrfxWq7Zo7YqwZEcx8DPE HTJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=wb2fHfkIShsywg5/oBM3bCmDMY+Ve5EQ8K0Aj3en2wo=; b=0qiITEUeDursgMe7Txo8w8TwnEnVzeScHM3jH6hU/ELCa+v4vvO/mEpIWcMAvW/xIH fsyZm/szUISyO55DjZQ060gEqY8ZMHgBxARfg1UnqyVy47W90gKPeh8n7RRwMxNTA0zN xrOjaiD+T/oeV7W7wC4YqnVA/MaSF/hatctIfj7YiLl4Lh/4ezi5okVjTR9R6/BuDSyQ 23nUOI2v1KcLjZ4c1Y1YilznVUllKcL5z3xni32/vU5+cKQzWho8dSP8caWFGXCxLhPf i7U0S+V4PMtRsrz1R95ny/keIhfUBvF3tD6A1OWwAt8l0DYjGBcJ73HriilA2K/WZq1T J4LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=sy3HzR1Z; 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 lp12-20020a17090b4a8c00b001fbbcd6f8eesi308396pjb.73.2022.09.08.16.02.28; Thu, 08 Sep 2022 16:02: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=@linux-foundation.org header.s=korg header.b=sy3HzR1Z; 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 S229586AbiIHXAn (ORCPT + 99 others); Thu, 8 Sep 2022 19:00:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbiIHXAl (ORCPT ); Thu, 8 Sep 2022 19:00:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD8548049B; Thu, 8 Sep 2022 16:00:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 601C0B822BB; Thu, 8 Sep 2022 23:00:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A8FFC433C1; Thu, 8 Sep 2022 23:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1662678037; bh=vYPZUFtvIrLJhPcquNWaDGwB5oL31gsB6D0AD6z9rJQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=sy3HzR1ZkaJfKRDdCP4OLoYBeWeh4eIRqMfLL7ZBQlhaiwqz1aisqc8MUwmVw8DxR shM+GGV54BycgoCQzb+SizuHv28toymYLlQYIb8FzilE2pg+7agKdzitEEC0D5aV8N 6DldiyP1gzdaUtdYgodAlyCd6GiJ4gWthhB1nPlU= Date: Thu, 8 Sep 2022 16:00:35 -0700 From: Andrew Morton To: Dan Williams Cc: Jonathan Cameron , Davidlohr Bueso , , , , , , , , , , Subject: Re: [PATCH -next] memregion: Add arch_flush_memregion() interface Message-Id: <20220908160035.f030e3e533a996eadc04dbd5@linux-foundation.org> In-Reply-To: <631a7206afc2_166f29413@dwillia2-xfh.jf.intel.com.notmuch> References: <20220829212918.4039240-1-dave@stgolabs.net> <20220907153016.f7cd4f42a337fedae8319f28@linux-foundation.org> <631940536d040_2736529437@dwillia2-xfh.jf.intel.com.notmuch> <20220908141319.00000f01@huawei.com> <631a7206afc2_166f29413@dwillia2-xfh.jf.intel.com.notmuch> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 Thu, 8 Sep 2022 15:51:50 -0700 Dan Williams wrote: > Jonathan Cameron wrote: > > On Wed, 7 Sep 2022 18:07:31 -0700 > > Dan Williams wrote: > > > > > Andrew Morton wrote: > > > > I really dislike the term "flush". Sometimes it means writeback, > > > > sometimes it means invalidate. Perhaps at other times it means > > > > both. > > > > > > > > Can we please be very clear in comments and changelogs about exactly > > > > what this "flush" does. With bonus points for being more specific in the > > > > function naming? > > > > > > > > > > That's a good point, "flush" has been cargo-culted along in Linux's > > > cache management APIs to mean write-back-and-invalidate. In this case I > > > think this API is purely about invalidate. It just so happens that x86 > > > has not historically had a global invalidate instruction readily > > > available which leads to the overuse of wbinvd. > > > > > > It would be nice to make clear that this API is purely about > > > invalidating any data cached for a physical address impacted by address > > > space management event (secure erase / new region provision). Write-back > > > is an unnecessary side-effect. > > > > > > So how about: > > > > > > s/arch_flush_memregion/cpu_cache_invalidate_memregion/? > > > > Want to indicate it 'might' write back perhaps? > > So could be invalidate or clean and invalidate (using arm ARM terms just to add > > to the confusion ;) > > > > Feels like there will be potential race conditions where that matters as we might > > force stale data to be written back. > > > > Perhaps a comment is enough for that. Anyone have the "famous last words" feeling? > > Is "invalidate" not clear that write-back is optional? Maybe not. Yes, I'd say that "invalidate" means "dirty stuff may of may not have been written back". Ditto for invalidate_inode_pages2(). > Also, I realized that we tried to include the address range to allow for > the possibility of flushing by virtual address range, but that > overcomplicates the use. I.e. if someone issue secure erase and the > region association is not established does that mean that mean that the > cache invalidation is not needed? It could be the case that someone > disables a device, does the secure erase, and then reattaches to the > same region. The cache invalidation is needed, but at the time of the > secure erase the HPA was unknown. > > All this to say that I feel the bikeshedding will need to continue until > morale improves. > > I notice that the DMA API uses 'sync' to indicate, "make this memory > consistent/coherent for the CPU or the device", so how about an API like > > memregion_sync_for_cpu(int res_desc) > > ...where the @res_desc would be IORES_DESC_CXL for all CXL and > IORES_DESC_PERSISTENT_MEMORY for the current nvdimm use case. "sync" is another of my pet peeves ;) In filesystem land, at least. Does it mean "start writeback and return" or does it mean "start writeback, wait for its completion then return".