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 017FAC7618D for ; Thu, 6 Apr 2023 15:52:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 47A0F6B0071; Thu, 6 Apr 2023 11:52:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 450CB6B0074; Thu, 6 Apr 2023 11:52:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 340976B0075; Thu, 6 Apr 2023 11:52:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 246696B0071 for ; Thu, 6 Apr 2023 11:52:02 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CCC34C1313 for ; Thu, 6 Apr 2023 15:52:01 +0000 (UTC) X-FDA: 80651407242.18.535A2F1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 0191E8000D for ; Thu, 6 Apr 2023 15:51:58 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZkW7pc7p; spf=pass (imf02.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680796319; 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=rXGtO/ZmgcxJ+0cLf6d2t80Dy16O6Eu74rSJdt26LEE=; b=oQ0GhWmqKkzqmN/JPNRKOEEeOFhkT54UIo1KoCzFcKmLmZjWWtARmKVkp5vKdW8DbM+wkN pFMmjvJC0xuJWZ2lBzQwUrcuYHpnIuQj7M4nvFLLib+hc5n45acDT4NE7guQ/CppXjl4OQ J9YQPW0Sy3+Z5RFdmjHLaUoIiWFN8c8= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZkW7pc7p; spf=pass (imf02.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680796319; a=rsa-sha256; cv=none; b=MgaF/9zzWDIWhuCr1zFBC3MnIKg3A9Of+4MvIqIVSkCUupWTs/s2iQA7lJmk7BguFopYwH 26pAfixhpnB3OnLtgxANuLLwwMdJoOfXuWJQazkta0CH/1MJAbFp4AaF/pWwQAKXEMFI7i NSAo3dCZLyYF55qfy5VOJelDIMKTAXs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680796318; 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=rXGtO/ZmgcxJ+0cLf6d2t80Dy16O6Eu74rSJdt26LEE=; b=ZkW7pc7pNo/dlO7QBx4P32TuqKNP8zf6eEJ6IE+1MdR8tveiAxWthyFotoyaCz2nXi1AjD Wq879Vg8C58sG8tm0ZJlSf4zc6PSGWMXY5Jv451m9F817dX5u5JC21NRrkXeeVtI5KcRNc xm8qfY1u2GWD9bmjhlgcxS7Tzfj4iMg= 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_256_GCM_SHA384) id us-mta-593-7Trq87nHPsm3T6TATTn7RA-1; Thu, 06 Apr 2023 11:51:57 -0400 X-MC-Unique: 7Trq87nHPsm3T6TATTn7RA-1 Received: by mail-wm1-f70.google.com with SMTP id j27-20020a05600c1c1b00b003edd2023418so20438819wms.4 for ; Thu, 06 Apr 2023 08:51:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680796316; x=1683388316; h=content-transfer-encoding:in-reply-to:subject:organization:from :content-language:references:cc:to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rXGtO/ZmgcxJ+0cLf6d2t80Dy16O6Eu74rSJdt26LEE=; b=uV5aOag6nL8VdY5lDIq91O4Og1JqaHPuyJ6czBJtLx5lo5hLNRRJmyVKP9LHfNYwm9 5Ab3wfyD0jfxJ8iPVuijdqwksemIz16bXSaUBmfpTqrKkrAdJQldLZUKd/skY2XvCfal 9PhM9ACw6UDq4pTET3wYXW+xib18cdLwp7KXBBNr3/Cc6m/26Xn/R4ehvSWyUKdeZcBo 243bmEI4NipN0C5uEujXJHmKNLhkTSBqn3LX2aqkkgoCLYKJxYXYAU4Bf681MrpmpZUv aa9PPgHjlkqv3yQIr3qFJR8oaiyBY9krPdrKzX9lZU6Tctx5G2Z7T07n1bcjVWa4OTqF BsJw== X-Gm-Message-State: AAQBX9cNis55j1pbZ0KCwOIu0bFIb7NWtnZz3Kmh+XFIHdp7iWJyegOo 1ABAeDhfAg9pRxYHE7WGYSst0dsKybxueA1LqpJL32BXJ3SJBaSIeplBF2DQOIuEX6jte82uqEF NNfxDz8+jP40= X-Received: by 2002:a5d:4b48:0:b0:2c5:5349:22c1 with SMTP id w8-20020a5d4b48000000b002c5534922c1mr4313703wrs.5.1680796315818; Thu, 06 Apr 2023 08:51:55 -0700 (PDT) X-Google-Smtp-Source: AKy350ay4SJLqt5fA44R22zdeLYwjok7IPAqD9HIjt6I2uRSHvro/TvSjV0I+pG8tJTj7AgJtBYNWg== X-Received: by 2002:a5d:4b48:0:b0:2c5:5349:22c1 with SMTP id w8-20020a5d4b48000000b002c5534922c1mr4313662wrs.5.1680796315457; Thu, 06 Apr 2023 08:51:55 -0700 (PDT) Received: from ?IPV6:2003:cb:c705:6300:a8be:c1ad:41a1:2bf7? (p200300cbc7056300a8bec1ad41a12bf7.dip0.t-ipconnect.de. [2003:cb:c705:6300:a8be:c1ad:41a1:2bf7]) by smtp.gmail.com with ESMTPSA id l13-20020a5d668d000000b002e61e002943sm2031659wru.116.2023.04.06.08.51.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Apr 2023 08:51:54 -0700 (PDT) Message-ID: <248392c0-52d1-d09d-75ec-9e930435c053@redhat.com> Date: Thu, 6 Apr 2023 17:51:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 To: Peter Zijlstra , Marcelo Tosatti Cc: Frederic Weisbecker , Yair Podemsky , linux@armlinux.org.uk, mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, davem@davemloft.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, will@kernel.org, aneesh.kumar@linux.ibm.com, akpm@linux-foundation.org, arnd@arndb.de, keescook@chromium.org, paulmck@kernel.org, jpoimboe@kernel.org, samitolvanen@google.com, ardb@kernel.org, juerg.haefliger@canonical.com, rmk+kernel@armlinux.org.uk, geert+renesas@glider.be, tony@atomide.com, linus.walleij@linaro.org, sebastian.reichel@collabora.com, nick.hawkins@hpe.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, vschneid@redhat.com, dhildenb@redhat.com, alougovs@redhat.com, jannh@google.com, Yang Shi References: <20230404134224.137038-1-ypodemsk@redhat.com> <20230404134224.137038-4-ypodemsk@redhat.com> <20230405195226.GB365912@hirez.programming.kicks-ass.net> <20230406132928.GM386572@hirez.programming.kicks-ass.net> <20230406140423.GA386634@hirez.programming.kicks-ass.net> <20230406150213.GQ386572@hirez.programming.kicks-ass.net> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH 3/3] mm/mmu_gather: send tlb_remove_table_smp_sync IPI only to CPUs in kernel mode In-Reply-To: <20230406150213.GQ386572@hirez.programming.kicks-ass.net> 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 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0191E8000D X-Rspam-User: X-Stat-Signature: xg8cfozxmx6ihbqpfphnju6eiypwhiwr X-HE-Tag: 1680796318-545449 X-HE-Meta: U2FsdGVkX1/Xtdm9GvldqiJN9QBPW7BQFqD0h3dlrH7rCHF5TXeSVEKOgmO2EzL+NP1Uj8jAb+CKBEypfujiGjxlLwpwlk532I2foE+WKLrQCzHuYQ2M6hysvxKzEL+TPLYiETWVrJWnwg/rkmcdkrUd1eHTrqw0VXZsdcoSVfuLwBJhnCHS/Jo4mBEp3x4eVw5kGREMdNNWUMy3MBpYmIrfzJJdLMegx8h1M9mFfB27VM39UqQi6e/BAAtXGSQZKIgZAd/JnnKfyoYGxZ4ZuW7Ka6+EEAaREw/xJ1rMzVJ4RFzkRi1XA9/6IFjtBHB6FX1S3WcYXYhpHVEA6O6wmGHnNQRTzPU/Iy6/jLoVrckyFTYXUT40HfZw1m0FR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LOVdh8zK5dpPj79LH5ZqZ6XMpL3k4YYETVgOkUV3aJCV2slgNEI8I0R6635aT5zi4vL0m5+25+V8D1fgpc7E6n5T7OiI/AQS+FaUhrHD5j3FmwnXJSl8zxKfkLda+S7XFnte7Sy5ybTUPvm5inNI09w4BDG4QQZj0c9H3i6hSf4jKnu0cXJUkmNQFqudz2COFdo1t4higSqTQ== 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 06.04.23 17:02, Peter Zijlstra wrote: > On Thu, Apr 06, 2023 at 04:04:23PM +0200, Peter Zijlstra wrote: >> On Thu, Apr 06, 2023 at 03:29:28PM +0200, Peter Zijlstra wrote: >>> On Thu, Apr 06, 2023 at 09:38:50AM -0300, Marcelo Tosatti wrote: >>> >>>>> To actually hit this path you're doing something really dodgy. >>>> >>>> Apparently khugepaged is using the same infrastructure: >>>> >>>> $ grep tlb_remove_table khugepaged.c >>>> tlb_remove_table_sync_one(); >>>> tlb_remove_table_sync_one(); >>>> >>>> So just enabling khugepaged will hit that path. >>> >>> Urgh, WTF.. >>> >>> Let me go read that stuff :/ >> >> At the very least the one on collapse_and_free_pmd() could easily become >> a call_rcu() based free. >> >> I'm not sure I'm following what collapse_huge_page() does just yet. > > DavidH, what do you thikn about reviving Jann's patches here: > > https://bugs.chromium.org/p/project-zero/issues/detail?id=2365#c1 > > Those are far more invasive, but afaict they seem to do the right thing. > I recall seeing those while discussed on security@kernel.org. What we currently have was (IMHO for good reasons) deemed better to fix the issue, especially when caring about backports and getting it right. The alternative that was discussed in that context IIRC was to simply allocate a fresh page table, place the fresh page table into the list instead, and simply free the old page table (then using common machinery). TBH, I'd wish (and recently raised) that we could just stop wasting memory on page tables for THPs that are maybe never going to get PTE-mapped ... and eventually just allocate on demand (with some caching?) and handle the places where we're OOM and cannot PTE-map a THP in some descend way. ... instead of trying to figure out how to deal with these page tables we cannot free but have to special-case simply because of GUP-fast. -- Thanks, David / dhildenb