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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DCBBCA0EC0 for ; Mon, 11 Aug 2025 09:30:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1077157.1438229 (Exim 4.92) (envelope-from ) id 1ulOqq-0004dZ-A9; Mon, 11 Aug 2025 09:29:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1077157.1438229; Mon, 11 Aug 2025 09:29:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ulOqq-0004dS-6G; Mon, 11 Aug 2025 09:29:56 +0000 Received: by outflank-mailman (input) for mailman id 1077157; Mon, 11 Aug 2025 09:29:54 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ulOqo-0004dM-TO for xen-devel@lists.xenproject.org; Mon, 11 Aug 2025 09:29:54 +0000 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [2a00:1450:4864:20::634]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id bcbe3934-7695-11f0-a325-13f23c93f187; Mon, 11 Aug 2025 11:29:53 +0200 (CEST) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-af968aa2de4so760406866b.1 for ; Mon, 11 Aug 2025 02:29:53 -0700 (PDT) Received: from [192.168.1.5] (user-109-243-64-38.play-internet.pl. [109.243.64.38]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-af91dfd4b31sm1960350966b.85.2025.08.11.02.29.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Aug 2025 02:29:52 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: bcbe3934-7695-11f0-a325-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754904593; x=1755509393; darn=lists.xenproject.org; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=ygEu8Zq34Qj+4eE6Zo2ZjMIiW9SUV/Kk87MPF/tT2VY=; b=Se+fbOdXSRtnjVY93xfKRTAdkNeKO7w5QdML5nrEyWeBsIpGtYplrMxyklTGRO62DL FtvHnvv6XEclmlvMrlt3SMUpWrL96jzAFtp3GkC/hF+4tSdw1NgieFFS7butWkT19CtI SgEPXil/4l8X3w6iCdb+aQ2fvOvUy5IwhOoBu0IZcbgEW+I22BqjFbP/FFEocZrCFyOH m4pRxT+Nfp1FEJUorD2R3q+oF+l3/qporEk2yvaoDdV20dtuPzyj1cMgFvKwvDqX6fny Jff4yx6C4Wn8sd7mQlskzgoPjuHJa7C1NLt8jBxb4b7LfKCJmsyDcCbdKmjMrfJ70963 M63w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754904593; x=1755509393; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=ygEu8Zq34Qj+4eE6Zo2ZjMIiW9SUV/Kk87MPF/tT2VY=; b=Clh9/46Wu5c5b8zCHYtV93sxwu5Bbb59iBq+mvoUs36LCG9a8ZrAqgXaCEuncL0ck6 XAN3EXc78Xr51S2sa+2lN27ittKlU0OTGStmm1D2vK8uons1y25hYvbs3bBY4RPVIODE XU+3b5DesxS/q7ARQIS17EetI0JfCvVUZ3si/lGOpVEuhdMTcYPnRpytCIJVEeblmK5F brOTDX9tgj5ZdnLAphy7Vz1GFrSHR8loDyLR0QlkOg3aHSwzzaHLy3MQNfOKNZIzLYI4 lS3izbo0W7Es8VWrE0nriao9gSKmr5oKfxu40idJNSExlI+Npr1nrWd66eA6zu53fEtj mtrA== X-Forwarded-Encrypted: i=1; AJvYcCVKJMqVJDQh6kVE1N7Es0aXUO0qsiXBm6Ri1x5czDPKvScCxVLHA+cvtnla9rvHSiDe0T4Pfwnlt1g=@lists.xenproject.org X-Gm-Message-State: AOJu0YzJt+sF+hzl8dV4nHh5j3N72eqShwJi4aM0ZXU1sh0Lo9B26pcf Xs1OSaUGhVUPHvpYUrqPMiXKuoSIvk1yH477P48/tcVaqD/W0+XmUCEL X-Gm-Gg: ASbGncuqRPurHH/WgFrEpCepcL7+sM5xkkb5yPmr6pCgBnBOhJUrEcveFIwPS7s15qx NCGLTphepTPf9+NjcCIAggU2QFDhrQ+yfexoR9sU4ehWjBlpQKMb8JnbkKyf0Fl4ZVNvQMZoE3P GFcbkkgS95IsMuW6+FdlKsTOi5tu0zUbLcof7U0/LkIW9/cswcVq8cPC3IJ3o5/dURyZ+w3p6e+ +cB+xMXooZ/N4PFG+bxbBN9uOcc3neCaHlP6E7Jeq4pYTa02/YWtcNYwnccVdoUponYVNbFZUxN 9k++znbnnOdehT+/QiV3PtYU2MDM2dcGk2KW6d80gXTdJTK++qJ4E1WB/8GvYh9mTldz0741w6k SsiAQzwyPodXN6UfxkrNkfd1NFnmw8NTNB02mjk+FthsJZYj1BdDFxf0heUBiwjuAE/M6xcU= X-Google-Smtp-Source: AGHT+IFd8UJ5bwzo5FO2pkFNIF2c/faOTe1hNAdhQI7m35AbUmaa/g9grOw+c3n8D7pUpk1qvlr0yw== X-Received: by 2002:a17:906:730a:b0:af9:c31c:eeca with SMTP id a640c23a62f3a-af9c6546458mr1234671566b.48.1754904593108; Mon, 11 Aug 2025 02:29:53 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------ZP86uGEkdA3IPxgR203hpA6P" Message-ID: <89787fe2-3eea-44b7-ad38-82d0d09be06f@gmail.com> Date: Mon, 11 Aug 2025 11:29:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 11/20] xen/riscv: implement function to map memory in guest p2m To: Jan Beulich Cc: Alistair Francis , Bob Eshleman , Connor Davis , Anthony PERARD , Michal Orzel , Julien Grall , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , xen-devel@lists.xenproject.org, Andrew Cooper References: <31c75a64-8b69-47ac-9e08-6010fa6cfb9c@gmail.com> Content-Language: en-US From: Oleksii Kurochko In-Reply-To: This is a multi-part message in MIME format. --------------ZP86uGEkdA3IPxgR203hpA6P Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 8/11/25 9:28 AM, Jan Beulich wrote: > On 08.08.2025 15:46, Oleksii Kurochko wrote: >> On 8/5/25 5:20 PM, Jan Beulich wrote: >>> On 31.07.2025 17:58, Oleksii Kurochko wrote: >>>> +/* Unlock the flush and do a P2M TLB flush if necessary */ >>>> +void p2m_write_unlock(struct p2m_domain *p2m) >>>> +{ >>>> + /* >>>> + * The final flush is done with the P2M write lock taken to avoid >>>> + * someone else modifying the P2M wbefore the TLB invalidation has >>> Nit: Stray 'w'. >>> >>>> + * completed. >>>> + */ >>>> + p2m_tlb_flush_sync(p2m); >>> Wasn't the plan to have this be conditional? >> Not really, probably, I misunderstood you before. >> >> Previously, I only had|p2m_force_tlb_flush_sync()| here, instead of >> |p2m_tlb_flush_sync()|, and the latter includes a condition check on >> |p2m->need_flush|. > Just to re-iterate my point: Not every unlock will require a flush. Hence > why I expect the flush to be conditional upon there being an indication > that some change was done that requires flushing. > The flush is actually conditional; the condition is inside |p2m_tlb_flush_sync()|: void p2m_tlb_flush_sync(struct p2m_domain *p2m) { if ( p2m->need_flush ) p2m_force_tlb_flush_sync(p2m); } ~ Oleksii --------------ZP86uGEkdA3IPxgR203hpA6P Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit


On 8/11/25 9:28 AM, Jan Beulich wrote:
On 08.08.2025 15:46, Oleksii Kurochko wrote:
On 8/5/25 5:20 PM, Jan Beulich wrote:
On 31.07.2025 17:58, Oleksii Kurochko wrote:
+/* Unlock the flush and do a P2M TLB flush if necessary */
+void p2m_write_unlock(struct p2m_domain *p2m)
+{
+    /*
+     * The final flush is done with the P2M write lock taken to avoid
+     * someone else modifying the P2M wbefore the TLB invalidation has
Nit: Stray 'w'.

+     * completed.
+     */
+    p2m_tlb_flush_sync(p2m);
Wasn't the plan to have this be conditional?
Not really, probably, I misunderstood you before.

Previously, I only had|p2m_force_tlb_flush_sync()| here, instead of
|p2m_tlb_flush_sync()|, and the latter includes a condition check on
|p2m->need_flush|.
Just to re-iterate my point: Not every unlock will require a flush. Hence
why I expect the flush to be conditional upon there being an indication
that some change was done that requires flushing.

The flush is actually conditional; the condition is inside
p2m_tlb_flush_sync():
  void p2m_tlb_flush_sync(struct p2m_domain *p2m)
  {
    if ( p2m->need_flush )
      p2m_force_tlb_flush_sync(p2m);
  }

~ Oleksii
--------------ZP86uGEkdA3IPxgR203hpA6P--