From patchwork Fri Aug 2 15:55:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13751750 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 2A1C1C3DA4A for ; Fri, 2 Aug 2024 15:56:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4C516B009B; Fri, 2 Aug 2024 11:56:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC9B06B009C; Fri, 2 Aug 2024 11:56:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96C8F6B009D; Fri, 2 Aug 2024 11:56:27 -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 7731A6B009B for ; Fri, 2 Aug 2024 11:56:27 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3A37E1611E7 for ; Fri, 2 Aug 2024 15:56:27 +0000 (UTC) X-FDA: 82407757614.19.9A367DF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 8B12C1C0005 for ; Fri, 2 Aug 2024 15:56:25 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="ethd7/TO"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.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=1722614138; a=rsa-sha256; cv=none; b=GQ1cImYOTvWhXRNMZ6u7FLpNsTJOve/LJr5m99wuBe4ULQxTiku1Gp5lYzortdv3HyYpct BU9inUnZLXNa/+D2gTRkWhjdi7wwTMb2yrnCJCeLcOs6sW0OYCv0DjvwaCBrCwM1tSdwb1 iawwrtgcIh0txCHp7x+fKQ12gVcu5fw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="ethd7/TO"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.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=1722614138; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Mv/si6kOfwIvneZw24kO6Mkvevsw9QN/WnWMpKXtofY=; b=ZE6cyOEkF+nE/UC3gPZRTX5cjbl7H45RX4oB1QyOUX7KN4+k1dQUmy4FGosEzVUW1/2cwU z09kUJTHFtQgNcHvZYzDk5VEh5/dNGSxEKcy48fEfV3YNGY2TRb2okb0YT0gHU2X3xs2/I zoPF+cPC4K05FpKY3RZGJaON32eH4ds= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722614184; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mv/si6kOfwIvneZw24kO6Mkvevsw9QN/WnWMpKXtofY=; b=ethd7/TOR6mOGjdtHCtCfoMV4pv4EClKlB1peSKIx/PFd4JX+M841h7GUnM2r+IzDVa1G2 6AvQhVq5g3O3cdLW27WY0s9mI9qANhSHdJSlLim62oPBm1nzIyv1yWrYfHS/y/GD6ubdg8 BiHnzzWPt45k89nShtRF7s6fJCgvNes= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-261-HVr8hLF5NxywldDisXzbUw-1; Fri, 02 Aug 2024 11:56:21 -0400 X-MC-Unique: HVr8hLF5NxywldDisXzbUw-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7675919B9A9B; Fri, 2 Aug 2024 15:56:19 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.113]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7F6E1300019D; Fri, 2 Aug 2024 15:56:13 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Jonathan Corbet , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Sven Schnelle , Gerald Schaefer Subject: [PATCH v1 07/11] mm/huge_memory: convert split_huge_pages_pid() from follow_page() to folio_walk Date: Fri, 2 Aug 2024 17:55:20 +0200 Message-ID: <20240802155524.517137-8-david@redhat.com> In-Reply-To: <20240802155524.517137-1-david@redhat.com> References: <20240802155524.517137-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8B12C1C0005 X-Stat-Signature: tzwpea5mggmcg4wnpbmyrrupk1phodj5 X-Rspam-User: X-HE-Tag: 1722614185-410622 X-HE-Meta: U2FsdGVkX18DkWb+NJK3eNHTDoJB6TNVe59E6De8xzaeURZ6WkFcwzZdMqjicrbXGh6Y2of94Urn3tVaOYl+iqjfyiOAFHJVyDOqU5a7El6OBRVWorRlSYdlCQPWDAPt/HugDNlJztin81vxmpixLEeXdYBsqVyvyhBk+ktFw0fWNctetPQnOEQIRwzIX6an42jfI9qfkm60D2rc0Y8l6HNAdZqaFtBmkFuuRBYRVW5qhlXSGwFi8gEfkX/trV04J/KQxk3DCMxwaFSJL9My+U5qff2YjigmCxKJ0mEnLwUIUyfNBQl2Mes+AvONO6OUgBcDzj2DlQvGLmdlYyNJZNcWcMWcvQoloPO2P+FhvQkcWj6KjzuNhOROtHIQu5JuUP6hRCOzwKaOwkbgscT6WYPSAFcFaw6gkCno31U94CpxE9Ya9NFclu1Yn92izeFVPKeG7dAISk9FEuLzY2X7PltqIrEZi+rcM43JGfvo8y7vb5IbI9glwEcqSr15pLF6mtQRIsMCvNY7AIv+9gXRITh7Dl6DL3C1m1eh+DhvDkGXPqZ3eMS7yA4fVDlCD2gIwjo4d/dcJdtLNuU0ksSvJo4NJCsr2X02ztUG7Jwnj16E0JUjbFwPAorabDsJkP49VZgx6Y/KBE9kR6cqqnHPYI+xqarEkxy0rKEvMHwKwBKL4h4PhjhGJU0jts6OZrkTNG0o2fXxOdGOpb/NFDWFTkoPIqy9BsP9Ta2cVWQewg1Ksff3WWEng0ECwcPDtebWyp7S7oatE4FvqR/gc4hjIVifZcsAflnUiM8ESbM/6GEt+At5VZ2f0OWvm2M9oEccwO6sn2LmgOdcsaqlWSotFiqCEVedckBSc4LJM7YeseqHjMRs6vwkbqjTdka3jHDE7kmUCHzbHOX183Qh84CEBf5wT7S8hLo0z7KQqj61YS6bJ6tW1V8gVNLtkzP23v/yndlYQf71yAP25sVMcDS EZmLqFaW SgdKDW3+Eg56w+q6Am3vUgvsaIO9Mq7UCvVY2FAmMZx+3D4eODcWLsHRjdYd8WyYhOg4d1vMsdcvsUk5mouN4bGL322zGiClasMj0EdrdG4eJee48MchtxxevOuDJ0PLKNQvnpVGgzaXvLqmDuPRxNvGaiBuGNBY1MlDHKD2be05DS06ytPj0lMezK6rqf1xG7rX9BCnHqjEKHaGaHzCSDwlmXEV/4mfh1NUbaOl/PrnfyOaaOYYl49y0A20WJ9YI0+D4UcqM3ZvAilzVmUzvoUG3gqWkIjMJ+U4Hz2HND2WAQuPje3gcrsHbcnLCcoR1xrYRgCu2Wl42UA5pdnYqLeWuUw== 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: Let's remove yet another follow_page() user. Note that we have to do the split without holding the PTL, after folio_walk_end(). We don't care about losing the secretmem check in follow_page(). Signed-off-by: David Hildenbrand Signed-off-by: David Hildenbrand --- mm/huge_memory.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 0167dc27e365..697fcf89f975 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -3507,7 +3508,7 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start, */ for (addr = vaddr_start; addr < vaddr_end; addr += PAGE_SIZE) { struct vm_area_struct *vma = vma_lookup(mm, addr); - struct page *page; + struct folio_walk fw; struct folio *folio; if (!vma) @@ -3519,13 +3520,10 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start, continue; } - /* FOLL_DUMP to ignore special (like zero) pages */ - page = follow_page(vma, addr, FOLL_GET | FOLL_DUMP); - - if (IS_ERR_OR_NULL(page)) + folio = folio_walk_start(&fw, vma, addr, 0); + if (!folio) continue; - folio = page_folio(page); if (!is_transparent_hugepage(folio)) goto next; @@ -3544,13 +3542,19 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start, if (!folio_trylock(folio)) goto next; + folio_get(folio); + folio_walk_end(&fw, vma); if (!split_folio_to_order(folio, new_order)) split++; folio_unlock(folio); -next: folio_put(folio); + + cond_resched(); + continue; +next: + folio_walk_end(&fw, vma); cond_resched(); } mmap_read_unlock(mm);