From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anshuman Khandual Date: Fri, 25 Oct 2019 08:36:14 +0000 Subject: Re: [PATCH V7] mm/debug: Add tests validating architecture page table helpers Message-Id: <763d58b4-f532-0bba-bf2b-71433ac514fb@arm.com> List-Id: References: <69256008-2235-4AF1-A3BA-0146C82CCB93@lca.pw> <3cfec421-4006-4159-ca32-313ff5196ff9@c-s.fr> In-Reply-To: <3cfec421-4006-4159-ca32-313ff5196ff9@c-s.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: Christophe Leroy , Qian Cai Cc: Mark Rutland , linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org, Peter Zijlstra , James Hogan , Tetsuo Handa , Heiko Carstens , Michal Hocko , linux-mm@kvack.org, Dave Hansen , Paul Mackerras , sparclinux@vger.kernel.org, Thomas Gleixner , linux-s390@vger.kernel.org, Michael Ellerman , x86@kernel.org, Russell King - ARM Linux , Matthew Wilcox , Steven Price , Jason Gunthorpe , Gerald Schaefer , linux-snps-arc@lists.infradead.org, Ingo Molnar , Kees Cook , Masahiro Yamada , Mark Brown , "Kirill A . Shutemov" , Dan Williams , Vlastimil Babka , linux-arm-kernel@lists.infradead.org, Sri Krishna chowdary , Ard Biesheuvel , Greg Kroah-Hartman , linux-mips@vger.kernel.org, Ralf Baechle , linux-kernel@vger.kernel.org, Paul Burton , Mike Rapoport , Vineet Gupta , Martin Schwidefsky , Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" , Mike Kravetz On 10/25/2019 12:41 PM, Christophe Leroy wrote: > > > Le 25/10/2019 à 07:52, Qian Cai a écrit : >> >> >>> On Oct 24, 2019, at 11:45 PM, Anshuman Khandual wrote: >>> >>> Nothing specific. But just tested this with x86 defconfig with relevant configs >>> which are required for this test. Not sure if it involved W=1. >> >> No, it will not. It needs to run like, >> >> make W=1 -j 64 2>/tmp/warns >> > > Are we talking about this peace of code ? > > +static unsigned long __init get_random_vaddr(void) > +{ > +    unsigned long random_vaddr, random_pages, total_user_pages; > + > +    total_user_pages = (TASK_SIZE - FIRST_USER_ADDRESS) / PAGE_SIZE; > + > +    random_pages = get_random_long() % total_user_pages; > +    random_vaddr = FIRST_USER_ADDRESS + random_pages * PAGE_SIZE; > + > +    WARN_ON((random_vaddr > TASK_SIZE) || > +        (random_vaddr < FIRST_USER_ADDRESS)); > +    return random_vaddr; > +} > + > > ramdom_vaddr is unsigned, > random_pages is unsigned and lower than total_user_pages > > So the max value random_vaddr can get is FIRST_USER_ADDRESS + ((TASK_SIZE - FIRST_USER_ADDRESS - 1) / PAGE_SIZE) * PAGE_SIZE = TASK_SIZE - 1 > And the min value random_vaddr can get is FIRST_USER_ADDRESS (that's when random_pages = 0) That's right. > > So the WARN_ON() is just unneeded, isn't it ? It is just a sanity check on possible vaddr values before it's corresponding page table mappings could be created. If it's worth to drop this in favor of avoiding these unwanted warning messages on x86, will go ahead with it as it is not super important. > > Christophe >