Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3721494pxb; Mon, 4 Oct 2021 08:14:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1aUhiTWclKi9RNKiKO7EZO9HqkIlqc51RXS/AgLp8HLaB04nyerxmI2062tGcGXvY1frR X-Received: by 2002:a63:441c:: with SMTP id r28mr10978161pga.94.1633360492789; Mon, 04 Oct 2021 08:14:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633360492; cv=none; d=google.com; s=arc-20160816; b=izNUXcPmjVGGmCJ9FM//9UVcaE5VK2EIl36W6c90h4yy+/v+XybJHM89jKKwMne9E5 d50STn45t6Vbb3qc2mI29h1CA3Qi2w7L/dZLh0roCtgIi3pCFS2w4DqIejK6otJsWBcF QdnzZQsXB1WioZDO8PxhQPBLh0f5T/5kCL5NvDDGSyedDu8ztu4j9885XuG7KswPTdDG sotXqW2NS6YrvvYdfHM9ywK3MdF/JdsGL1XBBB44+l+A/Vy9d4fD8LT9Sa2/X/mu8QV1 4CBosO1C9K7vNXzD+65r4PAiTJQ2+n6fbMR0rLFsfZulIeG+eM5R+JnjZV1+GISfz0OV jFOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=OUdZ/nUYlMda2qgf/QTNrmYQhSZjUvD2BVvzV1p93qg=; b=lyhWeChUVkPun6tgkefowmRHtH4oJkBx79MZU6yWEXLjslpnYcimMDISB6WiPEMCbc m7l2gLFYfGd5hnXQEADnFPiKzZvsbtdGf77nY72/KDCxPLsbR2+7Eb279+YldQDumFvb tRGtf6f42mXbzS6ERZSHTvWKgheWXucTj/A+1ihvhxx+zgZQDszeZcbSCpUUKq9b6FQq GXUyDMYAldfk+M0qjNMPBdBfVvhJ2nJRHDmjIUJLP68xddwdkhiV/LJVcT14N0eqhBMR RkXUPBFP5l6DKi1tgObjm4ax7o08gQlO6LR7Vh95P8m5JVVVzqzGBdJ8JtPwK1BYmJJ/ U8pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=PlAvfOCa; dkim=neutral (no key) header.i=@suse.de; 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 q18si1732633pjp.61.2021.10.04.08.14.39; Mon, 04 Oct 2021 08:14:52 -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=PlAvfOCa; dkim=neutral (no key) header.i=@suse.de; 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 S234817AbhJDNEd (ORCPT + 99 others); Mon, 4 Oct 2021 09:04:33 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:43104 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234829AbhJDNCw (ORCPT ); Mon, 4 Oct 2021 09:02:52 -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-out2.suse.de (Postfix) with ESMTPS id 319A91FDE4; Mon, 4 Oct 2021 13:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1633352462; 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=OUdZ/nUYlMda2qgf/QTNrmYQhSZjUvD2BVvzV1p93qg=; b=PlAvfOCalzYQ013C27JLg5Vy+Z/vf/uiwSxm/Bu7hjNt8wwEbE5U/Zfb4Q5zNo6sYv8ILY C2BPI/WuFfsZ0g92iMgEb9/0NuTXgirsFWkBAwQenu8AN1XMDIFExA7ukjd7YB3pRyXBVb CsCEXhrrDH6uOD1RH2MPnr7KI2MyyQM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1633352462; 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=OUdZ/nUYlMda2qgf/QTNrmYQhSZjUvD2BVvzV1p93qg=; b=j7d7WR2b8JODNDoPphHnSSXZWwz4S5Hp3n8mb1sh/dtyIw6HKEitN96ypyum4uBT9GH0X3 OIkN4WfZ7Tn5WBBQ== 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 5136313CEE; Mon, 4 Oct 2021 13:01:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wPEiDw37WmGKPAAAMHmgww (envelope-from ); Mon, 04 Oct 2021 13:01:01 +0000 Date: Mon, 4 Oct 2021 15:00:59 +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 1/5] hugetlb: add demote hugetlb page sysfs interfaces Message-ID: References: <20211001175210.45968-1-mike.kravetz@oracle.com> <20211001175210.45968-2-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211001175210.45968-2-mike.kravetz@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 01, 2021 at 10:52:06AM -0700, Mike Kravetz wrote: > -which function as described above for the default huge page-sized case. > +The demote interfaces provide the ability to split a huge page into > +smaller huge pages. For example, the x86 architecture supports both > +1GB and 2MB huge pages sizes. A 1GB huge page can be split into 512 > +2MB huge pages. Demote interfaces are not available for the smallest > +huge page size. The demote interfaces are: > + > +demote_size > + is the size of demoted pages. When a page is demoted a corresponding > + number of huge pages of demote_size will be created. By default, > + demote_size is set to the next smaller huge page size. If there are > + multiple smaller huge page sizes, demote_size can be set to any of > + these smaller sizes. Only huge page sizes less then the current huge s/then/than ? > static void __init hugetlb_init_hstates(void) > { > - struct hstate *h; > + struct hstate *h, *h2; > > for_each_hstate(h) { > if (minimum_order > huge_page_order(h)) > @@ -2995,6 +2995,23 @@ static void __init hugetlb_init_hstates(void) > /* oversize hugepages were init'ed in early boot */ > if (!hstate_is_gigantic(h)) > hugetlb_hstate_alloc_pages(h); > + > + /* > + * Set demote order for each hstate. Note that > + * h->demote_order is initially 0. > + * - We can not demote gigantic pages if runtime freeing > + * is not supported. > + */ > + if (!hstate_is_gigantic(h) || > + gigantic_page_runtime_supported()) { Based on the comment, I think that making the condition explicit looks better from my point of view. if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) continue; > + for_each_hstate(h2) { > + if (h2 == h) > + continue; > + if (h2->order < h->order && > + h2->order > h->demote_order) > + h->demote_order = h2->order; > + } > + } > } > VM_BUG_ON(minimum_order == UINT_MAX); > } > @@ -3235,9 +3252,29 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, > return 0; > } > -- Oscar Salvador SUSE L3