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 0A0BCC77B7F for ; Wed, 17 May 2023 11:58:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B96C900004; Wed, 17 May 2023 07:58:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7691B900003; Wed, 17 May 2023 07:58:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 630F2900004; Wed, 17 May 2023 07:58:49 -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 556DD900003 for ; Wed, 17 May 2023 07:58:49 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2899B8053B for ; Wed, 17 May 2023 11:58:49 +0000 (UTC) X-FDA: 80799600378.17.14C3E89 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf12.hostedemail.com (Postfix) with ESMTP id 4F19C40005 for ; Wed, 17 May 2023 11:58:47 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=txqECijh; dkim=pass header.d=linutronix.de header.s=2020e header.b=DJtqAo5m; spf=pass (imf12.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684324727; 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=Bu0AMDxFLp3tBIXStVxYzz74iDayYiJXQy5Xc0+dHz0=; b=CzyfcXvZiwg0Q2kgE0Z2VrN6QbU/nJb1ncFRpTkY12PMxYYWLsrCD6oAoH+8RhpP3B14A9 HXCkN3gHWTMFUbDaeovqRZ0W+334aXAhcvBP6PQKkMkz1JHfrwtpHZN+S5GkpJTOhlKJJc 7vZKhdlqAmjhDPOyAISBwH5pvXZdFno= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=txqECijh; dkim=pass header.d=linutronix.de header.s=2020e header.b=DJtqAo5m; spf=pass (imf12.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684324727; a=rsa-sha256; cv=none; b=0FOl3CY2ZYps8EtCb7ZrXFiEeZnsJ4wFOgHbaXVINTCsGbNAC62C4VHPmjhwxGETBfYHlI bnGGYwloEtr8aGAZjVQ9VNHuNzEPLmTz4867Xr7/WboXwSYqHps4ewODikElu44Xn2KPR7 dRuGxtTGhIBLOwC5rrhnGdHwXyhHf5g= From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684324725; 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=Bu0AMDxFLp3tBIXStVxYzz74iDayYiJXQy5Xc0+dHz0=; b=txqECijhJPqlVrVGMFqMFf6TYjEkE9lcC/2vwcnGKbGR/J/HeJnRbo9pP9fz27G1A1xiqd KGqMgIHTfZpsM7T4otbyEqOX1dQGb0Vjwk+RkDwqznKpOuhcQCRnE/S8/YSPz6pgtJRXEA HfuMK98gaY8KbVa5Sj1u+S2I/PL7FF7ArcYNa9/PYL9k79BMRke7TSXgCKUzRPs85vR51J OwbKn0q572P4lRsAjR9RXXjVGGPqr8EjZN+I5L0U43Q2Vkunknl9BCuA2N4PcnL/PjTVwr KPMnh0KlwXDBYZx9m6naTKn2ViOTMZjCE7JPVFJdMCOYFZob5uEAJxtFBY25vA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684324725; 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=Bu0AMDxFLp3tBIXStVxYzz74iDayYiJXQy5Xc0+dHz0=; b=DJtqAo5mYRqgSvrjqSUuT3To1tTAyxuC44EK6B2tZ+Y3L4D+7uSYtQEdI/eOsPOy1WaN06 /H5FTK3KPrvZE0AQ== To: Uladzislau Rezki Cc: Uladzislau Rezki , "Russell King (Oracle)" , Andrew Morton , linux-mm@kvack.org, Christoph Hellwig , Lorenzo Stoakes , Peter Zijlstra , Baoquan He , John Ogness , linux-arm-kernel@lists.infradead.org, Mark Rutland , Marc Zyngier , x86@kernel.org Subject: Re: Excessive TLB flush ranges In-Reply-To: References: <87r0rg93z5.ffs@tglx> <87cz308y3s.ffs@tglx> <87y1lo7a0z.ffs@tglx> <87o7mk733x.ffs@tglx> <87leho6wd9.ffs@tglx> Date: Wed, 17 May 2023 13:58:44 +0200 Message-ID: <87o7mj5fuz.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 4F19C40005 X-Stat-Signature: p97mif1p991nozmt56jxegshxnqo3awb X-HE-Tag: 1684324727-805994 X-HE-Meta: U2FsdGVkX18axsXMVMLoU0JS6+p25l73GIJjWvAh4BH9mo1JWN6bDXZxIF4yA4H4NM6BEIzDfPVUEArN/iFYglHkkW37ZEu7w6736XB4hlOnHEKN/DXUuo47qJ/nty+wWc8QJNe8HwM5ZQl3GH1DxzdbXxo5xf+mMvO34lSOPq0fa3B1bJRm7TPNjw95EXLx2pQiSLKuqLytq7QjsbKeNWc7EcxxeA2ihXiPX3wj9PhTAT7nCd+YD05p2GBesyEv7veuxYHtPWoELd0CI0fVoFHTCYpDa3a7Dno6M+ZbjxbCoVp24GcXXFLnMp8wyy0qR3jWbFg+DpRucrQuYyMsG2OiuzLnO8svFer2WnBOPvc/TAkCypBuhzufHgzqAFGVfkg4h4dhwW54cPGoaM5Go+7GbQDXCow8W+EMMsuoZncmHxLszG+dFz4QI1FIae5QKW2JSiIzNFqpS4VdaXlTDxFRYh0boJFSs6bI6AvXhg5Jy6OgaHwPtZtOgxrZBfEk27nNANGbDPK2rt1IekVmD0j13/9Lqkd+B80l6H6dNSfdZVfm15IMTQtSPrQGmzrQW5vs8OiVA6t8Uqw7lVYOqPIVkwM2IBcEeldL8P1MVo7/FeNbu6222yhHPU/ONCw9uONksg9fr3TO5zP4Dtt2MwaZNZ04z+ALapsnP/emOyX2aiNfKtQbNR4dNRF6AmtcnF3InYlT97ovqOT1g8U/mtuynXCrvtfXVAuQzO7odA1oQPM9lbC+qr0mo7sbuk9aN1cqGFr6ULKy/0WTnWncQFakHcpgRWElB3Dt7BzIAaMsxbXb8QrA2ATPutaontRJGhnLqq+dEzPpn9tWOu5byXmatGGY+85limuFEhoas3impfa3zve/Gk2Mf1KDYvwp40hawawZpFptLOhummUA23tRWq9RB5Q72Osxhb6yc0NcyDJKe33uDltT7e4Z4NdUCgyWq4rP2XnIQKoqboX aC1ZqPHy lTfRDo3SpfEiB1aAvVRN7gqnf11ep2Lk4HD096jg4yfNdHt4= 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, May 17 2023 at 13:26, Uladzislau Rezki wrote: > On Tue, May 16, 2023 at 07:04:34PM +0200, Thomas Gleixner wrote: >> The proposed flush_tlb_kernel_vas(list, num_pages) mechanism >> achieves: >> >> 1) It batches multiple ranges to _one_ invocation >> >> 2) It lets the architecture decide based on the number of pages >> whether it does a tlb_flush_all() or a flush of individual ranges. >> >> Whether the architecture uses IPIs or flushes only locally and the >> hardware propagates that is completely irrelevant. >> >> Right now any coalesced range, which is huge due to massive holes, takes >> decision #2 away. >> >> If you want to flush individual VAs from the core vmalloc code then you >> lose #1, as the aggregated number of pages might justify a tlb_flush_all(). >> >> That's a pure architecture decision and all the core code needs to do is >> to provide appropriate information and not some completely bogus request >> to flush 17312759359 pages, i.e. a ~64.5 TB range, while in reality >> there are exactly _three_ distinct pages to flush. >> > 1. > > I think, all two cases(logic) should be moved into ARCH code, so a decision > is made _not_ by vmalloc code how to flush, either fully, if it supported or > page by page that require list chasing. Which is exactly what my patch does, no? > 2. > void vfree(const void *addr) > { > ... > if (unlikely(vm->flags & VM_FLUSH_RESET_PERMS)) > vm_reset_perms(vm); <---- > ... > } > > so, all purged areas are drained in a caller context, so it is blocked > until the drain is done including flushing. I am not sure why it is done > from a caller context. > > IMHO, it should be deferred same way as we do in: > > static void free_vmap_area_noflush(struct vmap_area *va) How is that avoiding the problem? It just deferres it to some point in the future. There is no guarantee that batching will be large enough to justify a full flush. > if do not miss the point why vfree() has to do it directly. Keeping executable mappings around until some other flush happens is obviously neither a brilliant idea nor correct. Thanks tglx