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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0EFBC43460 for ; Thu, 15 Apr 2021 08:29:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6432611AB for ; Thu, 15 Apr 2021 08:29:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231650AbhDOIaC (ORCPT ); Thu, 15 Apr 2021 04:30:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:38514 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231251AbhDOI37 (ORCPT ); Thu, 15 Apr 2021 04:29:59 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 06EC4AE72; Thu, 15 Apr 2021 08:29:36 +0000 (UTC) Date: Thu, 15 Apr 2021 10:29:33 +0200 From: Oscar Salvador To: Michal Hocko Cc: Andrew Morton , Mike Kravetz , Vlastimil Babka , David Hildenbrand , Muchun Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 5/7] mm: Make alloc_contig_range handle free hugetlb pages Message-ID: References: <20210413104747.12177-1-osalvador@suse.de> <20210413104747.12177-6-osalvador@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 13, 2021 at 03:40:18PM +0200, Michal Hocko wrote: > > + /* > > + * Call __prep_new_huge_page() to construct the hugetlb page, and > > + * enqueue it then to place it in the freelists. After this, > > + * counters are back on track. Free hugepages have a refcount of 0, > > + * so we need to decrease new_page's count as well. > > + */ > > + __prep_new_huge_page(new_page); > > + __prep_account_new_huge_page(h, nid); > > I think it would help to put something like the following into the > comment above this really strange construct. > > /* > * new_page needs to be initialized with the standard > * hugetlb state. This is normally done by > * prep_new_huge_page but that takes hugetlb_lock which > * is already held so we need to open code it here. > * Reference count trick is needed because allocator > * gives us referenced page but the pool requires pages > * with 0 refcount. > */ Ok, I will try to add more info, thanks Michal! -- Oscar Salvador SUSE L3