Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4387680pxj; Tue, 8 Jun 2021 13:04:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5NAVYnO92iaMqS1q/t9z8nBXPwHQLKcptW5SzcZL2xcfUtOnzzOzBbbzpYsrxsJgnIfCQ X-Received: by 2002:a17:906:b74a:: with SMTP id fx10mr24961445ejb.248.1623182668631; Tue, 08 Jun 2021 13:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623182668; cv=none; d=google.com; s=arc-20160816; b=yh0A3IaT1waJ8mHVapXR5HhEiicfKaGjscjfU3qRkoPRqE4/xFJgy/uxNT2ZrO5fK1 tNkTHMnvE8anWAk8rbDjp2PeJ1EKZLHDyVZQuPPyn7lfxd0o378M7O4LmQNyCYZs9Yom zuiJ2nTH0EehdYRFqSrP3a9/MAWzzGKuN8G2I/RJpVqZvVeFA9cFPEG/+ReU4fwm9VQw stGPyuS90XMGF8MC1RuzGzHM9UV+PARZZVzFnjDbs+B9T0V0cEVNzJUmLnCp9qA+mWA1 n9CRwwc9JSAN+Fu2I/uClIo5Y3ajDOVZ8Bwy5pTkRk1Y54bj+tAEZ8Bl713tfz5f7Ow5 +oyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=U2RZsNcVZF/A9WKl6Syv2dkkUcnD6gzrLpGwOG0uKBA=; b=Xrttrw9o2fJBeU5tZ+VkdXWYYTT3XwSQ48Yh1MAKICnRwOtjKgwkyj8GWwwldJDqoe vayKlg+scQDbDpLfCCk5IonUdwtQWJT65dMWe1lxsiWhfnnu6wHHGp1do8IAn8GjESdm MGaT9G5yhrW5Nx71xF80qEAKA12lAbcca0TCANgtp/FASDMkhXxbsuHPZVOZUFvEEZuc AO+G9OadWWndINhe7Uns+nKkwYiwKiJSw2HRRc7K+umZN8hSCEKojpTCM3MPntfu5Bke TceN4jMkb0F8H8QxpB8FOnEB3eAha+bUyvRX6F3FShXU9e9MRhBkwJyxUJPwOa8QYSS7 UuhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Gcss2X89; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e3si487787eds.41.2021.06.08.13.03.26; Tue, 08 Jun 2021 13:04:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Gcss2X89; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234323AbhFHUDL (ORCPT + 99 others); Tue, 8 Jun 2021 16:03:11 -0400 Received: from mail-oi1-f172.google.com ([209.85.167.172]:43883 "EHLO mail-oi1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234064AbhFHUDI (ORCPT ); Tue, 8 Jun 2021 16:03:08 -0400 Received: by mail-oi1-f172.google.com with SMTP id x196so22373823oif.10 for ; Tue, 08 Jun 2021 13:01: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=lRVQfnVqEXzkBFVb1mE5yl3EUnUkA3yiiIyrGxrPn8YndbZdU3Zb4B0HdjokofF9A/ Z84M9yOvDYL0N0TlSZD/1d5Akqr8ARF4SMKcUs0Fnr0uy459DCKPIRYhncopZucr3Nj/ w5KlmHFH1ymy3xU3prmvGBO5pBKnCmxz5xTqh5BJTatX2WVT4eDQfTYUJNK2EppRtyx5 rJc9ty3fTpyMziQpmVSTe1Y0/P8mVUBIKcMU9TI8Y55ZRnjRVzWh8kneI4LPPz7NDQCd lve6g0YaQD7PDXh8IjwgHRangJJehtl8Z/fwPukIVTzpjEf6cM/cxz6GjjalG5Tj/bkc 33tA== X-Gm-Message-State: AOAM532EV/gL9ngA9Sz15ZfLnr6CI26MRiRQ9anR7IXsVlDYWaz0K08d psZ7YRP8wTSp16hjNdBRYr7A+8yAcUVpEQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > >