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 8C436C43334 for ; Fri, 22 Jul 2022 06:38:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CAE486B0072; Fri, 22 Jul 2022 02:38:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C35358E0001; Fri, 22 Jul 2022 02:38:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD5A76B0074; Fri, 22 Jul 2022 02:38:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 970E26B0072 for ; Fri, 22 Jul 2022 02:38:18 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 66FA7140AB2 for ; Fri, 22 Jul 2022 06:38:18 +0000 (UTC) X-FDA: 79713781476.14.160063A Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf09.hostedemail.com (Postfix) with ESMTP id 6EA97140019 for ; Fri, 22 Jul 2022 06:38:17 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Lq073327nz1M8KS; Fri, 22 Jul 2022 14:35:27 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 22 Jul 2022 14:38:13 +0800 Subject: Re: [PATCH 5/5] hugetlbfs: fix confusing hugetlbfs stat To: Mike Kravetz CC: , , , References: <20220721131637.6306-1-linmiaohe@huawei.com> <20220721131637.6306-6-linmiaohe@huawei.com> From: Miaohe Lin Message-ID: Date: Fri, 22 Jul 2022 14:38:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658471898; a=rsa-sha256; cv=none; b=vb/aXE9elAEE1R7qhPAPujt3Mea+BIG7ZGQIKaQzh71CDiYIW+Mw0EBAnIG7SiRf6Wn9T/ UKrbep8JgHA5LRo9hR0DPAK54CFlgkHeRaYWV/3O0bFHdM7u1BQZOCoVc+enfnj7+oMNfz qz5aZPxslG+9KJcNYy/rMJOvRX3a4/k= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658471898; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QecetwaU0lkDjhrpp04Mu3LrLKcZOp03DeyDwBWvu6k=; b=u/7bgnOZVfA07vpTmsdRW9PKKDtoMjC7qXwrtwMQIHOO1T6sJPB0RFgKQdunSPUFX0IggX hPKjVzqtsPuZ9MUF79H3ghsv2o3z0ne244Dz9SCpl1mnWetf+2MRoWdRFmnVDUNM2fwHP+ CBsxpFJvdRNx4u4b0y+vfyhjNhIIH/w= X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam01 X-Stat-Signature: b9d8fw6pmq46jcx43znnsjmsnck11q3n X-Rspamd-Queue-Id: 6EA97140019 X-HE-Tag: 1658471897-37236 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 2022/7/22 8:28, Mike Kravetz wrote: > On 07/21/22 21:16, Miaohe Lin wrote: >> When size option is not specified, f_blocks, f_bavail and f_bfree will be >> set to -1 instead of 0. Likewise, when nr_inodes is not specified, f_files >> and f_ffree will be set to -1 too. Check max_hpages and max_inodes against >> -1 first to make sure 0 is reported for max/free/used when no limit is set >> as the comment states. > > Just curious, where are you seeing values reported as -1? The check >From the standard statvfs() function. > for sbinfo->spool was supposed to handle these cases. Seems like it sbinfo->spool could be created when ctx->max_hpages == -1 while ctx->min_hpages != -1 in hugetlbfs_fill_super. > should handle the max_hpages == -1 case. But, it doesn't look like it > considers the max_inodes == -1 case. > > If I create/mount a hugetlb filesystem without specifying size or nr_inodes, > df seems to report zero instead of -1. > > Just want to understand the reasoning behind the change. I wrote a test program: #include #include int main(void) { struct statvfs buf; if (statvfs("/root/huge/", &buf) == -1) { printf("statvfs() error\n"); return -1; } printf("f_blocks %lld, f_bavail %lld, f_bfree %lld, f_files %lld, f_ffree %lld\n", buf.f_blocks, buf.f_bavail, buf.f_bfree, buf.f_files, buf.f_ffree); return 0; } And test it in my env: [root@localhost ~]# mount -t hugetlbfs none /root/huge/ [root@localhost ~]# ./stat f_blocks 0, f_bavail 0, f_bfree 0, f_files 0, f_ffree 0 [root@localhost ~]# umount /root/huge/ [root@localhost ~]# mount -t hugetlbfs -o min_size=32M none /root/huge/ [root@localhost ~]# ./stat f_blocks -1, f_bavail -1, f_bfree -1, f_files -1, f_ffree -1 [root@localhost ~]# umount /root/huge/ [root@localhost ~]# mount -t hugetlbfs -o min_size=32M,size=64M none /root/huge/ [root@localhost ~]# ./stat f_blocks 32, f_bavail 32, f_bfree 32, f_files -1, f_ffree -1 [root@localhost ~]# umount /root/huge/ [root@localhost ~]# mount -t hugetlbfs -o min_size=32M,size=64M,nr_inodes=1024 none /root/huge/ [root@localhost ~]# ./stat f_blocks 32, f_bavail 32, f_bfree 32, f_files 1024, f_ffree 1023 [root@localhost ~]# umount /root/huge/ Or am I miss something? > Thanks.