[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wj9w5NxTcJsqpvYUiL3OBOH-J3=4-vXcc3GaG_U8H-gJw@mail.gmail.com>
Date: Sat, 1 Jun 2019 09:28:54 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Christoph Hellwig <hch@....de>
Cc: Paul Burton <paul.burton@...s.com>,
James Hogan <jhogan@...nel.org>,
Yoshinori Sato <ysato@...rs.sourceforge.jp>,
Rich Felker <dalias@...c.org>,
"David S. Miller" <davem@...emloft.net>,
Nicholas Piggin <npiggin@...il.com>,
Khalid Aziz <khalid.aziz@...cle.com>,
Andrey Konovalov <andreyknvl@...gle.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>,
linux-mips@...r.kernel.org,
Linux-sh list <linux-sh@...r.kernel.org>,
sparclinux@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
Linux-MM <linux-mm@...ck.org>,
"the arch/x86 maintainers" <x86@...nel.org>,
Linux List Kernel Mailing <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 08/16] sparc64: add the missing pgd_page definition
Both sparc64 and sh had this pattern, but now that I look at it more
closely, I think your version is wrong, or at least nonoptimal.
On Sat, Jun 1, 2019 at 12:50 AM Christoph Hellwig <hch@....de> wrote:
>
> +#define pgd_page(pgd) virt_to_page(__va(pgd_val(pgd)))
Going through the virtual address is potentially very inefficient, and
might in some cases just be wrong (ie it's definitely wrong for
HIGHMEM style setups).
It would likely be much better to go through the physical address and
use "pfn_to_page()". I realize that we don't have a "pgd to physical",
but neither do we really have a "pgd to virtual", and your
"__va(pgd_val(x))" thing is not at allguaranteed to work. You're
basically assuming that "pgd_val(x)" is the physical address, which is
likely not entirely incorrect, but it should be checked by the
architecture people.
The pgd value could easily have high bits with meaning, which would
also potentially screw up the __va(x) model.
So I thgink this would be better done with
#define pgd_page(pgd) pfn_to_page(pgd_pfn(pgd))
where that "pgd_pfn()" would need to be a new (but likely very
trivial) function. That's what we do for pte_pfn().
IOW, it would likely end up something like
#define pgd_to_pfn(pgd) (pgd_val(x) >> PFN_PGD_SHIFT)
David?
Linus
Powered by blists - more mailing lists