All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Wei Wang <wei.w.wang@hotmail.com>
Cc: "suravee.suthikulpanit@amd.com" <suravee.suthikulpanit@amd.com>,
	"thomas.lendacky@amd.com" <thomas.lendacky@amd.com>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"kevin.tian@intel.com" <kevin.tian@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>
Subject: Re: [PATCH v1] iommu/amd: Set C-bit only for RAM-backed PTEs in IOMMU page tables
Date: Fri, 24 Oct 2025 11:34:23 -0300	[thread overview]
Message-ID: <20251024143423.GF847003@nvidia.com> (raw)
In-Reply-To: <SI2PR01MB43936BE606220BBABCFA30DCDCF1A@SI2PR01MB4393.apcprd01.prod.exchangelabs.com>

On Fri, Oct 24, 2025 at 02:23:54PM +0000, Wei Wang wrote:
> > Again we should not be trying to guess if something is "ram" or not
> > deep inside the iommu code. We have IOMMU_MMIO specifically to tell
> > the iommu if it is ram or not.
> 
> Sorry I think my main confusion here is why this is considered a ‘guess’ of RAM.
> The function page_is_ram() clearly returns whether it is RAM, right? 

IIRC it is not reliable. We have a lot of things in modern systems
that are cachable ram-like objects that page_is_ram() may or may not
return true on.

Further, page_is_ram is very expensive:

int __weak page_is_ram(unsigned long pfn)
{
        return walk_system_ram_range(pfn, 1, NULL, __is_ram) == 1;

We really don't want to be doing something like that for every IOMMU
PTE.

For your immediate problem IOMMU_MMIO is better, but broadly I think
this will need some attention later. I'm not sure how something like
CXL cachable ram is supposed to work through these APIs, or if it
should have the C bit set.

Jason

      reply	other threads:[~2025-10-24 14:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-23 15:15 [PATCH v1] iommu/amd: Set C-bit only for RAM-backed PTEs in IOMMU page tables Wei Wang
2025-10-23 16:01 ` Jason Gunthorpe
2025-10-24  3:05   ` Wei Wang
2025-10-24 11:40     ` Jason Gunthorpe
2025-10-24 14:23       ` Wei Wang
2025-10-24 14:34         ` Jason Gunthorpe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251024143423.GF847003@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=thomas.lendacky@amd.com \
    --cc=wei.w.wang@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.