From: Mark Rutland <mark.rutland@arm.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
linux-arm-kernel@lists.infradead.org,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
Alexander Potapenko <glider@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Dmitry Vyukov <dvyukov@google.com>,
Ard Biesheuvel <ardb@kernel.org>,
linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com
Subject: Re: [PATCH] arm64/mm: Define PTE_SHIFT
Date: Fri, 7 Mar 2025 16:09:23 +0000 [thread overview]
Message-ID: <Z8saM94ixmDNjZzV@J2N7QTR9R3.cambridge.arm.com> (raw)
In-Reply-To: <c3dddb6f-dce1-45a6-b5f1-1fd247c510ab@arm.com>
On Fri, Mar 07, 2025 at 02:50:56PM +0530, Anshuman Khandual wrote:
> On 3/7/25 14:37, Ryan Roberts wrote:
> > On 07/03/2025 05:08, Anshuman Khandual wrote:
> >> #define EARLY_LEVEL(lvl, lvls, vstart, vend, add) \
> >> - (lvls > lvl ? EARLY_ENTRIES(vstart, vend, SWAPPER_BLOCK_SHIFT + lvl * (PAGE_SHIFT - 3), add) : 0)
> >> + (lvls > lvl ? EARLY_ENTRIES(vstart, vend, SWAPPER_BLOCK_SHIFT + \
> >> + lvl * (PAGE_SHIFT - PTE_SHIFT), add) : 0)
> >
> > nit: not sure what style guide says, but I would indent this continuation an
> > extra level.
>
> IIUC - An indentation is not normally required with a line continuation although
> the starting letter should match the starting letter in the line above but after
> the '(' (if any).
Regardless of indenttation, the existing code is fairly hard to read,
and I reckon it'd be better to split up, e.g.
| /* Number of VA bits resolved by a single translation table level */
| #define PTDESC_TABLE_SHIFT (PAGE_SHIFT - PTDESC_ORDER)
|
| #define __EARLY_LEVEL(lvl, vstart, vend, add) \
| EARLY_ENTRIES(vstart, vend, SWAPPER_BLOCK_SHIFT + lvl * PTDESC_TABLE_SHIFT, add)
|
| #define EARLY_LEVEL(lvl, lvls, vstart, vend, add) \
| ((lvls) > (lvl) ? __EARLY_LEVEL(lvl, vstart, vend, add) : 0)
... and ignoring the use of _SHIFT vs _ORDER, I think that structure is
far more legible.
With that, we can fold EARLY_ENTRIES() and __EARLY_LEVEL() together and
move the 'add' into EARLY_LEVEL(), e.g.
| /* Number of VA bits resolved by a single translation table level */
| #define PTDESC_TABLE_SHIFT (PAGE_SHIFT - PTDESC_ORDER)
|
| #define EARLY_ENTRIES(lvl, vstart, vend) \
| (SPAN_NR_ENTRIES(vstart, vend, SWAPPER_BLOCK_SHIFT + lvl * PTDESC_TABLE_SHIFT))
|
| #define EARLY_LEVEL(lvl, lvls, vstart, vend, add) \
| ((lvls) > (lvl) ? EARLY_ENTRIES(lvl, vstart, vend) + (add) : 0)
... which I think makes the 'add' a bit easier to understand too.
Mark.
prev parent reply other threads:[~2025-03-07 16:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 5:08 Anshuman Khandual
2025-03-07 7:38 ` Ard Biesheuvel
2025-03-07 8:36 ` Anshuman Khandual
2025-03-07 9:07 ` Ryan Roberts
2025-03-07 9:20 ` Anshuman Khandual
2025-03-07 11:16 ` Ard Biesheuvel
2025-03-07 16:09 ` Mark Rutland [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=Z8saM94ixmDNjZzV@J2N7QTR9R3.cambridge.arm.com \
--to=mark.rutland@arm.com \
--cc=andreyknvl@gmail.com \
--cc=anshuman.khandual@arm.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ryabinin.a.a@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=will@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
all inboxes | Powered by JetHome®