Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp285790lqh; Thu, 28 Mar 2024 01:49:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWpiIlGFhrf/6nyuZdBQsiCm3//9NwZxA01MiFQZcUM8DUnGsfkLXZugLnedBU7fU6aflDzP2tCJeUIzU/hCEwmlDF46beyuYV6a7zrIA== X-Google-Smtp-Source: AGHT+IFhCwPa6P+Sr5Iq70Sa/dodxPFy2qmrZ++/hA6YBGynw9a/ze2gRl54DqiaQLzfg/frXl54 X-Received: by 2002:a05:6a00:2306:b0:6e7:f4:3661 with SMTP id h6-20020a056a00230600b006e700f43661mr2699803pfh.13.1711615745393; Thu, 28 Mar 2024 01:49:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711615745; cv=pass; d=google.com; s=arc-20160816; b=Cz+hQfE4TwJ8HhoxZwYMti7Lt7Ri4G7rZ5le5VzbyYh/p++3sPm8EL4O/bfOkCBUHj BAZTbqPh5/IDG2f2okFoTQjnZ1IB7QCJMOGYTiwCQNo5rNkrnqLTFa3ZGpg0n6FRm86f XdwUs6EP3+l4Pjsgewsh6nX5xvURwQn50uMXcV7PSXe6XWemnIQW9+CY0LUcST4Clbqo WqhXQ1vxELPslO1yLnyEonRB56uo9CeTqs6wxXOeIALtVSjmMgwdhdGwopBuY17kKjsV /ORcZY5vkvIhXVmwDEYuL1ozqGfAzPOiAe4OQplOSr5lE5x/nzX/OgFg4cudHfRgmFFL lcUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=Y1Dn9ykcsV3cGVDefyvl6FiNo7n0eYqaOpMWU8LlgRc=; fh=3cULz2uNDeJifropYdulCahm9pRRJlGVKjRQ33O9T9A=; b=u93sVTBjxHW5WqF+lDNACz3w36Rbq1DXrwW70G9df8NaqQNUImavKvY1lLlIdCvoRl q/py/pO3OHuoYvvw61UKgTIMz8nJf22AnTk+eF1EdaJhRn+iaQveInWeGeCOzCY2QM3y b0PAOFNiyhFsWa6y/jDOQ7aR+ECZJ6c+b9kuE7qc4DeoUSzWe6V5bBdmA9pG7G5sY417 hApOgLRiO9R+kSL6WqHi0hq6UsSa0y8+CL/jXeGGKKq2JFAixiB25AbgEjdhv0G/nlda huhgxeJCFsEECsqIdkJHhC910vs6xIgvdJ/OCHJc2LrwmAmLEVdoJBxKm3MpwNdH6Boy wA8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-122597-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122597-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bm19-20020a656e93000000b005e83f3259e2si1056661pgb.165.2024.03.28.01.49.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 01:49:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122597-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-122597-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122597-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id F37D42864A0 for ; Thu, 28 Mar 2024 08:48:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5EEB50279; Thu, 28 Mar 2024 08:48:13 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B915724219 for ; Thu, 28 Mar 2024 08:48:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711615693; cv=none; b=twOj0PB0k6vxDq0NsjQls8pgUWBCLPlDwU9dzll7Xaxj7gw22Ly7BSYna4GaY1hTV6Vw3kx9pt2qwPX5qEiVZPbQ1vw9BlJ7WpsSi1Wg1ICWRLpZh8ORLngIZ83nj1xFx+pOogVr5NPNVMQLutyM+m/m6dwBsnt4YyOTUD+bhH8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711615693; c=relaxed/simple; bh=jmmqgYh4xhYWdZhCBFwvyvxclQIee8SJpDjlrL/T+nE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=j962ADfKHLFmeBKwqz6G4dg3ZbgrFhumeAO4nF6cyRlPY97nF2WqnPiU16qEcqoniayXRTEhXYEXQuZMNqJ/+86793rk+edeFZAd0WRLa7ltq2iwZKtRtj6Aq8JwVbifVzqrWLrynaNaoRb3nTqy5+teCJhhY5ttD5f6nGM3R3g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 015E12F4; Thu, 28 Mar 2024 01:48:45 -0700 (PDT) Received: from [10.57.72.121] (unknown [10.57.72.121]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AA9463F64C; Thu, 28 Mar 2024 01:48:08 -0700 (PDT) Message-ID: <8d28bf39-041b-40f0-90dd-332e69f6c50d@arm.com> Date: Thu, 28 Mar 2024 08:48:06 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 5/6] mm: vmscan: Avoid split during shrink_folio_list() Content-Language: en-GB To: Barry Song <21cnbao@gmail.com> Cc: Andrew Morton , David Hildenbrand , Matthew Wilcox , Huang Ying , Gao Xiang , Yu Zhao , Yang Shi , Michal Hocko , Kefeng Wang , Chris Li , Lance Yang , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Barry Song References: <20240327144537.4165578-1-ryan.roberts@arm.com> <20240327144537.4165578-6-ryan.roberts@arm.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 28/03/2024 08:18, Barry Song wrote: > On Thu, Mar 28, 2024 at 3:45 AM 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 want >> 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 list_head *folio_list, >> if (!can_split_folio(folio, NULL)) >> goto activate_locked; >> /* >> - * Split folios without a PMD map right >> - * away. Chances are some or all of the >> - * tail pages can be freed without IO. >> + * Split partially mapped folios right >> + * away. We can free the unmapped pages >> + * without IO. >> */ >> - if (!folio_entire_mapcount(folio) && >> + 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. > > During the debugging of thp counter patch v2, I noticed the discrepancy between > THP_SWPOUT_FALLBACK and THP_SWPOUT. Ahh good spot! I had noticed this previously and clearly forgot all about it. I'm on holiday today and over the long weekend in the UK. I'll take a proper look next week and send a fix. > > Should we make adjustments to the counter? > > 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_list)) > goto activate_locked; > #ifdef CONFIG_TRANSPARENT_HUGEPAGE > - > count_memcg_folio_events(folio, THP_SWPOUT_FALLBACK, 1); > - count_vm_event(THP_SWPOUT_FALLBACK); > + if (folio_test_pmd_mappable(folio)) { > + > count_memcg_folio_events(folio, THP_SWPOUT_FALLBACK, 1); > + > count_vm_event(THP_SWPOUT_FALLBACK); > + } > #endif > if (!add_to_swap(folio)) > goto activate_locked_split; > > > 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