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=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 6DBE4C433E0 for ; Tue, 12 Jan 2021 11:45:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 168B623104 for ; Tue, 12 Jan 2021 11:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730433AbhALLoq (ORCPT ); Tue, 12 Jan 2021 06:44:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728431AbhALLoq (ORCPT ); Tue, 12 Jan 2021 06:44:46 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1331C061786 for ; Tue, 12 Jan 2021 03:44:05 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id m5so1490316pjv.5 for ; Tue, 12 Jan 2021 03:44:05 -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=YXgK4lRZ9KFIZd6/lO39RKwyKYxTIqhJvO9L+itxVOY=; b=E1kst2tXTMFQJDZxPRDVfYPneeubPmbOWsFnTQkvuSZg5zvYvD5+0yEDnDF8qkN9BP 657+XVe9yrBS8clnMKfyqIIXgqpjvTu0N/NyQaNuLNJWORC4xiZaWRM9xjtlySkNwsM0 1sDaGLVgx0CnUDPNjy5TqE+G96ULAOU5uOPodXuDdidheJZcvoiodrTwOG2K7N0AaJnH umaVi13EGBZKbAH1CAhghwHP3x+vry3WyI20ngDXJh+C2FhyftdlH/HWK9MzjKp0pWMC DRZY1fbhTn3YmOVtsOhcJwHFwsJJ/S9l2vvD4t3E6RlAwaVvxDUgBHNNVU9uv28yAzAr 4JfQ== 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=YXgK4lRZ9KFIZd6/lO39RKwyKYxTIqhJvO9L+itxVOY=; b=aERArHy7pJcJ9yafZFFalL4ApI7q607d0hGO1PHT8sKzN0G9+AOSLbsX0tLE5fNFxG cbR1FRkU2Y0SnllUu72OJc1JpaGSAhlmy01OhXa1cAeJd1ITptPPngDJl4bQzjdvtNmW rXOGMVK6/NIdwOO3YIJayv3DuZcWqqGxxVL/qbrhmbdxUgYNTk/8+v+qA4Q9ynhJX/YM MS9voIAQkhkIlJ4hJmZ7RvYxZWz2uv/hP1/c9QxuPA80NnQDYR2PzBrLVaGzp580fiYd KMVqvxmeKk8BJwB6o8Wc+HtWKRhFDT/+EvGJ575kkDwCV6COgnGc/W2sDnvp2vJfOma2 5Sfw== X-Gm-Message-State: AOAM531NoPCNuG/LAfuI2dn88KmPYj5glXfleXjLfBf8oV5OhBUntsaJ e44m/QavyPlCBUF081mr9PtJUkBRRW3v51CwyIb0Uw== X-Google-Smtp-Source: ABdhPJwhJTuvwURefw5F76iCXx8fAufBEOUt+yDBCmtfhDnc12TggdrqEgSGxOoLHs+vnRoKR3Pm9R4V3jihjOTSA1s= X-Received: by 2002:a17:90a:ba88:: with SMTP id t8mr4162139pjr.229.1610451844939; Tue, 12 Jan 2021 03:44:04 -0800 (PST) MIME-Version: 1.0 References: <20210110124017.86750-1-songmuchun@bytedance.com> <20210110124017.86750-4-songmuchun@bytedance.com> <20210112100213.GK22493@dhcp22.suse.cz> <20210112111712.GN22493@dhcp22.suse.cz> In-Reply-To: <20210112111712.GN22493@dhcp22.suse.cz> From: Muchun Song Date: Tue, 12 Jan 2021 19:43:21 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v3 3/6] mm: hugetlb: fix a race between freeing and dissolving the page To: Michal Hocko Cc: Mike Kravetz , Andrew Morton , Naoya Horiguchi , Andi Kleen , Linux Memory Management List , LKML , linux- stable Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > -- > Michal Hocko > SUSE Labs 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=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 25E1FC433E0 for ; Tue, 12 Jan 2021 11:44:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 94F2E23107 for ; Tue, 12 Jan 2021 11:44:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94F2E23107 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 D19148D009C; Tue, 12 Jan 2021 06:44:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC91A8D0090; Tue, 12 Jan 2021 06:44:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDE918D009C; Tue, 12 Jan 2021 06:44:06 -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 A9C0D8D0090 for ; Tue, 12 Jan 2021 06:44:06 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 77FCC180AD807 for ; Tue, 12 Jan 2021 11:44:06 +0000 (UTC) X-FDA: 77696939292.22.owl43_1e06e5827515 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 56E3018038E67 for ; Tue, 12 Jan 2021 11:44:06 +0000 (UTC) X-HE-Tag: owl43_1e06e5827515 X-Filterd-Recvd-Size: 4759 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Jan 2021 11:44:05 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id u4so1487688pjn.4 for ; Tue, 12 Jan 2021 03:44:05 -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=YXgK4lRZ9KFIZd6/lO39RKwyKYxTIqhJvO9L+itxVOY=; b=E1kst2tXTMFQJDZxPRDVfYPneeubPmbOWsFnTQkvuSZg5zvYvD5+0yEDnDF8qkN9BP 657+XVe9yrBS8clnMKfyqIIXgqpjvTu0N/NyQaNuLNJWORC4xiZaWRM9xjtlySkNwsM0 1sDaGLVgx0CnUDPNjy5TqE+G96ULAOU5uOPodXuDdidheJZcvoiodrTwOG2K7N0AaJnH umaVi13EGBZKbAH1CAhghwHP3x+vry3WyI20ngDXJh+C2FhyftdlH/HWK9MzjKp0pWMC DRZY1fbhTn3YmOVtsOhcJwHFwsJJ/S9l2vvD4t3E6RlAwaVvxDUgBHNNVU9uv28yAzAr 4JfQ== 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=YXgK4lRZ9KFIZd6/lO39RKwyKYxTIqhJvO9L+itxVOY=; b=AdDHaEDKA7Kx8PscANgei9lVqxEn8y99j3juKI3BmwVt7CgNOH8LRAkxyMLTp9U88J IUP1TRbn62gJWZEy7RiqyywJ0UpqCnFxcsefWaZd8hCIYCMCz+lwfVKKji7Rpc3PU3/R Y0ugHRVCanu93h3vmfXw7b1bOMrDZk4HM6vMeT+SKiyZ7PaQD4aAuaCRH/cM0g5+Jw+y PyLBAWwBac/jzjNLyBR4kNhaNeVJ6Ob7onEm6YNDbLGvTOqLa1hfWdpjahIlOS+EbK9Q FOQW6NQHPMsasAS/YLdVc4Xgn3t+tSJJEZXp9x341bEzmx5K8rCNS10rhhGLbaLZ4juL UsQQ== X-Gm-Message-State: AOAM531wXNxs/4e2Q/xqsAYL3yGcmq1XrpJNGOTzXUp4cDC2DdCY8Tby zLcQEu3b+yL/3QSgX6RYPB0qMwNGomwAOArk2Smvkw== X-Google-Smtp-Source: ABdhPJwhJTuvwURefw5F76iCXx8fAufBEOUt+yDBCmtfhDnc12TggdrqEgSGxOoLHs+vnRoKR3Pm9R4V3jihjOTSA1s= X-Received: by 2002:a17:90a:ba88:: with SMTP id t8mr4162139pjr.229.1610451844939; Tue, 12 Jan 2021 03:44:04 -0800 (PST) MIME-Version: 1.0 References: <20210110124017.86750-1-songmuchun@bytedance.com> <20210110124017.86750-4-songmuchun@bytedance.com> <20210112100213.GK22493@dhcp22.suse.cz> <20210112111712.GN22493@dhcp22.suse.cz> In-Reply-To: <20210112111712.GN22493@dhcp22.suse.cz> From: Muchun Song Date: Tue, 12 Jan 2021 19:43:21 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v3 3/6] mm: hugetlb: fix a race between freeing and dissolving the page To: Michal Hocko Cc: Mike Kravetz , Andrew Morton , Naoya Horiguchi , Andi Kleen , Linux Memory Management List , LKML , linux- stable 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 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? > -- > Michal Hocko > SUSE Labs