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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_NONE 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 DB346C433ED for ; Wed, 7 Apr 2021 08:21:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5BC1E613CE for ; Wed, 7 Apr 2021 08:21:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BC1E613CE 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 B1F2D6B007D; Wed, 7 Apr 2021 04:21:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ACF546B007E; Wed, 7 Apr 2021 04:21:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96FCF6B0080; Wed, 7 Apr 2021 04:21:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0135.hostedemail.com [216.40.44.135]) by kanga.kvack.org (Postfix) with ESMTP id 7D44B6B007D for ; Wed, 7 Apr 2021 04:21:42 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 39C36180ACEE9 for ; Wed, 7 Apr 2021 08:21:42 +0000 (UTC) X-FDA: 78004877244.26.6D0519B Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf08.hostedemail.com (Postfix) with ESMTP id 8BDFD80192D4 for ; Wed, 7 Apr 2021 08:21:34 +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=1617783700; 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=m3JZQ76Lk/bU7ik3mcWkmrq+4nBKvW17MCmmVyxB7lw=; b=FUYhfplpuretZ8z4Ls3TdJEHgyq3WTcTUH14CnOnGd38WZf7oMYTp2fMHEho8RhLwENHvS 1fKX2nNGb83WPGqtSfof+Xyl1vHsyoXpe5drYDEjrvrx6rJ/ZNZ+OXs4mI7/quAyWa0yBG hbzs0OXvyrV2ft2xA2zbXlji3bLfFVE= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 533BDB03B; Wed, 7 Apr 2021 08:21:40 +0000 (UTC) Date: Wed, 7 Apr 2021 10:21:37 +0200 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 , Joonsoo Kim , Barry Song , Will Deacon , Andrew Morton Subject: Re: [PATCH v4 4/8] hugetlb: create remove_hugetlb_page() to separate functionality Message-ID: References: <20210405230043.182734-1-mike.kravetz@oracle.com> <20210405230043.182734-5-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 8BDFD80192D4 X-Stat-Signature: 6xq35chfb5j5tjybmoyqkkc9gsrwx48z X-Rspamd-Server: rspam02 Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf08; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617783694-823088 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 Tue 06-04-21 09:49:13, Mike Kravetz wrote: > On 4/6/21 2:56 AM, Michal Hocko wrote: > > On Mon 05-04-21 16:00:39, Mike Kravetz wrote: [...] > >> @@ -2298,6 +2312,7 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, > >> /* > >> * Freed from under us. Drop new_page too. > >> */ > >> + remove_hugetlb_page(h, new_page, false); > >> update_and_free_page(h, new_page); > >> goto unlock; > >> } else if (page_count(old_page)) { > >> @@ -2305,6 +2320,7 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, > >> * Someone has grabbed the page, try to isolate it here. > >> * Fail with -EBUSY if not possible. > >> */ > >> + remove_hugetlb_page(h, new_page, false); > >> update_and_free_page(h, new_page); > >> spin_unlock(&hugetlb_lock); > >> if (!isolate_huge_page(old_page, list)) > > > > the page is not enqued anywhere here so remove_hugetlb_page would blow > > when linked list debugging is enabled. > > I also thought this would be an issue. However, INIT_LIST_HEAD would > have been called for the page so, OK, this is true for a freshly allocated hugetlb page (prep_new_huge_page. It's a very sublte dependency though. In case somebody ever wants to fortify linked lists and decides to check list_del on an empty list then this would wait silently to blow up. > Going forward, I agree it would be better to perhaps add a list_empty > check so that things do not blow up if the debugging code is changed. Yes this is less tricky then a bool flag or making more stages of the tear down. 2 stages are more than enough IMHO. > At one time I also thought of splitting the functionality in > alloc_fresh_huge_page and prep_new_huge_page so that it would only > allocate/prep the page but not increment nr_huge_pages. We already have that distinction. alloc_buddy_huge_page is there to allocate a fresh huge page without any hstate accunting. Considering that giga pages are not supported for the migration anyway, maybe this would make Oscar's work slightly less tricky? -- Michal Hocko SUSE Labs