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 2B61FC433EF for ; Thu, 21 Apr 2022 03:18:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A31306B0071; Wed, 20 Apr 2022 23:18:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E2086B0073; Wed, 20 Apr 2022 23:18:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8842F6B0074; Wed, 20 Apr 2022 23:18:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 7943F6B0071 for ; Wed, 20 Apr 2022 23:18:50 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4418320CD5 for ; Thu, 21 Apr 2022 03:18:50 +0000 (UTC) X-FDA: 79379429220.23.4715756 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf28.hostedemail.com (Postfix) with ESMTP id D928DC0026 for ; Thu, 21 Apr 2022 03:18:46 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id n11-20020a17090a73cb00b001d1d3a7116bso4933102pjk.0 for ; Wed, 20 Apr 2022 20:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=NghepmBiaj68pxaOpcG/lSCzSAs3yu0ibKXLD1qTgVU=; b=455j9DFRMs2U4tYQSDrRfRP4nUqSK00fXmqysu4e/bPsZzlckCyuXj/B4Y6S4Gy/kd 1cPTlmK7Sd2NHhR1t9aI7qj1qUlQWyrAYwUxjmz7MscUTz06a2PReygGRCEl5sjU1p5s AShoRN1705vDVF8/K9zjL0TN+7kAAREvbQUhlvYHBcEQVZOT/GNOBbxPDf8C8V0hFYY0 LLA5kIohpZqvAhApQQS63aPM9CE4FIuwkFLEIYSalcxOfL5BfO19RUh+VyRh4JK8FIUw 8McGY06AAEkYHoCJHRq1xbsa22lUGKS44moWcUmuY+LDfdF+v1XkArmdR+uUaKOIPdWi Bfsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NghepmBiaj68pxaOpcG/lSCzSAs3yu0ibKXLD1qTgVU=; b=SSMbksbCX/nbGnpVtYz6psHadnxVTB/w7CRsNBXWyeAXTfXWrvUfuuEFAig5iov6QV snAQ21nlwh0TceyxCWR8lsezGwKB9skSUvdChUjKqU53eXuhVttyLLICuTh6C0PwjM0t LBLjZRtcf0dKHLsHCtlVf/bGKQcdBCeIbhItjLTYI0q7iiHC2SKXx0kzHTHw37fxvnOt vhbLELkEb5amzBSUMIvNABRFWFD/pWPa+vTGDyk5uPsypqgne9hqgEvSHrDLaR+5SJFi oH+xaJ6sYeV8h6s+6mqqp0s1G59ytPqhYII8Y8UEHyXbAPc1giJwYa3X8/15LVaCu18d SywQ== X-Gm-Message-State: AOAM530E0rksvTbSlsd+M2DNG6EfFHKxaGD9rw+jDkfexg+jTsw9wzNM 6F/dGNmzniS0DkZNJ86rD/wjkw== X-Google-Smtp-Source: ABdhPJymzdzVbaGcv9D9XGC4x7JH8QeNZKFSjMs5U0NY0Qf5J+81At3RmjwzuwOZY02fSOmyeqBv7g== X-Received: by 2002:a17:902:7407:b0:159:6a:8beb with SMTP id g7-20020a170902740700b00159006a8bebmr17249263pll.168.1650511127951; Wed, 20 Apr 2022 20:18:47 -0700 (PDT) Received: from localhost ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id j6-20020aa79286000000b004fdf02851eesm21039552pfa.4.2022.04.20.20.18.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 20:18:47 -0700 (PDT) Date: Thu, 21 Apr 2022 11:18:44 +0800 From: Muchun Song To: Mike Kravetz Cc: Masahiro Yamada , Jonathan Corbet , Andrew Morton , "Luis R. Rodriguez" , Kees Cook , Iurii Zaikin , Oscar Salvador , David Hildenbrand , "open list:DOCUMENTATION" , Linux Kernel Mailing List , Linux Memory Management List , duanxiongchun@bytedance.com, smuchun@gmail.com Subject: Re: [PATCH v8 1/4] mm: hugetlb_vmemmap: introduce CONFIG_HUGETLB_PAGE_HAS_OPTIMIZE_VMEMMAP Message-ID: References: <20220413144748.84106-1-songmuchun@bytedance.com> <20220413144748.84106-2-songmuchun@bytedance.com> <9bd9c89a-b2fb-04dd-0aac-c42f2ee9e1a1@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9bd9c89a-b2fb-04dd-0aac-c42f2ee9e1a1@oracle.com> Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=455j9DFR; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf28.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: D928DC0026 X-Stat-Signature: ir678ojhquj9z4uenit6od534x15teph X-HE-Tag: 1650511126-988750 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 Wed, Apr 20, 2022 at 04:30:02PM -0700, Mike Kravetz wrote: > On 4/20/22 10:11, Masahiro Yamada wrote: > > On Wed, Apr 13, 2022 at 11:48 PM Muchun Song wrote: > >> > >> If the size of "struct page" is not the power of two but with the feature > >> of minimizing overhead of struct page associated with each HugeTLB is > >> enabled, then the vmemmap pages of HugeTLB will be corrupted after > >> remapping (panic is about to happen in theory). But this only exists when > >> !CONFIG_MEMCG && !CONFIG_SLUB on x86_64. However, it is not a conventional > >> configuration nowadays. So it is not a real word issue, just the result > >> of a code review. But we have to prevent anyone from configuring that > >> combined configurations. In order to avoid many checks like "is_power_of_2 > >> (sizeof(struct page))" through mm/hugetlb_vmemmap.c. Introduce a new macro > > Sorry for jumping in so late. I am far from expert in Kconfig so did not pay > much attention to all those discussions. > > Why not just add one (or a few) simple runtime checks for struct page not a > power of two before enabling hugetlb vmemmap optimization in the code? Sure, > it would be ideal to never build/include the vmemmap optimization code if > this can be detected at config time. However, it seems this is a very rare > combination and the checks for it at config time are very complex. Right. Iterated and explored through 8 versions, I realized checking it at config time is very complex. > Would we really need many checks throughout the code as you mention above? > Or, do we only need to check or two before enabling > hugetlb_optimize_vmemmap_key? Yep, now there is only one place where needs to check that size. I think I should go back to v1, it is simpler. Thanks Mike.