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 033D5C433EF for ; Fri, 11 Mar 2022 07:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347139AbiCKHZY (ORCPT ); Fri, 11 Mar 2022 02:25:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242146AbiCKHZT (ORCPT ); Fri, 11 Mar 2022 02:25:19 -0500 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E487B1B60A5 for ; Thu, 10 Mar 2022 23:24:15 -0800 (PST) Received: by mail-yb1-xb36.google.com with SMTP id l2so15561858ybe.8 for ; Thu, 10 Mar 2022 23:24:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qcSIpjSWLhRrlsmQ73YhW910e9trxsztOOdRdWeu+CM=; b=DFLmC0sR8O0uNQmc+1zmAeHAvecET0WlDEJnBSKoVFCvkv3cBpuO5WuhVbfB4PxBD1 ehKR5Dr5xJd4bFYYxUH7U7XMBKmU8rVNjA5dP8bxPIvt+9Xn023rIdzys+Tf1zkgMNIM u8Nizo4CdA3QOXfRVdWADCNsO6NDLaFrOBozkSRB6k1RZ7CZxbAh72CPyFUjp5XG+hhW 43d/dB7B9OSQxh//G4dqCoQj3nbbJBNDPlhXXadcNob9/KocXGMBubjd8bXDQdSSMSV4 OX41CNxCWNU75dqRaRgbTVS4Jr2kXpcRd5bihFDevGfrlDMr0hjl67lFU23W5cGbSsw3 RwHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qcSIpjSWLhRrlsmQ73YhW910e9trxsztOOdRdWeu+CM=; b=oSGXY/abR+KtjY9zX6aXFFplKC1OsTaHQ2yQ4MxIefWxD7VLSNS7bb13pgicBhL62K CWb7XULNs7FihdGpPiXPk/veZQmmTJmqeE/a44O/0CybFFxx7XghOz9g7eX7sB5+e+m0 PRLRBJi8+CcKLEjZqhEPjnabAmHNvcUy0/FgcyBstgSTYkn7H/9UOaPV3LhZNAuDmXsb rhZu5TVt2/Ecx4e5wGtrN23g+7nF04FwgjMaTZWFzvIVyKwoRb5y1mPMB4ctLb7W9kOc WMZCRH+BBIX4awryNGoFCOy4pXsgSb24cLx+1ZUdZqITUSy9pKE2SVM+KSwsGxyH7tmT RRcg== X-Gm-Message-State: AOAM5336bLxm5m/Hh8sXCNdsopvC4b5ExRBTYvw/IueBkW6XPvP0WP66 NkYiRXMOXOFLWUmILqGs3yDDtxJIKSIL2y2whVLAYA== X-Google-Smtp-Source: ABdhPJxtqLKdhvvwiS5rMHsZrRQUvSdu4UvCC24UiLt2rPUxgxcqOAsceLK3Em3mxZXVMmXs5iN0M+fF7P3DwGHZ+yY= X-Received: by 2002:a25:d188:0:b0:628:ba86:ee68 with SMTP id i130-20020a25d188000000b00628ba86ee68mr6854831ybg.427.1646983455057; Thu, 10 Mar 2022 23:24:15 -0800 (PST) MIME-Version: 1.0 References: <20220307130708.58771-1-songmuchun@bytedance.com> <20220307130708.58771-2-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Fri, 11 Mar 2022 15:22:29 +0800 Message-ID: Subject: Re: [PATCH v3 1/4] mm: hugetlb: disable freeing vmemmap pages when struct page crosses page boundaries To: Luis Chamberlain 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 11, 2022 at 5:31 AM Luis Chamberlain wrote: > > 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) > Excellent. I'll try this approach. Thanks very much.