Received: by 2002:ac2:48a3:0:0:0:0:0 with SMTP id u3csp558685lfg; Fri, 11 Mar 2022 13:13:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4IZwRE3XFSo5HoP3vEFvAalYyTN/hyUoaPVEDWUgzDoK1JTa22RLzUaO6nEi14qokKEgT X-Received: by 2002:a17:902:e80d:b0:151:e043:a2c3 with SMTP id u13-20020a170902e80d00b00151e043a2c3mr12285567plg.64.1647033238531; Fri, 11 Mar 2022 13:13:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647033238; cv=none; d=google.com; s=arc-20160816; b=GmziJhfjNmoqbZUEwRtTqgIIhE+4D5NirPDzN7exQLTUhZLQ7XPNtNNFnOBQ+lzua1 hpzYzWmMuL1Bl4Ym+O3mQQmx8M+biVvNgkL1lWHqb/pk7Sy9dEm0gA+noMFoY58fnbda 0AgCVK2GM7oVzc5DxYohFwDSt1rE0WacCC8xGMUMSkidYjjB/RbjQ2cpJVGta5H//vEx kjUXeXLUDiGIrgm4PWrXSlD0aaWzXXCYDC+ZxSPnOPJnis3lidnyk00m7omtyWRYB3Gi 9Taw0RKhvhB+MAhrUCBzml8arXy7V5129jWDBl5PeY9+EBoRRfdWeg0nXlRt64Rz9Uhx 4JAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=hXDUTjVWZxaANyNbVmfaGwGIxc8fx/dmvUspBOucNHU=; b=0Ps5TjpuQoYF24Dtrd3RQXedxQBZovyVKdeI2+wwDCJn/aoPq6s+iAI+n0mMvkC9uE 4jf5H8rVtC1e4+mbVtUAaGq21r5Wvtt3JQ7DHQddY+sXUoUyATS1u14x4KBHJa3g55HE 866O38ztUefQdNEkVOTAPEgxfT03MhlTfVywP1FTVY2K3ZvK3MdMBbTkFMWltyHC0jEh QIWiLuFDuvld3rLi2JQ9HN9ymLe2RxEhrZ+NDCd8lB26BSm1vg3JV1sTWZQE8Tssdg9t uRD2thkRwRNaejGfC39p51B90zuOCDZATFDRYRVDz6/36Q2WF3WnEu3yMhjqPH+a2yYZ bkNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=SLbeJyQS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d34-20020a631d62000000b0037306863f64si9155893pgm.701.2022.03.11.13.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 13:13:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=SLbeJyQS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D67AA1EC24B; Fri, 11 Mar 2022 12:53:01 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239214AbiCJVct (ORCPT + 99 others); Thu, 10 Mar 2022 16:32:49 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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