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 02910C76196 for ; Thu, 6 Apr 2023 13:17:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20F5A6B0071; Thu, 6 Apr 2023 09:17:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1BD6D6B0074; Thu, 6 Apr 2023 09:17:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 085956B007B; Thu, 6 Apr 2023 09:17:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id ED6036B0071 for ; Thu, 6 Apr 2023 09:17:02 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B11FC1212D1 for ; Thu, 6 Apr 2023 13:17:02 +0000 (UTC) X-FDA: 80651016684.07.F699B23 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 32B911A000A for ; Thu, 6 Apr 2023 13:16:58 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=COG5BabD; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680787019; 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=LyLWq4qOx1xU0bxV6bHK7gb5g8imneWyvQWEYXMsdJw=; b=k21NaHdy3PTmOrdUGdqxK9u+al35tymrJkoQKpvxDefwYoyB5zCctEWEa4w65hrkvCoH4U +RzMLrEmA0XFJYexkx072UQNfomkuh1eDhGs4teMRdM6Pkl2s5QE0UxmGwTmfn/rAA5uBg GA+to+leqmi5ayUv7mxwb7UQL+zc1rE= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=COG5BabD; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680787019; a=rsa-sha256; cv=none; b=XlIiHHZXQiM+K6J+YBxiiOIn1eQQKhVZheAsx26bXl3+4+fipVHhojadTig6T6PpAoLLvt IltdwVdS6UmB2+xtDyx7nYfWZrA3q3s42blWier8/Qx4dEDXjHYKSe8Q5VSxiPKo/7+JIB K9fs/xzaZJlePrXIjYWWr5BXPKWWoYw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680787018; 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=LyLWq4qOx1xU0bxV6bHK7gb5g8imneWyvQWEYXMsdJw=; b=COG5BabD9J5sU2n6dBrFzLjHIRP5NC6tQDE167skwBSAq3NwYkmiC/8ghPoyxHThRqLQ0w bk8MmQnbQYF4pU8CR1jrDQx+OoqMMF5oryqAteLMhyS1miX1GNXBl8J3fPZaVdQ3jzgdpU xs9EIaeA5tBryfqM6cSZZwhGUBnhDbw= 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-612-LTw34yIZO-qtviR3tWXTcA-1; Thu, 06 Apr 2023 09:16:57 -0400 X-MC-Unique: LTw34yIZO-qtviR3tWXTcA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2EF4B857F81; Thu, 6 Apr 2023 13:16:55 +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 86155C1602C; Thu, 6 Apr 2023 13:16:54 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 8BB9E41306EC9; Thu, 6 Apr 2023 09:38:50 -0300 (-03) Date: Thu, 6 Apr 2023 09:38:50 -0300 From: Marcelo Tosatti To: Peter Zijlstra 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 Subject: Re: [PATCH 3/3] mm/mmu_gather: send tlb_remove_table_smp_sync IPI only to CPUs in kernel mode Message-ID: References: <20230404134224.137038-1-ypodemsk@redhat.com> <20230404134224.137038-4-ypodemsk@redhat.com> <20230405195226.GB365912@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230405195226.GB365912@hirez.programming.kicks-ass.net> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: 32B911A000A X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 7r85eqex6et4sodi4ciikn56s4tntq47 X-HE-Tag: 1680787018-744386 X-HE-Meta: U2FsdGVkX1/yvR0ZVM16I+vhp5E8QDMdCN4DWNSeqzCB06baK1pNIsaOGq4TdqV+/Bp/s9hZbO6oKVDASBYLpZvic8jZJjwEut42+XxOjMJmTIt5EjFUKG74pP2W8+gck9zIJysjMjW5auzvvuhPK5R3cOakTE4Mbb8zLUCbRhTBWqPD8o8UTnLVK5My6u8Wwc30S7U49DZwXMI+ese7ojwIpWNTbeL8Wwf1EMw7bhrd58rCa/J4NWHWzysRbHrvlnkX/QHOB9DkwbBvi1tC0BMFpNriXgRgOGdjLNGAGtxeJE32cS59+D9GtkEmZ80SwP11LTNdNdVS/cYx+kVMoiZD/oDv5b05gooSkNgUJufhfOAO43F8+OD+4TcLN+1jbi+QRDFNriwHtc70q4F6P5pZ5KzEkCQjd9Ck5xvNsFBsYsRigqg9r13941jJYnAEmr4c0q+1PTHjxHW8rrbhDCvcibFNCDm5fSbaJzG3oMWsuYx0IyokMYmoa9gy6un90QswCfPCjNgQsHLKx4JYsAh42T5kfqH7v+ELB2PkZUfpjAvwQgOcoDFvQ+XSYiiXHZUGb2MlO+xGdniyMrCq0FiOe6kPV/uJa1zh+EPL5573cwLhJ8gcysOXJtnLhphJvULpOOVJRDyvvkD+qCDEEezmlAmFLgE7nsz12ZhBtRCjPnCZZcb9DRyEk6rAUd8Bokk68dkPrkd1FLcMn9d8ckaTqj4TnPRMcFIyTBFC8iRPOzcLsJxDhQZx+E9JKCPoe7u8ToXCzIxKHOK6yGWW3BnCXjGbi4F6076YF17vkih0N/fbqjHJyGpDmClckcx2yqWEFf3uD0/lj1F3mHLkKwlZ2DYdJ4VKgDTEeZvbJYaCpayBgj2QF7ztBuhicS2NCUTln0ANII7NSkCxfh4ZW34RcnkZ6rUkLHNNv4YV51Y8Oa3kfy1Mb3oZdhdGq8DnBt/Xerj35ViSVoV7+fd 5dkh8rEU fstjKgPkMWe4wbgLtsAJ964w/OiaVLPp8n0kMmjBsTRnHUe3fecn+raekeDgquGZBVKlD0UneL6PM+TIuiTlkBiY8+QTZjNXISEi5I+jp54NX+OVwGWFvh6DXoGk8g9Lopm8wAnyNHI1ah/tp+yaepN7ED0BlGweCqXbZyIPGylFS3DRzOBHXp3dPMa7FZRrhxdeCthCwcsDtKI6CXu4d2PJhoqe+7SkF9bsKGPYRKNegpavGYdnC6lv3sEblX+b0GFAJH1S3h4mA4IO+lsad/Yr5GKPjAVdug75mwDhzszOEoaEZZ7swpsQXuw== 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 05, 2023 at 09:52:26PM +0200, Peter Zijlstra wrote: > On Wed, Apr 05, 2023 at 04:45:32PM -0300, Marcelo Tosatti wrote: > > On Wed, Apr 05, 2023 at 01:10:07PM +0200, Frederic Weisbecker wrote: > > > On Wed, Apr 05, 2023 at 12:44:04PM +0200, Frederic Weisbecker wrote: > > > > On Tue, Apr 04, 2023 at 04:42:24PM +0300, Yair Podemsky wrote: > > > > > + int state = atomic_read(&ct->state); > > > > > + /* will return true only for cpus in kernel space */ > > > > > + return state & CT_STATE_MASK == CONTEXT_KERNEL; > > > > > +} > > > > > > > > Also note that this doesn't stricly prevent userspace from being interrupted. > > > > You may well observe the CPU in kernel but it may receive the IPI later after > > > > switching to userspace. > > > > > > > > We could arrange for avoiding that with marking ct->state with a pending work bit > > > > to flush upon user entry/exit but that's a bit more overhead so I first need to > > > > know about your expectations here, ie: can you tolerate such an occasional > > > > interruption or not? > > > > > > Bah, actually what can we do to prevent from that racy IPI? Not much I fear... > > > > Use a different mechanism other than an IPI to ensure in progress > > __get_free_pages_fast() has finished execution. > > > > Isnt this codepath slow path enough that it can use > > synchronize_rcu_expedited? > > 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.