From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0BE0CD128A for ; Mon, 8 Apr 2024 09:33:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 88EBD6B008C; Mon, 8 Apr 2024 05:33:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 83E276B0093; Mon, 8 Apr 2024 05:33:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B8506B0096; Mon, 8 Apr 2024 05:33:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4DEFC6B008C for ; Mon, 8 Apr 2024 05:33:36 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0FDC4A0CCC for ; Mon, 8 Apr 2024 09:33:36 +0000 (UTC) X-FDA: 81985852032.11.62470C0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id B116C4000D for ; Mon, 8 Apr 2024 09:33:33 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DjHgfNSg; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712568813; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ojlpELsEYKDYYe32o3soti90BTMWSzTF8f1kuKv5or0=; b=IlFk1CsRNPFigMOwpaN2Fwgn6gvk+fGul/syVk+CUXhf9npNlIagWLJ+A8mFdpx+X2FGvK pLoj5yCtmlAqv/poBceIAtTPFzbc33AXCytCH1gc3JoM0iFfG0yIHs5VzCJ5SdtRGTGzYq nf+6MZjsenN3mDPW/rAYl3FzmUWu0nA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DjHgfNSg; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712568813; a=rsa-sha256; cv=none; b=D2qgXJlZ/6Xp+jjGl3pdidCKBmwHFQon6V4A354YVDCCGTCjCHyn25eeQEat/ogIGywI27 xcK5JP1l1HCSEHz8EWIglwIiHYYHmUbY2cUuXUotqZNNAYOXcj5ZOb/2l2c0ZwfBOozMd6 Bx6k9JkJ+ynMtAXlDdtM5x5Re3zNOe0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712568813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=ojlpELsEYKDYYe32o3soti90BTMWSzTF8f1kuKv5or0=; b=DjHgfNSgF4YImgXYWDV+fOfGGDp2mFTEHAP+Mc3KnIL9+/J9w7kmffAZMWgh1EHAybqlSx re7bfZc4jnVIXb5vbuM2vZ2GxztksFKX0izU5DmNrys8Ccdz+rfyRNc/S2yNbwVRvLmQ0Y NHfqpOuBUcP6J032u/3GVvB13++Wpaw= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-211-AoFu4ObEO4CBT3PEBxCX0Q-1; Mon, 08 Apr 2024 05:33:31 -0400 X-MC-Unique: AoFu4ObEO4CBT3PEBxCX0Q-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4147de378b9so21405015e9.3 for ; Mon, 08 Apr 2024 02:33:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712568810; x=1713173610; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ojlpELsEYKDYYe32o3soti90BTMWSzTF8f1kuKv5or0=; b=eYMLhuySbaqVCugu24cV8JEZUDVa91BiV717Nwq2BFl7ZmD+BYScyt/PpvkMu7/HPr GJXOs/iUH3cbAlw2YmvAU0bbBqPGjKSGeel+TSmdO5efByHgZ8sDXk3MqftfvJaSgT9u vdeYbeboxw94qi2HyMPWE/SzYfjFgDhomnXOo/HdFINNq1uax7disPHkwBu8k2dAd77a cyPBnWUCul/rt/VEtONWkdHIewAxWx8u7DkOQyl0MPeg6dcCzWEl6cVbY51FhDVpjOH2 ni4bAZbPaH6a5a4KeKu+4u16R3C7uiwLgm+5qC7DghXwXq44gDgrlFWJW1hF26FVyvL6 rpdQ== X-Forwarded-Encrypted: i=1; AJvYcCVU3AsGMGQHNoYFVtMo847uyeChTwIMcnea5GzFrEi2aknkXV8/JZvDfqfxPgj4Kh7s1AqaAt+DMQRSdFMd82jePuU= X-Gm-Message-State: AOJu0YzWSVl1438bzXyFrNgRNWbNN1ry7zw9Fs8PQapmyqmOxOypznFe Hswvw19b9tjAlD2LALpVtFQt77HBCxJdkAAQ9KBIyqMC2Ggeb5nIn6iicfIuQ+vM+mT8Tr4ZgoH 87rWa/mQMyabRyAf5fpyIrSpy/ZJRABeondNBbCEvMIMpJ8dO X-Received: by 2002:a05:600c:19cc:b0:414:60fe:8f2b with SMTP id u12-20020a05600c19cc00b0041460fe8f2bmr6992509wmq.18.1712568810596; Mon, 08 Apr 2024 02:33:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFHNA/H8EPbldGCNj0FZbemiFqJlie0oB8laGvHFKccYmDSXzXMORWtAvdg8h2iiqi0noRThA== X-Received: by 2002:a05:600c:19cc:b0:414:60fe:8f2b with SMTP id u12-20020a05600c19cc00b0041460fe8f2bmr6992490wmq.18.1712568810157; Mon, 08 Apr 2024 02:33:30 -0700 (PDT) Received: from ?IPV6:2003:cb:c718:1300:9860:66a2:fe4d:c379? (p200300cbc7181300986066a2fe4dc379.dip0.t-ipconnect.de. [2003:cb:c718:1300:9860:66a2:fe4d:c379]) by smtp.gmail.com with ESMTPSA id m6-20020a05600c4f4600b004166cdae639sm3367681wmq.35.2024.04.08.02.33.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Apr 2024 02:33:29 -0700 (PDT) Message-ID: <10f8227a-c8e1-4873-aff3-6260cbe4378c@redhat.com> Date: Mon, 8 Apr 2024 11:33:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 4/6] mm: swap: Allow storage of all mTHP orders To: Ryan Roberts , "Huang, Ying" Cc: Andrew Morton , Matthew Wilcox , Gao Xiang , Yu Zhao , Yang Shi , Michal Hocko , Kefeng Wang , Barry Song <21cnbao@gmail.com>, Chris Li , Lance Yang , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240403114032.1162100-1-ryan.roberts@arm.com> <20240403114032.1162100-5-ryan.roberts@arm.com> <87edbhaexj.fsf@yhuang6-desk2.ccr.corp.intel.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9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w7Kv AxBQXWeXhJI9XQssfrf4Gusdqx8nPEpfOqCtbbwJMATbHyqLt7/oz/5deGuwxgb65pWIzufa N7eop7uh+6bezi+rugUI+w6DABEBAAHCwXwEGAEIACYCGwwWIQQb2cqtc1xMOkYN/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: B116C4000D X-Stat-Signature: rqhpkxnq7mnc55wpowsuhob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bPO5B4OAszQmGGvg5HMNYaZ4MrZRvI2LmnCbVIxY+Sbktmwz1hVr3u1MrASQVCxPcpiY22hCBAF9oexBVIi0FHgHpy0cecvx2atveAfxGkDHAySeAsDrr3o93ht2DRf0qxSyU3pNzuleWHVW6TZDoc2wovV+/liHvWVHwXqMpqVNoGMkXCtsaaGSOPNQxqBaVGp1v0IqbpJ8CWo18j0L1IQfi0WObA82duY5C/MMId4Byjj1dh0OSmnQf868iM4D4PsPHiT9LtUB7a+iZe2NvME+lo0X0pZ8P42Y5weYvvxd4capzFwmmJrwfwMM38ylTIYzPFpK8xG1cX8g7ZaZrtqJBRyyy1vmh89Du7AHDayO4JY0RjR/oTgFSGIm4rChhb6470nbc0694jhL6Tcs26z3dk1Bkd5ecKqkKoBGH/A0VjOpDi8gZSsukBZ7Vs/Vw/7C7d7gTkdkuDbS1ez5qusAU8sbvd5r50BrsTvbNa36gKhKXx5Y8UONnnEeQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 08.04.24 11:24, Ryan Roberts wrote: > On 07/04/2024 07:02, Huang, Ying wrote: >> David Hildenbrand writes: >> >>> On 03.04.24 13:40, Ryan Roberts wrote: >>>> Multi-size THP enables performance improvements by allocating large, >>>> pte-mapped folios for anonymous memory. However I've observed that on an >>>> arm64 system running a parallel workload (e.g. kernel compilation) >>>> across many cores, under high memory pressure, the speed regresses. This >>>> is due to bottlenecking on the increased number of TLBIs added due to >>>> all the extra folio splitting when the large folios are swapped out. >>>> Therefore, solve this regression by adding support for swapping out >>>> mTHP >>>> without needing to split the folio, just like is already done for >>>> PMD-sized THP. This change only applies when CONFIG_THP_SWAP is enabled, >>>> and when the swap backing store is a non-rotating block device. These >>>> are the same constraints as for the existing PMD-sized THP swap-out >>>> support. >>>> Note that no attempt is made to swap-in (m)THP here - this is still >>>> done >>>> page-by-page, like for PMD-sized THP. But swapping-out mTHP is a >>>> prerequisite for swapping-in mTHP. >>>> The main change here is to improve the swap entry allocator so that >>>> it >>>> can allocate any power-of-2 number of contiguous entries between [1, (1 >>>> << PMD_ORDER)]. This is done by allocating a cluster for each distinct >>>> order and allocating sequentially from it until the cluster is full. >>>> This ensures that we don't need to search the map and we get no >>>> fragmentation due to alignment padding for different orders in the >>>> cluster. If there is no current cluster for a given order, we attempt to >>>> allocate a free cluster from the list. If there are no free clusters, we >>>> fail the allocation and the caller can fall back to splitting the folio >>>> and allocates individual entries (as per existing PMD-sized THP >>>> fallback). >>>> The per-order current clusters are maintained per-cpu using the >>>> existing >>>> infrastructure. This is done to avoid interleving pages from different >>>> tasks, which would prevent IO being batched. This is already done for >>>> the order-0 allocations so we follow the same pattern. >>>> As is done for order-0 per-cpu clusters, the scanner now can steal >>>> order-0 entries from any per-cpu-per-order reserved cluster. This >>>> ensures that when the swap file is getting full, space doesn't get tied >>>> up in the per-cpu reserves. >>>> This change only modifies swap to be able to accept any order >>>> mTHP. It >>>> doesn't change the callers to elide doing the actual split. That will be >>>> done in separate changes. >>>> Reviewed-by: "Huang, Ying" >>>> Signed-off-by: Ryan Roberts >>>> --- >>>> include/linux/swap.h | 10 ++- >>>> mm/swap_slots.c | 6 +- >>>> mm/swapfile.c | 175 ++++++++++++++++++++++++------------------- >>>> 3 files changed, 109 insertions(+), 82 deletions(-) >>>> diff --git a/include/linux/swap.h b/include/linux/swap.h >>>> index 5e1e4f5bf0cb..11c53692f65f 100644 >>>> --- a/include/linux/swap.h >>>> +++ b/include/linux/swap.h >>>> @@ -268,13 +268,19 @@ struct swap_cluster_info { >>>> */ >>>> #define SWAP_NEXT_INVALID 0 >>>> +#ifdef CONFIG_THP_SWAP >>>> +#define SWAP_NR_ORDERS (PMD_ORDER + 1) >>>> +#else >>>> +#define SWAP_NR_ORDERS 1 >>>> +#endif >>>> + >>>> /* >>>> * We assign a cluster to each CPU, so each CPU can allocate swap entry from >>>> * its own cluster and swapout sequentially. The purpose is to optimize swapout >>>> * throughput. >>>> */ >>>> struct percpu_cluster { >>>> - unsigned int next; /* Likely next allocation offset */ >>>> + unsigned int next[SWAP_NR_ORDERS]; /* Likely next allocation offset */ >>>> }; >>>> struct swap_cluster_list { >>>> @@ -471,7 +477,7 @@ swp_entry_t folio_alloc_swap(struct folio *folio); >>>> bool folio_free_swap(struct folio *folio); >>>> void put_swap_folio(struct folio *folio, swp_entry_t entry); >>>> extern swp_entry_t get_swap_page_of_type(int); >>>> -extern int get_swap_pages(int n, swp_entry_t swp_entries[], int entry_size); >>>> +extern int get_swap_pages(int n, swp_entry_t swp_entries[], int order); >>>> extern int add_swap_count_continuation(swp_entry_t, gfp_t); >>>> extern void swap_shmem_alloc(swp_entry_t); >>>> extern int swap_duplicate(swp_entry_t); >>>> diff --git a/mm/swap_slots.c b/mm/swap_slots.c >>>> index 53abeaf1371d..13ab3b771409 100644 >>>> --- a/mm/swap_slots.c >>>> +++ b/mm/swap_slots.c >>>> @@ -264,7 +264,7 @@ static int refill_swap_slots_cache(struct swap_slots_cache *cache) >>>> cache->cur = 0; >>>> if (swap_slot_cache_active) >>>> cache->nr = get_swap_pages(SWAP_SLOTS_CACHE_SIZE, >>>> - cache->slots, 1); >>>> + cache->slots, 0); >>>> return cache->nr; >>>> } >>>> @@ -311,7 +311,7 @@ swp_entry_t folio_alloc_swap(struct folio *folio) >>>> if (folio_test_large(folio)) { >>>> if (IS_ENABLED(CONFIG_THP_SWAP)) >>>> - get_swap_pages(1, &entry, folio_nr_pages(folio)); >>>> + get_swap_pages(1, &entry, folio_order(folio)); >>> >>> The only comment I have is that this nr_pages -> order conversion adds >>> a bit of noise to this patch. >>> >>> AFAIKS, it's primarily only required for "cluster->next[order]", >>> everything else doesn't really require the order. >>> >>> I'd just have split that out into a separate patch, or simply >>> converted nr_pages -> order where required. >>> >>> Nothing jumped at me, but I'm not an expert on that code, so I'm >>> mostly trusting the others ;) >> >> The nr_pages -> order conversion replaces ilog2(nr_pages) with >> (1<> don't need to worry about whether nr_pages is a power of 2. Do you >> think that this makes sense? > > I think that David's point was that I should just split out that change to its > own patch to aid readability? I'm happy to do that if no one objects. Yes. Or avoiding it and not caring about a ilog vs. 1<