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.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, 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 758C7C7618B for ; Thu, 25 Jul 2019 14:39:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F149218EA for ; Thu, 25 Jul 2019 14:39:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SVrTjode" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729160AbfGYOj2 (ORCPT ); Thu, 25 Jul 2019 10:39:28 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:53152 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbfGYOj1 (ORCPT ); Thu, 25 Jul 2019 10:39:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=38kZYSDy3zC5/h/SWKUk1efaWYIuv6kOUF9lD42ddaQ=; b=SVrTjodeLNK7q0jCMYEkBveo4 Zu8/xuN291RTd2NCB0e0+OKyqdrkLflFyiEomdig7SwNxjlQDVAFmlQ2jeu20983UVJf83F2NB1eA 5GNZIlel3ONkkxUoEQSUm6JN7E1HklNo+yop3vUZEmV775yV+YPo6NKgu6tqVvjKADkkdeAlwDaXg qxc/MJUpLs89zfDsR86K96FcPpSsvxoeEJxChdYwnoF/UzBTxasoFp/jNygj7PyXRonQta/gM89q8 fPQ7GNopogRdlK47Z+dQF7P0aVZ8Oq5puPimr1TAo1+SQaiNFVfNa2j0J3pcmRuzNBLX+Y7aLOjNj 7aDrkIKmg==; Received: from willy by bombadil.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1hqett-0001f5-5B; Thu, 25 Jul 2019 14:39:21 +0000 Date: Thu, 25 Jul 2019 07:39:21 -0700 From: Matthew Wilcox To: Anshuman Khandual Cc: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Mark Rutland , Mark Brown , Steven Price , Ard Biesheuvel , Masahiro Yamada , Kees Cook , Tetsuo Handa , Sri Krishna chowdary , Dave Hansen , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC] mm/pgtable/debug: Add test validating architecture page table helpers Message-ID: <20190725143920.GW363@bombadil.infradead.org> References: <1564037723-26676-1-git-send-email-anshuman.khandual@arm.com> <1564037723-26676-2-git-send-email-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1564037723-26676-2-git-send-email-anshuman.khandual@arm.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 25, 2019 at 12:25:23PM +0530, Anshuman Khandual wrote: > This adds a test module which will validate architecture page table helpers > and accessors regarding compliance with generic MM semantics expectations. > This will help various architectures in validating changes to the existing > page table helpers or addition of new ones. I think this is a really good idea. > lib/Kconfig.debug | 14 +++ > lib/Makefile | 1 + > lib/test_arch_pgtable.c | 290 ++++++++++++++++++++++++++++++++++++++++++++++++ Is this the right place for it? I worry that lib/ is going to get overloaded with test code, and this feels more like mm/ test code. > +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE > +static void pmd_basic_tests(void) > +{ > + pmd_t pmd; > + > + pmd = mk_pmd(page, prot); But 'page' isn't necessarily PMD-aligned. I don't think we can rely on architectures doing the right thing if asked to make a PMD for a randomly aligned page. How about finding the physical address of something like kernel_init(), and using the corresponding pte/pmd/pud/p4d/pgd that encompasses that address? It's also better to pass in the pfn/page rather than using global variables to communicate to the test functions. > + /* > + * A huge page does not point to next level page table > + * entry. Hence this must qualify as pmd_bad(). > + */ > + WARN_ON(!pmd_bad(pmd_mkhuge(pmd))); I didn't know that rule. This is helpful because it gives us somewhere to document all these tricksy little rules. > +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD > +static void pud_basic_tests(void) Is this the right ifdef? 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=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,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 43CA3C7618B for ; Thu, 25 Jul 2019 14:39:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1D776218EA for ; Thu, 25 Jul 2019 14:39:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="StYlfgOL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D776218EA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1R2jCc2j4KEX3Btg90m6poAbnZ1pNPc05409JAt7kk0=; b=StYlfgOLtU5o64 F3PBkeXmINfcV+tNAm5DT2qIIhoPU+7mP4FRd/069dSpPs3Xi1kSjI+2mM7m/rzCva+RpVCQt6uPN CvN7Pg0JegYwOUvUuBN0nJ/zxS1c5PZX9jqZc/GC/Oo4jWsDA2scQen82ZBriMU7+60twbKN8mGqp Cnp2vnOOnsvVmMEc/NCFAYCZNP9M/qFAJkByITuWetUcU4d16PLYGIVFUEgOGFfvXwoIqmNt1D2CY hifRltdYJWbMy6X+1ucpTVBDCiAs65INj1bMs52DHWY8YQyxJcjwrRAnDI0AB77JHMLn+BAlexONZ geM1R2xZfOtEQ/XbRc5A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hqetv-0001fR-UW; Thu, 25 Jul 2019 14:39:24 +0000 Received: from willy by bombadil.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1hqett-0001f5-5B; Thu, 25 Jul 2019 14:39:21 +0000 Date: Thu, 25 Jul 2019 07:39:21 -0700 From: Matthew Wilcox To: Anshuman Khandual Subject: Re: [RFC] mm/pgtable/debug: Add test validating architecture page table helpers Message-ID: <20190725143920.GW363@bombadil.infradead.org> References: <1564037723-26676-1-git-send-email-anshuman.khandual@arm.com> <1564037723-26676-2-git-send-email-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1564037723-26676-2-git-send-email-anshuman.khandual@arm.com> User-Agent: Mutt/1.11.4 (2019-03-13) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Kees Cook , Sri Krishna chowdary , Ard Biesheuvel , Masahiro Yamada , Tetsuo Handa , x86@kernel.org, Dave Hansen , linux-kernel@vger.kernel.org, Steven Price , linux-mm@kvack.org, Mark Brown , Andrew Morton , Michal Hocko , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jul 25, 2019 at 12:25:23PM +0530, Anshuman Khandual wrote: > This adds a test module which will validate architecture page table helpers > and accessors regarding compliance with generic MM semantics expectations. > This will help various architectures in validating changes to the existing > page table helpers or addition of new ones. I think this is a really good idea. > lib/Kconfig.debug | 14 +++ > lib/Makefile | 1 + > lib/test_arch_pgtable.c | 290 ++++++++++++++++++++++++++++++++++++++++++++++++ Is this the right place for it? I worry that lib/ is going to get overloaded with test code, and this feels more like mm/ test code. > +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE > +static void pmd_basic_tests(void) > +{ > + pmd_t pmd; > + > + pmd = mk_pmd(page, prot); But 'page' isn't necessarily PMD-aligned. I don't think we can rely on architectures doing the right thing if asked to make a PMD for a randomly aligned page. How about finding the physical address of something like kernel_init(), and using the corresponding pte/pmd/pud/p4d/pgd that encompasses that address? It's also better to pass in the pfn/page rather than using global variables to communicate to the test functions. > + /* > + * A huge page does not point to next level page table > + * entry. Hence this must qualify as pmd_bad(). > + */ > + WARN_ON(!pmd_bad(pmd_mkhuge(pmd))); I didn't know that rule. This is helpful because it gives us somewhere to document all these tricksy little rules. > +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD > +static void pud_basic_tests(void) Is this the right ifdef? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel