Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp256494pxj; Tue, 1 Jun 2021 21:13:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwY4TXLjwXt7ZKh25otIrUHpQwTQVrR+/M6eM0op2+9o5Wlss192P77qr2i6+ooFdmwlNCG X-Received: by 2002:a50:a6c2:: with SMTP id f2mr29361232edc.39.1622607235464; Tue, 01 Jun 2021 21:13:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622607235; cv=none; d=google.com; s=arc-20160816; b=B7IPTY1jxDPyBUfrM5jAe1EFlUtLC2zj/cWXsPYGsYMkyyBcHQ0p/j2Tdl/pGBLa3E x3PjkEdM6awpHC7a/Y9pz8odHJhG7SzwKZIAQrHVhsWqA7/9EU6h/Aiji/Qm6zG1tZnG XH6xvkok4pG3uDd8opVGTslS7s1Yf/EHJeyXZ5XOguk+rao/nXGuT0LqNYj9F1JpWxZO LsGuZmZCrHDfU6hNw2VvdzwFv9fHrDKLYzTrjRy7ZdcMYogNZoDQF/o1zQPvpl7af5VS kbpr2FUoJBDKyl2nbp8EIgqn6Q2te0PiyZRD8osmQy0Oig+sAvrBcZD4vqenBOA+Rsxm J8AA== 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=HQV8M5XAayt+ncUYGFs2kVflqLirLblM5PPt/2myQQM=; b=yLNynWunHkqT6C3KqwWT13nJ4JEVaV7brTEr97gJyL9mdf1c8bNBhaLOHk/MPZQjy5 j2hNGoEoyJ+n2s+fA9B9I3OkdhRdFSpVzsXi/m73gLkCeUjn4+fsA3fxRV+oIa+X0+3q C5EiukNgLqQuF1immsxVW+J+ueuZLZsxE9FcW4Q7Owwr908hATvErt0ozTEqV6sKQzjc 4XEMAE8BaIhgBRgSxxauBF9NgRPHyIzkBsX66aRp2IQAnrDxsgm3U+ehT7FG6eHfL4r5 1sYAZ3Gopgo7fwCkytoBM0I0Tc+jfi4U8dN8AYVBE7L6/e2TsyBHvWZOwI2Gzekq87el OLrg== 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 r9si17106701ejr.730.2021.06.01.21.13.32; Tue, 01 Jun 2021 21:13:55 -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 S231231AbhFBD3f (ORCPT + 99 others); Tue, 1 Jun 2021 23:29:35 -0400 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:50291 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230511AbhFBD3e (ORCPT ); Tue, 1 Jun 2021 23:29:34 -0400 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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