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 X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4DAEC433E1 for ; Wed, 8 Jul 2020 22:11:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5173D206DF for ; Wed, 8 Jul 2020 22:11:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5173D206DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hisilicon.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DD4016B0002; Wed, 8 Jul 2020 18:11:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D86C66B0003; Wed, 8 Jul 2020 18:11:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C74F76B0005; Wed, 8 Jul 2020 18:11:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id ADDC46B0002 for ; Wed, 8 Jul 2020 18:11:29 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 69D788248D52 for ; Wed, 8 Jul 2020 22:11:29 +0000 (UTC) X-FDA: 77016305898.12.ocean20_1c0868426ec0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 39F6418012888 for ; Wed, 8 Jul 2020 22:11:29 +0000 (UTC) X-HE-Tag: ocean20_1c0868426ec0 X-Filterd-Recvd-Size: 5150 Received: from huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Wed, 8 Jul 2020 22:11:28 +0000 (UTC) Received: from dggemi404-hub.china.huawei.com (unknown [172.30.72.56]) by Forcepoint Email with ESMTP id D9DBF9BAF1658D408F63; Thu, 9 Jul 2020 06:11:24 +0800 (CST) Received: from DGGEMI525-MBS.china.huawei.com ([169.254.6.177]) by dggemi404-hub.china.huawei.com ([10.3.17.142]) with mapi id 14.03.0487.000; Thu, 9 Jul 2020 06:11:16 +0800 From: "Song Bao Hua (Barry Song)" To: Roman Gushchin , Mike Kravetz CC: Andrew Morton , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Linuxarm , "Jonathan Cameron" Subject: RE: [PATCH v3] mm/hugetlb: avoid hardcoding while checking if cma is enable Thread-Topic: [PATCH v3] mm/hugetlb: avoid hardcoding while checking if cma is enable Thread-Index: AQHWVBOoulIbQRW0JUWzWUpoYRXjrqj8AzOAgAFtnQCAABEKgIAAvWLg Date: Wed, 8 Jul 2020 22:11:15 +0000 Message-ID: References: <20200707040204.30132-1-song.bao.hua@hisilicon.com> <20200707125641.dbd2ccd63f525aa5870069d8@linux-foundation.org> <9066e009-5ed2-1992-d70d-fd27b4bf5871@oracle.com> <20200708184615.GA251665@carbon.dhcp.thefacebook.com> In-Reply-To: <20200708184615.GA251665@carbon.dhcp.thefacebook.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.126.202.83] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 39F6418012888 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: > -----Original Message----- > From: Roman Gushchin [mailto:guro@fb.com] > Sent: Thursday, July 9, 2020 6:46 AM > To: Mike Kravetz > Cc: Andrew Morton ; Song Bao Hua (Barry Song) > ; linux-mm@kvack.org; > linux-kernel@vger.kernel.org; Linuxarm ; Jonathan > Cameron > Subject: Re: [PATCH v3] mm/hugetlb: avoid hardcoding while checking if cm= a > is enable >=20 > On Wed, Jul 08, 2020 at 10:45:16AM -0700, Mike Kravetz wrote: > > On 7/7/20 12:56 PM, Andrew Morton wrote: > > > On Tue, 7 Jul 2020 16:02:04 +1200 Barry Song > wrote: > > > > > >> hugetlb_cma[0] can be NULL due to various reasons, for example, node= 0 > has > > >> no memory. so NULL hugetlb_cma[0] doesn't necessarily mean cma is no= t > > >> enabled. gigantic pages might have been reserved on other nodes. > > > > > > I'm trying to figure out whether this should be backported into 5.7.1= , > > > but the changelog doesn't describe any known user-visible effects of > > > the bug. Are there any? > > > > Barry must have missed this email. He reported the issue so I was hopi= ng > > he would reply. Yep. it should be better to backport it into 5.7. it doesn't cause serious = crash or failure, but could cause double reservation or cma leak. > > > > Based on the code changes, I believe the following could happen: > > - Someone uses 'hugetlb_cma=3D' kernel command line parameter to reserv= e > > CMA for gigantic pages. > > - The system topology is such that no memory is on node 0. Therefore, > > no CMA can be reserved for gigantic pages on node 0. CMA is reserved > > on other nodes. > > - The user also specifies a number of gigantic pages to pre-allocate on > > the command line with hugepagesz=3D hugepages=3D<= N> > > - The routine which allocates gigantic pages from the bootmem allocator > > will not detect CMA has been reserved as there is no memory on node 0= . > > Therefore, pages will be pre-allocated from bootmem allocator as well > > as reserved in CMA. > > > > This double allocation (bootmem and CMA) is the worst case scenario. N= ot > > sure if this is what Barry saw, and I suspect this would rarely happen. > > > > After writing this, I started to think that perhaps command line parsin= g > > should be changed. If hugetlb_cma=3D is specified, it makes no sense t= o > > pre-allocate gigantic pages. Therefore, the hugepages=3D paramemter > > should be ignored and flagged with a warning if hugetlb_cma=3D is spec= ified. > > This could be checked at parsing time and there would be no need for su= ch > > a check in the allocation code (except for sanity cheching). > > > > Thoughts? I just cleaned up the parsing code and could make such a > change > > quite easily. >=20 > I agree. Basically, if hugetlb_cma_size > 0, we should not pre-allocate > gigantic pages. It would be much simpler and more reliable than the exist= ing > code. I agree this is a better solution, if hugetlb_cma has higher priority than = bootmem gigantic pages, we should document it. >=20 > Thank you! Thanks Barry