From: Joerg Roedel <joro@8bytes.org>
To: Qian Cai <cai@lca.pw>
Cc: iommu@lists.linux-foundation.org, Joerg Roedel <jroedel@suse.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] iommu/amd: Use 'unsigned long' for domain->pt_root
Date: Fri, 26 Jun 2020 10:05:40 +0200 [thread overview]
Message-ID: <20200626080539.GP3701@8bytes.org> (raw)
In-Reply-To: <20200625153720.GA1127@lca.pw>
Hi Qian,
On Thu, Jun 25, 2020 at 11:37:20AM -0400, Qian Cai wrote:
> On Thu, Jun 25, 2020 at 04:52:27PM +0200, Joerg Roedel wrote:
> > - u64 pt_root = atomic64_read(&domain->pt_root);
> > + unsigned long pt_root = domain->pt_root;
>
> The pt_root might be reload later in case of register pressure where the
> compiler decides to not store it as a stack variable, so it needs
> smp_rmb() here to match to the smp_wmb() in
> amd_iommu_domain_set_pt_root() to make the load visiable to all CPUs.
>
> Then, smp_rmb/wmb() wouldn't be able to deal with data races, so it
> needs,
>
> unsigned long pt_root = READ_ONCE(domain->pt_root);
>
> >
> > pgtable->root = (u64 *)(pt_root & PAGE_MASK);
> > pgtable->mode = pt_root & 7; /* lowest 3 bits encode pgtable mode */
> > @@ -164,7 +164,13 @@ static void amd_iommu_domain_get_pgtable(struct protection_domain *domain,
> >
> > static void amd_iommu_domain_set_pt_root(struct protection_domain *domain, u64 root)
> > {
> > - atomic64_set(&domain->pt_root, root);
> > + domain->pt_root = root;
>
> WRITE_ONCE(domain->pt_root, root);
Thanks for your review. I addressed your comments and will send an
updated version shortly.
Regards,
Joerg
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
prev parent reply other threads:[~2020-06-26 8:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 14:52 [PATCH 0/2] iommu/amd: Don't use atomic64_t for domain->pt_root Joerg Roedel
2020-06-25 14:52 ` [PATCH 1/2] iommu/amd: Add helper functions to update domain->pt_root Joerg Roedel
2020-06-25 14:52 ` [PATCH 2/2] iommu/amd: Use 'unsigned long' for domain->pt_root Joerg Roedel
2020-06-25 15:37 ` Qian Cai
2020-06-26 8:05 ` Joerg Roedel [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=20200626080539.GP3701@8bytes.org \
--to=joro@8bytes.org \
--cc=cai@lca.pw \
--cc=iommu@lists.linux-foundation.org \
--cc=jroedel@suse.de \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).