Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp556432pxj; Wed, 2 Jun 2021 06:03:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV2aweSoP8Z6MzG4KymxswUDAl06vqDFk3SUgvo8yKf+cWtUtwCit/LrB0esnLh7Prg020 X-Received: by 2002:a17:906:5285:: with SMTP id c5mr33637118ejm.282.1622639002993; Wed, 02 Jun 2021 06:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622639002; cv=none; d=google.com; s=arc-20160816; b=K/AKKIoYY1+fZU9Syc9oRBqBW8wM1uSB4RK+5n5axM7QFjrBwFj83J/hJSIPSekz4Y Hr5aXr4qNyhrqV8CSEcROnZD4bfTqxq9f8wifEwooskK/rAHqtitD6T2JfcBrDnDlWcx kmzt5YyMOd6OrmzZTtvjUnlJrp4YL+NDaImj3UU3XpnbGuc04X6pKj1EpqHEkab9sCf+ GG7Fxg6FcIK8gumHdagMxJw7A5ljxxBfcP01UTrJqESQDdOrv389ZQBSB5Uqn3YSzTD6 D+rDney0v9mhzF2wjuyoefFBRTQxHwgDCMYC3FYRF7nOArwKmmYtzx6nHgam0VXIgXav fsSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=TRs2yzQu03iQmRt2jIekN3rC4oJfnPVJC8feSYgpmPA=; b=DCMt0aupI0C60paNdWUiNN6gqrBPjRqr4+pMpwJpV50j6Werm2MJj8DA8Qx5nSxvM1 TTSeXZ9S6qNQS2alYxmhLwFK6YJHNWtAbQi7ne+7c5G4aSKsDbyG7cQbIaTtep6CkA5E 9gy5okZZhoVT2ZcURzoI60XnEy0ISgpQNwbCZtpAR/xvGGl4KzfGVoMbjSNsKRIuAdmi GGnzcTOLIFBOuIraqO3eOx83oOqczWWRzbsQtifEsgLVGqAc9XReFt3MOb0bKxtjpM7w Ry1O8ZfqKOd51ltkxTGsKGDr1QzLtxvlUDOILcGJdK6aD6RDWyj2B2nEU/YtHf+phuBF vE8g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rv25si7774587ejb.507.2021.06.02.06.02.55; Wed, 02 Jun 2021 06:03:22 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229663AbhFBNBb (ORCPT + 99 others); Wed, 2 Jun 2021 09:01:31 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:37326 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229654AbhFBNB0 (ORCPT ); Wed, 2 Jun 2021 09:01:26 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R481e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=xuyu@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0Ub3L1eD_1622638773; Received: from xuyu-mbp15.local(mailfrom:xuyu@linux.alibaba.com fp:SMTPD_---0Ub3L1eD_1622638773) by smtp.aliyun-inc.com(127.0.0.1); Wed, 02 Jun 2021 20:59:41 +0800 Subject: Re: [PATCH] mm, thp: relax migration wait when failed to get tail page To: Matthew Wilcox Cc: Hugh Dickins , 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: <71c320bf-3fcb-f8c0-65e4-ff706af05607@linux.alibaba.com> From: Yu Xu Message-ID: <1c6b8331-3b74-83fd-abdb-4d7d8f19eb9d@linux.alibaba.com> Date: Wed, 2 Jun 2021 20:59:33 +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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/2/21 7:58 PM, Matthew Wilcox wrote: > On Wed, Jun 02, 2021 at 11:27:47AM +0800, Yu Xu wrote: >> 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? > > No, having your own reference on a page prevents the page from being > split. But that's a good question to ask. Thanks. I have recalled that head page is frozen when splitting THP. -- Thanks, Yu