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 33C17C433DB for ; Tue, 12 Jan 2021 11:17:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C7343208B3 for ; Tue, 12 Jan 2021 11:17:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7343208B3 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 504798D0098; Tue, 12 Jan 2021 06:17:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 48DF98D0090; Tue, 12 Jan 2021 06:17:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 37D5B8D0098; Tue, 12 Jan 2021 06:17:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0247.hostedemail.com [216.40.44.247]) by kanga.kvack.org (Postfix) with ESMTP id 1EF518D0090 for ; Tue, 12 Jan 2021 06:17:15 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DE9FC1EE6 for ; Tue, 12 Jan 2021 11:17:14 +0000 (UTC) X-FDA: 77696871588.04.flag54_4f081bc27515 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id C41028000049 for ; Tue, 12 Jan 2021 11:17:14 +0000 (UTC) X-HE-Tag: flag54_4f081bc27515 X-Filterd-Recvd-Size: 3259 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Jan 2021 11:17:14 +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=1610450233; 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=97KhOYscrblZbMeomBN2OsfHkBm7iceqQ0+tB9TjaiY=; b=UXZKc0r24JAjpfmJUKxmocX34zbM6DppGMqDoKb7eTZqIyVfS/GH/oijAcnD2S2tdqM07q iWKhnvU0aGW9gGLvuDQ8lTe+kHAHq5kWEfBFDFS71YHN1/2JZOzGFnx10P4kGP9Cc8WnHS hkmrILgXO3PFXjfzdJ5z6XAPnfnw8hA= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 55111B7F8; Tue, 12 Jan 2021 11:17:13 +0000 (UTC) Date: Tue, 12 Jan 2021 12:17:12 +0100 From: Michal Hocko To: Muchun Song Cc: Mike Kravetz , Andrew Morton , Naoya Horiguchi , Andi Kleen , Linux Memory Management List , LKML , linux- stable Subject: Re: [External] Re: [PATCH v3 3/6] mm: hugetlb: fix a race between freeing and dissolving the page Message-ID: <20210112111712.GN22493@dhcp22.suse.cz> References: <20210110124017.86750-1-songmuchun@bytedance.com> <20210110124017.86750-4-songmuchun@bytedance.com> <20210112100213.GK22493@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 12-01-21 18:13:02, Muchun Song wrote: > On Tue, Jan 12, 2021 at 6:02 PM Michal Hocko wrote: > > > > On Sun 10-01-21 20:40:14, Muchun Song wrote: > > [...] > > > @@ -1770,6 +1788,14 @@ int dissolve_free_huge_page(struct page *page) > > > int nid = page_to_nid(head); > > > if (h->free_huge_pages - h->resv_huge_pages == 0) > > > goto out; > > > + > > > + /* > > > + * We should make sure that the page is already on the free list > > > + * when it is dissolved. > > > + */ > > > + if (unlikely(!PageHugeFreed(head))) > > > + goto out; > > > + > > > > Do you really want to report EBUSY in this case? This doesn't make much > > sense to me TBH. I believe you want to return 0 same as when you race > > and the page is no longer PageHuge. > > Return 0 is wrong. Because the page is not freed to the buddy allocator. > IIUC, dissolve_free_huge_page returns 0 when the page is already freed > to the buddy allocator. Right? 0 is return when the page is either dissolved or it doesn't need dissolving. If there is a race with somebody else freeing the page then there is nothing to dissolve. Under which condition it makes sense to report the failure and/or retry dissolving? -- Michal Hocko SUSE Labs