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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A5F5C433FE for ; Thu, 10 Mar 2022 21:31:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344004AbiCJVcu (ORCPT ); Thu, 10 Mar 2022 16:32:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343997AbiCJVcr (ORCPT ); Thu, 10 Mar 2022 16:32:47 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F38B7192CB8; Thu, 10 Mar 2022 13:31:45 -0800 (PST) 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: Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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