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 21406C433DB for ; Tue, 5 Jan 2021 07:11:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 83240224F9 for ; Tue, 5 Jan 2021 07:11:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83240224F9 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 D95CB8D0059; Tue, 5 Jan 2021 02:11:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D1FF18D0036; Tue, 5 Jan 2021 02:11:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE83D8D0059; Tue, 5 Jan 2021 02:11:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id A5B958D0036 for ; Tue, 5 Jan 2021 02:11:16 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 6E2218248047 for ; Tue, 5 Jan 2021 07:11:16 +0000 (UTC) X-FDA: 77670850152.27.shop63_0015fa5274d7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 4F94C3D663 for ; Tue, 5 Jan 2021 07:11:16 +0000 (UTC) X-HE-Tag: shop63_0015fa5274d7 X-Filterd-Recvd-Size: 6306 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 Jan 2021 07:11:15 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id be12so15888069plb.4 for ; Mon, 04 Jan 2021 23:11:15 -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:content-transfer-encoding; bh=jF+DtZTdf3XOUzGrgz40msoOI/xU6UYEv4/RowGJ930=; b=HZWoYwmD/CdrJ8rzLKS14XErMJgI5t5wiROJYA3mQ1PAuaIUb99hqvUxbdObWI07a6 lNnmjZyXuAMmaUxZaXPejfCeqYvQV+nNtZI096B53vB6/ucr2rHkROYwLo7JqA5bJaxP sUK5BH7S2G7Zr4qa4TBJ4UIZyD/2xs0gQaBTlTm0KVueuUqX57EUtqQASObLYs1qtGHR RQ7pGxpMqPpaXFEdvncuZSi29hsINhFck8r4DxdDHy/tm0YjQOGErJlTCeGRCgEJ9mgg Euw8Yq91kHK8NI+UWaQ7ZWYvkw1PCdY/Hwr01Y5y7AP/la+0Wt7TzC8/k3IcWzTPFpCy 6jQg== 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:content-transfer-encoding; bh=jF+DtZTdf3XOUzGrgz40msoOI/xU6UYEv4/RowGJ930=; b=hZmOGQvNaJ3YlgbMFF6XOItZCV71h0JpBn7sNuWgF3et7u+INMye14m+ZZh3r8mqx/ 5nmQrLj0hYu61V5xGHxI8Iuqfrphus1PnhPeEs0trh1JiQ/WD7rKUcuzH/Qocu4Hl8NF C20ENFbFLlmqnJsTm828Lj0oRgRkJK0E72jiTgpZySUI7BVOKc7LVxRoA/xXxt4PMW+a 0DJtUSKQSaGQZiRVXK6uazE9pnglPNx0+vtOTbVQGntVKufX3cJbcC1pr1uCHFK/AfDf B1FI1ZI7aCaHvQlvxTPj7edn1SnI5tPLsY3a+KC06L3ZNalVOZT4r6XgSZSnx4Gkx0Pu rnTQ== X-Gm-Message-State: AOAM531EVmBnsvES7sZgPUjArAnEBiNuBMvniTYBE7rnIZunO4fB1rqu bK5H97LKhc51U5618LGbBhuYViv/c9AfMajd/Aa40w== X-Google-Smtp-Source: ABdhPJyl0WsuJL+NczdFKJGZo0dLamcwYR3uJs2y9R2saJkXN8MwuRU43VF57WxJvN6VP+c/ONR0IDzy9HAlRXxLBmA= X-Received: by 2002:a17:90a:ba88:: with SMTP id t8mr2754358pjr.229.1609830674226; Mon, 04 Jan 2021 23:11:14 -0800 (PST) MIME-Version: 1.0 References: <20210104065843.5658-1-songmuchun@bytedance.com> <20210104065843.5658-4-songmuchun@bytedance.com> <20210105063757.GA7244@hori.linux.bs1.fc.nec.co.jp> In-Reply-To: <20210105063757.GA7244@hori.linux.bs1.fc.nec.co.jp> From: Muchun Song Date: Tue, 5 Jan 2021 15:10:35 +0800 Message-ID: Subject: Re: [External] Re: [PATCH 4/6] mm: hugetlb: add return -EAGAIN for dissolve_free_huge_page To: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= Cc: "mike.kravetz@oracle.com" , "akpm@linux-foundation.org" , "n-horiguchi@ah.jp.nec.com" , "ak@linux.intel.com" , "mhocko@suse.cz" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 2:38 PM HORIGUCHI NAOYA(=E5=A0=80=E5=8F=A3=E3=80=80= =E7=9B=B4=E4=B9=9F) wrote: > > On Mon, Jan 04, 2021 at 02:58:41PM +0800, Muchun Song wrote: > > When dissolve_free_huge_page() races with __free_huge_page(), we can > > do a retry. Because the race window is small. > > > > 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-u= se > > - * (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 fr= ee list > > * when it is dissolved. > > */ > > - if (unlikely(!PageHugeFreed(head))) > > + if (unlikely(!PageHugeFreed(head))) { > > + rc =3D -EAGAIN; > > goto out; > > + } > > If dissolve_free_huge_page() races with __free_huge_page() and we detect > it with this check, the hugepage is expected to be freed or dissolved by > __free_huge_page(), so is it enough just to return with rc =3D 0 without = retrying? The dissolve_free_huge_page() aims to free the page to the buddy allocator not the hugepage pool. So it is not enough just to return 0, right? Or did you mean that we set the page temporary here and let the __free_huge_page do the freeing later for us? Thanks. > > Thanks, > Naoya Horiguchi > > > > > /* > > * 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 =3D start_pfn; pfn < end_pfn; pfn +=3D 1 << minimum_orde= r) { > > page =3D pfn_to_page(pfn); > > +retry: > > rc =3D dissolve_free_huge_page(page); > > + if (rc =3D=3D -EAGAIN) > > + goto retry; > > if (rc) > > break; > > } > > -- > > 2.11.0 > >