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 DD527C433EF for ; Mon, 13 Jun 2022 09:01:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 27F588D016E; Mon, 13 Jun 2022 05:01:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 22F2F8D016C; Mon, 13 Jun 2022 05:01:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F6938D016E; Mon, 13 Jun 2022 05:01:51 -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 041428D016C for ; Mon, 13 Jun 2022 05:01:51 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 03DDA34512 for ; Mon, 13 Jun 2022 09:01:49 +0000 (UTC) X-FDA: 79572619980.22.2820D7D Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf16.hostedemail.com (Postfix) with ESMTP id 183E1180083 for ; Mon, 13 Jun 2022 09:01:48 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id z14so856519pgh.0 for ; Mon, 13 Jun 2022 02:01: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=dpkFPXwH8N70T2WIaGxLUqPTMbphsnf0gmKqluawR5w=; b=jreuVdGv6lf5T0ak6AmbOb79gJnnkRPj55ArCmGE+9q16i/W4yyNDItf+WoX7Qod5G v6Ox4HL5s5CdRLXadrGeF9+4Wynirq+pruiqrLo3dEHkQxKemDm1crfIGSX/af8U4H8G 4C7mHWsJFyrFCOc+ib9tMZqfARjHodA6d4eOZiuETuOkQ/rc8Mv1UnyIliNECrRxECG4 fIG+fhBliVI4qncveDU2MhhbOzrroRrk0A32z4kSia98SqfrgclP1EqbOGuysZBxxYEO YQNfmC1G2eIVQi7sgTmJveQCRndww8IW1Zp43yhq7vOIZS7SLn3NOKfnwKK5neAAEzzv oKPw== 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=dpkFPXwH8N70T2WIaGxLUqPTMbphsnf0gmKqluawR5w=; b=AH+xhOgYq8DBol0qUYHPm24XL+wesIjUEf8lXMNwwz5QwFXgVqwDUh0ekX9DoGl7od KVEnxUt6N3OKoFRX/2maz9ZUEA8Gvwsi8m8Zupa30WY56HvtFVj4mDakYpmpMg22oSr/ Zh8DhJgN8sbZRPCDtM0QAwFoKKAbjuutPh65T3KeJg4wA9p5J63dSwNR3qppG2PSpNae WGorZL0KLE5wGVKjrDrP+u5fTyfde35K9XhOlqe3Qtv8D6e7Jl8NJrVVQ9xGXTXV0AD2 gWb2muV7Qq6gET3MUieubtfGEhniRG2HX6As95bnb8ZiqgNISQZc/aG2PXFr6No0Du5j 21FA== X-Gm-Message-State: AOAM531qmRiMsq6Wt2thQfp0n1le4pa0oYNvViIJpuyiPzbHFaoQlBMZ PRDjJNVkDTqoYvaKsAh4xg3uVVS8rDK8s5hiog8= X-Google-Smtp-Source: ABdhPJxApn2CFCOq6CupZRjITh38l7zl4N2mKhELqQ9kxxOlAbz6FnIv59v+4TjqrZcmd0e/7ENCnQ== X-Received: by 2002:a05:6a00:410a:b0:51e:6fc6:e4da with SMTP id bu10-20020a056a00410a00b0051e6fc6e4damr20340880pfb.84.1655110907858; Mon, 13 Jun 2022 02:01:47 -0700 (PDT) Received: from localhost ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id q5-20020a170902c74500b001638a171558sm4509347plq.202.2022.06.13.02.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jun 2022 02:01:47 -0700 (PDT) Date: Mon, 13 Jun 2022 17:01:43 +0800 From: Muchun Song To: Oscar Salvador Cc: mike.kravetz@oracle.com, david@redhat.com, akpm@linux-foundation.org, corbet@lwn.net, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH 6/6] mm: hugetlb_vmemmap: improve hugetlb_vmemmap code readability Message-ID: References: <20220613063512.17540-1-songmuchun@bytedance.com> <20220613063512.17540-7-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655110909; a=rsa-sha256; cv=none; b=MWPmnHY3kntW7vQBQRkF+AhdBVimgYOb2y4/m4/7peDMO/6UTLa7c34NADr7Hi5Owx3dck 3GfgrEDK8DNJbOUCLrS3Gxmeeysyu8kslquhaTOypDubezb1wT5dAcY+OgNNIHW5Za8j5h 2f7TFpKcoT0SjUDhufogandOs3smbn4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=jreuVdGv; spf=pass (imf16.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655110909; 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=dpkFPXwH8N70T2WIaGxLUqPTMbphsnf0gmKqluawR5w=; b=i7f+DstVGXHr+wn2IAgP9pTWGhzM1iMRgU/eCgxx3ed2892xfikz415oZsOKc6Lq79j/DS 9A/EEajhgQDuwSCv+c9qOY7c3CPl5kirsFlFf7jlvbDQjOiSY+x9XJA3tH1Ezh5KJ6X3K5 vfEyxXlps3qQASYtvmgGCobT5b/6dyk= X-Rspamd-Queue-Id: 183E1180083 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=jreuVdGv; spf=pass (imf16.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: y8d66nm7aezfcmphwby8gwhiukm7jj7i X-HE-Tag: 1655110908-23512 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000029, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jun 13, 2022 at 10:33:48AM +0200, Oscar Salvador wrote: > On Mon, Jun 13, 2022 at 02:35:12PM +0800, Muchun Song wrote: > > -static __init int hugetlb_vmemmap_sysctls_init(void) > > +static int __init hugetlb_vmemmap_init(void) > > { > > + const struct hstate *h; > > + bool optimizable = false; > > + > > /* > > - * If "struct page" crosses page boundaries, the vmemmap pages cannot > > - * be optimized. > > + * There are only (RESERVE_VMEMMAP_SIZE / sizeof(struct page)) struct > > + * page structs that can be used when HVO is enabled. > > */ > > - if (is_power_of_2(sizeof(struct page))) > > - register_sysctl_init("vm", hugetlb_vmemmap_sysctls); > > + BUILD_BUG_ON(__NR_USED_SUBPAGE >= RESERVE_VMEMMAP_SIZE / sizeof(struct page)); > > I need to take another look, but from the first glance there is something > here that caught my eye. > Thanks for taking a look. This is introduced in commit f41f2ed43ca5. > > + > > + for_each_hstate(h) { > > + char buf[16]; > > + unsigned int size = 0; > > + > > + if (hugetlb_vmemmap_optimizable(h)) > > + size = hugetlb_vmemmap_size(h) - RESERVE_VMEMMAP_SIZE; > > + optimizable = size ? true : optimizable; > > This feels weird, just use false instead of optimizable. > This is a loop, we shoud keep "optimizable" as "true" as long as there is one hstate is optimizable. How about: if (size) optimizable = true; > > + string_get_size(huge_page_size(h), 1, STRING_UNITS_2, buf, > > + sizeof(buf)); > > + pr_info("%d KiB vmemmap can be optimized for a %s page\n", > > + size / SZ_1K, buf); > > I do not have a strong opinion but I wonder whether this brings a lot. > I thought the users can know what size HugeTLB is optimizable via this log. E.g. On aarch64, 64KB HugeTLB cannot be optimizable. I do not have a strong opinion as well, if anyone think it is unnecessary, I'll drop it in next version. Thanks.