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 2DC5CC43334 for ; Wed, 29 Jun 2022 05:55:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65D666B0071; Wed, 29 Jun 2022 01:55:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60DA96B0072; Wed, 29 Jun 2022 01:55:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D5598E0001; Wed, 29 Jun 2022 01:55:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3ED3A6B0071 for ; Wed, 29 Jun 2022 01:55:14 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1037761391 for ; Wed, 29 Jun 2022 05:55:14 +0000 (UTC) X-FDA: 79630210548.16.6C82B46 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf20.hostedemail.com (Postfix) with ESMTP id C33021C000B for ; Wed, 29 Jun 2022 05:55:12 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id g10-20020a17090a708a00b001ea8aadd42bso15006894pjk.0 for ; Tue, 28 Jun 2022 22:55:12 -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=94SNj+bfUaqeA4+uNDnU29zDWORUfea9gHEDob5a9do=; b=q9JXdbLNWvzcTKItVrJEAKSJqXSdpJuMcVam/iQ19oILMIUql+ezlVs/Ba+iRVfZ1C UvdBtOdFUjOjf8D5JP4HcCZWynYHFhK2WnG1rMfMKN/gcNpp3HyPMOkayfhk0taORRpn Mw3Xe+AvOwjybK3xY9sJQt8/Mlnxp1uei//koBq0iiJlDJH20LhHIXIrzyjp8VrdtSgG 8yVZu8aBRFZye3oUqp4ZTwtlfunYXsimPwhXxHHR+xP/oj06+ihqF2avPf+KSSLUqiDZ q/mGcI1e4jzCPlcASOr6mfmrPgWRJrw4ykN3P4C1gnKiQY5BSktUM2HKbNrdTU5xFMpP 1YFA== 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=94SNj+bfUaqeA4+uNDnU29zDWORUfea9gHEDob5a9do=; b=Q0tidhqPzPnNKxbTEbCqOVPUbrmZ+shEDyDtpRX6iegNHOW32yMbi2C7f+WZSfWvtN iDFQhkM581KH1CCGX6R+fuM43GFoWZ4EE/r/vxh26Ng2eArpHlCE2NY+7qccCbGShPDE A9KIbyi0rcvm6D8LA4L05tSrwr7G+5Uh/JKb4AXjxDPBlXyDOOY+fQAFCsSZFrCDxQs3 Se7gqZiUI7y+PGGH0nFVxcnvoknpKRNlw6VaIBRcBiH0TtvY7kuHGSdnRJ/HDG/gsZ1d wjtf24jHZS5YjcJ6dMyaTcSKQJkjI7cNs33X8TX0At94ZQXn93kDTuG7z0wOQtyr3lhD RF8g== X-Gm-Message-State: AJIora9nhrqMEWTKoElhhgE2vwBaHhp34gbZvyCUCdNwevUKxTK6fBjF mfMMcyFZtwYJGbPT5xHUu6yiWg== X-Google-Smtp-Source: AGRyM1sA/8PT0iAe0wBxu1s9us+UTFRVCahSkFBCCP9Ke8ZrHP2Wudr+UDZH2uuxiNicrLlILN5qfw== X-Received: by 2002:a17:902:f091:b0:16a:7e5:494f with SMTP id p17-20020a170902f09100b0016a07e5494fmr7332311pla.34.1656482111399; Tue, 28 Jun 2022 22:55:11 -0700 (PDT) Received: from localhost ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id g38-20020a635226000000b0040cb1f55391sm10267815pgb.2.2022.06.28.22.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 22:55:11 -0700 (PDT) Date: Wed, 29 Jun 2022 13:55:07 +0800 From: Muchun Song To: Mike Kravetz Cc: david@redhat.com, akpm@linux-foundation.org, corbet@lwn.net, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, duanxiongchun@bytedance.com Subject: Re: [PATCH v2 6/8] mm: hugetlb_vmemmap: improve hugetlb_vmemmap code readability Message-ID: References: <20220628092235.91270-1-songmuchun@bytedance.com> <20220628092235.91270-7-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=q9JXdbLN; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf20.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656482113; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=94SNj+bfUaqeA4+uNDnU29zDWORUfea9gHEDob5a9do=; b=fKgn7L/RGxAjkvOwiTOoo7mBvGqz7coklAlu14Li3RFXDTejLJIzRzDuM8dd+mgZ0L59ec P7U7ZrLehnCqrTdvdBrb0rw/+MoEtjiG2BB+pg1xntEJbHMTlnfldo/s9e5a2PQwbk8jGq m7MW7OfUiJF8QAZW+bCdyO360G6bUro= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656482113; a=rsa-sha256; cv=none; b=kZwYGKQ9oPP0Hdk+4p13e7GPCLJLMCxDRj4YK9egKJJuaGe5pTcG/2rcH139zoECpI4gM+ uhSlZoBzBEccCnhAicJTMn2DsIMN4h1G7l4i26xfuE1lyGGUhPpxYSO3/a72kkcnW9gYRQ REbNr+9SRa0CXHCmW0pWWIxohdlrjlE= X-Stat-Signature: 3xfraztsct3uyu6tw73e7sr49sp8wnba X-Rspamd-Queue-Id: C33021C000B Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=q9JXdbLN; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf20.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1656482112-357109 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, Jun 28, 2022 at 05:23:21PM -0700, Mike Kravetz wrote: > On 06/28/22 17:22, Muchun Song wrote: > > There is a discussion about the name of hugetlb_vmemmap_alloc/free in > > thread [1]. The suggestion suggested by David is rename "alloc/free" > > to "optimize/restore" to make functionalities clearer to users, > > "optimize" means the function will optimize vmemmap pages, while > > "restore" means restoring its vmemmap pages discared before. This > > commit does this. > > > > Another discussion is the confusion RESERVE_VMEMMAP_NR isn't used > > explicitly for vmemmap_addr but implicitly for vmemmap_end in > > hugetlb_vmemmap_alloc/free. David suggested we can compute what > > hugetlb_vmemmap_init() does now at runtime. We do not need to worry > > for the overhead of computing at runtime since the calculation is > > simple enough and those functions are not in a hot path. This commit > > has the following improvements: > > > > 1) The function suffixed name ("optimize/restore") is more expressive. > > 2) The logic becomes less weird in hugetlb_vmemmap_optimize/restore(). > > 3) The hugetlb_vmemmap_init() does not need to be exported anymore. > > 4) A ->optimize_vmemmap_pages field in struct hstate is killed. > > 5) There is only one place where checks is_power_of_2(sizeof(struct > > page)) instead of two places. > > 6) Add more comments for hugetlb_vmemmap_optimize/restore(). > > 7) For external users, hugetlb_optimize_vmemmap_pages() is used for > > detecting if the HugeTLB's vmemmap pages is optimizable originally. > > In this commit, it is killed and we introduce a new helper > > hugetlb_vmemmap_optimizable() to replace it. The name is more > > expressive. > > > > Link: https://lore.kernel.org/all/20220404074652.68024-2-songmuchun@bytedance.com/ [1] > > Signed-off-by: Muchun Song > > --- > > include/linux/hugetlb.h | 7 +-- > > include/linux/sysctl.h | 4 ++ > > mm/hugetlb.c | 15 ++--- > > mm/hugetlb_vmemmap.c | 143 ++++++++++++++++++++---------------------------- > > mm/hugetlb_vmemmap.h | 41 +++++++++----- > > 5 files changed, 102 insertions(+), 108 deletions(-) > > Thanks! I like the removal of hugetlb_vmemmap_init and printing directly > from report_hugepages. Still need to look at your your command parsing > patches. > Thanks Mike. I am also trying to think about if it is easy to split the command parsing patch to some small patches for easily reviewing. > > @@ -3191,8 +3191,10 @@ static void __init report_hugepages(void) > > char buf[32]; > > > > string_get_size(huge_page_size(h), 1, STRING_UNITS_2, buf, 32); > > - pr_info("HugeTLB registered %s page size, pre-allocated %ld pages\n", > > + pr_info("HugeTLB: registered %s page size, pre-allocated %ld pages\n", > > buf, h->free_huge_pages); > > + pr_info("HugeTLB: %d KiB vmemmap can be freed for a %s page\n", > > + hugetlb_vmemmap_optimizable_size(h) / SZ_1K, buf); > > } > > } > > My first thought was "Why report vmemmap freed pages if not enabled?". > However, since it can be enabled at runtime it is best always print. > That's what I thought. > Reviewed-by: Mike Kravetz > Thanks. > -- > Mike Kravetz >