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 BDBC3C77B73 for ; Wed, 19 Apr 2023 11:41:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 528908E0005; Wed, 19 Apr 2023 07:41:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D9118E0001; Wed, 19 Apr 2023 07:41:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A1E78E0005; Wed, 19 Apr 2023 07:41:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2A9C28E0001 for ; Wed, 19 Apr 2023 07:41:49 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 01A5FA0253 for ; Wed, 19 Apr 2023 11:41:48 +0000 (UTC) X-FDA: 80697951138.26.F010AFE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 2EBF210000D for ; Wed, 19 Apr 2023 11:41:47 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=aV0nZ0rO; spf=pass (imf05.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@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=1681904507; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=i+ljsW3KAuErNDeeE9uh+f3S5vccVtwLnf4UBEcIcgs=; b=j6CcXyR7l+QUF26UcmFa3klrgDv7ykOdr+tAsxCTN0H+6vu0bW3hc8R8a6wGJwBadkxxMM 2cxji/22MDIvEaY+8TTgNl0Qci66LbSbkZuJykVf7aYOUVTsI5ezj/QVABV2WqfOikLmS2 jbMEAvuBWuUyGrAZHQDmIZBAGUK0UWs= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=aV0nZ0rO; spf=pass (imf05.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681904507; a=rsa-sha256; cv=none; b=04TsdfoRznQH9yy3fzvf4wyZ56dPfT0Bwk/MzfkJeb0C099h6Eql/SDfQ6cNsO0R9sCN8v 5bdgQV6O9hMabbxQIXbVxPKtvRAs44UUPrr3SBml1/SLYZ7K4K5hdXPpb9+Zr6AE5FB4R/ aFF4H53Hv+/NSlN5vWdR4qMCBw627uM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681904506; 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: in-reply-to:in-reply-to:references:references; bh=i+ljsW3KAuErNDeeE9uh+f3S5vccVtwLnf4UBEcIcgs=; b=aV0nZ0rOPpKxA53CETPSTeR4QDO1q87aYwDQiHgv1z1WGcFZAshbciI0n+UENVZZjNrZ4f gcUt2zOi1qT5w9TheUE3rNg5G9/U7zzOGhobtspCyoKurx9Xx7hsIG30gbTmsFaiwQnB09 TWoETCMq4TYG3AokynnYgI2vQnroauQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-342-WCYnVo6lNP6ZqvgcTniNgw-1; Wed, 19 Apr 2023 07:41:43 -0400 X-MC-Unique: WCYnVo6lNP6ZqvgcTniNgw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E9F1A810BD4; Wed, 19 Apr 2023 11:41:40 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 48B721121315; Wed, 19 Apr 2023 11:41:40 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 7E64240512CCB; Wed, 19 Apr 2023 08:39:48 -0300 (-03) Date: Wed, 19 Apr 2023 08:39:48 -0300 From: Marcelo Tosatti To: David Hildenbrand Cc: Peter Zijlstra , 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 Subject: Re: [PATCH 3/3] mm/mmu_gather: send tlb_remove_table_smp_sync IPI only to CPUs in kernel mode Message-ID: References: <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> <248392c0-52d1-d09d-75ec-9e930435c053@redhat.com> <20230406182749.GA405948@hirez.programming.kicks-ass.net> <914e826e-3fab-4540-d3a1-24ca39b1cf0a@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <914e826e-3fab-4540-d3a1-24ca39b1cf0a@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2EBF210000D X-Stat-Signature: apnhi9h5h7r44knxybk731w9quufz6s9 X-HE-Tag: 1681904507-657287 X-HE-Meta: U2FsdGVkX1/yHtFia56+2DSdfBtbo4rK86+MQUpUCZshRXFZIJxozGhptTTp5kWmwYrFgKwsFbkOXe8exjTjAJQxy5fmb03hotTKmyzh4SvytrCSn1N4HfRBEPGzcv2bSuV+81YZOZSmNCn5xKw5FtTYmNqfLEkqe4MBBXoCKT4NhBQ9dOkja+iwcxbJcWorEXtJA/rb+I4/f7MisvSm3hdCMAnK1K0Aj6EE/GYFRFPv+KrLSuE1IxsEKlDyNxe7fYs88M/3XGILxWAOilD/ttlk6qB4e+9zWsv8lmL2HbdrD5wEsv+E2xllRAOmwBSGGfsubG3F6QxuYEM57WOLQD/mXqPRJOZNyd7BycpbJCnROFHQGJlaYhzcPpXxWOmu6Yl5tKF8sCJgNggdn8eokRpfAgddsJOQs3Edzxc+g0yzzmNeq5CkQuAeI//SP6Q5rrRps0rdwan52K4Ji605EhRKQZ3PwQFZ+5Kp35tA7VHtSjvcBNwUR0P3JT3GyOOU0dGY9IldHZcpe/nqZ6AWoc8evB1Y0wUKJXudd9XJo+OhhZez4Be5n58d+mjWTTLyPqsDLvklravmV1CZylTsBR9WdyG4Mu+jDP09cJDbOkBwhe9RumJKn+W3EyMjz2wdOk470CLtslASwotFpH8U0kCNGf2p1N4aWJS8WtmJkuEQutcuF68wgLyRXeh/HxNkT1p1G5TxQW0B5iR4yQ2DqiD3sfbZa2LlwMV1CEzxRe+CSXDClFpVbJ7k7uRqjLvr7EtR4ZDLvmnaWw7T8i+uwZkEZ8GjkL65xvUUvCRrafJ6+lNCYrCnTOY+A5CxSZ6f2WOpN2a5xt7riewlv+7JpDhNki7nj+C/H1miqiGaUvfsK3zRMHDeYZUTDoiGs3QI0l+b8LrUImW5WPzplyAA/k/G0C57g1cZs4aL/P5yZNIlavOPp6NZsPBJkfm+cJciHgdPcdqB1DoEAr6RNK+ zFfc4t6R oUhXK7Gm3S6mPOeJaynVHXaofbJDzRx3e7+qWWW2ve+wz0/2vFiZdwFntuN84kobE17AtN275c/x39+bbuulBFFIRKX5uUnUeOIixhPR57cqRhLnftW7rYkaGgy+ghYi3L16yDH/PGHjQbi73Rt19O3PlJRZSKF8DTdr+UUnQYFuftnCoudNhggKJEY45Gi2Eal6p6/uucoESEWfq6DMgX+zle9iDCHpvgCIG7PJNXOsgoKl0HqSx+avHzBUhdsNacyKnZtWwEyyVNbEWqGRi3aa9RKCLQkpU1um76T5mL7numyhh9VSm3hPzdqLieT57kkvSIQuID4lamPf3rYeJE4ZnjfUlx5kIv4qxab9pQl4ApXFROMYHFCv/h39xXOWqGb4/HXu+9Ucsa2sllxhcnhdHM0aslX6Uzof1DoEBhYkEG/oNHfmoBPcgPg== 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 Wed, Apr 19, 2023 at 01:30:57PM +0200, David Hildenbrand wrote: > On 06.04.23 20:27, Peter Zijlstra wrote: > > On Thu, Apr 06, 2023 at 05:51:52PM +0200, David Hildenbrand wrote: > > > On 06.04.23 17:02, Peter Zijlstra wrote: > > > > > > 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. > > > > Yes, and I think that was the right call. However, we can now revisit > > without having the pressure of a known defect and backport > > considerations. > > > > > 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. > > > > Not keeping them around sounds good to me, but I'm not *that* familiar > > with the THP code, most of that happened after I stopped tracking mm. So > > I'm not sure how feasible is it. > > > > But it does look entirely feasible to rework this page-table freeing > > along the lines Jann did. > > It's most probably more feasible, although the easiest would be to just > allocate a fresh page table to deposit and free the old one using the mmu > gatherer. > > This way we can avoid the khugepaged of tlb_remove_table_smp_sync(), but not > the tlb_remove_table_one() usage. I suspect khugepaged isn't really relevant > in RT kernels (IIRC, most of RT setups disable THP completely). People will disable khugepaged because it causes IPIs (and the fact one has to disable khugepaged is a configuration overhead, and a source of headache for configuring the realtime system, since one can forget of doing that, etc). But people do want to run non-RT applications along with RT applications (in case you have a single box on a priviledged location, for example). > > tlb_remove_table_one() only triggers if __get_free_page(GFP_NOWAIT | > __GFP_NOWARN); fails. IIUC, that can happen easily under memory pressure > because it doesn't wait for direct reclaim. > > I don't know much about RT workloads (so I'd appreciate some feedback), but > I guess we can run int memory pressure as well due to some !rt housekeeping > task on the system? Yes, exactly (memory for -RT app will be mlocked).