On 4/28/23 17:38, Kirill A. Shutemov wrote: > BTW, I think the static check can be relaxed. Checking size against > PAGE_SIZE is rather conservative: there's 8 TB (or 4 PB for 5-level > paging) guard hole at the begging of kernel address space. Whatever we relax it to, let's make sure we get a note in Documentation/x86/x86_64/mm.rst. But that's totally minor and we can fix it up later. Have anyone seen any actual code generation difference between: return (long)ptr >= 0; and return !((unsigned long)ptr & (1UL<<(BITS_PER_LONG-1))); ? I'm seeing gcc generate the same code for both the <=PAGE_SIZE side and the 'sum' side. It's longer, but I'd rather read the explicit "check bit 63" than the positive/negative address space thing. I certainly grok both, but have to think through the "(long)ptr >= 0" check every time. I guess it also wouldn't matter as much either if we hid it in a helper like the attached patch and I didn't have to read it twice. ;)