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.8 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_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 59838C433DB for ; Thu, 18 Mar 2021 10:12:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C20B764E81 for ; Thu, 18 Mar 2021 10:12:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C20B764E81 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 3AF7C6B0070; Thu, 18 Mar 2021 06:12:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3863F6B0071; Thu, 18 Mar 2021 06:12:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 275816B0072; Thu, 18 Mar 2021 06:12:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0146.hostedemail.com [216.40.44.146]) by kanga.kvack.org (Postfix) with ESMTP id 0C0246B0070 for ; Thu, 18 Mar 2021 06:12:32 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9FB747817 for ; Thu, 18 Mar 2021 10:12:31 +0000 (UTC) X-FDA: 77932580502.01.ABE9C6B Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf01.hostedemail.com (Postfix) with ESMTP id 31C285001522 for ; Thu, 18 Mar 2021 10:12:30 +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=1616062349; 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=jz16ifXJDJC4ftXE2JnZpLbMRVjlU9F4fxHP55xDnOU=; b=DkIU0uYPo/x/mCrfCR96kefe7Ss4g1mMv/uQsGM1LB4M2W0YUiIVQ6wHoxF7+C9111Tmsu 0WftMg5JgIrS7MYTykqvqLVx6nU7gYuVFtVb+EI7HiVFM2wDDO6W8vFy2/Paesn518jiBy VSDgbf9FXHIj7pPhQMChX6GTe0Bodpg= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CD366AD71; Thu, 18 Mar 2021 10:12:29 +0000 (UTC) Date: Thu, 18 Mar 2021 11:12:28 +0100 From: Michal Hocko To: Oscar Salvador Cc: Andrew Morton , Vlastimil Babka , David Hildenbrand , Muchun Song , Mike Kravetz , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 4/5] mm: Make alloc_contig_range handle in-use hugetlb pages Message-ID: References: <20210317111251.17808-1-osalvador@suse.de> <20210317111251.17808-5-osalvador@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: t69cttpp5kud4siim6fr7b98g1izjfno X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 31C285001522 Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616062350-814772 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 18-03-21 10:59:10, Oscar Salvador wrote: > On Thu, Mar 18, 2021 at 10:29:57AM +0100, Michal Hocko wrote: > > On Thu 18-03-21 09:54:01, Oscar Salvador wrote: > > [...] > > > @@ -2287,10 +2288,12 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page) > > > goto unlock; > > > } else if (page_count(old_page)) { > > > /* > > > - * Someone has grabbed the page, fail for now. > > > + * Someone has grabbed the page, try to isolate it here. > > > + * Fail with -EBUSY if not possible. > > > */ > > > - ret = -EBUSY; > > > update_and_free_page(h, new_page); > > > + if (!isolate_huge_page(old_page, list) > > > + ret = -EBUSY; > > > goto unlock; > > > } else if (!HPageFreed(old_page)) { > > > > I do not think you want to call isolate_huge_page with hugetlb_lock > > held. You would need to drop the lock before calling isolate_huge_page. > > Yeah, that was an oversight. As I said I did not compile it(let alone > test it), otherwise the system would have screamed I guess. > > I was more interested in knowing whether how did it look wrt. retry > concerns: Yes this looks much more to my taste. If we need to retry then it could just goto retry there. The caller doesn't really have to care. > @@ -2287,10 +2288,14 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page) > goto unlock; > } else if (page_count(old_page)) { > /* > - * Someone has grabbed the page, fail for now. > + * Someone has grabbed the page, try to isolate it here. > + * Fail with -EBUSY if not possible. > */ > - ret = -EBUSY; > update_and_free_page(h, new_page); > + spin_unlock(&hugetlb_lock); > + if (!isolate_huge_page(old_page, list) > + ret = -EBUSY; > + spin_lock(&hugetlb_lock); > goto unlock; simply return ret; here -- Michal Hocko SUSE Labs