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 57163C433EF for ; Mon, 7 Mar 2022 17:04:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEFAE8D0003; Mon, 7 Mar 2022 12:04:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BA2BB8D0001; Mon, 7 Mar 2022 12:04:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A66F38D0003; Mon, 7 Mar 2022 12:04:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id 9A3738D0001 for ; Mon, 7 Mar 2022 12:04:52 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 580B28C58F for ; Mon, 7 Mar 2022 17:04:52 +0000 (UTC) X-FDA: 79218214824.16.83A1804 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) by imf24.hostedemail.com (Postfix) with ESMTP id 5CD44180013 for ; Mon, 7 Mar 2022 17:04:50 +0000 (UTC) Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-2d07ae0b1c4so171752687b3.11 for ; Mon, 07 Mar 2022 09:04:49 -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=MFytkXFVm+nQKBfdysr1CcxHAqYCnsg45+4U4K+ObQM=; b=4nXPz/240sTZkTNjrrs+YCUsZXJ69EFBHPB4zrzlis4OZy6aLv9xkGR+r5be2fVmfs PEFFMQp6c8hnOFOpwKWExugg1BcQ5/SvRKOOFxDtKUKr8y4pVFwIrFFF+rS9E0Ey6T4X t5b4BFCCWTqKOtckWBbRvAXOnqFn4jyBu2LXY6HMi0VEgnO7IaaQq1PduZfg6mjOnUGK mYXR+KWSp8EEbDu1mkeIaIpCQOzGYzMpYVmjuC2Dyzi8+jKs7p8xWcXzFSQBQ4dZzpKO TdB+ORLfdFIQKKlM1tB7rExkxI4EtpLiVN0raeK2SJKuI146TvS43W4PnTQbc3Rpc3Gw WeQQ== 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=MFytkXFVm+nQKBfdysr1CcxHAqYCnsg45+4U4K+ObQM=; b=yG82y/byw2HgtWnbvx7lfZ3G8Gq33u8as/4xIAOFaa3ciL4iWD/paqkMzUXmguAwa9 lLnTyXhxxgjdYWjr3ve79SPZWELob7iSWLDvpdCKphgSh12oS3HUD6B+DmL517IYt4/5 dEqbWEE3GfDDx7do52iZqKZzuMyCocQudmmQyw/mh/6st658L6Jn9geeoa07NQE5iru0 IwTExkgP2lv8Mh2lwBFgi0QjNws1OsAPeOhqo1Jz6tJH5CNO/3ijtsBAwP88mG5bofbX +AqQ52QG6cKBLrnOYPwlhMvgRLiQ+ZNEsGpPxVXOVz0GGd5zPTqPTSxTYJr3sZdmdEzs nrMA== X-Gm-Message-State: AOAM530SWp1cvkKpxrFems/PuKG5FnvSLbfpE7W3+v9xuBZv5fr2BCAJ mRiwQi1w+f2LyA/9WLUDq9ShVKSf25IcKTeIy4q+mg== X-Google-Smtp-Source: ABdhPJztR+S2W/s9ItNiWnCahlnxnbCNypLwubklaZAxAS+l5RMXq/fSTQrA9tZ86ojAdf2uRsrxoeq1F/D9AmvN2/0= X-Received: by 2002:a0d:e609:0:b0:2d6:b8b0:8608 with SMTP id p9-20020a0de609000000b002d6b8b08608mr9223373ywe.31.1646672689245; Mon, 07 Mar 2022 09:04:49 -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: Tue, 8 Mar 2022 01:03:08 +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" X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 5CD44180013 X-Stat-Signature: icpx4pafij4gz7ob7boppbhtwgy5mffd Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="4nXPz/24"; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf24.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.128.176 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-HE-Tag: 1646672690-766879 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 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. Thanks.