Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4412314pxb; Tue, 5 Oct 2021 02:34:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1CNh/b2gNz//pqImRxVVZVLo757Krl+a4UoFBG80lFnua2TNK2pnduPrHbujFoGp5GYWC X-Received: by 2002:aa7:8bd3:0:b0:44c:68b3:a52e with SMTP id s19-20020aa78bd3000000b0044c68b3a52emr7853942pfd.74.1633426463914; Tue, 05 Oct 2021 02:34:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633426463; cv=none; d=google.com; s=arc-20160816; b=ryOTV0iDc1h4FVLAn7kxvnOciiaOC68Jsue9WPZrelR+C+6T3BvKy6cSueWQ8WRRkJ TXqe/5aUVovo4ehgVTOQS7VJA4l6jxT8QBu1TxrrC1E4TvZemS4Ni+zaV8/IUvbdnsuR nw0KojUJdTobMTZgJqbZhPFK5/CsxhXamz8Wsknnghncw8rLgbpF9j3/SciFgV/U5f9l kwbsc3GDgjLhNmCowbEv+zGvt2CJgrPTFOHze1gjo6WV2aI4SMYbrHiuvA0DW+taSeG6 EcmCx+UQ2EVDkxr8ezDEe1+aJTTQIQisPG+h0Ie6DwOYsXeRHmjI11COLYF958Tyc1GU Hovw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=HAkjnMZVZvrpnMAU3yhNhqnfSKBwfeJfs42ZqvYDQ1Y=; b=X32nan1YiOLc31cIx++2cjUDonALLTF/IgEq5kmjrbOTFFaoAUnBXHZVxMK1FEmYtY 5uRU2YyOVgMK7jW3RlOGLoSAhIci+udMD7hUeMkfvu4azlGdYqZl964JlVrRwgsPXRfc 1iFh7eYwGrLjGFkeWSFz6MtYTZ1gAx9EkvbBQNHEU4AsqhB0QKOTHsLbTIvx0XJ9P8Xt Eb1NTxh+FNixnbUCVCHSXNTQOtPKpb4jZXLWW8FMQ1U5TZtGNAssiYoOdUlqEB7jT/y1 lY/YfwHNMPMW6+hHfWVmNRULDEy51jyVLXZL1rhap0M5dlf/CCZwQfyWM/Eh0Y+9jy+R YiBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=1KumHG76; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y63si14965150pgd.399.2021.10.05.02.34.11; Tue, 05 Oct 2021 02:34:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=1KumHG76; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233077AbhJEJfP (ORCPT + 99 others); Tue, 5 Oct 2021 05:35:15 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:35564 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232658AbhJEJfO (ORCPT ); Tue, 5 Oct 2021 05:35:14 -0400 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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