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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3757C433EF for ; Thu, 10 Mar 2022 21:31:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 02BCC8D0002; Thu, 10 Mar 2022 16:31:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F1DB58D0001; Thu, 10 Mar 2022 16:31:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0BC08D0002; Thu, 10 Mar 2022 16:31:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0072.hostedemail.com [216.40.44.72]) by kanga.kvack.org (Postfix) with ESMTP id CE2F28D0001 for ; Thu, 10 Mar 2022 16:31:47 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 775AA9CD49 for ; Thu, 10 Mar 2022 21:31:47 +0000 (UTC) X-FDA: 79229773854.20.7DB310F Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf28.hostedemail.com (Postfix) with ESMTP id A9A86C000D for ; Thu, 10 Mar 2022 21:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=hXDUTjVWZxaANyNbVmfaGwGIxc8fx/dmvUspBOucNHU=; b=SLbeJyQS9Z8zsqhg28pFcFjGF7 a3oYJINv+p4BxZ2p8HN5twBPvAyaOwVe0+XqUDhnVIUIseDVeGziE+/gRa3g/XtwcmA/g8/bcYh+N aEzryAoGihBDOvkvB9aLX5ejESI/fP9fpn4zOp+Him25I7/CGgMXpCqIrX8CirdFc+spNzvkE6kB4 ETkXANSO3Y7dJyKDM/twOCV2/WH/tMOHK9NRkIk1stL/IDSUqk7eqGLEB0Gk3+cs2c5pHi2hjw0Io Biy4jE4jiljSnU1kr5XunmlMFnYCdiHMR1ya2uDj5JCtb5vlho3YP5fpxSEPKWBp8Sx/sbjD3n/DI PnUl+NGw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nSQNl-00E5UB-U1; Thu, 10 Mar 2022 21:31:37 +0000 Date: Thu, 10 Mar 2022 13:31:37 -0800 From: Luis Chamberlain To: Muchun Song Cc: Jonathan Corbet , Mike Kravetz , Andrew Morton , Kees Cook , Iurii Zaikin , Oscar Salvador , David Hildenbrand , Linux Doc Mailing List , LKML , Linux Memory Management List , Xiongchun duan , Muchun Song Subject: Re: [PATCH v3 1/4] mm: hugetlb: disable freeing vmemmap pages when struct page crosses page boundaries Message-ID: References: <20220307130708.58771-1-songmuchun@bytedance.com> <20220307130708.58771-2-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: A9A86C000D X-Stat-Signature: id6mjbg78jxedh677ajaexodmordqwxa Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=SLbeJyQS; spf=none (imf28.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1646947906-804136 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 Tue, Mar 08, 2022 at 01:03:08AM +0800, Muchun Song wrote: > On Tue, Mar 8, 2022 at 12:35 AM Luis Chamberlain wrote: > > > > On Mon, Mar 07, 2022 at 09:07:05PM +0800, Muchun Song wrote: > > > If the size of "struct page" is not the power of two and this > > > feature is enabled, then the vmemmap pages of HugeTLB will be > > > corrupted after remapping (panic is about to happen in theory). > > > > Huh what? If a panic is possible best we prevent this in kconfig > > all together. I'd instead just put some work into this instead of > > adding all this run time hacks. > > If the size of `struct page` is not power of 2, then those lines added > by this patch will be optimized away by the compiler, therefore there > is going to be no extra overhead to detect this. > > > > > Can you try to add kconfig magic to detect if a PAGE_SIZE is PO2? > > > > I agree with you that it is better if we can move this check > into Kconfig. I tried this a few months ago. It is not easy to > do this. How to check if a `struct page size` is PO2 in > Kconfig? If you have any thoughts please let me know. Can you query this with a script? config HAS_PAGE_SIZE_PO2 bool default $(shell, scripts/check_po2_page_size.sh arguments_are_allowed) Luis