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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 B0D8AC433DB for ; Fri, 26 Feb 2021 09:51:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 198D864ED5 for ; Fri, 26 Feb 2021 09:51:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 198D864ED5 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 7E37B6B0005; Fri, 26 Feb 2021 04:51:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7933F6B006C; Fri, 26 Feb 2021 04:51:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 682896B006E; Fri, 26 Feb 2021 04:51:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id 4F9FA6B0005 for ; Fri, 26 Feb 2021 04:51:27 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 03B6E182E5D7D for ; Fri, 26 Feb 2021 09:51:27 +0000 (UTC) X-FDA: 77859951414.04.BD0BAD3 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf30.hostedemail.com (Postfix) with ESMTP id 6C5FBE0011E6 for ; Fri, 26 Feb 2021 09:51:26 +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=1614333085; 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=8ELmdVBlgSFEM0c+8AL7CXModPBPz81obvz/7XnzWnc=; b=CPKMJQj54h34+7/Xoeo8J4aZTqTa6EYLB3mHPan+F006P17R7stKKFzXzupg5uR4LM//Zd 240pjifIk35pgZJTw0ntGpLRtWtr8zsNmnBdK7KpT5cKEvv5wte7OcPTVKRJCWM6/zRqvt AzQ6yA5kxKv1joQZk6eJ3WlyGNIe/l0= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3C875AAAE; Fri, 26 Feb 2021 09:51:25 +0000 (UTC) Date: Fri, 26 Feb 2021 10:51:24 +0100 From: Michal Hocko To: Oscar Salvador Cc: Andrew Morton , Mike Kravetz , David Hildenbrand , Muchun Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] mm: Make alloc_contig_range handle free hugetlb pages Message-ID: References: <20210222135137.25717-1-osalvador@suse.de> <20210222135137.25717-2-osalvador@suse.de> <20210226094507.GA3240@linux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210226094507.GA3240@linux> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 6C5FBE0011E6 X-Stat-Signature: bphk87x1fzh3ha8q5hub13sqtgwmwp8j Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf30; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614333086-482533 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 26-02-21 10:45:14, Oscar Salvador wrote: > On Fri, Feb 26, 2021 at 09:35:09AM +0100, Michal Hocko wrote: > > I think it would be helpful to call out that specific case explicitly > > here. I can see only one scenario (are there more?) > > __free_huge_page() isolate_or_dissolve_huge_page > > PageHuge() == T > > alloc_and_dissolve_huge_page > > alloc_fresh_huge_page() > > spin_lock(hugetlb_lock) > > // PageHuge() && !PageHugeFreed && > > // !PageCount() > > spin_unlock(hugetlb_lock) > > spin_lock(hugetlb_lock) > > 1) update_and_free_page > > PageHuge() == F > > __free_pages() > > 2) enqueue_huge_page > > SetPageHugeFreed() > > spin_unlock(&hugetlb_lock) > > I do not think there are more scenarios. The thing is to find a !page_count && > !PageHugeFreed. > AFAICS, this can only happen after: > put_page->put_page_test_zero->..->_free_huge_page gets called but __free_huge_page > has not reached enqueue_huge_page yet (as you just described above) > > By calling out this case, you meant to describe it in the changelog? Yes. [...] > > struct hstate *h; > > > > /* > > * The page might have been dissloved from under our feet > > * so make sure to carefully check the state under the lock. > > * Return success on when racing as if we dissloved the page > > * ourselves. > > */ > > spin_lock(&hugetlb_lock); > > if (PageHuge(page)) { > > head = compound_head(page); > > h = page_hstate(head); > > } else { > > spin_unlock(&hugetlb_lock); > > return true; > > } > > spin_unlock(&hugetlb_lock); > > Yes, I find this less eyesore. > > I will fix it up in v4. Thanks! -- Michal Hocko SUSE Labs