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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 619CEC4332F for ; Thu, 3 Nov 2022 09:52:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DB9B6B0071; Thu, 3 Nov 2022 05:52:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 864C16B0072; Thu, 3 Nov 2022 05:52:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DEB36B0073; Thu, 3 Nov 2022 05:52:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 576386B0071 for ; Thu, 3 Nov 2022 05:52:47 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2E268161159 for ; Thu, 3 Nov 2022 09:52:47 +0000 (UTC) X-FDA: 80091666774.05.0732988 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 9D84B180004 for ; Thu, 3 Nov 2022 09:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667469165; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aI/nsBdIJq/KxhD4Raxc4CwIaTT63mvtTzDOA0DnrVU=; b=cHhtzHzfNqHqxeUrVo0IghveX9c1UkhWPT5zykzHwk2THzAv8JgGDUwjYJY2LlItTdkbH8 8zUzOXOam+6gw55tB3ZBp7ny/t4ArR5ZSaVt0aq+KpI+CFnWXXTHbEIIEeOBgf5j/00Zl3 pX9zlYYkVa5/uh7xPWm3j5J8PAEGStM= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-142-NnR5n5-BOeu_bIQmXG4QFw-1; Thu, 03 Nov 2022 05:52:44 -0400 X-MC-Unique: NnR5n5-BOeu_bIQmXG4QFw-1 Received: by mail-wm1-f70.google.com with SMTP id c10-20020a7bc84a000000b003cf81c2d3efso276064wml.7 for ; Thu, 03 Nov 2022 02:52:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aI/nsBdIJq/KxhD4Raxc4CwIaTT63mvtTzDOA0DnrVU=; b=anX4N7rr59YvNLQHHrPw/DQL/NkKYTy9f8kNCKA4NGoSJfOMJNJ5H3pafxQKgD81iy 7Ddj19hZX9w0M7nt6J4Iggxe4N82XkTJBD0aVhYbdgu2P9y/ptLWTplWRX/GnElAF2n5 0IbuFZEXBfb7+xJL1wSdBAPtH5e+h6Jllf5hvbQzhb0iFq3UWPg798rjF5W82OySmnuv H+VJfdU8y2k3KG7yMN9P00Qel56tQT/d6XLLX5idyLKwLKqd1qkjnZs4+5V5jL763SCG 2yAi3OzKG6WXLHo8EpJEwbEd6L2mWbH9z+13hZ7dicGlrVZRGP5Pp6yXk5c2eoAhxQ2t ZaKA== X-Gm-Message-State: ACrzQf3YP2LngrwV1nRFWCn3CmqSFzOfoT0Y1Ed1Tm/osDHB5uO77y3/ 8R30yUYN0MxNnVSnT0f4OKJiUXe41i14gIqgT/0pJYxEE/9XF8kpM5z2scFD8q5RbnidSuemmEt ua26p+WIK95I= X-Received: by 2002:a5d:6688:0:b0:238:3e06:9001 with SMTP id l8-20020a5d6688000000b002383e069001mr1770179wru.308.1667469163424; Thu, 03 Nov 2022 02:52:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5KkrKgbb3XOO6+/a6+n0NrIKf/x0VQGYxL1f39jwyafE67d1Pfvlw11Xfu/Llx7ijyIysmtw== X-Received: by 2002:a5d:6688:0:b0:238:3e06:9001 with SMTP id l8-20020a5d6688000000b002383e069001mr1770154wru.308.1667469163083; Thu, 03 Nov 2022 02:52:43 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:a400:e2d7:3ee3:8d35:ac8? (p200300cbc707a400e2d73ee38d350ac8.dip0.t-ipconnect.de. [2003:cb:c707:a400:e2d7:3ee3:8d35:ac8]) by smtp.gmail.com with ESMTPSA id c6-20020adffb06000000b002366dd0e030sm403224wrr.68.2022.11.03.02.52.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Nov 2022 02:52:42 -0700 (PDT) Message-ID: <4f6d8fb5-6be5-a7a8-de8e-644da66b5a3d@redhat.com> Date: Thu, 3 Nov 2022 10:52:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 To: Linus Torvalds , Peter Zijlstra , Will Deacon , Aneesh Kumar , Nick Piggin , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle Cc: Nadav Amit , Jann Horn , John Hubbard , X86 ML , Matthew Wilcox , Andrew Morton , kernel list , Linux-MM , Andrea Arcangeli , "Kirill A . Shutemov" , Joerg Roedel , Uros Bizjak , Alistair Popple , linux-arch References: <47678198-C502-47E1-B7C8-8A12352CDA95@gmail.com> <140B437E-B994-45B7-8DAC-E9B66885BEEF@gmail.com> From: David Hildenbrand Organization: Red Hat Subject: Re: mm: delay rmap removal until after TLB flush In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667469166; a=rsa-sha256; cv=none; b=L4DVdUZfYwJOf+GFnh//TuuOQyROCSVIvOGmLp/9M1UllfOI/QjJw4ukdS1u4skxDIwBS+ C1xnFMAizHR+EqHNbK1PXPQObndJgkd9fRs5UZ+ABH3VLsgc6AzQ34FB2gvU5/xkwBm4hO w5IHz2EJN8i76jVfFG/5Oe0va5ErPBw= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cHhtzHzf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667469166; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aI/nsBdIJq/KxhD4Raxc4CwIaTT63mvtTzDOA0DnrVU=; b=3HR60/tkfr47LKTivfr5gcLswOfYGB1bcAKK2obTLT1iqhPlgp9IGz5O6xihwAyNehlbd2 fEIeOn1dKV3JlglthQRkv7v7ybIhqJWubLmahn7KDmMxHCZXnINgUWuaxHitezN40PMnno e1ooqKr6JJ4uIoPN149nHHjQtiSuv4c= X-Stat-Signature: 5pdese1u4moa5pfp6zexf4g9tfajjskw X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9D84B180004 X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cHhtzHzf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com X-HE-Tag: 1667469166-109421 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 31.10.22 19:43, Linus Torvalds wrote: > Updated subject line, and here's the link to the original discussion > for new people: > > https://lore.kernel.org/all/B88D3073-440A-41C7-95F4-895D3F657EF2@gmail.com/ > > On Mon, Oct 31, 2022 at 10:28 AM Linus Torvalds > wrote: >> >> Ok. At that point we no longer have the pte or the virtual address, so >> it's not going to be exactly the same debug output. >> >> But I think it ends up being fairly natural to do >> >> VM_WARN_ON_ONCE_PAGE(page_mapcount(page) < 0, page); >> >> instead, and I've fixed that last patch up to do that. > > Ok, so I've got a fixed set of patches based on the feedback from > PeterZ, and also tried to do the s390 updates for this blindly, and > pushed them out into a git branch: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?h=mmu_gather-race-fix > > If people really want to see the patches in email again, I can do > that, but most of you already have, and the changes are either trivial > fixes or the s390 updates. > > For the s390 people that I've now added to the participant list maybe > the git tree is fine - and the fundamental explanation of the problem > is in that top-most commit (with the three preceding commits being > prep-work). Or that link to the thread about this all. > > That top-most commit is also where I tried to fix things up for s390 > that uses its own non-gathering TLB flush due to > CONFIG_MMU_GATHER_NO_GATHER. > > NOTE NOTE NOTE! Unlike my regular git branch, this one may end up > rebased etc for further comments and fixes. So don't consider that > stable, it's still more of an RFC branch. > > At a minimum I'll update it with Ack's etc, assuming I get those, and > my s390 changes are entirely untested and probably won't work. > > As far as I can tell, s390 doesn't actually *have* the problem that > causes this change, because of its synchronous TLB flush, but it > obviously needs to deal with the change of rmap zapping logic. > > Also added a few people who are explicitly listed as being mmu_gather > maintainers. Maybe people saw the discussion on the linux-mm list, but > let's make it explicit. > > Do people have any objections to this approach, or other suggestions? > > I do *not* consider this critical, so it's a "queue for 6.2" issue for me. > > It probably makes most sense to queue in the -MM tree (after the thing > is acked and people agree), but I can keep that branch alive too and > just deal with it all myself as well. > > Anybody? Happy to see that we're still decrementing the mapcount before decrementingthe refcount, I was briefly concerned. I was not able to come up quickly with something that would be fundamentally wrong here, but devil is in the detail. Some minor things could be improved IMHO (ENCODE_PAGE_BITS naming is unfortunate, TLB_ZAP_RMAP could be a __bitwise type, using VM_WARN_ON instead of VM_BUG_ON). I agree that 6.2 is good enough and that upstreaming this via the -MM tree would be a good way to move forward. -- Thanks, David / dhildenb