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 D8164C4345F for ; Thu, 11 Apr 2024 14:51:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 498016B007B; Thu, 11 Apr 2024 10:51:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 448666B0087; Thu, 11 Apr 2024 10:51:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3107D6B0089; Thu, 11 Apr 2024 10:51:02 -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 10D086B007B for ; Thu, 11 Apr 2024 10:51:02 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C038B40A08 for ; Thu, 11 Apr 2024 14:51:01 +0000 (UTC) X-FDA: 81997538322.24.FE28A58 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id A290680015 for ; Thu, 11 Apr 2024 14:50:58 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=htssSxQm; dmarc=none; spf=none (imf30.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712847059; 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=ySKvrwPo8uea30YwZAfejWfUzP0Mp1IBm6Q6ft0K7Zk=; b=65w+nNwfrgErBK1KXYarN004LqfBdgjF8anDq943Xet2U4aZnhWqO+c3klAPqEfZMkO8r5 NZmCjuMnHHWK95kANUtAQbwbA0DUtUl/epVVH2UA5Dw7avuJzD79TFDftart2azc+J917C ITLPwdg/dkEnClMB9LeVwbL0RMPwoM0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=htssSxQm; dmarc=none; spf=none (imf30.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712847059; a=rsa-sha256; cv=none; b=dLQdUR5B+e85pcGUAXN5iYloj7TynuRrHlGIAW+v4eiBjRMUoigzxoEnJ8ugHtVDPmqHWJ PVt4zIAJ8CzSAhHydUH2+2htCldRV/nJsRdb7936sOVoXzCd0JDt3iWsn3+N8mz/kLlsdT VSSNIaUruX13u18Nqz02D61Lr6mOFe4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ySKvrwPo8uea30YwZAfejWfUzP0Mp1IBm6Q6ft0K7Zk=; b=htssSxQmNkaN/RBmRfuL8kT7KL zs5tNDETd96x1RY31+TkcVRnN6WV94kOkQkEK4fcKec1UMYpM2QD3LGlrhz6yHPMrZHI3eKyjZ7n0 nm1kYHZR5oOyXbkQ22iBzIcaUg7mpCKhDKOzrCqQhM3x1uw/qHxMYuq6bkiARJ8S3B42KzWgspH1E 2qFdTTYsuLf6aiDQCTPNlBhwA8LuvWARsfrz3lvGDzySjZozO6TpwpjVyUzomU14+EcJxVcgsQJo2 W5hsYOjHgpl6clMZIPdtJNryOvYPBq8Ee4bA4oRpK9sG+Rxgt6KVBvzsFamoa/xK/eVmbY5ji/0hg C29DVCRQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruvlO-000000079zO-3dqQ; Thu, 11 Apr 2024 14:50:54 +0000 Date: Thu, 11 Apr 2024 15:50:54 +0100 From: Matthew Wilcox To: Peter Xu Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Suren Baghdasaryan , Lokesh Gidra , "Liam R . Howlett" , Alistair Popple Subject: Re: [PATCH] mm: Always sanity check anon_vma first for per-vma locks Message-ID: References: <20240410170621.2011171-1-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A290680015 X-Stat-Signature: mrx7mniwmg7xoc469mridenaybx9h1sr X-Rspam-User: X-HE-Tag: 1712847058-994945 X-HE-Meta: U2FsdGVkX19DYEs/VS4fgMowRYqADbSZNGevHDI6kE+useqh57ecBapoSVXWzLYhVFWb8PBfFzIt4PPP1JOw1ds4OUjZCqpMU9hnD+uAWyLuO4qP6H3UM44ZefNoMb83eUMoB/h83agCFewkbToRGIjMP8n9Gw4m0u5yw23bRQC4+PHnU0TCeeNRQqtWAb8LBcQmny4kV2n4ajCewO3InESC2pydOW6NnoUF/h0pjvW9gqu9YBm4Tmznup7kw+gsuzjkww2pX0Y8tRVfj2nepdVi0r4oyjwUDyLDzLHhGY26yb6gT7r5PTn6fakz7lTKeZVpm+VB1wj5SlTsPvQeTZFJrIqfQo1XT/M9ylKZalBNN6l+0Hpjt3sUei3As4jDJw0WWkBGwnEJKF3/IgZtZmh9jl1gWd1ldO5j0IzB2EDdlOIwyKUtYRRadQB6L87uxd4F0Rv3b3WoKPDw76a4xX6xMpQxDt3hlx1DjOVL/LAVQNA+5CtUfKD20nn0+obqQBj7QBDX2U/2jptgbM54/Ca49o+rbgQzYQP6ki/BuLSwuvVm7T1ywU0AhziDfxizF4IMcIoToHQPvEr8HsInazdlgNdbthcyxC0VWTfuap/YLVZhb6UuhKYU4m7LW3lsdx8uh7TY+LS1baiNQBfEqAcMy+qbnZMDC05mKYDnldCXEs6zYwWmSpoxU/DE6kRE01zJYBDiDAM/uX614iBMcakDAK94gyZzYu85Ee0S4srGkgAl8fy+73sSvV6OVeEmEcgmAwJL97+BeW29qQTKm9azg7T1japg04bGZgTfDzRyLM9/dT3cgdkQaggBmH5wkAuPmgsuCNxPHcy7HZ1GtUU1IDlaNQ4cy4sPlMGmCybF+IhuLh3medqjPcVc0NagXBrEao5PmcLauDiVdCaizxY675FMdZZc5kn/eVfnacBaUAUsAoR+4lWtvaxMzd2WpPKC8qaKRShD0c93sWu YOEPkvk4 B9180yPsLViU8h0FY9V+osOJkY9lYOnYoIU2/NkGWvL/QMAQD3iuEMrtpXMq484cVj7bgvJuYOIjgCmdSVD10mpZGPrF1pNGd3qFWFql0kqAiNztSCG5ZJDYFE2efTOXjgDd+MbBMKgGOdLMIjX0l51wj3PBer5VFSFARrWxwvXTrVF28zYxI4psnzA== 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: List-Subscribe: List-Unsubscribe: On Wed, Apr 10, 2024 at 08:20:04PM -0400, Peter Xu wrote: > On Thu, Apr 11, 2024 at 12:59:09AM +0100, Matthew Wilcox wrote: > > On Wed, Apr 10, 2024 at 05:23:18PM -0400, Peter Xu wrote: > > > On Wed, Apr 10, 2024 at 10:10:45PM +0100, Matthew Wilcox wrote: > > > > > I can do some tests later today or tomorrow. Any suggestion you have on > > > > > amplifying such effect that you have concern with? > > > > > > > > 8 socket NUMA system, 800MB text segment, 10,000 threads. No, I'm not > > > > joking, that's a real customer workload. > > > > > > Well, I believe you, but even with this, that's a total of 800MB memory on > > > a giant moster system... probably just to fault in once. > > > > > > And even before we talk about that into details.. we're talking about such > > > giant program running acorss hundreds of cores with hundreds of MB text, > > > then... hasn't the program developer already considered mlockall() at the > > > entry of the program? Wouldn't that greatly beneficial already with > > > whatever granule of locks that a future fault would take? > > > > I don't care what your theory is, or even what your benchmarking shows. > > I had basically the inverse of this patch, and my customer's workload > > showed significant improvement as a result. Data talks, bullshit walks. > > Your patch is NAKed and will remain NAKed. > > Either would you tell me your workload, I may try it. > > Or, please explain why it helps? If such huge library is in a single VMA, > I don't see why per-vma lock is better than mmap lock. If the text is > combined with multiple vmas, it should only help when each core faults at > least on different vmas, not the same. Oh, you really don't understand. The mmap_lock is catastrophically overloaded. Before the per-VMA lock, every page fault took it for read, and every call to mmap() took it for write. Because our rwsems are fair, once one thread has called mmap() it waits for all existing page faults to complete _and_ blocks all page faults from starting until it has completed. That's a huge source of unexpected latency for any multithreaded application. Anything we can do to avoid taking the mmap_sem, even for read, helps any multithreaded workload. Your suggestion that "this is rare, it doesn't matter" shows that you don't get it. That you haven't found a workload where you can measure it shows that your testing is inadequate. Yes, there's added complexity with the per-VMA locks. But we need it for good performance. Throwing away performance on a very small reduction in complexity is a terrible trade-off.