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=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 EAF96C388F7 for ; Tue, 10 Nov 2020 16:15:19 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 7C0EE206E3 for ; Tue, 10 Nov 2020 16:15:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kQMB+OKJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C0EE206E3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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=merlin.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=qb61TLDINBVqK5ug+P60f5fnTf8gOSDysJ90jkN4IC4=; b=kQMB+OKJePjtm+TYtO7khh9ZY 3l/O6kFSaZ8bWGCha7Vg+wVPLi1J6HEjgC4ZawzWUy8boU4MnREE9ve7akpapFLwjFtLdUCtmsQYC ggRG+Ywctym9rekoECTaSJetq6nA+Eu46Txj6Q8S8lPg1/jgyZt2z8YLMXnaPRZhHcPz11kbfQJUK XAd596cnAYg8x9rBfqelokYIx0IKNXvkZrjXaccOc7uqdk+bYcQfgYIWXwWWDKq/z98Z+/EYA21Yh UalxlZ86vYOnXDGh+WVuK9OvId1FTR+lkFVj8RPo4b5pC7vnVysr9mnuLHCbWO59GaqIOCSEnLtDn RuLq1SJzg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcWII-0004kV-JI; Tue, 10 Nov 2020 16:14:54 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcWIF-0004je-JL for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 16:14:52 +0000 Received: from trantor (unknown [2.26.170.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 09261206E3; Tue, 10 Nov 2020 16:14:48 +0000 (UTC) Date: Tue, 10 Nov 2020 16:14:46 +0000 From: Catalin Marinas To: Ard Biesheuvel Subject: Re: [PATCH v2 3/4] arm64: mm: make vmemmap region a projection of the linear region Message-ID: References: <20201008153602.9467-1-ardb@kernel.org> <20201008153602.9467-4-ardb@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201110_111451_903552_6A2F0DEA X-CRM114-Status: GOOD ( 29.62 ) 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: Will Deacon , Steve Capper , Geert Uytterhoeven , Linux ARM , Anshuman Khandual Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Nov 10, 2020 at 04:42:53PM +0100, Ard Biesheuvel wrote: > On Tue, 10 Nov 2020 at 16:39, Catalin Marinas wrote: > > On Tue, Nov 10, 2020 at 03:08:45PM +0100, Ard Biesheuvel wrote: > > > On Tue, 10 Nov 2020 at 14:10, Ard Biesheuvel wrote: > > > > On Tue, 10 Nov 2020 at 13:55, Geert Uytterhoeven wrote: > > > > > On Thu, Oct 8, 2020 at 5:43 PM Ard Biesheuvel wrote: > > > > > > --- a/arch/arm64/mm/init.c > > > > > > +++ b/arch/arm64/mm/init.c > > > > > > @@ -504,6 +504,8 @@ static void __init free_unused_memmap(void) > > > > > > */ > > > > > > void __init mem_init(void) > > > > > > { > > > > > > + BUILD_BUG_ON(!is_power_of_2(sizeof(struct page))); > > > > > > > > > > This check is triggering for me. > > > > > > > > > > If CONFIG_MEMCG=n, sizeof(struct page) = 56. > > > > > > > > > > If CONFIG_HAVE_ALIGNED_STRUCT_PAGE=y, this is mitigated by > > > > > the explicit alignment: > > > > > > > > > > #ifdef CONFIG_HAVE_ALIGNED_STRUCT_PAGE > > > > > #define _struct_page_alignment __aligned(2 * sizeof(unsigned long)) > > > > > #else > > > > > #define _struct_page_alignment > > > > > #endif > > > > > > > > > > struct page { ... } _struct_page_alignment; > > > > > > > > > > However, HAVE_ALIGNED_STRUCT_PAGE is selected only if SLUB, > > > > > while my .config is using SLAB. > > > > > > > > > > > > > Thanks for the report. I will look into this. > > > > > > OK, so we can obviously fix this easily by setting > > > CONFIG_HAVE_ALIGNED_STRUCT_PAGE=y unconditionally instead of only 'if > > > SLUB'. The question is whether that is likely to lead to any > > > performance regressions. > > > > I'm not sure I understand. The mem_init() bug triggers if sizeof(struct > > page) is not a power of 2. HAVE_ALIGNED_STRUCT_PAGE forces the page > > alignment to 16 bytes but, for example, a 48-byte structure is not a > > power of 2. > > True, but looking at include/linux/mm_types.h, I don't see how that > would happen. Not with 48 and probably won't ever go beyond 64 for "production" builds. But say someone wants to experiment with some debug data in struct page and adds a long. The structure (I think 64 now with MEMCG=y) becomes 72, force-aligned to 80. That triggers the build-bug. Anyway, I don't mind the forced alignment, only that the build-bug you added has a different requirement than what HAVE_ALIGNED_STRUCT_PAGE provides (power of 2 vs 16-byte aligned). AFAICT, VMEMMAP_START is a compile-time value, PAGE_OFFSET is also compile-time, so can we not revert to the original virt_to_page and page_to_virt macros? They'd not be as efficient but it may not matter much (and if the struct size is a power of 2, the compiler should change the division/multiplication by shifts). -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel