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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 8C305C433C1 for ; Thu, 25 Mar 2021 19:39:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3242F61A31 for ; Thu, 25 Mar 2021 19:39:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3242F61A31 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C9B236B0070; Thu, 25 Mar 2021 15:39:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C24C96B0071; Thu, 25 Mar 2021 15:39:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9E146B0072; Thu, 25 Mar 2021 15:39:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0071.hostedemail.com [216.40.44.71]) by kanga.kvack.org (Postfix) with ESMTP id 89B8D6B0070 for ; Thu, 25 Mar 2021 15:39:53 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 444C71840CAFB for ; Thu, 25 Mar 2021 19:39:53 +0000 (UTC) X-FDA: 77959411866.22.B551035 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf20.hostedemail.com (Postfix) with ESMTP id 2A34D138 for ; Thu, 25 Mar 2021 19:39:51 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1616701191; 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=b0888TBfmWBnV5AafdCEkU4aD3WyTEXqOjET2rCeeBw=; b=dJBsZf98L8e5tQDlne/q8amQKIljJOO0PDtoSw5NGJTWWsriMwKS8K22jbpvHwGShmECGz 4lspJ2Ww9sVjz26i9DeaSZQ+sEZ62QltIRJoDiORdmyH14hHtZXY1fihlhx8q9H/MZehx9 jyeXn5W3Zmsa+OjyN+zF04jdCwkKVX0= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1A671AF57; Thu, 25 Mar 2021 19:39:51 +0000 (UTC) Date: Thu, 25 Mar 2021 20:39:48 +0100 From: Michal Hocko To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Roman Gushchin , Shakeel Butt , Oscar Salvador , David Hildenbrand , Muchun Song , David Rientjes , Miaohe Lin , Peter Zijlstra , Matthew Wilcox , HORIGUCHI NAOYA , "Aneesh Kumar K . V" , Waiman Long , Peter Xu , Mina Almasry , Hillf Danton , Andrew Morton Subject: Re: [PATCH 5/8] hugetlb: call update_and_free_page without hugetlb_lock Message-ID: References: <20210325002835.216118-1-mike.kravetz@oracle.com> <20210325002835.216118-6-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: mb7zesuqcziouwaftrytxichjq9u4i6h X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 2A34D138 Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616701191-136013 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 Thu 25-03-21 10:12:05, Mike Kravetz wrote: > On 3/25/21 3:55 AM, Michal Hocko wrote: > > On Wed 24-03-21 17:28:32, Mike Kravetz wrote: > >> With the introduction of remove_hugetlb_page(), there is no need for > >> update_and_free_page to hold the hugetlb lock. Change all callers to > >> drop the lock before calling. > >> > >> With additional code modifications, this will allow loops which decrease > >> the huge page pool to drop the hugetlb_lock with each page to reduce > >> long hold times. > >> > >> The ugly unlock/lock cycle in free_pool_huge_page will be removed in > >> a subsequent patch which restructures free_pool_huge_page. > >> > >> Signed-off-by: Mike Kravetz > > > > Acked-by: Michal Hocko > > > > One minor thing below > > > > [...] > >> @@ -2563,22 +2572,37 @@ static void try_to_free_low(struct hstate *h, unsigned long count, > >> nodemask_t *nodes_allowed) > >> { > >> int i; > >> + struct list_head page_list; > >> + struct page *page, *next; > >> > >> if (hstate_is_gigantic(h)) > >> return; > >> > >> + /* > >> + * Collect pages to be freed on a list, and free after dropping lock > >> + */ > >> + INIT_LIST_HEAD(&page_list); > >> for_each_node_mask(i, *nodes_allowed) { > >> - struct page *page, *next; > >> struct list_head *freel = &h->hugepage_freelists[i]; > >> list_for_each_entry_safe(page, next, freel, lru) { > >> if (count >= h->nr_huge_pages) > >> - return; > >> + goto out; > >> if (PageHighMem(page)) > >> continue; > >> remove_hugetlb_page(h, page, false); > >> - update_and_free_page(h, page); > >> + INIT_LIST_HEAD(&page->lru); > > > > What is the point of rhis INIT_LIST_HEAD? Page has been removed from the > > list by remove_hugetlb_page so it can be added to a new one without any > > reinitialization. > > remove_hugetlb_page just does a list_del. list_del will poison the > pointers in page->lru. The following list_add will then complain about > list corruption. Are you sure? list_del followed by list_add is a normal API usage pattern AFAIK. INIT_LIST_HEAD is to do the first initialization before first use. -- Michal Hocko SUSE Labs