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=-23.3 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_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 4F844C47082 for ; Tue, 8 Jun 2021 20:00:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C670C6024A for ; Tue, 8 Jun 2021 20:00:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C670C6024A 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 3091B6B006C; Tue, 8 Jun 2021 16:00:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BAC66B006E; Tue, 8 Jun 2021 16:00:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15AD56B0070; Tue, 8 Jun 2021 16:00:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id D92FD6B006C for ; Tue, 8 Jun 2021 16:00:16 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 54B1B181AEF1F for ; Tue, 8 Jun 2021 20:00:16 +0000 (UTC) X-FDA: 78231623232.17.9AF8D91 Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) by imf23.hostedemail.com (Postfix) with ESMTP id F31AAA00025F for ; Tue, 8 Jun 2021 20:00:12 +0000 (UTC) Received: by mail-oi1-f170.google.com with SMTP id a26so2065194oie.11 for ; Tue, 08 Jun 2021 13:00:15 -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 :mime-version; bh=U2RZsNcVZF/A9WKl6Syv2dkkUcnD6gzrLpGwOG0uKBA=; b=Gcss2X89Z24QxoWCjkupZcyQxvltOXMO4xu2KRzWl4m/MCCqbHJF8VvBG0VTYAZFT7 3jxLHfmb4iAgb1VYTuP5B1tTWtSEDdw0aNpVfa1a4PK8GeFkdXPb3/Pm752zx0easOd7 /sjz2kw9KjVACzn+/2sWikMn28VWH3xDeqx7O5G0WA802vWNbt4ej0kqt2C5bRtI4lHG tEZS9QMz20qwOU1nAp2j4l8xtDz4iAubzKejqziWNFiwfCWIxyHAlx9MmRMc2gFeuQvd 4+M0uXn/CCeqUNqXU9DfNxeBUAtu9ZoW0tZ2R6EEKllkAcinFYujaSU/VEA4p6Hpeye+ 0oJg== 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:mime-version; bh=U2RZsNcVZF/A9WKl6Syv2dkkUcnD6gzrLpGwOG0uKBA=; b=NninE8t9cfzfE7YuTPRVAS9aQMk6AvCFitLv+3Eu/TWkTmJ9+lnLVDhrTjPyxlexf2 yRMuEPVmsFB3HrzolhOGRaC4EtoobNuGcndLnzvAwiE7v6vGpjtIhxk4jEX8N+Ky41yb +0CTZoUjOfCGvbbvR4+ti0ifUNwu63rJ70BXtLvk3O46mHrXe4rxmf3WDVxZ+Fbs/zeK zV68b+WYLk7qviJ4Mgw39R1VeFeLCrAELuBkbXdToA1/NokS/xoVzVmEqMH8iG36EDma sQzum1M6r4+9CevYJJsrTvr8wF1KsPwg1DxBq3d4SIsGTJGo/zBuw9isxmEV6ruisdN/ 5/Yg== X-Gm-Message-State: AOAM531w0MqFQ/szu5kURBdlztgVXWD4bTdjROyCvDryzH+1QSCf6q8e 30/l8sACthckE5iw0ewr9cmxig== X-Google-Smtp-Source: ABdhPJyEF1rs/MChREJFdaK9w/jVyCBBz3xtW5SQvXfvT1iUhSMvf2YYQxqoEcH3Dh1Qz/WSzh7KwQ== X-Received: by 2002:a05:6808:1146:: with SMTP id u6mr3998862oiu.130.1623182414747; Tue, 08 Jun 2021 13:00:14 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id d8sm1988140oom.37.2021.06.08.13.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 13:00:14 -0700 (PDT) Date: Tue, 8 Jun 2021 13:00:02 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Xu Yu cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, hughd@google.com, akpm@linux-foundation.org, gavin.dg@linux.alibaba.com Subject: Re: [PATCH v2] mm, thp: use head page in __migration_entry_wait In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: F31AAA00025F Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=Gcss2X89; spf=pass (imf23.hostedemail.com: domain of hughd@google.com designates 209.85.167.170 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: q7hc4ac3a4kb5g7xybuwwqt4711kueyj X-HE-Tag: 1623182412-955201 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, 8 Jun 2021, Xu Yu wrote: > We notice that hung task happens in a conner but practical scenario when But I still don't understand what you mean by "conner": common, corner, something else? Maybe just delete "conner but ". > 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 in fstat, 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 makes __migration_entry_wait operate on the compound head page, > thus waits for remap_page to complete, whether the THP is split > successfully or roll back. > > Note that put_and_wait_on_page_locked helps to drop the page reference > acquired with get_page_unless_zero, as soon as the page is on the wait > queue, before actually waiting. So splitting the THP is only prevented > for a brief interval. > > Fixes: ba98828088ad ("thp: add option to setup migration entries during PMD split") > Suggested-by: Hugh Dickins > Signed-off-by: Gang Deng > Signed-off-by: Xu Yu Thanks: Acked-by: Hugh Dickins And I hope Andrew will add Cc stable when it goes into his tree. I'll leave the (independent) discussion of optimal wakeup strategy to Kirill and Matthew: no strong opinion from me, it works as it is. > --- > mm/migrate.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mm/migrate.c b/mm/migrate.c > index b234c3f3acb7..41ff2c9896c4 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -295,6 +295,7 @@ void __migration_entry_wait(struct mm_struct *mm, pte_t *ptep, > goto out; > > page = migration_entry_to_page(entry); > + page = compound_head(page); > > /* > * Once page cache replacement of page migration started, page_count > -- > 2.20.1.2432.ga663e714 > >