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=-5.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=no 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 82ECFC4708F for ; Wed, 2 Jun 2021 03:27:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 34A7560200 for ; Wed, 2 Jun 2021 03:27:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 34A7560200 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C1CE66B006C; Tue, 1 Jun 2021 23:27:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF2BC6B006E; Tue, 1 Jun 2021 23:27:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE18D6B0070; Tue, 1 Jun 2021 23:27:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id 7B8DE6B006C for ; Tue, 1 Jun 2021 23:27:55 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 086F1181AC9B6 for ; Wed, 2 Jun 2021 03:27:55 +0000 (UTC) X-FDA: 78207349710.24.43ED804 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by imf17.hostedemail.com (Postfix) with ESMTP id 533454202A1C for ; Wed, 2 Jun 2021 03:27:43 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R541e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=xuyu@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0Ub.lqm4_1622604468; Received: from xuyu-mbp15.local(mailfrom:xuyu@linux.alibaba.com fp:SMTPD_---0Ub.lqm4_1622604468) by smtp.aliyun-inc.com(127.0.0.1); Wed, 02 Jun 2021 11:27:48 +0800 Subject: Re: [PATCH] mm, thp: relax migration wait when failed to get tail page To: Hugh Dickins , Matthew Wilcox Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, gavin.dg@linux.alibaba.com, Greg Thelen , Wei Xu , Nicholas Piggin , Vlastimil Babka References: From: Yu Xu Message-ID: <71c320bf-3fcb-f8c0-65e4-ff706af05607@linux.alibaba.com> Date: Wed, 2 Jun 2021 11:27:47 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 533454202A1C Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of xuyu@linux.alibaba.com designates 115.124.30.54 as permitted sender) smtp.mailfrom=xuyu@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspamd-Server: rspam03 X-Stat-Signature: jhqsgr3eemxgp96co9s3dx1gqkhdmi9o X-HE-Tag: 1622604463-67506 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000015, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 6/2/21 3:10 AM, Hugh Dickins wrote: > On Tue, 1 Jun 2021, Matthew Wilcox wrote: >> On Tue, Jun 01, 2021 at 09:55:56AM -0700, Hugh Dickins wrote: >>> >>> 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? >> >> You do realise you're strengthening my case for folios by suggesting >> that, don't you? ;-) > > Hah! Well, I do realize that I'm offering you a marketing opportunity. > And you won't believe how many patches I dread to post for fear of that ;-) > > But I'm not so sure that it strengthens your case: apparently folios > had not detected this? Or do you have a hoard of folio-detected fixes > waiting for the day, and a folio-kit for each of the stable releases? > >> >> I was going to suggest that it won't make any difference because the >> page reference count is frozen, but the freezing happens after the call >> to unmap_page(), so it may make a difference. > > I think that's a good point: I may have just jumped on the missing > compound_head(), without thinking it through as far as you have. > > I'm having trouble remembering the dynamics now; but I think there > are cond_resched()s in the unmap_page() part, so the splitter may > get preempted even on a non-preempt kernel; whereas the frozen > part is all done expeditiously, with interrupts disabled. > > Greg discovered the same issue recently, but we all got sidetracked, > and I don't know where his investigation ended up. He was in favour > of cond_resched(), I was in favour of compound_head(); and I think I I ever considered about using compound_head, but isn't there another race that, the following put_and_wait_on_page_locked operates on the "tail page" which has been split and is now a single page? Anyway, I will test and verify compound_head. > was coming to the conclusion that if cond_resched() is needed, it > should not be there in __migration_entry_wait(), but somewhere up > in mm/gup.c, so that other faults that retry, expecting to reschedule > on return to userspace, do not get trapped in kernelspace this way. Agreed. I will send v2, if cond_resched is still an option. > > Waiting on migration entries from THP splitting is an egregious > example, but others may be suffering too. > > Hugh > -- Thanks, Yu