Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2501937pxp; Mon, 7 Mar 2022 17:17:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyW5xPZypOlBYjY787SulByqnxsJf3Dkx0WeBTaoJM53sVq02PsUACSB5FowR7wJD0JNbW9 X-Received: by 2002:a17:902:da8f:b0:151:d7d9:eb77 with SMTP id j15-20020a170902da8f00b00151d7d9eb77mr12556394plx.150.1646702231322; Mon, 07 Mar 2022 17:17:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646702231; cv=none; d=google.com; s=arc-20160816; b=xAfgqIcuunnErPzeRkfCuA+kzJkB2cy2YRDzYXye44SsU0Vk9wILx1/WBOGD9Ad5p1 WAA9U5oGQtxkFjYvkSjoA8cXWPjcQxFA5O5S3xkuBhS4NsSu7EpIMsvL4dBWXc8BkM25 G19u8AVcR7Yo9xtMhRpQatvxuoUlk8xK8mu6/F4m0CmAr935R0Qp3rnl4VhatR5igOz5 eeogqFHUT+MaXrCltAmXnP7INqLBJKzGWYWTPv6nSG155lzdDNhbSYCfG5GCKu1xhRer n0pMlU414J1jHg/4odOoJ0xBs4ZSF51YTHJsz2FnmB5Ht3mhBm7s6ZEvzrP1Ps31fjo/ PywA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=X79+cMNSS1ZIdonvLOYEw31mZ4UOgIRIrMSuxiLNwqs=; b=TIc5Yqcn74eFmfrGoXAEiZuM4ly/VRGUk6+V9gs0hG7jt2JSCb+bBX7KkivRc+0255 pu5HrRpOUS84L6WnpVIUtJfkNfFmknBdEDrcaHuCAuCx3CafWcnRvP82vTs2HSliq22W Ee/nlwUQYBhpkAOm7z3Dm1kUm8qEh+6iMhuwUqhJ02AGtVLVjKMH+8Xt0x90yOi+FiJk egeLuvhzUbsBh1iMLWZelMWfcl3/KGMDOcjChfujCgqsymEsWIacZhGBv3h0v+8g4HxT Tx+tGySYitn4NZDE8+wg2SvNUx1ij+48/TvZUjXJpp92pNY79depmYwtHn+MJ6FTAmr/ TlaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Nd1UyuTv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14-20020a170902f54e00b0015195e2aa37si15334121plf.55.2022.03.07.17.16.50; Mon, 07 Mar 2022 17:17:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Nd1UyuTv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241156AbiCGROq (ORCPT + 99 others); Mon, 7 Mar 2022 12:14:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229715AbiCGROo (ORCPT ); Mon, 7 Mar 2022 12:14:44 -0500 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5C55888DE for ; Mon, 7 Mar 2022 09:13:49 -0800 (PST) Received: by mail-yb1-xb2b.google.com with SMTP id h126so32386807ybc.1 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=4AysCgz5JKxWOnE5fFzVuPSki/xvzZlTZtmvk1L/G7Tu6OQ94lG8VvU+FqRIrLUuy/ j0D8BJkoLqGH2FbYbqwAUNDan1hT/sRJ/gO8L2P6OGtZ+y1ZXLJCsexpun1iDS3aqp61 Xzh6+wZDU9z1G2gkwax4kEwaozuzo4YDySQKfHWwaVCpNecPUW+THT8nzJRq9S0WuQEE ryfKO98XeNfLZ/hagNqJRrhGWb1E5g5DmZvtILO/NxT+ZMEeUDL61LuhLLwhBNXPMujW O2ys4HtsMnQ40WyDDrtzax2LG5Rd9gT0b4ECl/9fVOQL9A/WK63faDVhn8jNzziVK7Sl RN/A== X-Gm-Message-State: AOAM5318dqhZ2wviAcQ7+piZ4phcyDulzEmd4LUjh0VM9ovMhgnMJyO2 Rm/eALQeer/vrHdclaXThyU825IZU2teNmfOH3azNA== 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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/