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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99237C7EE32 for ; Thu, 26 Jun 2025 09:55:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EF698D0005; Thu, 26 Jun 2025 05:55:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 07A9D8D0001; Thu, 26 Jun 2025 05:55:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E833B8D0005; Thu, 26 Jun 2025 05:55:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CE4568D0001 for ; Thu, 26 Jun 2025 05:55:44 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D4BB3104CF1 for ; Thu, 26 Jun 2025 09:55:43 +0000 (UTC) X-FDA: 83597094966.11.75D3CAB Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf03.hostedemail.com (Postfix) with ESMTP id A619F20006 for ; Thu, 26 Jun 2025 09:55:40 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of jonathan.cameron@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=jonathan.cameron@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750931741; a=rsa-sha256; cv=none; b=2XHyOXOxx23qxHJ2+TH0AnHmvSwHkrYS1qm1kMPPxBqHe5Pu0IHzq+PCUUPFgyUIC5E5cl PpFxOy59XYQioIIMt+McqDe9R7wQdZ7/BxjBDFh7J288JQAD/XBerckIvbZmQttbm3zU01 8noYv2wl5k/6Ncuzt41KR3znBODGdZc= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of jonathan.cameron@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=jonathan.cameron@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750931741; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n0X9odSBquWZgGrWGhDzkeU3VtuQN/OVuUzzgJaBZJo=; b=bFlyGCZAai6SX8qDqpjZgVEeo7rtuYqXvtgNyirBjncu20xzFYHWLIKlA5KExbTtKjswBF Qxy08ggG2efaJr3N8XbBTu0qDZs9A6ORZC50rN/TfB1bLYIL91HDxTwJH4PIXMNcoWmCwD 4gh/STwb7Fq8Df437gxm7BJk5Od9rtc= Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4bSYvB2ts6z6M508; Thu, 26 Jun 2025 17:54:46 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 610D61402EC; Thu, 26 Jun 2025 17:55:33 +0800 (CST) Received: from localhost (10.203.177.66) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 26 Jun 2025 11:55:32 +0200 Date: Thu, 26 Jun 2025 10:55:30 +0100 From: Jonathan Cameron To: Peter Zijlstra , CC: "H. Peter Anvin" , Catalin Marinas , , , , , , , , Will Deacon , Dan Williams , Davidlohr Bueso , Yicong Yang , Yushan Wang , Lorenzo Pieralisi , Mark Rutland , Dave Hansen , Thomas Gleixner , "Ingo Molnar" , Borislav Petkov , , Andy Lutomirski Subject: Re: [PATCH v2 0/8] Cache coherency management subsystem Message-ID: <20250626105530.000010be@huawei.com> In-Reply-To: <20250625180343.000020de@huawei.com> References: <20250624154805.66985-1-Jonathan.Cameron@huawei.com> <20250625085204.GC1613200@noisy.programming.kicks-ass.net> <20250625093152.GZ1613376@noisy.programming.kicks-ass.net> <20250625180343.000020de@huawei.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.203.177.66] X-ClientProxiedBy: lhrpeml500001.china.huawei.com (7.191.163.213) To frapeml500008.china.huawei.com (7.182.85.71) X-Stat-Signature: xsmtxx6iu5mgi7ooeypmnrw1g56dafxo X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A619F20006 X-Rspam-User: X-HE-Tag: 1750931740-6698 X-HE-Meta: U2FsdGVkX1+SxiUz99uydVxuKEEadSplgm3j5GGlg3stqZy0agLiUOdNqcr2c6R7bxRnmZYvpdQFinYRQ57EeSLS4Awfep7dkk9ZRAB/YOlDNDOBAaB3KKHrSb2Pzi+6hMbdFHvi0/6REfNYWcVMJ/EnHt43G/Ou4q3o2y9PJ4eU1CrULkr1ceLHvBAgRvSyMv1PISA/eyrmQFKBtv9nf9tZu5Czl3vWxMGwA+T8uAEwtWOkTHUpC1JAwjKPTv1oiZweoDOsbX2Li4JAJbNWRBEctS8ZrjgyGfgkia1N9FlQ3sjHZ4lnpPl21MN4jX6bq0yzlwl7sMB4hkLPMJ06TdhlJb5pfiH8vHZNUkt7NAHsPppRv/lvDdPdOHKuD8Bjz4sEZ4vzNwwcaMBemcOs3pMpw2F4+BAQMMeNWFztCgLMg9Jpy5/3JgMgYdQlhgNKULI6hEcjfCNBXxyHkbAiA+7xf49P7b6/sWjO6/GWKP5j8ylsfD77VQgKCqYXSpv095fRIihV+iBMtb6Pc7DjhmQr64DkifVmzlz5WfGSczCy3sqY4su0PS+amA8rw0qoiwHqB3WH4CXdE67eTXhzzzVQKVfxp4c0emer0c6uPZXKpsOTEdUrZt8dSJSOy8vhi4/XAOvT0CNvF7SYam3kUFbIP1wld9ZrrBalvY/aNh5cdQcju0WU2AAz+AbbGky5f3DLBFW/mmPzIGF/3tZegORfl3ik1gn2TuDVQSASrD8YYRXe6X1FUj1AJzc6/BwnEpUeu7nrgkCxc/TVOIyv3kcr5SgajjXEjU/yoiZnDcIXO7t49upjSjHTstP1x40otmd5M1GlhmOOThHo7oshMiS4hkHsoWixfMGEe4tBCs1uXU3a4WOQmtNkyFwm/gO9f5TIe4A33bQ7QOH5wdTwlUtWX/EDyYurSYHI8yiODlGLYzeyvv6SbEnc0qpUpG2Vfdlx5r5gtDB8Xjx1pnU Xe8v28op Wvto5WjPjGcjDYT6uk30/1i6Fg61LW3yJEpCUdGow8g+cSiDYhQMD+vhOGHHn4pI5D9DRYEdCi+URwz0JRewWrHJq5FFnQ/uEWxYVnQ3XvxNzwgFcCF5JgloaSfgIbr36KM4oKgjTRdFcDtv4O6DmT6Nf3UzvucBFCKcVWtlnrmoay9tz1DuUgtDPeFd2MxcNJMyctpZA0ZgPwEsdfyYc8gtws4k5HMI3wiZ5ytSipU+HQYeujwB109mly8tvowFIvf2NLUVqyoWlQxC4lVjlGyvg+vZtkZsMOGbsu8cLbPVoCl0MWb+QFg2a8Z5C91sbr2KwZdhWpcuS7CfcV6RkS7+POJrF45Um8yI953OaH/mUKoo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, 25 Jun 2025 18:03:43 +0100 Jonathan Cameron wrote: > On Wed, 25 Jun 2025 11:31:52 +0200 > Peter Zijlstra wrote: > > > On Wed, Jun 25, 2025 at 02:12:39AM -0700, H. Peter Anvin wrote: > > > On June 25, 2025 1:52:04 AM PDT, Peter Zijlstra wrote: > > > >On Tue, Jun 24, 2025 at 04:47:56PM +0100, Jonathan Cameron wrote: > > > > > > > >> On x86 there is the much loved WBINVD instruction that causes a write back > > > >> and invalidate of all caches in the system. It is expensive but it is > > > > > > > >Expensive is not the only problem. It actively interferes with things > > > >like Cache-Allocation-Technology (RDT-CAT for the intel folks). Doing > > > >WBINVD utterly destroys the cache subsystem for everybody on the > > > >machine. > > > > > > > >> necessary in a few corner cases. > > > > > > > >Don't we have things like CLFLUSH/CLFLUSHOPT/CLWB exactly so that we can > > > >avoid doing dumb things like WBINVD ?!? > > > > > > > >> These are cases where the contents of > > > >> Physical Memory may change without any writes from the host. Whilst there > > > >> are a few reasons this might happen, the one I care about here is when > > > >> we are adding or removing mappings on CXL. So typically going from > > > >> there being actual memory at a host Physical Address to nothing there > > > >> (reads as zero, writes dropped) or visa-versa. > > > > > > > >> The > > > >> thing that makes it very hard to handle with CPU flushes is that the > > > >> instructions are normally VA based and not guaranteed to reach beyond > > > >> the Point of Coherence or similar. You might be able to (ab)use > > > >> various flush operations intended to ensure persistence memory but > > > >> in general they don't work either. > > > > > > > >Urgh so this. Dan, Dave, are we getting new instructions to deal with > > > >this? I'm really not keen on having WBINVD in active use. > > > > > > > > > > WBINVD is the nuclear weapon to use when you have lost all notion of > > > where the problematic data can be, and amounts to a full reset of the > > > cache system. > > > > > > WBINVD can block interrupts for many *milliseconds*, system wide, and > > > so is really only useful for once-per-boot type events, like MTRR > > > initialization. > > > > Right this... But that CXL thing sounds like that's semi 'regular' to > > the point that providing some infrastructure around it makes sense. This > > should not be. > > I'm fully on board with the WBINVD issues (and hope for something new for > the X86 world). However, this particular infrastructure (for those systems > that can do so) is about pushing the problem and information to where it > can be handled in a lot less disruptive fashion. It can take 'a while' but > we are flushing only cache entries in the requested PA range. Other than > some potential excess snoop traffic if the coherency tracking isn't precise, > there should be limited affect on the rest of the system. > > So, for the systems I particularly care about, the CXL case isn't that bad. > > Just for giggles, if you want some horror stories the (dropped) ARM PSCI > spec provides for approaches that require synchronization of calls across > all CPUs. > > "CPU Rendezvous" in the attributes of CLEAN_INV_MEMREGION requires all > CPUs to make a call within an impdef (discoverable) timeout. > https://developer.arm.com/documentation/den0022/falp1/?lang=en > > I gather no one actually needs that on 'real' systems - that is systems > where we actually need to do these flushes! The ACPI 'RFC' doesn't support > that delight. Seems I introduced some confusion. Let me try summarizing: 1. x86 has a potential feature gap. From a CXL ecosystem point of view I'd like to see that gap closed. (Inappropriate for me to make any proposals on how to do it on that architecture). 2. This patch set has nothing to do with x86 (beyond modifying a function signature). The hardware it is targeting avoids many of the issues around WBINVD. The solution is not specific to ARM64, though the implementation I care about is on an ARM64 implementation. Right now, on x86 we have a functionally correct solution, this patch set adds infrastructure and 2 implementations to provide similar for other architectures. Jonathan