Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1454919rbb; Mon, 26 Feb 2024 09:44:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXZcqbiIrUhSwz2UPa0lPZSnt5Aih0T9p2XZ1nPJZ/Ozb6mTtj7FMzmqktyf2HSZhCTx1anx9wsKHFSXmLq4DqByIQMspjFeZvW37KDUg== X-Google-Smtp-Source: AGHT+IGfZEy9zX2kKYi+3B307Y8DgQ61ny6DMNjJw2X9/xQI7ULVR4NkMAl6/0NcqUYNondHuTlN X-Received: by 2002:ac8:7c56:0:b0:42e:8e86:3215 with SMTP id o22-20020ac87c56000000b0042e8e863215mr1587800qtv.59.1708969461509; Mon, 26 Feb 2024 09:44:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708969461; cv=pass; d=google.com; s=arc-20160816; b=tj8QlpL8cnz0sg3b0tqCmjvF50qleLU9kogdMLzMhSyNpVbDwrCTAHVcmiJOMBdlck josdpLB2X8lYy+Cdr+/V+IPn+LWSYyPY7V/8pZHkM9LY9WDflzwAFZtXkWJYTBaUrmEs DyBYA54VfHcgMcVNz2Bcou7Q44JIwPqlLtCdyNuV8yZvUNF1P7NJkzdSsodlu+gU7hRM 5PEaYcudAguw61pz3gWEYGgxy78DvA7E1NVyjtG8nOrF4UJ5HcYkRdtbyVgNRjwvqXFM ze0iTbEqZkbMC//dsSH/6EglLG41spq7IWX1PwW8SQP3TSIGecyAK0WvHYkhRSLy9rBM /ryw== 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=7Eo5ptl+csIuQRO4g7aw+yq6rgTcb4eqzCYIiJEzifQ=; fh=J9dLnO7E8EfhhtOvTvo1rPPmyW8nZUri+Edy5an+SEw=; b=EhkXQuKL+JM9ujIc6XwHoTPkK6Z2LN4CiZOz8tXbGtNMDaHSPB8kduXcL7GR4o3K9N vsDIa5VM/8fdnhoj98J0YIHE1p7iQyngSfKEjxo3bmKYra1mHxWCGB0nTCQaq53AJ7zg nI0hDGuy4ef5aXPRjDzz0Zw3teyiLPJU5CzK6nYlS/84zwiMriT5LKXgmJQ3LhJtzQOM vzNlnE5Q4O9s49F/GJ3nEu4B4VLakIHgTNO9yDzajaPmAgR37RRG4sit5F8ku6jm9wjC 5GJ8yq81QLCM2hxxrj2CAh7VVU0hNtB3meC+dE3TMVx2vCjbjEq14he2eIp7TCcFS4LC hiPQ==; 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-82091-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82091-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f16-20020ac84650000000b0042e7cdb27efsi3663383qto.161.2024.02.26.09.44.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:44:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82091-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-82091-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82091-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 145AA1C2A196 for ; Mon, 26 Feb 2024 17:44:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7495312DDA8; Mon, 26 Feb 2024 17:41:13 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96167605A1 for ; Mon, 26 Feb 2024 17:41:10 +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=1708969272; cv=none; b=NisDfoQbDvoBQHB23TwZoYyZ0N6W9ELDtqMqoVEVzz4dc/3ROsRbuH5lphm0DYhHJ+X820MKtdBjHa1lg0A9YtY9JngbUqEY1C0RvUtitTjum7pqZhY56W6j81+/5dfy2B4FmChBv1SLOp+Q0hmffGh01gsjQ9a8aAPHnLGkexA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708969272; c=relaxed/simple; bh=dOUW0bwkpdXqCxCp6JFzajwGpBaS9u7CxDWxetlC2TY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Az/Ep8fdTknvYNc/WGXfrCkfcTPULS+uryKiOhPxxg8+XOFzWwZlENEYlGJC4zet+NnYEImG/8jgT3X17p93uarwnLUyZNHXZqNatjK2a7JCYlBv1Em4VIwVGmFOKezsRbKQeBTj50O6Sm/wVGwXt2r4LJBDWJNueHcx0noF5UY= 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 2FEF9DA7; Mon, 26 Feb 2024 09:41:48 -0800 (PST) Received: from [10.57.67.4] (unknown [10.57.67.4]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E95DC3F73F; Mon, 26 Feb 2024 09:41:07 -0800 (PST) Message-ID: Date: Mon, 26 Feb 2024 17:41: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 v3 1/4] mm: swap: Remove CLUSTER_FLAG_HUGE from swap_cluster_info:flags Content-Language: en-GB To: David Hildenbrand , Andrew Morton , Matthew Wilcox , Huang Ying , Gao Xiang , Yu Zhao , Yang Shi , Michal Hocko , Kefeng Wang Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20231025144546.577640-1-ryan.roberts@arm.com> <20231025144546.577640-2-ryan.roberts@arm.com> <6541e29b-f25a-48b8-a553-fd8febe85e5a@redhat.com> From: Ryan Roberts In-Reply-To: <6541e29b-f25a-48b8-a553-fd8febe85e5a@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 22/02/2024 10:20, David Hildenbrand wrote: > On 22.02.24 11:19, David Hildenbrand wrote: >> On 25.10.23 16:45, Ryan Roberts wrote: >>> As preparation for supporting small-sized THP in the swap-out path, >>> without first needing to split to order-0, Remove the CLUSTER_FLAG_HUGE, >>> which, when present, always implies PMD-sized THP, which is the same as >>> the cluster size. >>> >>> The only use of the flag was to determine whether a swap entry refers to >>> a single page or a PMD-sized THP in swap_page_trans_huge_swapped(). >>> Instead of relying on the flag, we now pass in nr_pages, which >>> originates from the folio's number of pages. This allows the logic to >>> work for folios of any order. >>> >>> The one snag is that one of the swap_page_trans_huge_swapped() call >>> sites does not have the folio. But it was only being called there to >>> avoid bothering to call __try_to_reclaim_swap() in some cases. >>> __try_to_reclaim_swap() gets the folio and (via some other functions) >>> calls swap_page_trans_huge_swapped(). So I've removed the problematic >>> call site and believe the new logic should be equivalent. >> >> That is theĀ  __try_to_reclaim_swap() -> folio_free_swap() -> >> folio_swapped() -> swap_page_trans_huge_swapped() call chain I assume. >> >> The "difference" is that you will now (1) get another temporary >> reference on the folio and (2) (try)lock the folio every time you >> discard a single PTE of a (possibly) large THP. >> > > Thinking about it, your change will not only affect THP, but any call to > free_swap_and_cache(). > > Likely that's not what we want. :/ > Is folio_trylock() really that expensive given the code path is already locking multiple spinlocks, and I don't think we would expect the folio lock to be very contended? I guess filemap_get_folio() could be a bit more expensive, but again, is this really a deal-breaker? I'm just trying to refamiliarize myself with this series, but I think I ended up allocating a cluster per cpu per order. So one potential solution would be to turn the flag into a size and store it in the cluster info. (In fact I think I was doing that in an early version of this series - will have to look at why I got rid of that). Then we could avoid needing to figure out nr_pages from the folio.