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 8D466C3DA70 for ; Thu, 25 Jul 2024 21:56:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA66A6B0092; Thu, 25 Jul 2024 17:56:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D565B6B0093; Thu, 25 Jul 2024 17:56:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1DF96B0095; Thu, 25 Jul 2024 17:56:10 -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 A41D26B0092 for ; Thu, 25 Jul 2024 17:56:10 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 16129813F3 for ; Thu, 25 Jul 2024 21:56:10 +0000 (UTC) X-FDA: 82379633700.14.02A7A1F Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by imf16.hostedemail.com (Postfix) with ESMTP id 50DD718000C for ; Thu, 25 Jul 2024 21:56:08 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=1cX4BM15; spf=pass (imf16.hostedemail.com: domain of jthoughton@google.com designates 209.85.160.173 as permitted sender) smtp.mailfrom=jthoughton@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721944519; 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=o5zN0Ee2V5PvZ/loIwKVW1h0fdtsfazaCJoYyQYKYrE=; b=Q7aSqVGzouGwBW/0BZxzWBK8rp8ejwmhAPYY4JZvzG27F5+XMtDqJ3oYXwW109K2E12fY3 NgF0ZlB67zX2EVxOMLeHhTVtQvvjXUQF/Xu7/cPwP6vt8Ypo/92g7GKGa1t28NKWsRTS7D oThfMyRNw/4VF11Iu9EDUi/aWb74Qu4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721944519; a=rsa-sha256; cv=none; b=VISAY9c+nBsTz4g0FbwWlH/mg2H9igCvUQMVCoZT+s7QsRS+DjbjmYfq+nhWeyzr8dCGV4 Clee5i8FAZUcRJE7KOmRqvNy1DcrqprxO9mCvn3G7UQbEQJqjStazoIwnG5ed/fUHZ65HI fnQ9a6OfPJXhghCMYek55NwMq2O2dAc= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=1cX4BM15; spf=pass (imf16.hostedemail.com: domain of jthoughton@google.com designates 209.85.160.173 as permitted sender) smtp.mailfrom=jthoughton@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-44fe76fa0b8so21001cf.0 for ; Thu, 25 Jul 2024 14:56:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721944567; x=1722549367; 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=o5zN0Ee2V5PvZ/loIwKVW1h0fdtsfazaCJoYyQYKYrE=; b=1cX4BM151YEU+Q5lfbMiH2OUSeNH0+NUyQ0Z0HhKYd4wjTH1driD5EMupPbX6xiWyw pDqc1m7XI8HB9OoFrA09m4WnLoSCwNmaKlK8H1nYRclogmTztY8kJ7ytEMPFQzVRSbun CpFjofWgMnwv7LMPYi7SdBsElWJxVVc0PrbMPOlypn61/bo74NlyLGGYeOBcOS+nmCg1 81FY8c1NRB/CHYSEVEClMq/hG82ybGn9UP3IOZ0OOD6cRsPKbw/m63AEyztNU3sEep3b SY7mgP70h2dGUaWMgxWFQTe9jFaRAbXe4VS9LeDvErZe2ECx9Og8B/VPxrXZNhyy9nQq kwqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721944567; x=1722549367; 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=o5zN0Ee2V5PvZ/loIwKVW1h0fdtsfazaCJoYyQYKYrE=; b=QgNVFdaVT7DQf9ZSwotTUTlHzk+W4HxPl3adG34FgqhyZ6JVxSal0/1iBwpPXpkxDS 64FKpg7qmHxPMs57NjQthzImiBvfQ1M2rLE1oRO7TlJrL1tq9SPwB2KrXuj8wyeHKvAh 5lJXaoU83uPrlx724MGs7g7BrBZxrJ5TE5XYYczAQz70CdZ3cpn0/0mQwPzFM0fgTY+Y lagwBiRg6lIN3IKBzgPhY68wCDVmcQEXdyc+4wTVy2Mr2cRzjY2YrmiztqmF3sIxwReP J77NaJZyn+tdZHxD/g3j9hUVLYwyLvkVi9XOaaYb4p4l9Eh2qYvTshIzFliFZqkTGQKa 9SBg== X-Forwarded-Encrypted: i=1; AJvYcCXoHdp+Dx5mc2OsqJQC8NPIG5Cais1dUechNflHZWo6uUzHMdqwaw9Xjv/sm3qbqV1rSHKHxyeX/dhjtqoc/p8W+xQ= X-Gm-Message-State: AOJu0Yy9ybzBvgBQpODC4mguAgPdh+lHIl27suYnyc6I712ZX76S0VWO YP5YlOVkQloIbT89nBi1vELmg9Z4Qig2ZvMOQGRzUrIoQtZurrlg0UFtVE5kLqVkvN+M9ZMApA+ KGQVapv5cC9s4oiUVYdeOwAKL0Nm+l1bRS7Ul X-Google-Smtp-Source: AGHT+IFhP5/yTm7ISgwUHXy+IaF0SeriofzfJKq8H3XwJMAsEhtvrR3NBZlrFcMQ5LfszxCadNdzcI48wvWetEqqHuE= X-Received: by 2002:a05:622a:134b:b0:447:e76a:c04b with SMTP id d75a77b69052e-44ff3a6ea56mr930791cf.10.1721944567177; Thu, 25 Jul 2024 14:56:07 -0700 (PDT) MIME-Version: 1.0 References: <20240724011037.3671523-1-jthoughton@google.com> <20240724011037.3671523-4-jthoughton@google.com> In-Reply-To: <20240724011037.3671523-4-jthoughton@google.com> From: James Houghton Date: Thu, 25 Jul 2024 14:55:30 -0700 Message-ID: Subject: Re: [PATCH v6 03/11] KVM: arm64: Relax locking for kvm_test_age_gfn and kvm_age_gfn To: Andrew Morton , Paolo Bonzini Cc: 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 , Sean Christopherson , Shaoqin Huang , Suzuki K Poulose , Wei Xu , Will Deacon , Yu Zhao , 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-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 50DD718000C X-Stat-Signature: af7i5goq87wgxiakcwj61edska1bnba3 X-HE-Tag: 1721944568-988795 X-HE-Meta: U2FsdGVkX18ksMVT5+ybazriDQC62RzrB+3YnS8RNbNKeavs0c/qZRH0HGEvEX7sOupG04+zSkWt349+G5Zt4r+gUz9ukxdwfIHPidajuTUVEVMhXFgAXa4mftpEX7RFkU+pE9Pd7eGwo1dTIwv+qTokFhSGzkjmQm3Ai/gqWU/LWzsmLDEjwJPe9xGBJPXir8eDyJkNFf1/Ja45ZeJKoIqXUu7UrFh1i6g3EohASZZDPjDxECjSiYe7LvvKxcEuYNxLEV0677mOXoabmiPDYE/+YOQcbgCXgx59Mv5f2CAVU98IEantkvvQdAY3nhixqOYrUMOj04XHc5NdCMU1iPfx1sj9PbOBfrpko9NKTDVLupmEJ7IxqB2Zhc2jv2OfE95Id0GrO0+hX0Boj1Y/DXKMaypkmUonXx/hRnx8qDuuYPPZRVTTHCc4ReBHnaFFEhD3L8X5QWNXawbPaJmynCCwVotJss0zpEbXdXxXWxBsuSDJdlS01gBxuglUwqE4vMjAmi/b68PI4LCbI1sAUpRnhOthpJWbhz+1raQVwqSbxKKnP4PmP4exet3V0QH/vOajBLb2+NZL5Vr0xlcb+dBqT/d33ISyOpcP0DYq2mStXPswqGqB2uCbMuno9tCQ7J50dsJ8Jd0d7xWHnZzNu3yNcv4Z0WKiWKlJzIrjPlal1ELyLBltw13tbzrPBl5usnndSIpkl0R11kVrB9bZcFwKNVe10mPMx9s62tiz3aYJIrFrxYPoI+Rq2IkvDl9YGZRagiPzJeNOg16/vIPizgvey6AR1I6skjG/DZ0YsLQfI7fD2vQ0ZcSsEPkKwL1LJY5q+tC9A06HEW1R08civMPYC5LgW5Lypg5DCuPya8QEHEoExxiMZI/6bYS9QRx1R2I63Sq3NlcIjChE9B0WXWL5CJadAemoEIhfftPozsmydMGEd+L8MBWjGVDhVbCnV4xMYskBjR5pT6A1sVX 4dF8MYbZ VSygvnER1vCJgvaNtKpszsTFBfGWDjyEFuuRXPq142l0Rjx/qXfHcB/bdTpI1s060aUh9KOsZYqx3TlMr5CwaH2lEJyrWOket+C7aRAh5F01dtzw28yQkEayotHP9YA9yhLGy+qlnpY8CzbiUDwX9ib1NBQ3vuh4BQsGjXeRMF1mbrKPiH6gkjx4kKqQH0znqcjuQZQ0tq/SPDcik35UAxWJx+AxT68VoCGguaomrud+/wAI= 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 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() callback > 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_ONL= Y) # 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.321083083s= ) # Read lock vcpu wall time : 3.010848445s lru_gen avg pass duration : 0.306623698s, (passes:11, total:3.372860688= s) Aging is able to run significantly faster, but vCPU runtime isn't affected much (in this test). It would be really nice to motivate this patch with a test that didn't require patching the kernel... Oliver and Marc, please let me know if you'd like to see more data. I'm also happy to simply drop this patch.