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 497E7D462AB for ; Wed, 13 Nov 2024 14:23:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD9546B00BE; Wed, 13 Nov 2024 09:23:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B8BB76B00C2; Wed, 13 Nov 2024 09:23:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A27FA6B00C1; Wed, 13 Nov 2024 09:23:06 -0500 (EST) 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 7D1816B00BB for ; Wed, 13 Nov 2024 09:23:06 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 034A6A0A47 for ; Wed, 13 Nov 2024 14:23:05 +0000 (UTC) X-FDA: 82781286588.03.C5ECE6B Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by imf19.hostedemail.com (Postfix) with ESMTP id 134101A0006 for ; Wed, 13 Nov 2024 14:22:09 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=WkGG4jlL; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf19.hostedemail.com: domain of ptesarik@suse.com designates 209.85.218.50 as permitted sender) smtp.mailfrom=ptesarik@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731507607; 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=Egn5fEpckGR7euiSFSUPlqzHLdxGGw1Hgc2j7hHRnkA=; b=aajYx7kv12YLSY9v9RJLqZjyVNPjkdSvwsWN4v0p74UI1dYjae7BssS7K9yg00nxZRDeHa cgkj4e3W5qhynoeJFYqYgPJV9gPJi1Azk3jeypfwtWMFxfYhEqYbpQgpVoWmBgMtFys7j+ 5W1qWUCPDtYvifAfOo1AG0dhsi+gYRQ= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=WkGG4jlL; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf19.hostedemail.com: domain of ptesarik@suse.com designates 209.85.218.50 as permitted sender) smtp.mailfrom=ptesarik@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731507607; a=rsa-sha256; cv=none; b=KlqWesPHfck+UdJto1HC1dgoYjE5FuWneC7gspyzI30kxFciazjQyB+bIiFmB7Hy40mBBP 18v58qgODVCnsdaDyX4/TyhM3VB9SNPQ1M6GY42waGSpQol5Aml0A6v7Sd/xYo2H39I671 fWqjWo9tlx64pcciroEalsIH5O3rk7Q= Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a9a273e421fso35302066b.0 for ; Wed, 13 Nov 2024 06:23:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1731507782; x=1732112582; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=Egn5fEpckGR7euiSFSUPlqzHLdxGGw1Hgc2j7hHRnkA=; b=WkGG4jlLiZJayvHPCVPi2M+UfKRhHpDgj3Dj4TBKEGAWiFJ2Uw+Mv/UZeqirvX/RQ3 QsC0FFbaXOsblZjCtB10fisXvK+fmR584azvesIIM0Taym1H67cxarQfoqkTxmbDqh0v W9p98aaWd9CWfGxuPHTQz//ejXAHwQnVYNq0TfLAkVQfzcaM4dfdH9hUOLn1T2EovRBw 9gnQ4RzIK8xIJaiq3KJUxpNlYcQhFI3p6r5NoxZxyJk3EE4tAs7cvi0rTM0XDJIztP45 qx5AzM2kPEnYTjgNQ4W97HoxAsf7wQLmW2agX7N51zu38Xvf7jcetpSLRqQAo8EM38Pm 7ErQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731507782; x=1732112582; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Egn5fEpckGR7euiSFSUPlqzHLdxGGw1Hgc2j7hHRnkA=; b=Q5T3JNcPjU7HevFs8/KjJNsTGjWpls9+1SPg3zWBEVCYoo2QNAip2aLatb4zT/BGsC M/THO1ZaSuHw75at6nqZLx7Q1CZcH41Pz5wHIxItdTvdoJRqMtvAZOO3FZv6Wmn6f+TA sWEVDT3+WYVzwAz8jKW0USVkfomZn7yBXUlPpRzim3/fkhhCK3m16wD6EFYjY6zKopp/ osJfuO636nX5ZcYha4fQ5WyNkhS1adoSEgLG4yuj5XNcEoPzJrSYpZGBHeBV0t4DzBIQ 87VsMgfBuH5kcfEtqmNFI4lNuv8nRDSvXFR/4FNlGrcwCt7Q86PE2TIPNpzQVb4oaF9s EC8Q== X-Forwarded-Encrypted: i=1; AJvYcCVyA4E5K8e0QS6SAnj4kxtxhnwbfbnPPBPwC0G1zqZeFGKCOM4wzz/fKKNCQ2iNvVn8ud1j4U6ZQA==@kvack.org X-Gm-Message-State: AOJu0YwU33dgRCNBlKyFWrw3fWgqVsTUFvASMrBcA0nowAStq1/Tu1Wq wroMaGdF9pksUb6FBh+eXk68RM4a7/CU73/oLwFMFmhQ4qOeE6YT/QjKAIEHyp0= X-Google-Smtp-Source: AGHT+IE7qbFVHpgXUGHmdtQQ68GGSvuT61CnUcYwM27PSmisc3v4hDGM+TCD1/jQDY5GkVFC7sCumA== X-Received: by 2002:a17:906:794d:b0:a9a:a55:1e6 with SMTP id a640c23a62f3a-a9eefe9bae8mr803687466b.3.1731507782300; Wed, 13 Nov 2024 06:23:02 -0800 (PST) Received: from mordecai.tesarici.cz (dynamic-2a00-1028-83b8-1e7a-3010-3bd6-8521-caf1.ipv6.o2.cz. [2a00:1028:83b8:1e7a:3010:3bd6:8521:caf1]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa1dda672easm240519366b.40.2024.11.13.06.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 06:23:02 -0800 (PST) Date: Wed, 13 Nov 2024 15:22:59 +0100 From: Petr Tesarik To: Ryan Roberts Cc: Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , David Hildenbrand , Greg Marsden , Ivan Ivanov , Kalesh Singh , Marc Zyngier , Mark Rutland , Matthias Brugger , Miroslav Benes , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH v1 00/57] Boot-time page size selection for arm64 Message-ID: <20241113152259.57983855@mordecai.tesarici.cz> In-Reply-To: References: <20241014105514.3206191-1-ryan.roberts@arm.com> <20241017142752.17f2c816@mordecai.tesarici.cz> <20241111131442.51738a30@mordecai.tesarici.cz> <046ce0ae-b4d5-4dbd-ad9d-eb8de1bba1b8@arm.com> <20241112104544.574dd733@mordecai.tesarici.cz> <5a041e51-a43b-4878-ab68-4757d3141889@arm.com> <20241112115039.41993e4b@mordecai.tesarici.cz> <20241113134038.5843ab73@mordecai.tesarici.cz> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.43; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 134101A0006 X-Stat-Signature: fcf1mcigcdzwan46k8fyadr9o3uch3eu X-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uMF9en8t3R7ZabFz5zQsX34nfTmsbcfoT243BxLOIKwFyN2EdNI0t94AieNqopZ2cp1IIHUQkF3KoFi5ALMqJ+d4k9LEw1s8uEhI6NibKXV3ReSD+NcvSIUubnPntrviUZsFrQsA17qh1SUCGpG3Z6ykcqQunjYPgDXjRvXXJZncUw7RtFWj4K9jiasl+ggUz1YTaQtLFyRTCTdDR2mDVh/JcbEPlqEzUVxAhEqxysAmDJhpWNrA/JFO1dFSC330nSj2wlfvV9s8rSKlHKz3mfv9HdZ79zG5QpM7S2MsaayKMg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, 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, 13 Nov 2024 12:56:24 +0000 Ryan Roberts wrote: > On 13/11/2024 12:40, Petr Tesarik wrote: > > On Tue, 12 Nov 2024 11:50:39 +0100 > > Petr Tesarik wrote: > > > >> On Tue, 12 Nov 2024 10:19:34 +0000 > >> Ryan Roberts wrote: > >> > >>> On 12/11/2024 09:45, Petr Tesarik wrote: > >>>> On Mon, 11 Nov 2024 12:25:35 +0000 > >>>> Ryan Roberts wrote: > >>>> > >>>>> Hi Petr, > >>>>> > >>>>> On 11/11/2024 12:14, Petr Tesarik wrote: > >>>>>> Hi Ryan, > >>>>>> > >>>>>> On Thu, 17 Oct 2024 13:32:43 +0100 > >>>>>> Ryan Roberts wrote: > >>>>> [...] > >>>>>> Third, a few micro-benchmarks saw a significant regression. > >>>>>> > >>>>>> Most notably, getenv and getenvT2 tests from libMicro were 18% and 20% > >>>>>> slower with variable page size. I don't know why, but I'm looking into > >>>>>> it. The system() library call was also about 18% slower, but that might > >>>>>> be related. > >>>>> > >>>>> OK, ouch. I think there are some things we can try to optimize the > >>>>> implementation further. But I'll wait for your analysis before digging myself. > >>>> > >>>> This turned out to be a false positive. The way this microbenchmark was > >>>> invoked did not get enough samples, so it was mostly dependent on > >>>> whether caches were hot or cold, and the timing on this specific system > >>>> with the specific sequence of bencnmarks in the suite happens to favour > >>>> my baseline kernel. > >>>> > >>>> After increasing the batch count, I'm getting pretty much the same > >>>> performance for 6.11 vanilla and patched kernels: > >>>> > >>>> prc thr usecs/call samples errors cnt/samp > >>>> getenv (baseline) 1 1 0.14975 99 0 100000 > >>>> getenv (patched) 1 1 0.14981 92 0 100000 > >>> > >>> Oh that's good news! Does this account for all 3 of the above tests (getenv, > >>> getenvT2 and system())? > >> > >> It does for getenvT2 (a variant of the test with 2 threads), but not > >> for system. Thanks for asking, I forgot about that one. > >> > >> I'm getting substantial difference there (+29% on average over 100 runs): > >> > >> prc thr usecs/call samples errors cnt/samp command > >> system (baseline) 1 1 6937.18016 102 0 100 A=$$ > >> system (patched) 1 1 8959.48032 102 0 100 A=$$ > >> > >> So, yeah, this should in fact be my priority #1. > > > > Further testing reveals the workload is bimodal, that is to say the > > distribution of results has two peaks. The first peak around 3.2 ms > > covers 30% runs, the second peak around 15.7 ms covers 11%. Two per > > cent are faster than the fast peak, 5% are slower than slow peak, the > > rest is distributed almost evenly between them. > > FWIW, One source of bimodality I've seen on Ampere systems with 2 NUMA nodes is > placement of the kernel image vs placement of the running thread. If they are > remote from eachother, you'll see a slowdown. I've hacked this source away in > the past by effectively using only a single NUMA node (with the help of > 'maxcpus' and 'mem' kernel cmdline options). This system has only one NUMA node. But your comment leads in the right direction. CPU placement does play a role here. I can consistently get the fast results if I pin the benchmark process to a single CPU core, or more generally to a CPU set which shares the L2 cache (as found on eMAG). But the scheduler only considers LLC, which (with CONFIG_SCHED_CLUSTER=y) follows the complex affinity of the SLC. Long story short, without explicit affinity, the scheduler may place a forked child onto a CPU with a cold L2 cache, which harms short-lived processes (like the ones created by this benchmark). Now it all makes sense and it is totally unrelated to dynamic page size selection. :-) Petr T