Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4053551ybg; Fri, 25 Oct 2019 12:38:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+8JVYhXc4QYB2QEJ1YKOBxskqQ+lcOjhRLaLEqWruuQNx1YkDATRkimFftnb8o47PIp1Z X-Received: by 2002:a17:907:429e:: with SMTP id ny22mr4887104ejb.174.1572032305383; Fri, 25 Oct 2019 12:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572032305; cv=none; d=google.com; s=arc-20160816; b=PTAa7XPOuJWcgKZhQYJkclj8fsueJpusDp5RDT+m4mAsFSVp+EtR5cFtgAWWS7YmHI nBuiDx3a4lb2wG6nfI10zJooeDGzr5DcKpTrG0HRgY5B4KkriP2K4JUt6vtUhWFPTncf id0BiQ6b7DNLo+qPh5q+KRCfMKT9pFA6BRLCyhbAdHpne8gwcx/9d1+KfZhZN+BEvdQY EeHxr0B5CIxmfXSKmRRIm9RrsWYROaralRi3pT3nZKcU5y0NsntWXjGnIF8Cu7RZBlpK zwNbGRhTH78m0ymS/ONAQEfteN+0uZTkfTJbJ8Qf6pHVQXPfurHirZn2mF8kZWPEFi4G OtPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=5/9rLtkg9YNDlLP+L6QcPgWOMkyHBZKkjNjI8r2+D3g=; b=NfFv3d0kTg8C4wtRfNAgIJ0pafAb/eGNAhOXszr+eoX/+n25CzodvOGW4cjRoua3Zg mhRth9Ks/6XVQ3faT7Asu8EJM9fRVXsZRN0Sq+y7RwPdIPdqEoaeY3hiTwdmQixEZwU2 DeoIM9lfmxcj0mJ8YsIjJPN0wQb1t1HLB+PJhzdu4sAlPlC7uTqCzSQ389AdSQ9UlmJt Ro3qGGO4lw/R2vo3owiDVXO7mJ2Y23Q6YEMuruz8KUvtdQAjRk2IIwLSXf2J+HUaUOEq oT0Zjx2yLG3vcQJEuJpbWH5W93RwLbT9B69BQDNYX2NjHQd74y+cNTmUbFMQhYHWVzbh BoPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si1784967ejr.125.2019.10.25.12.38.02; Fri, 25 Oct 2019 12:38:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409024AbfJYKKT (ORCPT + 99 others); Fri, 25 Oct 2019 06:10:19 -0400 Received: from foss.arm.com ([217.140.110.172]:38382 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409013AbfJYKKS (ORCPT ); Fri, 25 Oct 2019 06:10:18 -0400 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: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/25/2019 02:22 PM, Christophe Leroy wrote: > > > Le 25/10/2019 à 10:24, Anshuman Khandual a écrit : >> >> >> 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. >> > > But you are checking what ? That the compiler does calculation correctly or what ? IIRC, probably this was for later if and when the vaddr calculation becomes dependent on other factors rather than this simple arithmetic involving start and end of process address space on a platform. > As mentionned just above, based on the calculation done, what you are testing cannot happen, so I'm having a hard time understanding what kind of sanity check it can be. You are right. > > 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 next time. > > Christophe >