Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp897738lqb; Wed, 29 May 2024 14:04:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXwERze4vIoIOxofRoIJ6BdBFLga4loOgaQPoZrfpi886s7rcvaApx3NGz7x/W1ydFfGQcanurBqe8UQNX75nolR3a7gkL2m8nF4f015A== X-Google-Smtp-Source: AGHT+IHtoDLb1xYaW5hxLZjC71mqiAU5K3t7He/h2zQlH0aAHAy4AvJenSukEKj6WVertG+1/0cC X-Received: by 2002:a17:906:80d8:b0:a59:9b52:cfc5 with SMTP id a640c23a62f3a-a65e8f7611emr15612066b.37.1717016651020; Wed, 29 May 2024 14:04:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717016651; cv=pass; d=google.com; s=arc-20160816; b=cczd+Pnuc3TmvxrsiAhCQ4MEo63MPb4ZgGNUyyodQmjWorafoJSNrxTWCEQFT5J7jX 5v3NaI7ZbtND4g3XnmhxvBECZ8dpNlqz3l3HQ7Cz9RIlzEH7l43j+OieSgXmfc19ZxA1 YOo/wzLKKjjBAtTOP9u4hLZtlDyPbjQA8QuX5qNIfG8aE0wJRaTSj08XW1vkRfjjAnkC ZpmdX8b7TamTfPwDFj7HYck9PhbEyC3o3Ac0VL51gi7Afzwr7OLXQW5FDHG0uz7xMRXs 6LCBNl1YV54OmG1C/XYmHZh6A8u6sfsRWxMoEXsKBbd0ljr9jURsVZF/jPRIo8/uw84l Yymg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=BCBSe826+nKw2daLQ4TIlXiD2I054RSipXGDwuLppXE=; fh=5vqPSB2yRQ3GOXGtLRxUXfzq1A1uCtbrD9+sHgQiQ+0=; b=sMzwiU76NNo3SKyXJmnEkcGcAGG3aIC2sB2MLhHg/v0coZyNbIQdKYRtWbxffGBDEJ 5GqlMKDPmEz8OW55+ODW8mhc5YFbSWs9j87/IChFy/+VNxHz+4gfBJK0vP/rKSHfWVvD yArxL0FtuJvWzN0azPuOVQR8wJTB27GLHc98uIGFenFAiRSZmifWIFnf3rjb4KVU/KN8 liHVlxv99IX0H4JAfwvwoASVSGLMUl7rBujCr78x1gn8ZgVS9affzRZII0sEM3A78UQq gpgNrvMnAs1faM09C0p1/eOLwSAoR1tdmJrk5Kttte35KZTmzRGnd/ng08hN7fCC5rYs 20rg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ai8QAR5e; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-194689-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194689-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cc6caa3si672218266b.693.2024.05.29.14.04.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 14:04:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194689-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ai8QAR5e; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-194689-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194689-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7ADDE1F246AE for ; Wed, 29 May 2024 21:04:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D58011C8FC3; Wed, 29 May 2024 21:04:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ai8QAR5e" Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AD631C8FB0 for ; Wed, 29 May 2024 21:04:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717016643; cv=none; b=UttrgA6So6rYNqmRy34Ri89vRlNivvT2IVN/xlhbYS1+NVtlxBw5g/m89Dbz3b+E6FBNbEiU7msN1OR9JsB8lfCw5eCibjsPg5ER0SG6T2p934GVfGdQAgl9mVbKk1H8I4N/1/DhglUmK/wmlDxavdxs9fz1Bh+gdEhuxpYMCD8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717016643; c=relaxed/simple; bh=BCBSe826+nKw2daLQ4TIlXiD2I054RSipXGDwuLppXE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=egTcnN1UqHFtNdpncIU8I8EhkATSJhoSqvPOl400kLGxA8qrKy3sKAS24/XsKDEMpBJxnE/jW2MmEjHDzBBb/7tB+2ZnoGTQZKX20kL0/Y+eX9MTAs3xoWIgMSP2OlQG+srnEHSGAbDFdZ1TsiNX0XGwRYH9GtW2Z9+9OSA7M8I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Ai8QAR5e; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-41ff3a5af40so4465e9.1 for ; Wed, 29 May 2024 14:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717016639; x=1717621439; darn=vger.kernel.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=BCBSe826+nKw2daLQ4TIlXiD2I054RSipXGDwuLppXE=; b=Ai8QAR5eD9hE58FabJ7IUan77gGrx6D9fzz2qxEFjH7BAjMx043mI+Q/AODvtvW6bH K0jSGe6lL9GDzAm09ShQ36vXHRSLZdBHjSNZYe8UxsDEa3UNgMuvk0RtQjslJqg/fz3F gcQ2Ddimuml9EDcGtDjDqu0ML7QxQSAkMj8B9NQNdT6A+UgFdv/BOE5/TecWhF4u9e22 2F+OmDNQI7fxpm80Jvni853aOc9uuTqUbk53wz+j8rmuQHoPPzgVnVWvno6o93Wujv3P L5PZorKBHjn+rEUcCAW3/nc6v2k+Gzl2V6RqqBbMVsUjFe/lGh3gm5dURiXQAOYtLFCa vPXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717016639; x=1717621439; 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=BCBSe826+nKw2daLQ4TIlXiD2I054RSipXGDwuLppXE=; b=iuXG2k7Bmv5TNwhVXsutQkEaKOjOgIUeAq86LJ6w23HLpof+vKSoc8pVBmNNYds11+ zY794ouC3+WSEImBY8RdYdKXFBkFRe5RBDkdoR0ytaHslX8Pp1+f5DVKSSxA4sxxBADs ueO3i1jm/49Ics206pVpIGYbrFjvGvTMVtDSWWIdJdy9ff4/1iGWusVs6foJqRRhcco3 d651H7xYDU2F19je96ChVAot7pG0GxIvwZa+UkV06J1mBc9kwLvetOAREcRJnAvDlGmW Z9huOJgww7HghAcisACOMg+N4x5aNDKjS0CAw1KK7zpdk7r7dELoY0w/3jAelVzjRZLo TiLw== X-Forwarded-Encrypted: i=1; AJvYcCU10TSnWj38OdpQBE+Tgmm6TrCtURz7CuDBByDE/KFErPY5pKNLGLW4zafNZqbWJeq8Wa8GRUfYRW6QOkhhvr2sr60rvJqcId+L1NEy X-Gm-Message-State: AOJu0Yxf/UqKtLe2g82QHJPc6whHjYCPtycPHp8pIhaYpIZk1L5OYHke g2pu+Q8ZEGVOSDS2I6dQohOFGIc8Juvbnnf+lqfRE3vuoJA4d5UDkJlv7pGo1BeEj9tyfTWQT1u X8+nh2H6FzlRd5f0nx5RS3pzCctg43OM41LFg X-Received: by 2002:a05:600c:3b85:b0:41b:4c6a:de7a with SMTP id 5b1f17b1804b1-42127ec7dbdmr148185e9.3.1717016639372; Wed, 29 May 2024 14:03:59 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240529180510.2295118-1-jthoughton@google.com> <20240529180510.2295118-3-jthoughton@google.com> In-Reply-To: <20240529180510.2295118-3-jthoughton@google.com> From: Yu Zhao Date: Wed, 29 May 2024 15:03:21 -0600 Message-ID: Subject: Re: [PATCH v4 2/7] mm: multi-gen LRU: Have secondary MMUs participate in aging To: James Houghton Cc: Andrew Morton , Paolo Bonzini , Albert Ou , Ankit Agrawal , Anup Patel , Atish Patra , Axel Rasmussen , Bibo Mao , Catalin Marinas , David Matlack , David Rientjes , Huacai Chen , James Morse , Jonathan Corbet , Marc Zyngier , Michael Ellerman , Nicholas Piggin , Oliver Upton , Palmer Dabbelt , Paul Walmsley , Raghavendra Rao Ananta , Ryan Roberts , Sean Christopherson , Shaoqin Huang , Shuah Khan , Suzuki K Poulose , Tianrui Zhao , Will Deacon , Zenghui Yu , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 29, 2024 at 12:05=E2=80=AFPM James Houghton wrote: > > Secondary MMUs are currently consulted for access/age information at > eviction time, but before then, we don't get accurate age information. > That is, pages that are mostly accessed through a secondary MMU (like > guest memory, used by KVM) will always just proceed down to the oldest > generation, and then at eviction time, if KVM reports the page to be > young, the page will be activated/promoted back to the youngest > generation. Correct, and as I explained offline, this is the only reasonable behavior if we can't locklessly walk secondary MMUs. Just for the record, the (crude) analogy I used was: Imagine a large room with many bills ($1, $5, $10, ...) on the floor, but you are only allowed to pick up 10 of them (and put them in your pocket). A smart move would be to survey the room *first and then* pick up the largest ones. But if you are carrying a 500 lbs backpack, you would just want to pick up whichever that's in front of you rather than walk the entire room. MGLRU should only scan (or lookaround) secondary MMUs if it can be done lockless. Otherwise, it should just fall back to the existing approach, which existed in previous versions but is removed in this version. > Do not do look around if there is a secondary MMU we have to interact > with. > > The added feature bit (0x8), if disabled, will make MGLRU behave as if > there are no secondary MMUs subscribed to MMU notifiers except at > eviction time. > > Suggested-by: Yu Zhao > Signed-off-by: James Houghton This is not what I suggested, and it would have been done in the first place if it hadn't regressed the non-lockless case. NAK.