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 13C30C433ED for ; Fri, 21 May 2021 02:17:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6D4816138C for ; Fri, 21 May 2021 02:17:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D4816138C 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 E9B4594000B; Thu, 20 May 2021 22:17:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4B178D0001; Thu, 20 May 2021 22:17:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9D2D94000B; Thu, 20 May 2021 22:17:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id 94E0C8D0001 for ; Thu, 20 May 2021 22:17:48 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 32C6E1802769D for ; Fri, 21 May 2021 02:17:48 +0000 (UTC) X-FDA: 78163627416.35.A1D6959 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf13.hostedemail.com (Postfix) with ESMTP id 9B8AEE000800 for ; Fri, 21 May 2021 02:17:43 +0000 (UTC) Received: by mail-pl1-f182.google.com with SMTP id a7so1468818plh.3 for ; Thu, 20 May 2021 19:17:45 -0700 (PDT) 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=mpTRo1Ap2rz+rRfpTotsbVCE4BSQeeHfMw+YQ+XQye8=; b=JA99I58UVOHKgTukkHfOUxC5u2seQ+Mc6ESOfaykGKvWFI16xuoDRvSvJbbQ422I3B 4UPd30qGQ5I/R0SFtOcotsQneHjv9/U1KPWH2uOMEwh6ZdOPdJvQ8KUqR685UfQOs8ir iLdMMunStdcdx6PvxkMVjTwvhHFRwQ9AkYJUjpxQG3uGjl4MhryaOcQ+1i8CsYDe3Faq IigeR1eCpMkMr1c6iY4tyRoaSCe0uykFooZIjJhy0g5/gjKx340S0utEGknEN3fxo+hM p70WNqEDZnji32C27hDqVp4W0eW6kesHj9FuEgL+OCyYmq78JxbGtsRukeIjAfcvC/+D QXUA== 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=mpTRo1Ap2rz+rRfpTotsbVCE4BSQeeHfMw+YQ+XQye8=; b=rhsKYpK0eolEcv8OuVyPJ6axsmpPgXSHhhrGhoUshuJgY2ElE9UB0i6XP6beXGCUNt uQfD7b2DnrHXhHgCnIr9pDiCTLKVRRiTlEaJUhOFlYWizIIVvOzT/GpCob/Le/v5U1rh xWyEtTWsA8rG4/REtnP+HPJW0t3/irBFSCt7bcKmtTHSSyEFChDdKRKuDE9TjpxdGYrL ZMniweF5N454whQz1iVrt/XU1cCCvtmBUJ4tpLTjwP6IS6tHmRw5Y3vcrS6qeDzMb75u ++rvvE8BYiIlHcc4Afm+vzJ8iPJzfi3oPiW+Zf0Q5F31eAZYuxThSAJKHbcV+wq/+BUc zvqA== X-Gm-Message-State: AOAM533V8ChZK3psg59Vb+OeIi6df243G/QaM5VRWDlmufbElbQ2FALp +ztIH5/aU43xneUlDYcYWG019qhITRYZbdRX9cXPWA== X-Google-Smtp-Source: ABdhPJxtaRwfr83mysqvFo8ibnlYuAul0GqVuOaLWvuX/FHA39Ac2ZgWetI46CwdLLHPwzWCkr+SP8POVJZQmaOinZk= X-Received: by 2002:a17:902:7407:b029:f0:dace:a5a9 with SMTP id g7-20020a1709027407b02900f0dacea5a9mr9180429pll.34.1621563464956; Thu, 20 May 2021 19:17:44 -0700 (PDT) MIME-Version: 1.0 References: <20210520025949.1866-1-songmuchun@bytedance.com> <20210519212412.5653163f94904b141d5d74ce@linux-foundation.org> <4802b996-6135-7817-374f-d8ddca7641ac@oracle.com> In-Reply-To: <4802b996-6135-7817-374f-d8ddca7641ac@oracle.com> From: Muchun Song Date: Fri, 21 May 2021 10:17:08 +0800 Message-ID: Subject: Re: [External] Re: [PATCH] mm: migrate: fix missing update page_private to hugetlb_page_subpool To: Mike Kravetz Cc: Andrew Morton , Oscar Salvador , Michal Hocko , David Hildenbrand , Matthew Wilcox , Linux Memory Management List , LKML , Xiongchun duan , zhengqi.arch@bytedance.com, fam.zheng@bytedance.com, Anshuman Khandual Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=JA99I58U; spf=pass (imf13.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9B8AEE000800 X-Stat-Signature: hjs5x6fdiheanio9oxbxzztyr41ocyja X-HE-Tag: 1621563463-778978 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 Fri, May 21, 2021 at 2:17 AM Mike Kravetz wrote: > > On 5/19/21 10:13 PM, Muchun Song wrote: > > On Thu, May 20, 2021 at 12:24 PM Andrew Morton > > wrote: > >> > >> On Thu, 20 May 2021 10:59:49 +0800 Muchun Song wrote: > >> > >>> Since commit d6995da31122 ("hugetlb: use page.private for hugetlb specific > >>> page flags") converts page.private for hugetlb specific page flags. We > >>> should use hugetlb_page_subpool() to get the subpool pointer instead of > >>> page_private(). The commit forgot to update it in the page migration > >>> routine. So fix it. > >>> > >>> ... > >>> > >>> --- a/mm/migrate.c > >>> +++ b/mm/migrate.c > >>> @@ -1290,7 +1290,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page, > >>> * page_mapping() set, hugetlbfs specific move page routine will not > >>> * be called and we could leak usage counts for subpools. > >>> */ > >>> - if (page_private(hpage) && !page_mapping(hpage)) { > >>> + if (hugetlb_page_subpool(hpage) && !page_mapping(hpage)) { > >>> rc = -EBUSY; > >>> goto out_unlock; > >>> } > >> > >> So it uses the wrong page*, so this isn't just a cosmetic fix. One > >> cannot tell from this changelog. > >> > >> Please describe the runtime effects of this bug. Please always include > >> this information when fixing bugs. And when adding them. > > > > OK. I should update the commit log in the next version. > > > > Unfortunately, it is more than a cosmetic fix. > > This 'could' prevent the migration of hugetlb pages. page_private(hpage) > is now used for hugetlb page specific flags. At migration time, the > only flag which could be set is HPageVmemmapOptimized. This flag will > only be set if the new vmemmap reduction feature is enabled. In > addition, !page_mapping() implies an anonymous mapping. So, this will > prevent migration of hugetb pages in anonymous mappings if the vmemmap > reduction feature is enabled. > > In addition, that if statement checked for the rare race condition of a > page being migrated while in the process of being freed. Since that > check is now wrong, we could leak hugetlb subpool usage counts. > > Muchun, feel free to use as much of that as you would like in the > updated commit message. Thanks Mike. I'll use this. > -- > Mike Kravetz