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=-24.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL 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 15FF3C4708F for ; Tue, 1 Jun 2021 16:56:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AA6FE613BD for ; Tue, 1 Jun 2021 16:56:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA6FE613BD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F2FAB6B006C; Tue, 1 Jun 2021 12:56:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EDF296B006E; Tue, 1 Jun 2021 12:56:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D32916B0070; Tue, 1 Jun 2021 12:56:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0210.hostedemail.com [216.40.44.210]) by kanga.kvack.org (Postfix) with ESMTP id 9C7BD6B006C for ; Tue, 1 Jun 2021 12:56:10 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 35C33180ACF62 for ; Tue, 1 Jun 2021 16:56:10 +0000 (UTC) X-FDA: 78205757700.25.C1FB9A2 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) by imf07.hostedemail.com (Postfix) with ESMTP id F2BFBA00025A for ; Tue, 1 Jun 2021 16:55:56 +0000 (UTC) Received: by mail-qv1-f43.google.com with SMTP id z1so7561307qvo.4 for ; Tue, 01 Jun 2021 09:56:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=C/GoBbxbbL1j3ZgEgqdllSBXYrRGp9vFh0BE3WavI/A=; b=ZUbP9CMDb5auLLc4hp9CECDW8oHfEsAPVdKYAaAoNncNvv8OT2rF9/4z9Cg9xn+g1o g79Lf792oGIoTVQRrRx/rxRvDDf/2599hBx40e8e3FU7d1rG+kEa+Kdg2CcRf3QfX2pw 9wDqJzUtUi9faJ9H8Uh/VrpvxCXjRQO76lDYA1D51utb+EaTeRnswSHMDMPmpe3DAO9E XJun8OO7zcF5WEOzJEzPiXtTHZ49HjXKa+qRWEwngI2MHvq/5+QwW/ilpmFOLRS9ao50 ArMp/2EkATuhnnq8Q3W1nERKyYC1hHROSgqSwlu1wQ1k+kNom5tDAbL5RfV3Sg1z9euS RDfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=C/GoBbxbbL1j3ZgEgqdllSBXYrRGp9vFh0BE3WavI/A=; b=Uygaeo/ETViZe19v/Ck214JLXH7sbvY3ilqTnafMq36ZjCHjv9OaRSIq01zPWeh/2c 535tyS47POI9fRnCYm0NEnyAnkp0s5N1p5tJ6DAyTLn238nkPfiblt5h4MR/jdBrfHnP r49NvG6XjZre0pDbijyWhpaU56pxkGbxWaYopkUxHEoYDBLOqRpMRz/khNTELwcbQbeB 0kzyahmTnBnI9nro4seMBb26hv76Lut3lqMXcVSeoffNn9dabLaXqFPm1myaEl41LLcf aWZDzl776sgmxtyirYN1tLau0kyaHG9lVUKeLe7BdiMbMoSlZqKkf+TJ2b8ze/DUzqTh ns3g== X-Gm-Message-State: AOAM533826NXdkfD2Z9AEx40AfZ19GVr1/8NWD/T0TZgkdY2CLHej5pS WRG+f20YF5N5TDHw68/GhaxxyQ== X-Google-Smtp-Source: ABdhPJzzLpK1gGAZ35uLeax+6NhU8wKNmaMJjD6arKlXzE67y02SAjN9GcgdjT8p1u5ntIOJxGQa+w== X-Received: by 2002:a0c:ee23:: with SMTP id l3mr23734537qvs.55.1622566568843; Tue, 01 Jun 2021 09:56:08 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id d21sm2407258qke.29.2021.06.01.09.56.07 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Tue, 01 Jun 2021 09:56:08 -0700 (PDT) Date: Tue, 1 Jun 2021 09:55:56 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Xu Yu cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, gavin.dg@linux.alibaba.com, Greg Thelen , Wei Xu , Matthew Wilcox , Nicholas Piggin , Vlastimil Babka Subject: Re: [PATCH] mm, thp: relax migration wait when failed to get tail page In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Rspamd-Queue-Id: F2BFBA00025A Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=ZUbP9CMD; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of hughd@google.com designates 209.85.219.43 as permitted sender) smtp.mailfrom=hughd@google.com X-Rspamd-Server: rspam03 X-Stat-Signature: w3f6xjykjnmnpdka8ygby995ekonw33m X-HE-Tag: 1622566556-734833 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 2 Jun 2021, Xu Yu wrote: > We notice that hung task happens in a conner but practical scenario when > CONFIG_PREEMPT_NONE is enabled, as follows. > > Process 0 Process 1 Process 2..Inf > split_huge_page_to_list > unmap_page > split_huge_pmd_address > __migration_entry_wait(head) > __migration_entry_wait(tail) > remap_page (roll back) > remove_migration_ptes > rmap_walk_anon > cond_resched > > Where __migration_entry_wait(tail) is occurred in kernel space, e.g., > copy_to_user, which will immediately fault again without rescheduling, > and thus occupy the cpu fully. > > When there are too many processes performing __migration_entry_wait on > tail page, remap_page will never be done after cond_resched. > > This relaxes __migration_entry_wait on tail page, thus gives remap_page > a chance to complete. > > Signed-off-by: Gang Deng > Signed-off-by: Xu Yu Well caught: you're absolutely right that there's a bug there. But isn't cond_resched() just papering over the real bug, and what it should do is a "page = compound_head(page);" before the get_page_unless_zero()? How does that work out in your testing? Hugh > --- > mm/migrate.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index b234c3f3acb7..df2dc39fe566 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -301,8 +301,11 @@ void __migration_entry_wait(struct mm_struct *mm, pte_t *ptep, > * is zero; but we must not call put_and_wait_on_page_locked() without > * a ref. Use get_page_unless_zero(), and just fault again if it fails. > */ > - if (!get_page_unless_zero(page)) > - goto out; > + if (!get_page_unless_zero(page)) { > + pte_unmap_unlock(ptep, ptl); > + cond_resched(); > + return; > + } > pte_unmap_unlock(ptep, ptl); > put_and_wait_on_page_locked(page, TASK_UNINTERRUPTIBLE); > return; > -- > 2.20.1.2432.ga663e714 > > >