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 3879DC47082 for ; Tue, 8 Jun 2021 12:00:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D0D6A6128D for ; Tue, 8 Jun 2021 12:00:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D0D6A6128D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 32B426B006C; Tue, 8 Jun 2021 08:00:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DB7E6B006E; Tue, 8 Jun 2021 08:00:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 108026B0070; Tue, 8 Jun 2021 08:00:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id D2FA16B006C for ; Tue, 8 Jun 2021 08:00:16 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D6A48181AEF1F for ; Tue, 8 Jun 2021 12:00:14 +0000 (UTC) X-FDA: 78230413548.32.28B0CA3 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by imf24.hostedemail.com (Postfix) with ESMTP id 0F0D9A0021D2 for ; Tue, 8 Jun 2021 12:00:10 +0000 (UTC) Received: by mail-lj1-f177.google.com with SMTP id u18so6460022lju.12 for ; Tue, 08 Jun 2021 05:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=uYU0wBlQGxD0TLzC1dztsvlGJDA1tbga5OhaOeNPfa8=; b=zbTsbmBNcYTv2dszMaSb1//4OEXSqqmXwpT2KhnVaKPW0N3YsFFxJEqwiZGoxW4tkY MHUJDrTPq8jmsRyipdRMm4bLN9oE8Kgm/+AB9yhqzlABNzRNEGXizx59Lu4cFLzvxgah Tgjw4GfnQHh87Lp0bMqWl5xZe5qQdJo3zjbwPOzPPkJ5+SPUxwhBKZSmrG1ldKDXOxXT ccutdvxZ2mnC6M6WWc1Yf0tNJQNpIe1pQ7RhKDlSdXYjdp5cJNoIpOhWIx/mzyl0wgNN ExC/3ZY3B4REllhqWJTTuvovmYdR1QVq45qwiVkFLiNqaUrEu/KYIaaE4YNbVqPriQaH nh8A== 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:message-id:references :mime-version:content-disposition:in-reply-to; bh=uYU0wBlQGxD0TLzC1dztsvlGJDA1tbga5OhaOeNPfa8=; b=LDOUwdU8Ta624H8SztGat+RPKegeWkvWtY/NYqa/JflR0W46PqzLWFxh/dfamp30j6 JmB5z0P9mxL30GeBHhyEAvQHh2D/vnHFdMy7W5FGubTzgVnJyCuz6Mqy+xu13c3VmS5J zg1VDWc0YGJUW9SrJH5bKT8lFFLlLmI9wQiF62mbYYtKhQU1PW1tcFTfbqplt+O6To1k FTxeQxFL62+7QlSuDw84OfwmZSQsMLQK843BRl6XPwSgu4cTKLLhlvrQSyVcO3SXHpmK eCpQcS012UnNJrk7kMroaprcVWHprJV96zBVssLYDE+6hCcDRlPd25spyVh9ZCINV52i jd4g== X-Gm-Message-State: AOAM532ygXraVv6MMx+DNKrlZFG1BHUIkAVwVdDqoFFZKpfLqb7G8IOj 276k4MG62AKYZscr9tjhk5Llvw== X-Google-Smtp-Source: ABdhPJwaeeFC8vZrtFP9XyW6k7l5rVCxcllnwZXrHnutDNQ/cO/h62uMPst3gxCGA1UQAtdc+TYJIg== X-Received: by 2002:a2e:b8cc:: with SMTP id s12mr18412608ljp.66.1623153612807; Tue, 08 Jun 2021 05:00:12 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id g20sm2229786lja.2.2021.06.08.05.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 05:00:12 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id EC77E102815; Tue, 8 Jun 2021 15:00:26 +0300 (+03) Date: Tue, 8 Jun 2021 15:00:26 +0300 From: "Kirill A. Shutemov" 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 Message-ID: <20210608120026.ugfh72ydjeba44bo@box.shutemov.name> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=zbTsbmBN; spf=none (imf24.hostedemail.com: domain of kirill@shutemov.name has no SPF policy when checking 209.85.208.177) smtp.mailfrom=kirill@shutemov.name; dmarc=none X-Stat-Signature: fd3ta7dcm8bap9kf66ixikoans3is94y X-Rspamd-Queue-Id: 0F0D9A0021D2 X-Rspamd-Server: rspam06 X-HE-Tag: 1623153610-538119 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, Jun 08, 2021 at 05:22:39PM +0800, 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 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 Looks good to me: Acked-by: Kirill A. Shutemov But there's one quirk: if split succeed we effectively wait on wrong page to be unlocked. And it may take indefinite time if split_huge_page() was called on the head page. Maybe we should consider waking up head waiter on head page, even if it is still locked after split? Something like this (untested): diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 63ed6b25deaa..f79a38e21e53 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2535,6 +2535,9 @@ static void __split_huge_page(struct page *page, struct list_head *list, */ put_page(subpage); } + + if (page == head) + wake_up_page_bit(page, PG_locked); } int total_mapcount(struct page *page) -- Kirill A. Shutemov