Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2084514lqz; Tue, 2 Apr 2024 06:58:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXBVtY3x7uo6N1Di1+eiL/X+HJECTn+OH3ITGpQ8WT9qcd0LeEqiqv+dy1Fe6Ke06qRPqT5WxygauhaTMnz/efkjjUmDPmZ72zrnf5+dg== X-Google-Smtp-Source: AGHT+IGSBrfEg899a7+ct6HsqJeEr217NyMAGGc4NLcSL7ZNnyZAmismjDHFoFlsTSQFPkKUpoOh X-Received: by 2002:a05:6a00:3928:b0:6e7:1ce6:a2f5 with SMTP id fh40-20020a056a00392800b006e71ce6a2f5mr20912373pfb.17.1712066322726; Tue, 02 Apr 2024 06:58:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712066322; cv=pass; d=google.com; s=arc-20160816; b=np7y3ddTkz8CkvBx/YJqB9w49g/hdDhtDPd4vAJlzo7KB7tg4Gel2ktpVstmKBDWLN 9jD1pm3vEE22LC6C3r7I9D4RvWWdJWYgCXR4OSIz+kmJIqo1bhqVdyQZrA8XsZf4PxGT f65HYgqoMVaZ5dn13MRfIN/SpcTpWliVkYu0cJqeNXCnxBI6yIG5Z31tT95LxD9IgWU9 7DZgTRsA2B3d6XKCOac/MaHG1pkixStncE6dKtNV//WRuHH290fY6TmONuwqB+jtIECL nLlCL/8w+6zwQj1YjrS/S2rjswm0oGYek+HBeqMhQf0UupX3UZpPBBHRcmlCtqdLWH3I oAbg== 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=37qcl+O6YD2iKKcTYX3TCpIUlrBbXdw/pysK7vT88Us=; fh=ROv1PvK/utbAMGk+vH5QndFVzgUyoQ1ChuMz7WvwSok=; b=w6fhTFZUtDHaPJucnvxyjbuCQT+WNe7pA4cE1J2cL72eh2NKVooWzJt7pa5WSrJBSY q07ojgorxGXKI+ZulmwSqfxOzPaoELJgcLlI9netmuz6aOHyZlh8FWR2/sxoEn1rZ+Kf qw9z1oXeRW08w7/A/FmD3gcqFl1aXc3Ys1bq4plqUFGnRXsJjU8/GDwe72e2ERfN8UGc YFQvHTzsgc9LlB3oTzIFHe0f7b2OdJFTqqjcpb8/yFWYk8K8KWisPbkLBJ+AA2y9HT9R bAMAZRW27WGFxqgKOxPjmC1ssPH9I19TlcuCRZfDRI/yDzU9UdMbAWjhKuZwvkBLQ4N6 KO/g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QzU0mpZO; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-128033-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128033-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g25-20020a633759000000b005f05ef19c3esi11087607pgn.759.2024.04.02.06.58.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 06:58:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128033-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QzU0mpZO; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-128033-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128033-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7C168B249B8 for ; Tue, 2 Apr 2024 13:22:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B4E6C7F7D9; Tue, 2 Apr 2024 13:22:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QzU0mpZO" Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 C882179B8A for ; Tue, 2 Apr 2024 13:22:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712064150; cv=none; b=kQm/5jWbo2GddIr7BOT8n4vN/y/ZHQz3haMU+cT0PCRkbqmUOwFqCtDb5/CxfSSl4xFlfZhno20ng6SZpCZY6INyeDeFewF3fk3H48Q1EbWhr//BXsl8o8VAfas7znLhgaI0Ib3d/K5Aie5zCDmuSY9nMqLlNq+2k1C9dr2Ihyg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712064150; c=relaxed/simple; bh=F3/KSztqXE1RJ4wE6tYtCNLde9NUViHXpH9XU3bO6Fo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=M9vm8PO//kkeYbtrFsHXMt6QuwOI7kh114K2xmxfAV3yWjeJNYN+x/RJJFC4XRINAg30V2cP/2EgONVELJIZ+26byBQsxe7k/nuPct6hMd6bWKRG7OFzbciZLEE5mFHuZxAu1Lh1Px8RMw6qOZLrUjC+upa2ahvVo/zbXi5Va3E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QzU0mpZO; arc=none smtp.client-ip=209.85.167.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-516b6e75dc3so558753e87.3 for ; Tue, 02 Apr 2024 06:22:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712064147; x=1712668947; 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=37qcl+O6YD2iKKcTYX3TCpIUlrBbXdw/pysK7vT88Us=; b=QzU0mpZOoYFl/eLZMpmpC4EGExQY2k8OgnR3JrC/Vc/KooUKU+BkjtS42wLxNPJSAW Uz9ADGSILKadacr5TjP9p1D4L4qau4vYs9Z6XMSBkZeJwctrzzJk3k9AEMBmtl6Oqv5o kyoLAyF/yI7Mj9uVZf4dpTtKeSnOHJ88RiLlGeTIzFqMs6XTOE58eCLIUW7i4xjIb318 2V1K1NvatVCi+bl6+3CLaraztTdhE6/95WNggCfu7hFXgbxujEagmtGiLqosbstCnVoy mL5xHWKncapyMB6oiA3SIhSOKOjZtf+czQaoGBqo/2gi4lTYbb/R9cXVX7mHawdqkTtO QuQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712064147; x=1712668947; 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=37qcl+O6YD2iKKcTYX3TCpIUlrBbXdw/pysK7vT88Us=; b=UbZ0OcjniDjeyZysBJM0MyhCTkr6+hDx2ESdwdcAOdpnyVq2vHW8JpGuk1jDGWiYg4 qO8dTnMT1nZCcrOj3GjsOurCLTzzUZ3ODxwBctg6hEUugqu0KRJW1Z76F5SRiGhthbsC 2kLHYoRle6iZhNL/NZveJaI7vLa8HfUreaZiqV4O1qYeiQYYRxA7jcJYGqf6ok30YmFj r1YjcD4F9swSjZedM6xWkVt+mdUuNT0yBvqaE/qhT9xp1IHpmfB41knqHMsrytIUh8cv J75Bf3ObyMVOFHgHjzO3Ha15lWv1U6zdNBjhvyggN72VKrZkBM7DzTLrIGzs2d4qWQiE 2uyA== X-Forwarded-Encrypted: i=1; AJvYcCVWqajrtetSN3yruU6AUYFhZlN+mEnDeK566c6W8khlNvVBnFdFQVmKOLHsg7QTcGVffh8fiYxM0vNxDWOMMCF5KNyWFYT/4LN3NcRD X-Gm-Message-State: AOJu0YzvPGXfsxh46EW6NfLaA3Xb9H57ddrQK2XtaYEcYOzw5m4aA2jY E4PoX1DqUReTXw/oG6SOK/CGBF1Fa54enQVTG8zwNgIARfbJc1R/OE1JU7csox5F0lunA4nLVXN 7YPFWML2tyOpxlvhgXLiP/xeDR60= X-Received: by 2002:a05:6512:2389:b0:515:be10:e288 with SMTP id c9-20020a056512238900b00515be10e288mr10983912lfv.21.1712064146755; Tue, 02 Apr 2024 06:22:26 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240327144537.4165578-1-ryan.roberts@arm.com> <20240327144537.4165578-6-ryan.roberts@arm.com> <63c9caf4-3af4-4149-b3c2-e677788cb11f@arm.com> In-Reply-To: <63c9caf4-3af4-4149-b3c2-e677788cb11f@arm.com> From: Lance Yang Date: Tue, 2 Apr 2024 21:22:15 +0800 Message-ID: Subject: Re: [PATCH v5 5/6] mm: vmscan: Avoid split during shrink_folio_list() To: Ryan Roberts Cc: Barry Song <21cnbao@gmail.com>, Andrew Morton , David Hildenbrand , Matthew Wilcox , Huang Ying , Gao Xiang , Yu Zhao , Yang Shi , Michal Hocko , Kefeng Wang , Chris Li , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Barry Song Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Baolin Wang's patch[1] has avoided confusion with PMD mapped THP related statistics. So, these three counters (THP_SPLIT_PAGE, THP_SPLIT_PAGE_FAILED, and THP_DEFERRED_SPLIT_PAGE) no longer include mTHP. [1] https://lore.kernel.org/linux-mm/a5341defeef27c9ac7b85c97f030f93e4368bb= c1.1711694852.git.baolin.wang@linux.alibaba.com/ On Tue, Apr 2, 2024 at 9:10=E2=80=AFPM Ryan Roberts = wrote: > > On 28/03/2024 08:18, Barry Song wrote: > > On Thu, Mar 28, 2024 at 3:45=E2=80=AFAM Ryan Roberts wrote: > >> > >> Now that swap supports storing all mTHP sizes, avoid splitting large > >> folios before swap-out. This benefits performance of the swap-out path > >> by eliding split_folio_to_list(), which is expensive, and also sets us > >> up for swapping in large folios in a future series. > >> > >> If the folio is partially mapped, we continue to split it since we wan= t > >> to avoid the extra IO overhead and storage of writing out pages > >> uneccessarily. > >> > >> Reviewed-by: David Hildenbrand > >> Reviewed-by: Barry Song > >> Signed-off-by: Ryan Roberts > >> --- > >> mm/vmscan.c | 9 +++++---- > >> 1 file changed, 5 insertions(+), 4 deletions(-) > >> > >> diff --git a/mm/vmscan.c b/mm/vmscan.c > >> index 00adaf1cb2c3..293120fe54f3 100644 > >> --- a/mm/vmscan.c > >> +++ b/mm/vmscan.c > >> @@ -1223,11 +1223,12 @@ static unsigned int shrink_folio_list(struct l= ist_head *folio_list, > >> if (!can_split_folio(folio, NU= LL)) > >> goto activate_locked; > >> /* > >> - * Split folios without a PMD = map right > >> - * away. Chances are some or a= ll of the > >> - * tail pages can be freed wit= hout IO. > >> + * Split partially mapped foli= os right > >> + * away. We can free the unmap= ped pages > >> + * without IO. > >> */ > >> - if (!folio_entire_mapcount(fol= io) && > >> + if (data_race(!list_empty( > >> + &folio->_deferred_list= )) && > >> split_folio_to_list(folio, > >> folio_= list)) > >> goto activate_locked; > > > > Hi Ryan, > > > > Sorry for bringing up another minor issue at this late stage. > > No problem - I'd rather take a bit longer and get it right, rather than r= ush it > and get it wrong! > > > > > During the debugging of thp counter patch v2, I noticed the discrepancy= between > > THP_SWPOUT_FALLBACK and THP_SWPOUT. > > > > Should we make adjustments to the counter? > > Yes, agreed; we want to be consistent here with all the other existing TH= P > counters; they only refer to PMD-sized THP. I'll make the change for the = next > version. > > I guess we will eventually want equivalent counters for per-size mTHP usi= ng the > framework you are adding. > > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 293120fe54f3..d7856603f689 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -1241,8 +1241,10 @@ static unsigned int shrink_folio_list(struct > > list_head *folio_list, > > folio_l= ist)) > > goto activate_locked; > > #ifdef CONFIG_TRANSPARENT_HUGEPAGE > > - > > count_memcg_folio_events(folio, THP_SWPOUT_FALLBACK, 1); > > - count_vm_event(THP_SWPOUT_FALLB= ACK); > > + if (folio_test_pmd_mappable(fol= io)) { > > + > > count_memcg_folio_events(folio, THP_SWPOUT_FALLBACK, 1); > > + > > count_vm_event(THP_SWPOUT_FALLBACK); > > + } > > #endif > > if (!add_to_swap(folio)) > > goto activate_locked_sp= lit; > > > > > > Because THP_SWPOUT is only for pmd: > > > > static inline void count_swpout_vm_event(struct folio *folio) > > { > > #ifdef CONFIG_TRANSPARENT_HUGEPAGE > > if (unlikely(folio_test_pmd_mappable(folio))) { > > count_memcg_folio_events(folio, THP_SWPOUT, 1); > > count_vm_event(THP_SWPOUT); > > } > > #endif > > count_vm_events(PSWPOUT, folio_nr_pages(folio)); > > } > > > > I can provide per-order counters for this in my THP counter patch. > > > >> -- > >> 2.25.1 > >> > > > > Thanks > > Barry >