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 28CE9CD1292 for ; Thu, 4 Apr 2024 20:45:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC6626B009E; Thu, 4 Apr 2024 16:45:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A76A76B009F; Thu, 4 Apr 2024 16:45:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93EF96B00A0; Thu, 4 Apr 2024 16:45:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 73A5E6B009E for ; Thu, 4 Apr 2024 16:45:37 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2ACF2120E3B for ; Thu, 4 Apr 2024 20:45:37 +0000 (UTC) X-FDA: 81973030314.18.EE2473D Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) by imf20.hostedemail.com (Postfix) with ESMTP id 33D8E1C0005 for ; Thu, 4 Apr 2024 20:45:34 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=xBNua1OY; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf20.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.218.175.177 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712263535; 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:dkim-signature; bh=faC9VnGInM+BsAmXSg8y4ZIaDISK1P0XMY+yn8LzviY=; b=blX+ZoEqRH8Q4JuNFuO1pIT+n2EMaybZXEvkhUG7IGklKl8CaPrq9B0Qs1HebL6xAfdKY/ qocxIAMzBvsGxo7xAvQhSyVuz9xjpu4crFV4kQW3PdMIWBGj6X6raQV/RQKLh6JndfvJWu +IOMCvai1UVYDVrPuOYvjiG5b9m0sqM= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=xBNua1OY; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf20.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.218.175.177 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712263535; a=rsa-sha256; cv=none; b=FjIup9LcFeW4VwaWzgN8Za+227E8UXXWBrNXrRK2w06h56a6hX2qvQXEp0aEW97IO7G51l eQ/9totbXuWavlXS7ZOKeYpk1e9v3cgYAyeKTB3gWQkXNRa3tYQWNuYDdfRqugBQc2Btpd JLuFbg8/nLF3kwqNJTVp8NEl6/5d8ew= Date: Thu, 4 Apr 2024 13:45:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1712263532; h=from:from: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=faC9VnGInM+BsAmXSg8y4ZIaDISK1P0XMY+yn8LzviY=; b=xBNua1OYabSdsuCixDGVv/AQ+feNNrnBTRqGMySX+zwCzvMlxsxocgI8dM02AzPcAkipfP QG9H1+0JmGBFDjqVW20DCK/sstkwwCN1hfj+aqegcsnDQkRq1GgMzhJzPSAicm1rli80gQ 962Ifs5oPx3NHdA7ODADAChniH7rV4Y= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Frank van der Linden Cc: linux-mm@kvack.org, muchun.song@linux.dev, akpm@linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] mm/hugetlb: pass correct order_per_bit to cma_declare_contiguous_nid Message-ID: References: <20240404162515.527802-1-fvdl@google.com> <20240404162515.527802-2-fvdl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Stat-Signature: 7yi4yx1qx5chpfemiz4qbun5xfjha51n X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 33D8E1C0005 X-HE-Tag: 1712263534-44785 X-HE-Meta: U2FsdGVkX19TnPqGYHpWj/gLDO3v1ML2ktRuzyanyI8X+PWcL/i9k9GGNzi7MY7DvRh9z2Bb3N67me25jllfZHvVXZQnSaTotw6qk8NBx2gcSr6mXdVYabNUn93ytHR9nLaWA/GpXGWRygSocR2swa828lGF35x/tBKiR9AZK7Ad8vDl82RRJ6iRbu66JSDo9qsvI2YijFiXZBkTk1GwGHoMPzq8aFfxgT0TBrEsyU14NyPqVj4Sjv9STAOFzuoil9Ysi6RHhj53d9MQYmYcZEcW3yRnJMOQuBSq/8ID3IEwl2AS4wbPIYocLEfTaTW+vgVsDgTVgvbk8NIN2y4ayclgiWR+A2QaodT2K69i/Q7X9TTNQmd5LBZinl0f1qCjyDp4gvokO3Ce9zlDHnwAt5B7CKvcjekIbeloYxGgwCk24LwasU3kWAGYWg//e/osW5cNJcqoaxBoRHhwFcwCbp/g07FXdfn9CqqRmJbVWrwCzUS7HMRvCtw1V/H+tCn9lKysQ/DbalTj35M967HfDtFMLu8kqwX+n4XKwg3kxTKhewAW2RpMiCI8JF3uHe38ki97WnRYCYMepRteUVrL37pDsBQclJwEkCewX1XqHXaHchNM0ieiYjssKL1nEBZD1NA/KV1hiQkrVeV4bV8m/1oildYqRRrH8WWGg6S3xHncfL18i2e6FdNR/qjux9kGCFjS0LAH1UkRhadEWsI3eITmv4FF89sEMkX5mduTPxN5H9MRdwU/Fu2VCLeFsMEzHIX6u+Y/dqlC+Dfd5/YN3qr1XEG2C6w9Tj1DMB573p2k7oxMHY0bF3HbhPNKa0ppDk9zVSaFgAj0h+RvWLV8uT59HBtkx5ntJnsmvxfZn7/5cwoUlcklMQB9S8yJRn5gzEQvDVz/y8GoNBR9c9t1Ac8Q4LzrjUJdq7TuGUXsEuXvILtgw8o8hR1xPEQGX6gFiMJsh9lk1GOX3fPCT9n s4sl8Jxr D96cKk01IilBX0sP9ebs5fnzg4czCOVkTMTJLONm8XaRdgpYjmnBG0ZNFVtBKBXoF+OCsHaARJufbWbIWXshVTXW5Hmy1GOIpAtEmM+sErM2cArH054H7WuqPnCQ3OOjNTeFeQfFpAnhM6V8+qw0umK9+REm1rHULfVsh2RuRtuxjCqdoHjq2TtXQpoUirGkjTGsk2AG7x6rp/zATMmTg+kj4epcdfX+p9tinjpwm1IDZpv4BsojiErgvxu8TNpF39/b/M+QuMqRKi9M= 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: List-Subscribe: List-Unsubscribe: On Thu, Apr 04, 2024 at 12:40:58PM -0700, Frank van der Linden wrote: > On Thu, Apr 4, 2024 at 11:56 AM Roman Gushchin wrote: > > > > On Thu, Apr 04, 2024 at 04:25:15PM +0000, Frank van der Linden wrote: > > > The hugetlb_cma code passes 0 in the order_per_bit argument to > > > cma_declare_contiguous_nid (the alignment, computed using the > > > page order, is correctly passed in). > > > > > > This causes a bit in the cma allocation bitmap to always represent > > > a 4k page, making the bitmaps potentially very large, and slower. > > > > > > So, correctly pass in the order instead. > > > > > > Signed-off-by: Frank van der Linden > > > Cc: Roman Gushchin > > > Fixes: cf11e85fc08c ("mm: hugetlb: optionally allocate gigantic hugepages using cma") > > > > Hi Frank, > > > > there is a comment just above your changes which explains why order_per_bit is 0. > > Is this not true anymore? If so, please, fix the comment too. Please, clarify. > > > > Thanks! > > Hi Roman, > > I'm assuming you're referring to this comment: > > /* > * Note that 'order per bit' is based on smallest size that > * may be returned to CMA allocator in the case of > * huge page demotion. > */ > > That comment was added in a01f43901cfb9 ("hugetlb: be sure to free > demoted CMA pages to CMA"). > > It talks about HUGETLB_PAGE_ORDER being the minimum order being given > back to the CMA allocator (after hugetlb demotion), therefore > order_per_bit must be HUGETLB_PAGE_ORDER. See the commit message for > that commit: > > "Therefore, at region setup time we use HUGETLB_PAGE_ORDER as the > smallest possible huge page size that can be given back to CMA." > > But the commit, while correctly changing the alignment, left the > order_per_bit argument at 0, even though it clearly intended to set > it at HUGETLB_PAGE_ORDER. The confusion may have been that > cma_declare_contiguous_nid has 9 arguments, several of which can be > left at 0 meaning 'use default', so it's easy to misread. > > In other words, the comment was correct, but the code was not. After > this patch, comment and code match. Indeed the mentioned commit which added a comment which was not aligned with the code was confusing. It all makes sense now, thank you for the explanation! Please, feel free to add Acked-by: Roman Gushchin for your patch. Thanks!