From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EC96CA9EA0 for ; Fri, 25 Oct 2019 10:10:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1601620663 for ; Fri, 25 Oct 2019 10:10:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1601620663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9D95C6B0003; Fri, 25 Oct 2019 06:10:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 989416B0006; Fri, 25 Oct 2019 06:10:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89E256B0007; Fri, 25 Oct 2019 06:10:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0223.hostedemail.com [216.40.44.223]) by kanga.kvack.org (Postfix) with ESMTP id 6A71D6B0003 for ; Fri, 25 Oct 2019 06:10:19 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id BFADB824999B for ; Fri, 25 Oct 2019 10:10:18 +0000 (UTC) X-FDA: 76081886916.11.chalk31_1fc5a41cfd125 X-HE-Tag: chalk31_1fc5a41cfd125 X-Filterd-Recvd-Size: 5661 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Fri, 25 Oct 2019 10:10:18 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4365B28; Fri, 25 Oct 2019 03:10:17 -0700 (PDT) Received: from [10.162.41.137] (p8cg001049571a15.blr.arm.com [10.162.41.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7FC723F6C4; Fri, 25 Oct 2019 03:10:05 -0700 (PDT) Subject: Re: [PATCH V7] mm/debug: Add tests validating architecture page table helpers To: Christophe Leroy , Qian Cai Cc: linux-mm@kvack.org, Andrew Morton , Vlastimil Babka , Greg Kroah-Hartman , Thomas Gleixner , Mike Rapoport , Jason Gunthorpe , Dan Williams , Peter Zijlstra , Michal Hocko , Mark Rutland , Mark Brown , Steven Price , Ard Biesheuvel , Masahiro Yamada , Kees Cook , Tetsuo Handa , Matthew Wilcox , Sri Krishna chowdary , Dave Hansen , Russell King - ARM Linux , Michael Ellerman , Paul Mackerras , Martin Schwidefsky , Heiko Carstens , "David S. Miller" , Vineet Gupta , James Hogan , Paul Burton , Ralf Baechle , "Kirill A . Shutemov" , Gerald Schaefer , Mike Kravetz , Ingo Molnar , linux-snps-arc@lists.infradead.org, linux-mips@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org References: <69256008-2235-4AF1-A3BA-0146C82CCB93@lca.pw> <3cfec421-4006-4159-ca32-313ff5196ff9@c-s.fr> <763d58b4-f532-0bba-bf2b-71433ac514fb@arm.com> From: Anshuman Khandual Message-ID: <78d13292-0cfe-31b6-7a9c-daf7fb7f3d23@arm.com> Date: Fri, 25 Oct 2019 15:40:36 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 10/25/2019 02:22 PM, Christophe Leroy wrote: >=20 >=20 > Le 25/10/2019 =C3=A0 10:24, Anshuman Khandual a =C3=A9crit=C2=A0: >> >> >> On 10/25/2019 12:41 PM, Christophe Leroy wrote: >>> >>> >>> Le 25/10/2019 =C3=A0 07:52, Qian Cai a =C3=A9crit=C2=A0: >>>> >>>> >>>>> On Oct 24, 2019, at 11:45 PM, Anshuman Khandual wrote: >>>>> >>>>> Nothing specific. But just tested this with x86 defconfig with rele= vant configs >>>>> which are required for this test. Not sure if it involved W=3D1. >>>> >>>> No, it will not. It needs to run like, >>>> >>>> make W=3D1 -j 64 2>/tmp/warns >>>> >>> >>> Are we talking about this peace of code ? >>> >>> +static unsigned long __init get_random_vaddr(void) >>> +{ >>> +=C2=A0=C2=A0=C2=A0 unsigned long random_vaddr, random_pages, total_u= ser_pages; >>> + >>> +=C2=A0=C2=A0=C2=A0 total_user_pages =3D (TASK_SIZE - FIRST_USER_ADDR= ESS) / PAGE_SIZE; >>> + >>> +=C2=A0=C2=A0=C2=A0 random_pages =3D get_random_long() % total_user_p= ages; >>> +=C2=A0=C2=A0=C2=A0 random_vaddr =3D FIRST_USER_ADDRESS + random_page= s * PAGE_SIZE; >>> + >>> +=C2=A0=C2=A0=C2=A0 WARN_ON((random_vaddr > TASK_SIZE) || >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (random_vaddr < FIRST_USE= R_ADDRESS)); >>> +=C2=A0=C2=A0=C2=A0 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 =3D TASK_SIZE - 1 >>> And the min value random_vaddr can get is FIRST_USER_ADDRESS (that's = when random_pages =3D 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 corresp= onding >> page table mappings could be created. If it's worth to drop this in fa= vor of >> avoiding these unwanted warning messages on x86, will go ahead with it= as it >> is not super important. >> >=20 > But you are checking what ? That the compiler does calculation correctl= y or what ? IIRC, probably this was for later if and when the vaddr calculation becom= es dependent on other factors rather than this simple arithmetic involving s= tart and end of process address space on a platform. > As mentionned just above, based on the calculation done, what you are t= esting cannot happen, so I'm having a hard time understanding what kind o= f sanity check it can be. You are right. >=20 > Can you give an exemple of a situation which could trigger the warning = ? I was mistaken. We dont need those checks for now, hence will drop them n= ext time. >=20 > Christophe >=20