Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp136622imu; Thu, 10 Jan 2019 20:07:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN4fPoa9KCBfQ17gZ32xkM3ogbz74wPxmT7edSlu0Z0lO4ytZp6ECnAvdBdeEowpYC3PTMn/ X-Received: by 2002:a17:902:f01:: with SMTP id 1mr12691323ply.143.1547179625079; Thu, 10 Jan 2019 20:07:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547179625; cv=none; d=google.com; s=arc-20160816; b=MvUPTXyNfaiHJuMhOWMi8KoJuAccqBq3JODuhdLdhgNovVY4dasA+cQdWAKKbpjVsy Tcuri5e3zqrLEwb822c9wBvm4F4evvVl0/s7d0WKq1BJFCxJp6GkuR4aunwukkbchTMN HitfIYh7Iln2nazSHjZDTdoQWb2MV3BpO3ry//cJ+GrSbBurzzPVxJ+ZBbD3NlZbk6ob Af8jbnvnMJJq6VOllT3BLRqUH7cks8TPFeFv2905U6/Itc+trljo0vXyocohvR9ldm5A j3d/8ujF/FoRAmBZ4aWbI4Q7etujNmyNBILQ1ODhAue1ghh1dUeyOxJa+H2KBQFshFNe 8E8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=Pbs3viVnbLmrJDgZToOWnI2RCPBUPFNlcmEf/PajdJI=; b=YHRDIaVyCxEP4OGVbaWvXHCNJci+wyv7huPNkijoCw5QaDuPxxe0FucyVkEkFezFdq BBgLTetoIBSlmNb7JTVYkPXE/N6bkvSCeL/EdTS2EZi1vF4GT5pdyqpy8qtZrXc9d2Oy S6MjTxplZA53hl4O1/rvStqF15tp1ycyGDobqt+nM/AAGWOjanh78YHrVwyMvyT7FS04 wqBa9w8pk3YuNG1QgCUCsf64A/NUyOdA+OQ28MndvMh8WtR2cCLWsWEsrwaGa/OOnHAO vHHCweIZAqFKRPfLTTzYlLQuS11MvQHG7aRM6vcXM85cv9pARm5ZI79GqYUXe8nKzvUK E9EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=be7UFB1L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id m35si59073669pgb.246.2019.01.10.20.06.49; Thu, 10 Jan 2019 20:07:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=be7UFB1L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729551AbfAKCIy (ORCPT + 99 others); Thu, 10 Jan 2019 21:08:54 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:33866 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728083AbfAKCIy (ORCPT ); Thu, 10 Jan 2019 21:08:54 -0500 Received: by mail-pl1-f195.google.com with SMTP id w4so6034636plz.1 for ; Thu, 10 Jan 2019 18:08:53 -0800 (PST) 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 :user-agent:mime-version; bh=Pbs3viVnbLmrJDgZToOWnI2RCPBUPFNlcmEf/PajdJI=; b=be7UFB1LIsM1GXBUnRqgUd1Bg5S47LHTc2yx/D8RMpNdLkrEnNcED8NWgmKomJqmIp WYgPN5abdriOnT3SevisE/0NwDFNJm98i7Be+Yrrs7w3sFyh7/lrZVItpBY6kofBUDOu pJb1Lh35mDCcDASTBoeUkDycl4LRVlQLpMsmSkvJxeZk/Txd1lR5ry5mibtvseHAiu2p RfOEXz8MP2uBBNzf/BVP27ymYip56gz6xvNjqpT11W93MQvBoF0Y3YoSVbzL3KzR5T9t 4exhZdcdIU4hoVbQE+e9wmpsTGnBFzRbm/SmI7DtE5/CFUvu2vCXhHJEJiD/zifhK4td x9Hg== 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:user-agent:mime-version; bh=Pbs3viVnbLmrJDgZToOWnI2RCPBUPFNlcmEf/PajdJI=; b=HDepZ6rbit++FOjmy3wrO/mv7slW2hkkTZVHgpiabe3h9q3dYVHE5SW9D9WnLGtytp WcHNvP/235PEKgvuqNIJA746JyMVs/T5kl9vpvwBAIBtBRp13OxWNReREvy4K8g5DNBu u0fsdgNNJbcDWUtqvpNtYkt0JwcatlVuqmMFrE2iqAwVwSm9Diq3sb8ewumC1gro6sHa b5eymmm27LfrtxFSTpPjDrzGtL022i1wOA3vL30+L1YszdO1VAoFiyoz7jBGriJtMsBj UFhEjOkUcbtUnWrX00ZtwwqEcpZOqaW2f1bplg94JlNk9QM6qTyi6n69Ie9vpDfXyNrn kJ5w== X-Gm-Message-State: AJcUukd97oxO141q/Jb3hXqYn/8cz5fIE7HW2mKhzqJKIJDPqyA6W7hM WhMwfoRS8BM4EpE0xJo20rvyXw== X-Received: by 2002:a17:902:5588:: with SMTP id g8mr12780632pli.22.1547172532918; Thu, 10 Jan 2019 18:08:52 -0800 (PST) Received: from [100.112.89.103] ([104.133.8.103]) by smtp.gmail.com with ESMTPSA id v9sm111315757pfg.144.2019.01.10.18.08.49 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Jan 2019 18:08:50 -0800 (PST) Date: Thu, 10 Jan 2019 18:08:37 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Vlastimil Babka cc: Hugh Dickins , Linus Torvalds , Andrew Morton , Baoquan He , Michal Hocko , Andrea Arcangeli , David Hildenbrand , Mel Gorman , David Herrmann , Tim Chen , Kan Liang , Andi Kleen , Davidlohr Bueso , Peter Zijlstra , Christoph Lameter , Nick Piggin , pifang@redhat.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Konstantin Khlebnikov Subject: Re: [PATCHi v2] mm: put_and_wait_on_page_locked() while page is migrated In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 10 Jan 2019, Vlastimil Babka wrote: > > For the record, anyone backporting this to older kernels should make > sure to also include 605ca5ede764 ("mm/huge_memory.c: reorder operations > in __split_huge_page_tail()") or they are in for a lot of fun, like me. Thanks a lot for alerting us all to this, Vlastimil. Yes, I consider Konstantin's 605ca5ede764 a must-have, and so had it already in all the trees on which I was testing put_and_wait_on_page_locked(), without being aware of the critical role it was playing. But you do enjoy fun, don't you? So I shouldn't apologize :) > > Long story [1] short, Konstantin was correct in 605ca5ede764 changelog, > although it wasn't the main known issue he was fixing: > > clear_compound_head() also must be called before unfreezing page > reference because after successful get_page_unless_zero() might follow > put_page() which needs correct compound_head(). > > Which is exactly what happens in __migration_entry_wait(): > > if (!get_page_unless_zero(page)) > goto out; > pte_unmap_unlock(ptep, ptl); > put_and_wait_on_page_locked(page); -> does put_page(page) > > while waiting on the THP split (which inserts those migration entries) > to finish. Before put_and_wait_on_page_locked() it would wait first, and > only then do put_page() on a page that's no longer tail page, so it > would work out despite the dangerous get_page_unless_zero() on a tail > page. Now it doesn't :) It took me a while to follow there, but yes, agreed. > > Now if only 605ca5ede764 had a CC:stable and a Fixes: tag... Machine > Learning won this round though, because 605ca5ede764 was added to 4.14 > stable by Sasha... I'm proud to have passed the Turing test in reverse, but actually that was me, not ML. My 173d9d9fd3dd ("mm/huge_memory: splitting set mapping+index before unfreeze") in 4.20 built upon Konstantin's, so I included his as a precursor when sending the stable guys pre-XArray backports. So Konstantin's is even in 4.9 stable now. Hugh