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 E5B73C433F5 for ; Wed, 6 Oct 2021 08:41:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9389F61139 for ; Wed, 6 Oct 2021 08:41:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9389F61139 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 E943F6B006C; Wed, 6 Oct 2021 04:41:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4481900003; Wed, 6 Oct 2021 04:41:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D33BA900002; Wed, 6 Oct 2021 04:41:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id C55C86B006C for ; Wed, 6 Oct 2021 04:41:19 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5E5581814942B for ; Wed, 6 Oct 2021 08:41:19 +0000 (UTC) X-FDA: 78665368278.15.23F1C34 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf05.hostedemail.com (Postfix) with ESMTP id 062905074F2C for ; Wed, 6 Oct 2021 08:41:18 +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-out2.suse.de (Postfix) with ESMTPS id B52791FE98; Wed, 6 Oct 2021 08:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1633509677; 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=8iu+sHBr3seFeFij8nLPdAVGaZLAx3fbH3tVLrNu7NQ=; b=TJDgMTMj6Wtd3SCKBoX+ex/PL+tUJK47pZ+vtJ45PEhdEPq4oHvYSXrv6Z2GHTPDjiNho9 XnydJBvT8I4QsICqybfqcBnUg0d6KvBTFrDskXKeoAWT2T1xCGeDl63MX87QFgS1M79vBg REEWPGN6X9bYTFCohe5y3xFf/h9js6Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1633509677; 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=8iu+sHBr3seFeFij8nLPdAVGaZLAx3fbH3tVLrNu7NQ=; b=Zo7W2GBFP3SlKdEXqVO73V0CuoBRtXKMOGesej1y2h+HXcLlnPPOBsfbbQYraAs1WyyhGm qISsCRRiKXZV/lAg== 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 1AD8213E19; Wed, 6 Oct 2021 08:41:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ep0IAy1hXWEaNAAAMHmgww (envelope-from ); Wed, 06 Oct 2021 08:41:17 +0000 Date: Wed, 6 Oct 2021 10:41:15 +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 5/5] hugetlb: add hugetlb demote page support Message-ID: <20211006084112.GA12288@linux> References: <20211001175210.45968-1-mike.kravetz@oracle.com> <20211001175210.45968-6-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211001175210.45968-6-mike.kravetz@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 062905074F2C X-Stat-Signature: zx5i81dwf9w1kap3fffxzxdxzss64tzu Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=TJDgMTMj; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Zo7W2GBF; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf05.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.29 as permitted sender) smtp.mailfrom=osalvador@suse.de X-HE-Tag: 1633509678-962238 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:10AM -0700, Mike Kravetz wrote: > Demote page functionality will split a huge page into a number of huge > pages of a smaller size. For example, on x86 a 1GB huge page can be > demoted into 512 2M huge pages. Demotion is done 'in place' by simply > splitting the huge page. > > Added '*_for_demote' wrappers for remove_hugetlb_page, > destroy_compound_gigantic_page and prep_compound_gigantic_page for use > by demote code. > > Signed-off-by: Mike Kravetz > --- > mm/hugetlb.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++----- > 1 file changed, 74 insertions(+), 8 deletions(-) > ... > +static int demote_free_huge_page(struct hstate *h, struct page *page) > +{ > + int i, nid = page_to_nid(page); > + struct hstate *target_hstate; > + int rc = 0; > + > + target_hstate = size_to_hstate(PAGE_SIZE << h->demote_order); > + > + remove_hugetlb_page_for_demote(h, page, false); > + spin_unlock_irq(&hugetlb_lock); > + > + rc = alloc_huge_page_vmemmap(h, page); > + if (rc) { > + /* Allocation of vmemmmap failed, we can not demote page */ > + spin_lock_irq(&hugetlb_lock); > + set_page_refcounted(page); > + add_hugetlb_page(h, page, false); > + return rc; > + } Question: You keep the original error code returned from alloc_huge_page_vmemmap() here, but then you lose it on demote_pool_huge_page() when doing the !demote_free_huge_page. Would not make more sense to keep it all the way down to demote_store() in case you want to return the actual error code? > + > + /* > + * Use destroy_compound_gigantic_page_for_demote for all huge page > + * sizes as it will not ref count pages. > + */ > + destroy_compound_gigantic_page_for_demote(page, huge_page_order(h)); It seems that for now we only allow gigantic pages to be demoted, but destroy_compound_gigantic_page_for_demote feels kind of wrong, even if it is only a wrapper that ends up calling _*gigantic_ functions. We want a routine that destroy a hugetlb to be demoted into smaller hugetlb pages, so the name gigantic makes little sense to appear in my opinion. > static int demote_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed) > __must_hold(&hugetlb_lock) > { > + int nr_nodes, node; > + struct page *page; > int rc = 0; > > lockdep_assert_held(&hugetlb_lock); > @@ -3313,9 +3377,15 @@ static int demote_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed) > if (!h->demote_order) > return rc; > > - /* > - * TODO - demote fucntionality will be added in subsequent patch > - */ > + for_each_node_mask_to_free(h, nr_nodes, node, nodes_allowed) { > + if (!list_empty(&h->hugepage_freelists[node])) { > + page = list_entry(h->hugepage_freelists[node].next, > + struct page, lru); > + rc = !demote_free_huge_page(h, page); I kinda dislike this as I pointed out. -- Oscar Salvador SUSE Labs