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 C21A5C3DA4A for ; Sat, 17 Aug 2024 01:04:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5660C6B03E4; Fri, 16 Aug 2024 21:04:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4EF358D0066; Fri, 16 Aug 2024 21:04:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 38EF16B03E6; Fri, 16 Aug 2024 21:04:09 -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 1826A6B03E4 for ; Fri, 16 Aug 2024 21:04:09 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BD4A61C1EE8 for ; Sat, 17 Aug 2024 01:04:08 +0000 (UTC) X-FDA: 82459940976.14.9646B70 Received: from mail-ua1-f53.google.com (mail-ua1-f53.google.com [209.85.222.53]) by imf26.hostedemail.com (Postfix) with ESMTP id 0FE7F140012 for ; Sat, 17 Aug 2024 01:04:06 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=FmA+ry0f; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf26.hostedemail.com: domain of yuzhao@google.com designates 209.85.222.53 as permitted sender) smtp.mailfrom=yuzhao@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723856563; 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=1ZkT/FAH8t+UEeZZlsBiF2qoKJwELVKvUU9sus3nhBA=; b=2+5s4/UsrIz6Y8IFB3GDK+JHtB4N9cSaBgvnn7Kcei4GBz4QCYlsdkUpkIQrWI62li5kPv fNlLv3/qIjdX2GmKLbHmoSkN8vdtfNFRq4l/sYIdlw1iHTwFa17MBefLmwFlZfYNy09j58 gqz1XctPnlENgJeb0z/jPgZLoxSnjko= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723856563; a=rsa-sha256; cv=none; b=6319rVWpb1Pmnjowv1dtr7Yr4wriOJCqf9yay2pV1K+4dSIQAHtfvZisIXl1dleUMLaEU2 vcu4EWbFxjgmM3l8Q/E1KpZvWkABPlJS4iYLJmkjSCDs6TtZrps7Cy2XdABdEi3TQ7c1M8 Q83A83hl1Dx/dRF98oj4M9Nxl7FMPb8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=FmA+ry0f; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf26.hostedemail.com: domain of yuzhao@google.com designates 209.85.222.53 as permitted sender) smtp.mailfrom=yuzhao@google.com Received: by mail-ua1-f53.google.com with SMTP id a1e0cc1a2514c-8430fdf256bso166029241.0 for ; Fri, 16 Aug 2024 18:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723856646; x=1724461446; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1ZkT/FAH8t+UEeZZlsBiF2qoKJwELVKvUU9sus3nhBA=; b=FmA+ry0fG7tN1KfTDMZiZhEQccHvNYqbEYWMW+DcxpCmOgIy5lNvHrz234SU9VdX8w Dm1/A5u2vQGzAeAzbnmZ29IMffhDy4FHxH9xZ+dZSZsuCaxsRp1LuSw4MnincUbsuWNB PSs+qoPq4MuGPy4eJvukaPwAQhlWujSp02RbMFSGA2M+EO9a2eNbjQxUVHWPzj0nCOuW 3B09YZ637QjxcG0vTmze6IQb46O4ClKymr+GvsNnV3t/gFYqatGXVAmyntfIJ2KCFCHt 0RRPca46pM/+EQvebx8lUcRVL3KVsB+cQ11+z1gGPBpLZOA85qnvwnrUKtq/dwDNjpIR viWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723856646; x=1724461446; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1ZkT/FAH8t+UEeZZlsBiF2qoKJwELVKvUU9sus3nhBA=; b=ZfZiFwYIwi+C5hDNRfS35CH5NhN4IZM45r3SOJqsPc8jEe4h04V+OMriWozOrkhhSr lOVP8qyVKOEq1yDe1cTe67UvPycfA8/R3cRmQtKthZe9FH8xEvuvCd0zAfmAkZE3bC37 5I1fU7gMYx3Ljh/sYm8VlhnxuVXTLa7Ev3dLmtWnaOw9b25Ui8EKChNOazKV/WPjDDul 8DQETQ4eM/FmqOEYb2iSqveZ/myx09iRo6cLaiGgkDXBrwMAxlmhSU1Eikx0nABGQEdW EPsqCAB0uzkMtsBtG36Q7IzFyH5VtHS2LazDZ3z6dWJULNh3GkGQVJ7v4Fxvq1Ns8npw 4ANA== X-Forwarded-Encrypted: i=1; AJvYcCWMICq3Usj8MYAaPQvZ4nqAcMc5dbxaI+RR9j8CzARoYC2tkpOKvxHafc3HZrv4UTTdnOhuAeDz8D+IxXTcNYb1Khg= X-Gm-Message-State: AOJu0Yz7casOcCohan4++K7uqRhBEgD7V3e9XNcHCFUVZTjVQVZOGJrd 7HyoHLMlmrOBvdysvemGKR0ibpRQGfzKLrhEI2v8ZfiWShu1owJQzHIh97oUm6eqIoJxIay9DaA +oSulBnkO/GRC/6rHsegD7fqbNI95E9AS5W3I X-Google-Smtp-Source: AGHT+IH+z/yVUCGn/kvsFe3FWe5Y4PrsBx6c3aNhHuqGExQKF6hhvvYIWba1m2Vl5PvAw0UlZYeqJffhxIB+o44gihE= X-Received: by 2002:a05:6102:3e85:b0:48f:e7c2:1faf with SMTP id ada2fe7eead31-497799a0eb9mr6016565137.28.1723856645893; Fri, 16 Aug 2024 18:04:05 -0700 (PDT) MIME-Version: 1.0 References: <20240724011037.3671523-1-jthoughton@google.com> <20240724011037.3671523-4-jthoughton@google.com> In-Reply-To: From: Yu Zhao Date: Fri, 16 Aug 2024 19:03:27 -0600 Message-ID: Subject: Re: [PATCH v6 03/11] KVM: arm64: Relax locking for kvm_test_age_gfn and kvm_age_gfn To: Sean Christopherson Cc: James Houghton , Andrew Morton , Paolo Bonzini , Ankit Agrawal , Axel Rasmussen , Catalin Marinas , David Matlack , David Rientjes , James Morse , Jason Gunthorpe , Jonathan Corbet , Marc Zyngier , Oliver Upton , Raghavendra Rao Ananta , Ryan Roberts , Shaoqin Huang , Suzuki K Poulose , Wei Xu , Will Deacon , Zenghui Yu , kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0FE7F140012 X-Stat-Signature: hupnitpmtm41hx4phj1t89dc3meymr14 X-Rspam-User: X-HE-Tag: 1723856646-325717 X-HE-Meta: U2FsdGVkX1+3Ptp0b4Uqtu6GeTOrR8LETc3tRkJ42W/FVTQuBalRHXmbG5Qwo0ERKbGQQNpQQ7Aoi4WV5nRuioQWM0FUb1eyT3loDi0y55nUegXZtOnQbA6M3EqaoQQ1sf5NSOVHtJPPjblHNEasBdJgnKlC67v2IjLlaFRzZ3751H63ZEYdEKLbeyLQhjT0+51g7hjWwIPE+YhOFPVtQzm2zUaFu1PwkjyMoS1Yrkcfn9gHsPc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sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Aug 16, 2024 at 6:46=E2=80=AFPM Sean Christopherson wrote: > > On Thu, Jul 25, 2024, James Houghton wrote: > > On Tue, Jul 23, 2024 at 6:11=E2=80=AFPM James Houghton wrote: > > > > > > Replace the MMU write locks (taken in the memslot iteration loop) for > > > read locks. > > > > > > Grabbing the read lock instead of the write lock is safe because the > > > only requirement we have is that the stage-2 page tables do not get > > > deallocated while we are walking them. The stage2_age_walker() callba= ck > > > is safe to race with itself; update the comment to reflect the > > > synchronization change. > > > > > > Signed-off-by: James Houghton > > > --- > > > > Here is some data to show that this patch at least *can* be helpful: > > > > # arm64 patched to do aging (i.e., set HAVE_KVM_MMU_NOTIFIER_YOUNG_FAST= _ONLY) > > # The test is faulting memory in while doing aging as fast as possible. > > # taskset -c 0-32 ./access_tracking_perf_test -l -r /dev/cgroup/memory > > -p -v 32 -m 3 > > > > # Write lock > > vcpu wall time : 3.039207157s > > lru_gen avg pass duration : 1.660541541s, (passes:2, total:3.321083= 083s) > > > > # Read lock > > vcpu wall time : 3.010848445s > > lru_gen avg pass duration : 0.306623698s, (passes:11, total:3.37286= 0688s) > > > > Aging is able to run significantly faster, but vCPU runtime isn't > > affected much (in this test). > > Were you expecting vCPU runtime to improve (more)? If so, lack of moveme= nt could > be due to KVM arm64 taking mmap_lock for read when handling faults: > > https://lore.kernel.org/all/Zr0ZbPQHVNzmvwa6@google.com For the above test, I don't think it's mmap_lock -- the reclaim path, e.g., when zswapping guest memory, has two stages: aging (scanning PTEs) and eviction (unmapping PTEs). Only testing the former isn't realistic at all. IOW, for a r/w lock use case, only testing the read lock path would be bad coverage.