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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77C6CC433F5 for ; Tue, 5 Oct 2021 09:33:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 034F761425 for ; Tue, 5 Oct 2021 09:33:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 034F761425 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6F2586B006C; Tue, 5 Oct 2021 05:33:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A2116B0071; Tue, 5 Oct 2021 05:33:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 543EA900002; Tue, 5 Oct 2021 05:33:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0200.hostedemail.com [216.40.44.200]) by kanga.kvack.org (Postfix) with ESMTP id 45FD26B006C for ; Tue, 5 Oct 2021 05:33:25 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id EE48382499A8 for ; Tue, 5 Oct 2021 09:33:24 +0000 (UTC) X-FDA: 78661870728.25.08958E6 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf18.hostedemail.com (Postfix) with ESMTP id 60C7B400281B for ; Tue, 5 Oct 2021 09:33:24 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 46A3A223DC; Tue, 5 Oct 2021 09:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1633426403; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HAkjnMZVZvrpnMAU3yhNhqnfSKBwfeJfs42ZqvYDQ1Y=; b=1KumHG76VHzfHN2eakwr7m9Rc6GOy1OJfBHrjb4jpEMb/HbyLu/N1YH3r+9su3ixr8o3Up 6D46D8zPhUq34xHqEqWG7UiVVa2qPiS48BCjSrcLEa9Id7DXSDK0q1Y3tNvrhzUiP+F8Fu EiRepmwDV4fLz8vk15FbI5UzdxLHpVM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1633426403; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HAkjnMZVZvrpnMAU3yhNhqnfSKBwfeJfs42ZqvYDQ1Y=; b=OO6tJsgZZ+3OA7Loi8gYvviGwUKYllMZVI9QLngFAXg5XYSQCi6OuBdODB6ZqC8NTBaI8q 7+STM7QX4c2hwqDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id AA6C713C1E; Tue, 5 Oct 2021 09:33:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id g4cOJ+IbXGGKBQAAMHmgww (envelope-from ); Tue, 05 Oct 2021 09:33:22 +0000 Date: Tue, 5 Oct 2021 11:33:21 +0200 From: Oscar Salvador To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, David Hildenbrand , Michal Hocko , Zi Yan , Muchun Song , Naoya Horiguchi , David Rientjes , "Aneesh Kumar K . V" , Andrew Morton Subject: Re: [PATCH v3 3/5] hugetlb: be sure to free demoted CMA pages to CMA Message-ID: <20211005093320.GC20412@linux> References: <20211001175210.45968-1-mike.kravetz@oracle.com> <20211001175210.45968-4-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211001175210.45968-4-mike.kravetz@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 60C7B400281B X-Stat-Signature: b45df5bsinyafyfbitswjydz3o6qrj8f Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=1KumHG76; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=OO6tJsgZ; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf18.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de X-HE-Tag: 1633426404-947943 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 Fri, Oct 01, 2021 at 10:52:08AM -0700, Mike Kravetz wrote: > When huge page demotion is fully implemented, gigantic pages can be > demoted to a smaller huge page size. For example, on x86 a 1G page > can be demoted to 512 2M pages. However, gigantic pages can potentially > be allocated from CMA. If a gigantic page which was allocated from CMA > is demoted, the corresponding demoted pages needs to be returned to CMA. > > Use the new interface cma_pages_valid() to determine if a non-gigantic > hugetlb page should be freed to CMA. Also, clear mapping field of these > pages as expected by cma_release. > > This also requires a change to CMA reservations for gigantic pages. > Currently, the 'order_per_bit' is set to the gigantic page size. > However, if gigantic pages can be demoted this needs to be set to the > order of the smallest huge page. At CMA reservation time we do not know to the smallest, or to the next smaller? Would you mind elaborating why? > @@ -3003,7 +3020,8 @@ static void __init hugetlb_init_hstates(void) > * is not supported. > */ > if (!hstate_is_gigantic(h) || > - gigantic_page_runtime_supported()) { > + gigantic_page_runtime_supported() || > + !hugetlb_cma_size || !(h->order <= HUGETLB_PAGE_ORDER)) { I am bit lost in the CMA area, so bear with me. We do not allow to demote if we specify we want hugetlb pages from the CMA? Also, can h->order be smaller than HUGETLB_PAGE_ORDER? I though HUGETLB_PAGE_ORDER was the smallest one. The check for HUGETLB_PAGE_ORDER can probably be squashed into patch#1. > for_each_hstate(h2) { > if (h2 == h) > continue; > @@ -3555,6 +3573,8 @@ static ssize_t demote_size_store(struct kobject *kobj, > if (!t_hstate) > return -EINVAL; > demote_order = t_hstate->order; > + if (demote_order < HUGETLB_PAGE_ORDER) > + return -EINVAL; This could probably go in the first patch. -- Oscar Salvador SUSE Labs