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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,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 674EAC433DB for ; Tue, 5 Jan 2021 03:47:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CC77A22582 for ; Tue, 5 Jan 2021 03:47:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC77A22582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E70E88D0050; Mon, 4 Jan 2021 22:47:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DFAF98D0036; Mon, 4 Jan 2021 22:47:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CEA148D0050; Mon, 4 Jan 2021 22:47:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0141.hostedemail.com [216.40.44.141]) by kanga.kvack.org (Postfix) with ESMTP id BA4D38D0036 for ; Mon, 4 Jan 2021 22:47:32 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7B84D1EE6 for ; Tue, 5 Jan 2021 03:47:32 +0000 (UTC) X-FDA: 77670336744.15.need23_2e1730a274d5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 562001814B0C1 for ; Tue, 5 Jan 2021 03:47:32 +0000 (UTC) X-HE-Tag: need23_2e1730a274d5 X-Filterd-Recvd-Size: 6371 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 Jan 2021 03:47:31 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id j1so15669063pld.3 for ; Mon, 04 Jan 2021 19:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=R6VBjqcK5YLZ5deMeqMm/AgkrrOL5bx12zvyrtcYvt8=; b=zvrg0g37kYpekFpHzLswoui8ovwcJGCeMJ0giV3ONJTxaEWTlz3OM7ncuumobeYx7y UNHcSxUmzThAZrUk2KUaMe1WLxtH9ab4j772D6wYNU2l3nQ8OCgqU3yavW7PrriYyK3z fQcIpEQh1munE0iiKCuBZu4Py0iM5kkqAoQNJTyrzGEHIL9ybMU5TMukupp6yQ14C9NA /x7zeMMd0ma90NGVQKdMTl90wF9VkyWz513nR2emqWoZmWRPKZyVNg0dQgkOHy2OkLAP SqYS0VopNy94c1MIibYggwMA0avL0WEPWEsj781DB18Blig+mVZ1NuQQyaTSuXrP1F78 s2VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=R6VBjqcK5YLZ5deMeqMm/AgkrrOL5bx12zvyrtcYvt8=; b=SZLyY7HrZg+4U/i7SPtfwICc5WIWrQgBwaVNnnSsOrqCRJaJgwdaykaleAWEg544HD xC4FN0ntf1KjDOMMqrv8nzXxVFwHgLKi3OvAKWVx/+BDSrci3xmSy8C1+MHrAKscrmNV N6rReTsxsKHbiawvenOrpxM6B7PoqiMyvz3gQnoJrf+bRBDiyYVaZEdGOTe70Y3cDFtp +R/onNodOiYQcme+9tb8vRBYKoT+X32SxNIT55XXVQ3CXXnqXZRhARVea3TUL+uj/qdM gnle9qml7RGoZh2P0X4e9KfmK1ZChK7V97dVqpF3V0hL1Q8AjLG6reRqVZnfgLhHfNDf rGqA== X-Gm-Message-State: AOAM532ovvqXv9OxN7BrkjivR7+gaeOs9M0XJf8L+uqKyG5/QD9YJizk hK3HvjftD4VpReb4/qb/ywiIvOKZBXuGF8uiii/Dsw== X-Google-Smtp-Source: ABdhPJybN/E/OaP+FLb4Fj1fxoISneSpVEx88JYdCzoMgKviF1z6kKZ8+17Ucm+6/BUwqg3Ft6T65hGLpA5K+XDZ6hQ= X-Received: by 2002:a17:90a:c588:: with SMTP id l8mr2061839pjt.147.1609818450281; Mon, 04 Jan 2021 19:47:30 -0800 (PST) MIME-Version: 1.0 References: <20210104065843.5658-1-songmuchun@bytedance.com> <20210104065843.5658-4-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Tue, 5 Jan 2021 11:46:51 +0800 Message-ID: Subject: Re: [External] Re: [PATCH 4/6] mm: hugetlb: add return -EAGAIN for dissolve_free_huge_page To: Mike Kravetz Cc: Andrew Morton , Naoya Horiguchi , Andi Kleen , mhocko@suse.cz, Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" 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, Jan 5, 2021 at 11:14 AM Muchun Song wrote: > > On Tue, Jan 5, 2021 at 9:33 AM Mike Kravetz wrote: > > > > On 1/3/21 10:58 PM, Muchun Song wrote: > > > When dissolve_free_huge_page() races with __free_huge_page(), we can > > > do a retry. Because the race window is small. > > > > In general, I agree that the race window is small. However, worst case > > would be if the freeing of the page is put on a work queue. Is it acceptable > > to keep retrying in that case? In addition, the 'Free some vmemmap' series > > may slow the free_huge_page path even more. > > I also consider the 'Free some vmemmap' series case. In my next > version series, I will flush the work before dissolve_free_huge_page > returns when encountering this race. So the retry is acceptable. > Right? Hi Mike, How about flushing the @free_hpage_work when encountering this race? > > Thanks. > > > > > In these worst case scenarios, I am not sure we want to just spin retrying. > > > > -- > > Mike Kravetz > > > > > > > > Signed-off-by: Muchun Song > > > --- > > > mm/hugetlb.c | 16 +++++++++++----- > > > 1 file changed, 11 insertions(+), 5 deletions(-) > > > > > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > > index 72608008f8b4..db00ae375d2a 100644 > > > --- a/mm/hugetlb.c > > > +++ b/mm/hugetlb.c > > > @@ -1763,10 +1763,11 @@ static int free_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed, > > > * nothing for in-use hugepages and non-hugepages. > > > * This function returns values like below: > > > * > > > - * -EBUSY: failed to dissolved free hugepages or the hugepage is in-use > > > - * (allocated or reserved.) > > > - * 0: successfully dissolved free hugepages or the page is not a > > > - * hugepage (considered as already dissolved) > > > + * -EAGAIN: race with __free_huge_page() and can do a retry > > > + * -EBUSY: failed to dissolved free hugepages or the hugepage is in-use > > > + * (allocated or reserved.) > > > + * 0: successfully dissolved free hugepages or the page is not a > > > + * hugepage (considered as already dissolved) > > > */ > > > int dissolve_free_huge_page(struct page *page) > > > { > > > @@ -1815,8 +1816,10 @@ int dissolve_free_huge_page(struct page *page) > > > * We should make sure that the page is already on the free list > > > * when it is dissolved. > > > */ > > > - if (unlikely(!PageHugeFreed(head))) > > > + if (unlikely(!PageHugeFreed(head))) { > > > + rc = -EAGAIN; > > > goto out; > > > + } > > > > > > /* > > > * Move PageHWPoison flag from head page to the raw error page, > > > @@ -1857,7 +1860,10 @@ int dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn) > > > > > > for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << minimum_order) { > > > page = pfn_to_page(pfn); > > > +retry: > > > rc = dissolve_free_huge_page(page); > > > + if (rc == -EAGAIN) > > > + goto retry; > > > if (rc) > > > break; > > > } > > >