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,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 EC45BC433DB for ; Tue, 12 Jan 2021 09:52:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADD02230FD for ; Tue, 12 Jan 2021 09:52:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392771AbhALJwa (ORCPT ); Tue, 12 Jan 2021 04:52:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391252AbhALJw2 (ORCPT ); Tue, 12 Jan 2021 04:52:28 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 553B6C061575 for ; Tue, 12 Jan 2021 01:51:48 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id y8so1115906plp.8 for ; Tue, 12 Jan 2021 01:51:48 -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=OMgiF78gUWEYLUGFiDuarkkkzIV0Lfaxz8wzZTO/7qs=; b=0A5uBL+U2u1qaGb5hU9qvxusYG4KmguNoH2B+jeIjKvKpeIE5QW3Q2YHulrFIAt1te OEL8cFaYV0Eh2EtYySH0iUH+9FtNhstuiriAuqHk92jpwsDGz2DfRwQfZP+km68dxFbD xIIwRfsyGtqG5FP1aZ7cAaVOAplmEcA0TdhmlK4Xw0FXB6T4sO6NhKVCkLbFbjM+83sp R3WRK3GrPNvwhM27EbFIU/huUgkyZR0AOFaGcXTijOZjiJ9LQK2bW+HbZ4pNewJHWqLm CQQDhSUpIOyFMZMdL/T9zqc7ZHC9DrmWU4o9wxty4PAu1I5HOJJqW/XwDtoeue/Whh08 OS6A== 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=OMgiF78gUWEYLUGFiDuarkkkzIV0Lfaxz8wzZTO/7qs=; b=kJSJM0p2TL5mKBAvmnvOrzlgpDRXxwRRennFdNgnlJ4+ZLyybIKvvYdcSV1oW62hN3 tBaL4kqD6C7Cdzc9WhjfMIdwPDesfrdcAC9nss0nDREaC7/PoLBxKaXVM+QuA9PGWWBU H7ixfKgFEELCYS/hpBBtFwhQN3cuystLpbscBEluW63DglyHuCp0jmZ5OHHPT/Kd/Oh6 N5ypsqwHU3FvsbGM2RKrbcl3eKF9FwQtYeAnm0R5sRPJA5H5MMEpfAATmObZ3iibcfuC 8zwZ2LcMw66SDbLwHsayPoia+TQNUTXwTvUCBTDoZuDkmDzb2tWqbPPA3Rqlg8U2a2yO 9v9Q== X-Gm-Message-State: AOAM532qyHEDnvlc94k/TEwif/Oh1720eO2EmhuUvFVA8KIEIqszO+Wx l5psDPyFvnB4pVAPG0sxlK89TqFKe/DgiSK/UfAJz1c1RCRl247DUkQ= X-Google-Smtp-Source: ABdhPJwoo3k/ywhTHur5E1sTqh0bqQW9nS+u+CN1Fh6a9ZkB9J1RhnGWGAvITbKo/fTVWlmfv3Ghr3O0eeA6kzDgwUw= X-Received: by 2002:a17:90a:5405:: with SMTP id z5mr3853388pjh.13.1610445107870; Tue, 12 Jan 2021 01:51:47 -0800 (PST) MIME-Version: 1.0 References: <20210110124017.86750-1-songmuchun@bytedance.com> <20210110124017.86750-5-songmuchun@bytedance.com> <20210112083335.GH22493@dhcp22.suse.cz> In-Reply-To: <20210112083335.GH22493@dhcp22.suse.cz> From: Muchun Song Date: Tue, 12 Jan 2021 17:51:05 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v3 4/6] mm: hugetlb: add return -EAGAIN for dissolve_free_huge_page To: Michal Hocko Cc: Mike Kravetz , Andrew Morton , Naoya Horiguchi , Andi Kleen , Linux Memory Management List , LKML 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 4:33 PM Michal Hocko wrote: > > On Mon 11-01-21 17:20:51, Mike Kravetz wrote: > > On 1/10/21 4:40 AM, Muchun Song wrote: > > > There is a race between dissolve_free_huge_page() and put_page(), > > > and the race window is quite small. Theoretically, we should return > > > -EBUSY when we encounter this race. In fact, we have a chance to > > > successfully dissolve the page if we do a retry. Because the race > > > window is quite small. If we seize this opportunity, it is an > > > optimization for increasing the success rate of dissolving page. > > > > > > If we free a HugeTLB page from a non-task context, it is deferred > > > through a workqueue. In this case, we need to flush the work. > > > > > > The dissolve_free_huge_page() can be called from memory hotplug, > > > the caller aims to free the HugeTLB page to the buddy allocator > > > so that the caller can unplug the page successfully. > > > > > > Signed-off-by: Muchun Song > > > --- > > > mm/hugetlb.c | 26 +++++++++++++++++++++----- > > > 1 file changed, 21 insertions(+), 5 deletions(-) > > > > I am unsure about the need for this patch. The code is OK, there are no > > issues with the code. > > > > As mentioned in the commit message, this is an optimization and could > > potentially cause a memory offline operation to succeed instead of fail. > > However, we are very unlikely to ever exercise this code. Adding an > > optimization that is unlikely to be exercised is certainly questionable. > > > > Memory offline is the only code that could benefit from this optimization. > > As someone with more memory offline user experience, what is your opinion > > Michal? > > I am not a great fun of optimizations without any data to back them up. > I do not see any sign this code has been actually tested and the > condition triggered. This race is quite small. I only trigger this only once on my server. And then the kernel panic. So I sent this patch series to fix some bugs. > > Besides that I have requested to have an explanation of why blocking on > the WQ is safe and that hasn't happened. I have seen all the caller of dissolve_free_huge_page, some caller is under page lock (via lock_page). Others are also under a sleep context. So I think that blocking on the WQ is safe. Right? > -- > 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=-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,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 EE813C433DB for ; Tue, 12 Jan 2021 09:51:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8EDE8230FD for ; Tue, 12 Jan 2021 09:51:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8EDE8230FD 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 E43F66B0176; Tue, 12 Jan 2021 04:51:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DF3716B0177; Tue, 12 Jan 2021 04:51:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0A8E6B0178; Tue, 12 Jan 2021 04:51:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id B85486B0176 for ; Tue, 12 Jan 2021 04:51:49 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7A773DE1D for ; Tue, 12 Jan 2021 09:51:49 +0000 (UTC) X-FDA: 77696656338.22.ducks32_3a0265e27514 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 598A918038E60 for ; Tue, 12 Jan 2021 09:51:49 +0000 (UTC) X-HE-Tag: ducks32_3a0265e27514 X-Filterd-Recvd-Size: 5375 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Jan 2021 09:51:48 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id b5so1331272pjl.0 for ; Tue, 12 Jan 2021 01:51:48 -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=OMgiF78gUWEYLUGFiDuarkkkzIV0Lfaxz8wzZTO/7qs=; b=0A5uBL+U2u1qaGb5hU9qvxusYG4KmguNoH2B+jeIjKvKpeIE5QW3Q2YHulrFIAt1te OEL8cFaYV0Eh2EtYySH0iUH+9FtNhstuiriAuqHk92jpwsDGz2DfRwQfZP+km68dxFbD xIIwRfsyGtqG5FP1aZ7cAaVOAplmEcA0TdhmlK4Xw0FXB6T4sO6NhKVCkLbFbjM+83sp R3WRK3GrPNvwhM27EbFIU/huUgkyZR0AOFaGcXTijOZjiJ9LQK2bW+HbZ4pNewJHWqLm CQQDhSUpIOyFMZMdL/T9zqc7ZHC9DrmWU4o9wxty4PAu1I5HOJJqW/XwDtoeue/Whh08 OS6A== 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=OMgiF78gUWEYLUGFiDuarkkkzIV0Lfaxz8wzZTO/7qs=; b=J+tgyIldClyWCAhnoelYaEx2NC36dOHLIJsqHdsZUH+gaTgnI3ktBl0vcVhw4djlV6 /MGGt6YiqRnhfBcuGzcA/sDbYBMKLZLFt+wqiJJ7RDuyKo/XJThzgNy0r4mXPZwQIj2r jICPwIYgEqferTLKpDw0+lnWiu0xwiqye78ZKQW4mboZVTlSEiF47iKkoTTXd8FBFEd+ ccILo/kIoldkz+aE+ZzCgdzCDoKJsVJOGBgbR1jJLvdeXvpaCU5mLzDnsnllV/Opo2MO YH6ViQI2yoCWsJA3dMDvfdrjExV862k7LKHD5e01QQV/rC1ch7BXFqsyk3hhoR2bHPC9 Dj+w== X-Gm-Message-State: AOAM533SdGT2OXy1gUQUKtoI5H6yR099A1V+g3EHO9M2bWqV1Cjfg0ph cQlOxwsqXw5Uv+oXxnQbspH/bEnq3GOFcUx+yZQLRw== X-Google-Smtp-Source: ABdhPJwoo3k/ywhTHur5E1sTqh0bqQW9nS+u+CN1Fh6a9ZkB9J1RhnGWGAvITbKo/fTVWlmfv3Ghr3O0eeA6kzDgwUw= X-Received: by 2002:a17:90a:5405:: with SMTP id z5mr3853388pjh.13.1610445107870; Tue, 12 Jan 2021 01:51:47 -0800 (PST) MIME-Version: 1.0 References: <20210110124017.86750-1-songmuchun@bytedance.com> <20210110124017.86750-5-songmuchun@bytedance.com> <20210112083335.GH22493@dhcp22.suse.cz> In-Reply-To: <20210112083335.GH22493@dhcp22.suse.cz> From: Muchun Song Date: Tue, 12 Jan 2021 17:51:05 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v3 4/6] mm: hugetlb: add return -EAGAIN for dissolve_free_huge_page To: Michal Hocko Cc: Mike Kravetz , Andrew Morton , Naoya Horiguchi , Andi Kleen , 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 12, 2021 at 4:33 PM Michal Hocko wrote: > > On Mon 11-01-21 17:20:51, Mike Kravetz wrote: > > On 1/10/21 4:40 AM, Muchun Song wrote: > > > There is a race between dissolve_free_huge_page() and put_page(), > > > and the race window is quite small. Theoretically, we should return > > > -EBUSY when we encounter this race. In fact, we have a chance to > > > successfully dissolve the page if we do a retry. Because the race > > > window is quite small. If we seize this opportunity, it is an > > > optimization for increasing the success rate of dissolving page. > > > > > > If we free a HugeTLB page from a non-task context, it is deferred > > > through a workqueue. In this case, we need to flush the work. > > > > > > The dissolve_free_huge_page() can be called from memory hotplug, > > > the caller aims to free the HugeTLB page to the buddy allocator > > > so that the caller can unplug the page successfully. > > > > > > Signed-off-by: Muchun Song > > > --- > > > mm/hugetlb.c | 26 +++++++++++++++++++++----- > > > 1 file changed, 21 insertions(+), 5 deletions(-) > > > > I am unsure about the need for this patch. The code is OK, there are no > > issues with the code. > > > > As mentioned in the commit message, this is an optimization and could > > potentially cause a memory offline operation to succeed instead of fail. > > However, we are very unlikely to ever exercise this code. Adding an > > optimization that is unlikely to be exercised is certainly questionable. > > > > Memory offline is the only code that could benefit from this optimization. > > As someone with more memory offline user experience, what is your opinion > > Michal? > > I am not a great fun of optimizations without any data to back them up. > I do not see any sign this code has been actually tested and the > condition triggered. This race is quite small. I only trigger this only once on my server. And then the kernel panic. So I sent this patch series to fix some bugs. > > Besides that I have requested to have an explanation of why blocking on > the WQ is safe and that hasn't happened. I have seen all the caller of dissolve_free_huge_page, some caller is under page lock (via lock_page). Others are also under a sleep context. So I think that blocking on the WQ is safe. Right? > -- > Michal Hocko > SUSE Labs