Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1224011lqe; Mon, 8 Apr 2024 02:32:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXbMRRALOulYqOs0SpKRRPKxXlJ9wbmrIGyZqnZX7XV4Pa9PuRcwOgUM837Qfy7gmYIZWcfPcJl/hUz4rtHS8VhrtWwagpLYp/953yRkw== X-Google-Smtp-Source: AGHT+IGaAEBMZgVqQ1M20YSzLlYhLrFD2T19GwfwDS6Lfh2sTxMlfLyYhqpTh4Ladr2hbclVv1Az X-Received: by 2002:a17:902:b492:b0:1e3:e249:41eb with SMTP id y18-20020a170902b49200b001e3e24941ebmr5028562plr.32.1712568766035; Mon, 08 Apr 2024 02:32:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712568766; cv=pass; d=google.com; s=arc-20160816; b=h5F+eHE8/sTyqtlg/Qbok4UBVxtKqFTvK3WY3S8YN9OljjFw/ETGb48E0EPwhxHN+S BNIMXCrRFx3MLrKbovP68HO2jnTqrluIMhjYIeV1qxK0oWBFAJ3emjGFU1lQk/KolLr8 9jkMSHjLjQGx6qeg98Y9XIWpigPLwCosoHSrG46d9bB9Utj8RQUTV0NmrIWojAij2NN0 gtgK+Y9HdbHOfHAXy7NnigBvbc+chwnEc1Bt5XUp+PLY7tTHr3GOyIMyisYDkOLxzzq8 XwfxTC9aG+1qxIY+8EJi5Md9UZoEij/EWwyWMZ0XeKzdC4SsmUW1tBQZ/2l3mIl83VJn LCJg== 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=PdknYLekP+qvefYXJW8uumM1vtzOnGHgE7CgcO7PS0M=; fh=AWDrjgcQ3P+3UQvkPvVHnXanG/NnL4Jy9ZjUHaGL5tE=; b=SDGObV2l7bqhB9V3+LlsxrIsjEIwwVMWelFlhfXd10pZkQMD+0/67ABbL5z5inFhOR gVaKHAZm/zGPiE6gmxLPshEJoKIjTbUNXFHIsuK6Wd7UBJvRmPEtk/TT9g9t3YQyVQtd vEXdkE94czWxGVvsrBPDSNBzyWxOnXXUb7w3QCpdZ6ENi8tTO/yErXm6ZOl/lP4ie52i qYaKbR6dtVs9Dujw13/duB6tj7Aa1YOUeDrS+O5Ds2N/++1y5lrx3nD549UkE4z4udX3 AH5mHnFuu4dAuW2YOoMWzJgE1ay5I7KWg31vocPgnby0YXmO4MdrcXbcRlNJ8E0ZJ/Lz fhjA==; 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-135154-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135154-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. [139.178.88.99]) by mx.google.com with ESMTPS id 20-20020a170902ee5400b001e2a44ff6c5si5830676plo.289.2024.04.08.02.32.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 02:32:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135154-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-135154-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135154-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 AC0E5282A76 for ; Mon, 8 Apr 2024 09:32:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F41534EB3D; Mon, 8 Apr 2024 09:32:03 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07D1F4E1BE for ; Mon, 8 Apr 2024 09:32:01 +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=1712568723; cv=none; b=E2yLuLEsmZqm/3/CgAuDpaTGDNrga2vHIdAmw4/voEcPFh2FayktCGaB7kMSuEExUJs3hBK2mWKXjb30ty3xo6RWSbseXTnY3mkJzJioZK/dd2WV7i14YmTwWRZd3zX4D2Unw2LO5irAj/Q/NpgrI5gPW0mQCOtHd6D6zFP/bwU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712568723; c=relaxed/simple; bh=AUaPVnuSfJpVtVo2zwvpnfKznV2o5PAdSasSe2Vn65s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=lWtckrFpynW2mYw1Gjio+/wIg9rk/DgOm414QqaU+KfoRkL1as1Ly67j5eRHCodtKVPe7EDj9gav55BeRlbxXj8D34UbAb/mi+5BjT6b0f7lx1wL35NA+fwtmgZekNw/Ca6aF3O2g4oZHsYHhHkb2fBDFPxTPd/Ql2mPuEQ6BRM= 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 CEB991007; Mon, 8 Apr 2024 02:32:31 -0700 (PDT) Received: from [10.57.73.169] (unknown [10.57.73.169]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 693B13F766; Mon, 8 Apr 2024 02:31:59 -0700 (PDT) Message-ID: <47eccc1b-71a2-43f3-8d44-7d26c6ddd4f0@arm.com> Date: Mon, 8 Apr 2024 10:31:58 +0100 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 v6 5/6] mm: vmscan: Avoid split during shrink_folio_list() Content-Language: en-GB To: David Hildenbrand , Andrew Morton , Matthew Wilcox , Huang Ying , Gao Xiang , Yu Zhao , Yang Shi , Michal Hocko , Kefeng Wang , Barry Song <21cnbao@gmail.com>, Chris Li , Lance Yang Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Barry Song References: <20240403114032.1162100-1-ryan.roberts@arm.com> <20240403114032.1162100-6-ryan.roberts@arm.com> <6653ce52-53a2-4d91-b98f-50f1608ae59c@redhat.com> From: Ryan Roberts In-Reply-To: <6653ce52-53a2-4d91-b98f-50f1608ae59c@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 05/04/2024 11:42, David Hildenbrand wrote: > On 03.04.24 13:40, 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. >> >> THP_SWPOUT and THP_SWPOUT_FALLBACK counters should continue to count >> events only for PMD-mappable folios to avoid user confusion. THP_SWPOUT >> already has the appropriate guard. Add a guard for THP_SWPOUT_FALLBACK. >> It may be appropriate to add per-size counters in future. >> >> Reviewed-by: David Hildenbrand >> Reviewed-by: Barry Song >> Signed-off-by: Ryan Roberts >> --- >>   mm/vmscan.c | 17 +++++++++++------ >>   1 file changed, 11 insertions(+), 6 deletions(-) >> >> diff --git a/mm/vmscan.c b/mm/vmscan.c >> index 00adaf1cb2c3..ffc4553c8615 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)) && > > Please violate the 80 chars rule where reasonable. > > " > Statements longer than 80 columns should be broken into sensible chunks, unless > exceeding 80 columns significantly increases readability and does not hide > information. > " > > > Likely some of that code here should be refactored into readable sub-functions. > > codingstyle also mentions > > "The answer to that is that if you need more than 3 levels of indentation, > you're screwed anyway, and should fix your program." > Boo! :) Yeah, no problem, I'll sort this.