Messages in this thread | | | Date | Mon, 20 Jul 2015 11:27:16 +0800 | From | Pan Xinhui <> | Subject | Re: [PATCH] x86/mm/pat: let level meaningful even NULL return in, lookup_address_in_pgd |
| |
hi, tglx thanks for your reply.
On 2015年07月17日 22:50, Thomas Gleixner wrote: > On Tue, 14 Jul 2015, Pan Xinhui wrote: >> If pmd or pud is not set, we may set a wrong page mapping level. > > No. The behaviour is simply undefined, if the return value of the > function is NULL. > > So what you are trying to do is to make the level information accurate > even for the failure case. > yes. it's good to report level information. then we can handle some errors.
>> We know *address* belongs to *pud*, however for some reasons *pmd* is >> NULL. For example, this address has no physical pages mapped. What we >> could benefit from this patch are below: >> 1) We can walk memory range easier. >> If addressA passed to lookup_address(), and NULL returned. We can pass >> addressA + level_to_size(level) to lookup_address() in next loop. >> ... >> if (!pte) { >> /* level_to_size has not been implemented in upstream*/ >> address += level_to_size(level); >> continue; >> } > > This example is completely useless because we do not see how the loop > itself looks like and how that improves anything. The proper way to do > this is to post: > > - the patch which changes the function > - another patch which makes use of the change > > But so far I cannot see any reason why we want to change it. > sorry for that. There are some debug patches protected. I will try to make a simple example in other mails.
>> ... >> 2) keep same behavior because level is set to PG_LEVEL_4K even when pte >> is NULL. > > And what's the actual benefit of #2? Keeping the same behaviour is a > requirement if you don't want to break any users of that function. > agree with you. :) I did not explain it in correct ways. When pte is NULL, lookup_address will return NULL on failure. however the level is correct and set to PG_LEVEL_4K. So what I am trying to do is that if lookup_address return NULL on *pud* or *pmd* NULL failure, level is still correct or more correct. A correct level information is very useful when we walk a large range of memory.
thanks xinhui
> Thanks, > > tglx >
| |