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 7FA10C433F5 for ; Mon, 7 Mar 2022 17:13:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 10FCC8D0002; Mon, 7 Mar 2022 12:13:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 098FA8D0001; Mon, 7 Mar 2022 12:13:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E84F78D0002; Mon, 7 Mar 2022 12:13:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id D40C98D0001 for ; Mon, 7 Mar 2022 12:13:50 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 84CD1A866B for ; Mon, 7 Mar 2022 17:13:50 +0000 (UTC) X-FDA: 79218237420.17.BE18ADB Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by imf19.hostedemail.com (Postfix) with ESMTP id C778D1A0013 for ; Mon, 7 Mar 2022 17:13:49 +0000 (UTC) Received: by mail-yb1-f182.google.com with SMTP id u10so12526096ybd.9 for ; Mon, 07 Mar 2022 09:13: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=X79+cMNSS1ZIdonvLOYEw31mZ4UOgIRIrMSuxiLNwqs=; b=Nd1UyuTvcWJZhAMUVe66Y3LBQ7krURoXNjJyL9N1qvXxDiuG1apnvlZVaERKYOeZCz S9BN14kz7JlilZvwPNsWQnbA+LJfF5CBuSx/lDCI8WaFL53mGzaKOhzw43I3p9HDdSor rZx1eKHHxcDsNyNS4+CiXfZNDH66pu3jrXPxA6j0vzr7ygp1CavI6Mn9hRe/R+SufDKn p+FMRo6UIuWO+HJ9ZysHVqhNZj8rUrshMFd11UjRHuIJ4+kGto/faPFLutotUvNU4pqV TxSIshPyAX6kurMeLjuUv8siLleryoFXojmKuS7fmXDqwgWzCvphiFzaR3GPJN8YxwIC 3DYw== 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=X79+cMNSS1ZIdonvLOYEw31mZ4UOgIRIrMSuxiLNwqs=; b=xiqvH19mSFTzw+B0rFSw+2qFrf23ewuddLaSE1Ol0tB2fo1lLT5oAE+iD8mVcoR1BK gOKIGSix2S6rY8uAU6JTJmJ7Oh6LNY8TGKjL/Zv7OuK9za00tCgZo++3N0Xba2dR2NKQ Svp9DEjf4jYO6y8woS2ispYq3QeF7+K0QoqlKZX9564hZEnhnr1BEYXWl/bqysBLvvdj WZKYszHOknn1Y8eeT3nc6dY/g9/YsFbzK3smuZZzE4rUryPyqlo4urdtR791ecHSGHpf LxNlAk54gxCngtBieDW55gRzC+5vVVXQcAICeFinHRDCtN0w1//PD03sxcRS7Bryp+92 WxZQ== X-Gm-Message-State: AOAM5330ibhEW4hAJXYWdqmpBcHs7Kf+P3n5uGbWXeK/dAFMGxPj+4to 5OA/rKJW2uvzycQoSiR2Z2mK8WonzTMQZxWvtNya602SXvUpuN+T X-Google-Smtp-Source: ABdhPJwWjHGDU3vKlcY2eVkECJJt/KQSRMof+n3QMrZTHYiiNY/DfKR3JuCdSzZZFz34oLIQv+Fsf2cV4EqROGV7FA0= X-Received: by 2002:a25:d188:0:b0:628:ba86:ee68 with SMTP id i130-20020a25d188000000b00628ba86ee68mr8622549ybg.427.1646673229137; Mon, 07 Mar 2022 09:13: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:12: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-Rspamd-Server: rspam10 X-Rspam-User: X-Stat-Signature: ttaooz8sx8zn1z5om5d698fk85zjmizs Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Nd1UyuTv; spf=pass (imf19.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.219.182 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspamd-Queue-Id: C778D1A0013 X-HE-Tag: 1646673229-268710 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 1:03 AM 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. > > Thanks. Here is a discussion [1] from a few months ago. [1] https://lore.kernel.org/all/CAMZfGtWfz8DcwKBLdf3j0x9Dt6ZvOd+MvjX6yXrAoKDeXxW95w@mail.gmail.com/