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 22B56C433F5 for ; Fri, 11 Mar 2022 07:24:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A3508D0002; Fri, 11 Mar 2022 02:24:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 952C68D0001; Fri, 11 Mar 2022 02:24:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 841688D0002; Fri, 11 Mar 2022 02:24:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0133.hostedemail.com [216.40.44.133]) by kanga.kvack.org (Postfix) with ESMTP id 70B0C8D0001 for ; Fri, 11 Mar 2022 02:24:17 -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 25B1B9AC93 for ; Fri, 11 Mar 2022 07:24:17 +0000 (UTC) X-FDA: 79231266954.16.576400F Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) by imf17.hostedemail.com (Postfix) with ESMTP id 0CAD440023 for ; Fri, 11 Mar 2022 07:24:15 +0000 (UTC) Received: by mail-yb1-f172.google.com with SMTP id h126so15602394ybc.1 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=g6omIlaGeS9or4jnsWvQS7yQj/yRazHZuAav/WrVpPbFXzx//yPoSO6VTZOskWq+Yw jWeU4yvLU+qiiaCnP7cuHI1KbHtGjv8E2+S76qIA+k8TLaT9Lphlg8ZRSRP3cIW+ic3W g4Pi/roRu/tBTrtVCeqWa7L7K1HuREwcljBuD9kB7D6Sn4J7WtvcU6T+pBJHljZJt53f kv2Ctplp0BVN8MttpZmsrWr+TSIaFiYMozY0AigrSJpBOQgE1amjFocoJ8HgBswprSAf quc2lwzmjUwuoQaIOZh+wxeOx9Lg5sSDZ/nEGctI4Mk4YYLNpo0NliO8RQOMYbcLPsEC CxOA== X-Gm-Message-State: AOAM533sIQgUeHX2PVwYgrYKfAFY775ahI0kCMglrEsmq0ZJmFsdw53X SFh1xhAXhBUnhspDohGPMNhIy+ItpBNYkJ8wHeusL0dSNNO7ZA== 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" X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0CAD440023 X-Stat-Signature: 9s1yssa3w9fynoa4599zux369qw75msh Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=DFLmC0sR; spf=pass (imf17.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.219.172 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1646983455-163364 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 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.