Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp96989pxp; Thu, 10 Mar 2022 23:36:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwB0ufPtBnBL0klpNWQzrNfMwxvKEjIQq9gtTxMHAB91dNSiH2I7hNz3XN854KB045ZQrd X-Received: by 2002:a17:906:2486:b0:6cf:ced9:e4cc with SMTP id e6-20020a170906248600b006cfced9e4ccmr7554223ejb.201.1646984170133; Thu, 10 Mar 2022 23:36:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646984170; cv=none; d=google.com; s=arc-20160816; b=NGvtYFvp8q5hNLGe0+pGbTen8JHG36PzhCyuMggpDeW9+9Z4LZaGeV4LTchKEEkVWC buhesIkkG2H5Q5jnekISRjySIwVKcdmYBjZGh24VGBZhj2UwK3eOhTpzcMSD1UHY95T1 f1GIodQyVscLx+bSc3GEzkN0EtC9suWDVFo39qMWHrgaVFWrmyS+CVZHwKct5MntGuoG HevMcNltMuCoJfLBPTyaFerKBsKsLbqSNxWzbEeiinCZ9rn8iKmxxqkxX6FzRUy1phEx vXR1j43HBabkN29JRmRDbouoYd76EYnhZ9XOP+70s8xMD7L/13ims8EKNYDtxEtpvkro x1mw== 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=qcSIpjSWLhRrlsmQ73YhW910e9trxsztOOdRdWeu+CM=; b=ZxCzouuTMhloA0f6VByBR4wvqeksBLPj4E/CFuxGbieNjvFsfhHV4psnG4FsFP1Dzj 0T2VgW1bU46RE1Xuu4lcMlKe4atUklx7KXy6PR8CHq5i0Y8kk2QY90ofmoMra0OREjND YiosVOnzQRsWTfgSEdyw7swJ0bWpjC8L4AofAwIiyVnGebbtV+6KuB2Wf04X1ggs2lUd PbVGQpP04b4hhjOzdvfZDK6Bg1GtIF7B8ZV91kWYMl2gvFeq/67VPO5Eg78IQCpND8j+ SK9Z7cW0rqRTpaWj4NvVMBkKbChapaLxsdMHcqCPBkvBbjBnqz3O2ScePTew88idOEUF HezQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=DFLmC0sR; 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 ss23-20020a170907c01700b006ce04d5158asi3645226ejc.194.2022.03.10.23.35.43; Thu, 10 Mar 2022 23:36:10 -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=DFLmC0sR; 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 S1347147AbiCKHZV (ORCPT + 99 others); Fri, 11 Mar 2022 02:25:21 -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-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-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=ham 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 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.