Re: [PATCH 1/2] arm64: Reduce add_map() complexity

Marc Zyngier
2024-03-09T09:53:16Z

On Fri, 08 Mar 2024 20:22:53 +0000,
Fabio Estevam <festevam@gmail.com> wrote:
>
> Hi Paul and Tom,
>
> On Tue, Feb 14, 2023 at 10:38 AM Ying-Chun Liu (PaulLiu)
> <paul.liu@linaro.org> wrote:
> >
> > From: Marc Zyngier <maz@kernel.org>
> >
> > In the add_map() function, for each level it populates, it iterates from
> > the root of the PT tree, making it ineficient if a mapping needs to occur
> > past level 1.
> >
> > Instead, replace it with a recursive (and much simpler) algorithm
> > that keeps the complexity as low as possible. With this, mapping
> > 512GB at level 2 goes from several seconds down to not measurable
> > on an A55 machine.
> >
> > We keep the block mappings at level 1 for now though.
> >
> > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
> > [ Paul: pick from the Android tree. Fixup Pierre's commit. Rebase to the
> > upstream ]
> > Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
> > Cc: Tom Rini <trini@konsulko.com>
> > Link: https://android.googlesource.com/platform/external/u-boot/+/96ad729cf4cab53bdff8222bb3eb256f38b5c3a6
> > Link: https://android.googlesource.com/platform/external/u-boot/+/6be9330601d81545c7c941e3609f35bf68a09059
>
> I know this is an old thread, but this commit causes the following
> boot regression on a colibri-imx8qxp board:
>
> U-Boot 2024.04-rc3-00070-gecc9298a893b (Mar 08 2024 - 17:15:31 -0300)
>
> CPU: NXP i.MX8QXP RevC A35 at 1200 MHz at 51C
>
> DRAM: 2 GiB
> "Error" handler, esr 0xbf000000

SError. Not good.

> elr: 0000000080020914 lr : 00000000800209c0 (reloc)
> elr: 00000000ffec4914 lr : 00000000ffec49c0
> x0 : 0060000070800401 x1 : 0000000070000000
> x2 : 0000000010000000 x3 : 0000000000000002
> x4 : 0000000040000000 x5 : 0060000000000401
> x6 : 0000000000000c00 x7 : 00000000fff45140
> x8 : 0060000000000000 x9 : 00000000fff45100
> x10: 000000000a200023 x11: 0000000000000002
> x12: 0000000000000002 x13: 00000000800a10e8
> x14: 00000000ffffffff x15: 00000000ffec4cb8
> x16: 0000000080056a88 x17: 0000000000000000
> x18: 00000000fd6c1d70 x19: 000000000f600000
> x20: 0000000000000000 x21: 0060000000000401
> x22: 0000000070a00000 x23: 0000000000200000
> x24: 0000000040000c28 x25: 00000000001fffff
> x26: 0000000000000003 x27: 0000000070a00000
> x28: 0000000000000002 x29: 00000000fd6bbfd0
>
> Code: 1100047a a90573fb aa0103fb 2a0303fc (b5000113)
> Resetting CPU ...
>
> resetting ...
>
> Reverting this commit on top of master fixes the boot regression.
>
> Any ideas?

It would be good to narrow down which access is generating this. It is
an asynchronous error, so the code above won't help.

Alternatively, and if you are sure that this is due to this change,
dumping the page tables and comparing them before and after would
help.

Thanks,

M.

--
Without deviation from the norm, progress is not possible.