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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, 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 35EF2C433DB for ; Thu, 7 Jan 2021 08:39:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C65E32311E for ; Thu, 7 Jan 2021 08:39:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C65E32311E 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 4257F8D0127; Thu, 7 Jan 2021 03:39:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3ACC18D011F; Thu, 7 Jan 2021 03:39:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 273998D0127; Thu, 7 Jan 2021 03:39:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id 0E28C8D011F for ; Thu, 7 Jan 2021 03:39:07 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4A585180AD80F for ; Thu, 7 Jan 2021 08:39:05 +0000 (UTC) X-FDA: 77678329050.21.dust38_080d033274e8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 23249180442C0 for ; Thu, 7 Jan 2021 08:39:05 +0000 (UTC) X-HE-Tag: dust38_080d033274e8 X-Filterd-Recvd-Size: 3176 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 Jan 2021 08:39:04 +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=1610008743; 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=rQYJA161FO+WtN+WmtlN8WqtKfaE+baJDIobZAh3vs4=; b=l3e8ujeYMXJ406uKQricD3HzY6Xhvp/tozPgkpSREWLMQHgSAQrCvO4orefyNDKN7hroxY dT4DQXAZ91GA+FRcLyYMmxlQS+H67SWOE471gXIJRaUR+gtVKUouxD8O7bf6v1klIWfdg1 6aOdgeTtBx5QHPiFA8pNbCB83MHDHGA= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 56C14ACAF; Thu, 7 Jan 2021 08:39:03 +0000 (UTC) Date: Thu, 7 Jan 2021 09:39:02 +0100 From: Michal Hocko To: Muchun Song Cc: Mike Kravetz , Andrew Morton , Naoya Horiguchi , Andi Kleen , Linux Memory Management List , LKML Subject: Re: [External] Re: [PATCH v2 4/6] mm: hugetlb: add return -EAGAIN for dissolve_free_huge_page Message-ID: <20210107083902.GB13207@dhcp22.suse.cz> References: <20210106084739.63318-1-songmuchun@bytedance.com> <20210106084739.63318-5-songmuchun@bytedance.com> <20210106170754.GU13207@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 Thu 07-01-21 11:11:41, Muchun Song wrote: > On Thu, Jan 7, 2021 at 1:07 AM Michal Hocko wrote: > > > > On Wed 06-01-21 16:47:37, Muchun Song wrote: > > > When dissolve_free_huge_page() races with __free_huge_page(), we can > > > do a retry. Because the race window is small. > > > > Is this a bug fix or mere optimization. I have hard time to tell from > > the description. > > It is optimization. Thanks. > > > > > > Signed-off-by: Muchun Song > > > --- > > > mm/hugetlb.c | 26 +++++++++++++++++++++----- > > > 1 file changed, 21 insertions(+), 5 deletions(-) > > > > > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > [...] > > > @@ -1825,6 +1828,14 @@ int dissolve_free_huge_page(struct page *page) > > > } > > > out: > > > spin_unlock(&hugetlb_lock); > > > + > > > + /* > > > + * If the freeing of the HugeTLB page is put on a work queue, we should > > > + * flush the work before retrying. > > > + */ > > > + if (unlikely(rc == -EAGAIN)) > > > + flush_work(&free_hpage_work); > > > > Is it safe to wait for the work to finish from this context? > > Yes. It is safe. Please expand on why in the changelog. Same for the optimization including some numbers showing it really helps. -- Michal Hocko SUSE Labs