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 2F698C433DB for ; Tue, 5 Jan 2021 03:15:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 94EB822581 for ; Tue, 5 Jan 2021 03:15:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94EB822581 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 A8C458D004E; Mon, 4 Jan 2021 22:15:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A3D068D0036; Mon, 4 Jan 2021 22:15:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92D058D004E; Mon, 4 Jan 2021 22:15:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0203.hostedemail.com [216.40.44.203]) by kanga.kvack.org (Postfix) with ESMTP id 7D1F98D0036 for ; Mon, 4 Jan 2021 22:15:27 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3F8A13624 for ; Tue, 5 Jan 2021 03:15:27 +0000 (UTC) X-FDA: 77670255894.12.steel49_030a5df274d5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 1C8F71801719E for ; Tue, 5 Jan 2021 03:15:27 +0000 (UTC) X-HE-Tag: steel49_030a5df274d5 X-Filterd-Recvd-Size: 5963 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 Jan 2021 03:15:25 +0000 (UTC) Received: by mail-pf1-f182.google.com with SMTP id d2so17590949pfq.5 for ; Mon, 04 Jan 2021 19:15:25 -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=374PX+r27VhlfV2TpHUAfDd6BqcAZV0CQiqGA0zU7J8=; b=W1n1q4WvrdywqUmyhut35HCgrPrMzw9uMhIJzTnWBETHHLmQxxfwS9Z/FZv/LyAVxP vVo7GoIQi98+ENtGDrWvlyKK+YYL5kewH0pwWftyYRpBm5FstiDaJHG2Ls6T3/83e/k2 0xr3CqN3olOLls3UB/ETU3qEr4dPUS9AkdBujbcK7citWllqNQFFxWkFsWdtVCL3M1ak Wy2m+H1znBiYKt6jZfa/fS6I04ElxTZFW13k+f6yvjvE7SxN7E8CujKLFxf8z89CWXgX 9zSNE6BnX08Hm7mmmQ4H/AWJT2tPjwneGdgnkr7CLjGp/hgVS5Z5o/NPwgoooUgG8OeM mIEw== 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=374PX+r27VhlfV2TpHUAfDd6BqcAZV0CQiqGA0zU7J8=; b=TQzJqXhzUGcsM0u8XivM9vrk5Rms1IoMwni39pjKXYCpLCV9fwpM5R9ff+ITMbQdTQ mLhis5eAhSkjpU8DsVK6luEp9/XrUE/k/IYQMdF3IDbVfp8ZTmAG2uXABiFCJc7JPxBl XDBl22g4etKDBdkUdTSaq+iTfmPWaEM4u86pohsIta75vPOTekbAsqx4e9drV2x9cpxh d7+Dg5Ka5SPtJ9BNgnR/4Hbc0Ygp8gI8H6ikrEFJmTtiuWzo9/VR7pP4o1iPqbt7XMWX Sy2TrwcusAu7U4y6Cl2zedSiu/GZdBgE61Nmczh6u64yy/6Y1nZHCcm8NNsxZm9Iq2fM tMEQ== X-Gm-Message-State: AOAM532rlg3Ak71iKtyW0XbNsECJLq8y5UrdJgv69eqMe5OoaXoIJHV1 ATeI4tZAXVCeTTy+UKEdBiLd4cziEgwoaUGN7rZLkQ== X-Google-Smtp-Source: ABdhPJyAjGaM3S3iiFfXERflIW7dbWrqo8z9pM4Bw0aLc6rm7OAkttFCEl5XP6PyYMXCS+D0vULRFLhDtejWq6lTb6A= X-Received: by 2002:a63:50a:: with SMTP id 10mr73473074pgf.273.1609816524718; Mon, 04 Jan 2021 19:15:24 -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:14:46 +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 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? 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; > > } > >