Re: [GIT PULL] MIPS changes for v5.8-rc1

From: Linus Torvalds
Date: Wed Jun 03 2020 - 21:24:11 EST


On Wed, Jun 3, 2020 at 6:11 PM maobibo <maobibo@xxxxxxxxxxx> wrote:
>
> On architectures that manage the access bit in hardware, access bit is
> set at the beginning even if there is no memory access. On MIPS system
> access bit is not set at the beginning, it is set in page fault handling.

I had a hard time parsing that.

But I think you mean that the access bit is already set in the pgprot
bits on other architectures. And yeah, you seem to be right for at
least x86.

So yes, it seems unnecessary to set the accessed bit again, when the
accessed bit is already there from the pgprot bits. Good point.

> I am investigating why access bit is not set at the
> beginning in MIPS system.

Yeah, that does seem to be the right thing to do.

On x86, we have (for example)

#define PAGE_COPY __pg(__PP| 0|_USR|___A|__NX| 0| 0| 0)
..
#define __P010 PAGE_COPY

where that "__A" bit is the accessed bit (_PAGE_ACCESSED), just a
small internal macro to make all those line up nicely.

And that ends up being used for that protection_map[] array.

MIPS fills in the initial protection bits in protection_map[] with
dummy values, and then seems to initialize them without ever setting
the accessed bit there.

Not sure why that initialization then doesn't just add the pte_mkyoung..

Linus