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 87536C46CD2 for ; Tue, 30 Jan 2024 09:33:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D8516B0093; Tue, 30 Jan 2024 04:33:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 060C36B00A3; Tue, 30 Jan 2024 04:33:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E43DA6B00A4; Tue, 30 Jan 2024 04:33:43 -0500 (EST) 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 D47FD6B00A0 for ; Tue, 30 Jan 2024 04:33:43 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7EFB81A0450 for ; Tue, 30 Jan 2024 09:33:43 +0000 (UTC) X-FDA: 81735465126.13.0149CC7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 20C9640025 for ; Tue, 30 Jan 2024 09:33:40 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Q2hjl6pI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of david@redhat.com designates 170.10.133.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=1706607221; 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=r8m7uPOH6IrpXxOx1GhKy9Dm1H+TruM8yPB84uxSQyo=; b=58BNgRl82DrQk7l0Nwm99zEPg5RCqxFS9h/o61odU0nkTZEcJh0rp1dZCBbXl+G16/OX+x 645VsHCS5B7I5pQHdtzjzwOaqbLZx5p0jxfAyxS+9pgk4lW/67QG44fY/ijTMkOTCmaMva BWA7b3Z+0Iu7+01FoNtXKtocd5+4cNM= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Q2hjl6pI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706607221; a=rsa-sha256; cv=none; b=pR/bqX6GvcyHJtFnPG3VuvukTUdIf9lOIAyUDr3IDlZYq3rTb7prBnhA8EcUNPYfgckSlz fQ1NfcZ4147JpKWPPQnKQxKeAzqb8xX9iLuND2LlwX2yeaqZljRlII6Itm90FaesXDkRgB rfYkQxZtcbvNtKuYGncKhIYhC9cVSso= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706607220; 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=r8m7uPOH6IrpXxOx1GhKy9Dm1H+TruM8yPB84uxSQyo=; b=Q2hjl6pIRJrzDxEOM9l/LDK7KMZf+bBh9qiKQpIwq8pMz41KNgt+8Qh7Y8hO6iPya0Ab8c 7y3ifleiLVgUosz3FOtXwpjs/hhnJSTSB+6OvUrcbIve26Ot2ViewAq9lnG6P38vAfjZcO i1OVcRERlrzZDn+wMWK5qfRJkufADEQ= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-134-GTwKJTGLOHyDTBuvr8xk6A-1; Tue, 30 Jan 2024 04:33:38 -0500 X-MC-Unique: GTwKJTGLOHyDTBuvr8xk6A-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-40efbba82c8so5454795e9.0 for ; Tue, 30 Jan 2024 01:33:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706607217; x=1707212017; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=r8m7uPOH6IrpXxOx1GhKy9Dm1H+TruM8yPB84uxSQyo=; b=H84dDO+UI/vN3WjhZPCb5OfeDOJUo2YZmjOsxbJTaVkj43ENGsnojrH0+op+RPGH/8 XpMR+Qv/akywiQDYxqcB25LslVCv/o4zysuYoklo/f3XqOK+m508Nro2iJPa7UknjvWP Kr1q/v/WcLDbXoYXmrqYnX0vmeoE9edCfi4FOi2Kdscanj0hwsZCiOroXvDQLHiSlebL 1GoReu7XZ7wCJsKjEpD9f9IgYFSGDaqOalwPI0UKSAn+tICdU6oJL+cB7coHkKQdKdC/ kmwa62YRAWvU+/6NLAH/NywOnnQEIDbQJ7+PChTaTzlql99Tnc9WfA8waaZ+qDUvhP1n ep6Q== X-Gm-Message-State: AOJu0YzQ2z//zvKJyCnqHHx5NMSz3BlGYnLoOGbYzYCBOLGb2Jo6G5N6 3u/CuXdofQBl4+I3eBKRYpweJkkA1yJMEzg0HdRIzMqoHPDU9S6LpSuj8VSKCDGA6wI4YYxOMHK yUpfec4ydn1r6ku6gF4fJTrKgXU81Rg7GmD9H6sXex4Mz/WU+/OuhcQTW X-Received: by 2002:a05:600c:3b29:b0:40f:a661:d2b with SMTP id m41-20020a05600c3b2900b0040fa6610d2bmr358001wms.13.1706607217278; Tue, 30 Jan 2024 01:33:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHo+KOR5lw3BrW72Ij0NfPypWhmMPY/4ZK+I4aQGqcJQVUJ42v4Bg58uAsBy+D89KjoZDWwDQ== X-Received: by 2002:a05:600c:3b29:b0:40f:a661:d2b with SMTP id m41-20020a05600c3b2900b0040fa6610d2bmr357962wms.13.1706607216838; Tue, 30 Jan 2024 01:33:36 -0800 (PST) Received: from ?IPV6:2003:cb:c708:2700:bdf6:739b:9f9d:862f? (p200300cbc7082700bdf6739b9f9d862f.dip0.t-ipconnect.de. [2003:cb:c708:2700:bdf6:739b:9f9d:862f]) by smtp.gmail.com with ESMTPSA id v9-20020a05600c470900b0040d87100733sm12550857wmo.39.2024.01.30.01.33.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Jan 2024 01:33:36 -0800 (PST) Message-ID: <38ec930c-7175-4bd4-a364-527fcf583148@redhat.com> Date: Tue, 30 Jan 2024 10:33:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 7/9] mm/mmu_gather: add __tlb_remove_folio_pages() To: Ryan Roberts , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Andrew Morton , Matthew Wilcox , Catalin Marinas , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , Michael Ellerman , Christophe Leroy , "Naveen N. Rao" , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Arnd Bergmann , linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org References: <20240129143221.263763-1-david@redhat.com> <20240129143221.263763-8-david@redhat.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQO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Gusdqx8nPEpfOqCtbbwJMATbHyqLt7/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-Queue-Id: 20C9640025 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 1gjkh35nmie5bc4iki6151nu1zdy86qf X-HE-T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+j85IKs7MJN3ou3Ll5u9fi4ZDt23YgPltT+FqRHGgRfzin5r60FTTvIdeNYw8AboNjHyAACj9j+if7VNvogDSodyXjIKCv7Qm/y7fD8Xy0O4TXzWG3KUQ1r2SyDJVPNZ2OKza1Ij8CPY9k3bxap6Wk8HmrvjJwCBJCYwE0A8kG4CfXCESCpY0KPujgPmcNUTgAhALZUEIDuneBYr8G7LpPo8pB/ss3OROxBX067Zz03GHnz8DEiJS18xXRXEdLW2SWpQLuYI5VogDUJ3cHWi4HqF2YaCf3ucP4+ARA2hA3Ds8E1F7PIp7LcEMUPCn6kqc/250q2t4P8VpL5pHczor3WSfr2ZvIqtfR/zozG2Ikz3qIMudjWIU19xg+UPwukRJ0n6wqbjYV225Sb0H4P9XKnjlvlLwRufsLcEvxACek8yyKYAztOjph/YVNRPw== 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 30.01.24 10:21, Ryan Roberts wrote: > On 29/01/2024 14:32, David Hildenbrand wrote: >> Add __tlb_remove_folio_pages(), which will remove multiple consecutive >> pages that belong to the same large folio, instead of only a single >> page. We'll be using this function when optimizing unmapping/zapping of >> large folios that are mapped by PTEs. >> >> We're using the remaining spare bit in an encoded_page to indicate that >> the next enoced page in an array contains actually shifted "nr_pages". >> Teach swap/freeing code about putting multiple folio references, and >> delayed rmap handling to remove page ranges of a folio. >> >> This extension allows for still gathering almost as many small folios >> as we used to (-1, because we have to prepare for a possibly bigger next >> entry), but still allows for gathering consecutive pages that belong to the >> same large folio. >> >> Note that we don't pass the folio pointer, because it is not required for >> now. Further, we don't support page_size != PAGE_SIZE, it won't be >> required for simple PTE batching. >> >> We have to provide a separate s390 implementation, but it's fairly >> straight forward. >> >> Another, more invasive and likely more expensive, approach would be to >> use folio+range or a PFN range instead of page+nr_pages. But, we should >> do that consistently for the whole mmu_gather. For now, let's keep it >> simple and add "nr_pages" only. >> >> Signed-off-by: David Hildenbrand >> --- >> arch/s390/include/asm/tlb.h | 17 +++++++++++ >> include/asm-generic/tlb.h | 8 +++++ >> include/linux/mm_types.h | 20 ++++++++++++ >> mm/mmu_gather.c | 61 +++++++++++++++++++++++++++++++------ >> mm/swap.c | 12 ++++++-- >> mm/swap_state.c | 12 ++++++-- >> 6 files changed, 116 insertions(+), 14 deletions(-) >> >> diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h >> index 48df896d5b79..abfd2bf29e9e 100644 >> --- a/arch/s390/include/asm/tlb.h >> +++ b/arch/s390/include/asm/tlb.h >> @@ -26,6 +26,8 @@ void __tlb_remove_table(void *_table); >> static inline void tlb_flush(struct mmu_gather *tlb); >> static inline bool __tlb_remove_page_size(struct mmu_gather *tlb, >> struct page *page, bool delay_rmap, int page_size); >> +static inline bool __tlb_remove_folio_pages(struct mmu_gather *tlb, >> + struct page *page, unsigned int nr_pages, bool delay_rmap); >> >> #define tlb_flush tlb_flush >> #define pte_free_tlb pte_free_tlb >> @@ -52,6 +54,21 @@ static inline bool __tlb_remove_page_size(struct mmu_gather *tlb, >> return false; >> } >> >> +static inline bool __tlb_remove_folio_pages(struct mmu_gather *tlb, >> + struct page *page, unsigned int nr_pages, bool delay_rmap) >> +{ >> + struct encoded_page *encoded_pages[] = { >> + encode_page(page, ENCODED_PAGE_BIT_NR_PAGES), >> + encode_nr_pages(nr_pages), >> + }; >> + >> + VM_WARN_ON_ONCE(delay_rmap); >> + VM_WARN_ON_ONCE(page_folio(page) != page_folio(page + nr_pages - 1)); >> + >> + free_pages_and_swap_cache(encoded_pages, ARRAY_SIZE(encoded_pages)); >> + return false; >> +} >> + >> static inline void tlb_flush(struct mmu_gather *tlb) >> { >> __tlb_flush_mm_lazy(tlb->mm); >> diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h >> index 2eb7b0d4f5d2..428c3f93addc 100644 >> --- a/include/asm-generic/tlb.h >> +++ b/include/asm-generic/tlb.h >> @@ -69,6 +69,7 @@ >> * >> * - tlb_remove_page() / __tlb_remove_page() >> * - tlb_remove_page_size() / __tlb_remove_page_size() >> + * - __tlb_remove_folio_pages() >> * >> * __tlb_remove_page_size() is the basic primitive that queues a page for >> * freeing. __tlb_remove_page() assumes PAGE_SIZE. Both will return a >> @@ -78,6 +79,11 @@ >> * tlb_remove_page() and tlb_remove_page_size() imply the call to >> * tlb_flush_mmu() when required and has no return value. >> * >> + * __tlb_remove_folio_pages() is similar to __tlb_remove_page(), however, >> + * instead of removing a single page, remove the given number of consecutive >> + * pages that are all part of the same (large) folio: just like calling >> + * __tlb_remove_page() on each page individually. >> + * >> * - tlb_change_page_size() >> * >> * call before __tlb_remove_page*() to set the current page-size; implies a >> @@ -262,6 +268,8 @@ struct mmu_gather_batch { >> >> extern bool __tlb_remove_page_size(struct mmu_gather *tlb, struct page *page, >> bool delay_rmap, int page_size); >> +bool __tlb_remove_folio_pages(struct mmu_gather *tlb, struct page *page, >> + unsigned int nr_pages, bool delay_rmap); >> >> #ifdef CONFIG_SMP >> /* >> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h >> index 1b89eec0d6df..198662b7a39a 100644 >> --- a/include/linux/mm_types.h >> +++ b/include/linux/mm_types.h >> @@ -226,6 +226,15 @@ struct encoded_page; >> /* Perform rmap removal after we have flushed the TLB. */ >> #define ENCODED_PAGE_BIT_DELAY_RMAP 1ul >> >> +/* >> + * The next item in an encoded_page array is the "nr_pages" argument, specifying >> + * the number of consecutive pages starting from this page, that all belong to >> + * the same folio. For example, "nr_pages" corresponds to the number of folio >> + * references that must be dropped. If this bit is not set, "nr_pages" is >> + * implicitly 1. >> + */ >> +#define ENCODED_PAGE_BIT_NR_PAGES 2ul > > nit: Perhaps this should be called ENCODED_PAGE_BIT_NR_PAGES_NEXT? There are a > couple of places where you check for this bit on the current entry and advance > to the next. So the "_NEXT" might make things clearer? Yes, makes sense, thanks for the suggestion. -- Cheers, David / dhildenb