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,URIBL_BLOCKED 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 84621C433E0 for ; Tue, 12 Jan 2021 12:37:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0F6A023110 for ; Tue, 12 Jan 2021 12:37:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F6A023110 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 2B4598D00A1; Tue, 12 Jan 2021 07:37:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 23D2A8D0090; Tue, 12 Jan 2021 07:37:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1065B8D00A1; Tue, 12 Jan 2021 07:37:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id EB4CC8D0090 for ; Tue, 12 Jan 2021 07:37:41 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id AA424362B for ; Tue, 12 Jan 2021 12:37:41 +0000 (UTC) X-FDA: 77697074322.16.grip95_111116c27515 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 8C410100E6903 for ; Tue, 12 Jan 2021 12:37:41 +0000 (UTC) X-HE-Tag: grip95_111116c27515 X-Filterd-Recvd-Size: 4135 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Jan 2021 12:37:40 +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=1610455060; 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=38R9LgWGn4HEbk8lBrJ1162Zlh+4fmrREhjPSswCAzI=; b=N7O1JFwWEvZ23+2FUC5qF2sVBZeBWItKxBIalOcY9CTay4lcsHp+Nc1Qv/jJhOXZ0CgXO0 i239RmMfoqjUxt2+iW75dpQMiO+QV+40IBMc4p0PbqjwxlNM0rtKvMYLHTRQV9b0jFuf4U SY7AsDPptkXSQWlSymYDRmMyS7h13T4= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DCDF9ACF5; Tue, 12 Jan 2021 12:37:39 +0000 (UTC) Date: Tue, 12 Jan 2021 13:37:38 +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: <20210112123738.GQ22493@dhcp22.suse.cz> References: <20210110124017.86750-1-songmuchun@bytedance.com> <20210110124017.86750-4-songmuchun@bytedance.com> <20210112100213.GK22493@dhcp22.suse.cz> <20210112111712.GN22493@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 19:43:21, Muchun Song wrote: > On Tue, Jan 12, 2021 at 7:17 PM Michal Hocko wrote: > > > > 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? > > If there is a race with somebody else freeing the page, the page > can be freed to the hugepage pool not the buddy allocator. Do > you think that this page is dissolved? OK, I see what you mean. Effectively the page would be in a limbo, not yet in the pool nor in the allocator but it can find its way to the either of the two. But I still dislike returning a failure because that would mean e.g. memory hotplug to fail. Can you simply retry inside this code path (drop the lock, cond_resched and retry)? -- Michal Hocko SUSE Labs