From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: kernel test robot <lkp@intel.com>,
linux-mm@kvack.org, llvm@lists.linux.dev,
oe-kbuild-all@lists.linux.dev,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>,
"Mike Rapoport (IBM)" <rppt@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
x86@kernel.org, linux-m68k@lists.linux-m68k.org,
linux-fsdevel@vger.kernel.org, kasan-dev@googlegroups.com,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Dimitri Sivanich <dimitri.sivanich@hpe.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Muchun Song <muchun.song@linux.dev>,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
Miaohe Lin <linmiaohe@huawei.com>,
Dennis Zhou <dennis@kernel.org>, Tejun Heo <tj@kernel.org>,
Christoph Lameter <cl@linux-foundation.org>,
Uladzislau Rezki <urezki@gmail.com>,
Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH V2 7/7] mm: Use pgdp_get() for accessing PGD entries
Date: Thu, 19 Sep 2024 10:11:02 +0100 [thread overview]
Message-ID: <ZuvqpvJ6ht4LCuB+@shell.armlinux.org.uk> (raw)
In-Reply-To: <8f43251a-5418-4c54-a9b0-29a6e9edd879@arm.com>
On Thu, Sep 19, 2024 at 01:25:08PM +0530, Anshuman Khandual wrote:
> arm (32) platform currently overrides pgdp_get() helper in the platform but
> defines that like the exact same version as the generic one, albeit with a
> typo which can be fixed with something like this.
pgdp_get() was added to arm in eba2591d99d1 ("mm: Introduce
pudp/p4dp/pgdp_get() functions") with the typo you've spotted. It seems
it was added with no users, otherwise the error would have been spotted
earlier. I'm not a fan of adding dead code to the kernel for this
reason.
> Regardless there is another problem here. On arm platform there are multiple
> pgd_t definitions available depending on various configs but some are arrays
> instead of a single data element, although platform pgdp_get() helper remains
> the same for all.
>
> arch/arm/include/asm/page-nommu.h:typedef unsigned long pgd_t[2];
> arch/arm/include/asm/pgtable-2level-types.h:typedef struct { pmdval_t pgd[2]; } pgd_t;
> arch/arm/include/asm/pgtable-2level-types.h:typedef pmdval_t pgd_t[2];
> arch/arm/include/asm/pgtable-3level-types.h:typedef struct { pgdval_t pgd; } pgd_t;
> arch/arm/include/asm/pgtable-3level-types.h:typedef pgdval_t pgd_t;
>
> I guess it might need different pgdp_get() variants depending applicable pgd_t
> definition. Will continue looking into this further but meanwhile copied Russel
> King in case he might be able to give some direction.
That's Russel*L*, thanks.
32-bit arm uses, in some circumstances, an array because each level 1
page table entry is actually two descriptors. It needs to be this way
because each level 2 table pointed to by each level 1 entry has 256
entries, meaning it only occupies 1024 bytes in a 4096 byte page.
In order to cut down on the wastage, treat the level 1 page table as
groups of two entries, which point to two consecutive 1024 byte tables
in the level 2 page.
The level 2 entry isn't suitable for the kernel's use cases (there are
no bits to represent accessed/dirty and other important stuff that the
Linux MM wants) so we maintain the hardware page tables and a separate
set that Linux uses in the same page. Again, the software tables are
consecutive, so from Linux's perspective, the level 2 page tables
have 512 entries in them and occupy one full page.
This is documented in arch/arm/include/asm/pgtable-2level.h
However, what this means is that from the software perspective, the
level 1 page table descriptors are an array of two entries, both of
which need to be setup when creating a level 2 page table, but only
the first one should ever be dereferenced when walking the tables,
otherwise the code that walks the second level of page table entries
will walk off the end of the software table into the actual hardware
descriptors.
I've no idea what the idea is behind introducing pgd_get() and what
it's semantics are, so I can't comment further.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2024-09-19 9:12 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-17 7:31 [PATCH V2 0/7] mm: Use pxdp_get() for accessing page table entries Anshuman Khandual
2024-09-17 7:31 ` [PATCH V2 1/7] m68k/mm: Change pmd_val() Anshuman Khandual
2024-09-17 8:40 ` Ryan Roberts
2024-09-17 10:20 ` David Hildenbrand
2024-09-17 10:27 ` Ryan Roberts
2024-09-17 10:30 ` David Hildenbrand
2024-09-17 7:31 ` [PATCH V2 2/7] x86/mm: Drop page table entry address output from pxd_ERROR() Anshuman Khandual
2024-09-17 10:22 ` David Hildenbrand
2024-09-17 11:19 ` Dave Hansen
2024-09-17 11:25 ` Anshuman Khandual
2024-09-17 11:31 ` David Hildenbrand
2024-09-17 7:31 ` [PATCH V2 3/7] mm: Use ptep_get() for accessing PTE entries Anshuman Khandual
2024-09-17 8:44 ` Ryan Roberts
2024-09-17 10:28 ` David Hildenbrand
2024-09-18 6:32 ` Anshuman Khandual
2024-09-19 8:04 ` David Hildenbrand
2024-09-19 9:20 ` Anshuman Khandual
2024-09-17 7:31 ` [PATCH V2 4/7] mm: Use pmdp_get() for accessing PMD entries Anshuman Khandual
2024-09-17 10:05 ` Ryan Roberts
2024-09-18 18:57 ` kernel test robot
2024-09-19 7:21 ` Anshuman Khandual
2024-09-18 19:07 ` kernel test robot
2024-09-19 7:12 ` Anshuman Khandual
2024-09-17 7:31 ` [PATCH V2 5/7] mm: Use pudp_get() for accessing PUD entries Anshuman Khandual
2024-09-17 7:31 ` [PATCH V2 6/7] mm: Use p4dp_get() for accessing P4D entries Anshuman Khandual
2024-09-17 7:31 ` [PATCH V2 7/7] mm: Use pgdp_get() for accessing PGD entries Anshuman Khandual
2024-09-18 20:30 ` kernel test robot
2024-09-19 7:55 ` Anshuman Khandual
2024-09-19 9:11 ` Russell King (Oracle) [this message]
2024-09-19 15:48 ` Ryan Roberts
2024-09-19 17:06 ` Russell King (Oracle)
2024-09-19 17:49 ` Ryan Roberts
2024-09-19 20:25 ` Russell King (Oracle)
2024-09-20 6:57 ` Ryan Roberts
2024-09-20 9:47 ` Russell King (Oracle)
2024-09-23 15:21 ` Ryan Roberts
2024-09-25 10:05 ` [PATCH V2 0/7] mm: Use pxdp_get() for accessing page table entries Christophe Leroy
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=ZuvqpvJ6ht4LCuB+@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=arnd@arndb.de \
--cc=cl@linux-foundation.org \
--cc=david@redhat.com \
--cc=dennis@kernel.org \
--cc=dimitri.sivanich@hpe.com \
--cc=hch@infradead.org \
--cc=kasan-dev@googlegroups.com \
--cc=linmiaohe@huawei.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-mm@kvack.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=muchun.song@linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=rppt@kernel.org \
--cc=ryabinin.a.a@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=tj@kernel.org \
--cc=urezki@gmail.com \
--cc=viro@zeniv.linux.org.uk \
--cc=x86@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).