From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A9EF7E576 for ; Fri, 26 Apr 2024 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714104060; cv=none; b=S/IbBCEeK9crVv0WsGKWZx0J3qrbWLzoINj6jv2JLnu6sT/yf3XTuGuJz2HkyCjVgJOwBoKUsZaTPsmLrYE4NbTsyDi7aupTnPjcHAXWJ6os5nqm6AtYw31PXbCvoAUQrE0lfXBMwtZVdQ5YFlCS2SaH6PfysaGo20b1VI59Z04= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714104060; c=relaxed/simple; bh=O4XzrWEFlMN3EyfjoW+QpQ7K6MQY5cYu2k79QF7xmN0=; h=Date:To:From:Subject:Message-Id; b=gAFn+CUmOpEjEMt7th9o9VgNr3ZQrPiP9Qks99l8FpJjRbxoL6vL+Y/kPqxaMdYv6MD9mfeRJyFmLwX8FlFcYwYje/bTDrDAZsqkim562mXqIRIqoZnuek4EIMjGbkG59q/pZ6r7TEb9pXOBl4oojFBcMzHRJMA9OjCvcjweTVk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=wW5YeGg+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="wW5YeGg+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2076C113CD; Fri, 26 Apr 2024 04:00:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1714104059; bh=O4XzrWEFlMN3EyfjoW+QpQ7K6MQY5cYu2k79QF7xmN0=; h=Date:To:From:Subject:From; b=wW5YeGg++A3xScKKPKHtVah/5JVGzShs2xcijEIWPQBCtAP8qOX46cckbU3y+hdDm Q99DD0XQp3En8cyq02qLqe65JBSOvhhhLCd6XdiWyYVFthKRMls4aWyArl/m+fuwgM K7iNQFJkugVOIi39yN/iIjAzYTyKoIvWI5ldZx90= Date: Thu, 25 Apr 2024 21:00:59 -0700 To: mm-commits@vger.kernel.org,willy@infradead.org,vbabka@suse.cz,shy828301@gmail.com,ryan.roberts@arm.com,rppt@kernel.org,riel@surriel.com,muchun.song@linux.dev,mpe@ellerman.id.au,lstoakes@gmail.com,kirill@shutemov.name,jthoughton@google.com,jhubbard@nvidia.com,jgg@nvidia.com,hch@infradead.org,david@redhat.com,christophe.leroy@csgroup.eu,axelrasmussen@google.com,aneesh.kumar@kernel.org,andrew.jones@linux.dev,aarcange@redhat.com,peterx@redhat.com,akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-stable] mm-gup-refactor-record_subpages-to-find-1st-small-page.patch removed from -mm tree Message-Id: <20240426040059.D2076C113CD@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The quilt patch titled Subject: mm/gup: refactor record_subpages() to find 1st small page has been removed from the -mm tree. Its filename was mm-gup-refactor-record_subpages-to-find-1st-small-page.patch This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: Peter Xu Subject: mm/gup: refactor record_subpages() to find 1st small page Date: Wed, 27 Mar 2024 11:23:26 -0400 All the fast-gup functions take a tail page to operate, always need to do page mask calculations before feeding that into record_subpages(). Merge that logic into record_subpages(), so that it will do the nth_page() calculation. Link: https://lkml.kernel.org/r/20240327152332.950956-8-peterx@redhat.com Signed-off-by: Peter Xu Reviewed-by: Jason Gunthorpe Tested-by: Ryan Roberts Cc: Andrea Arcangeli Cc: Andrew Jones Cc: Aneesh Kumar K.V (IBM) Cc: Axel Rasmussen Cc: Christophe Leroy Cc: Christoph Hellwig Cc: David Hildenbrand Cc: James Houghton Cc: John Hubbard Cc: Kirill A. Shutemov Cc: Lorenzo Stoakes Cc: Matthew Wilcox (Oracle) Cc: Michael Ellerman Cc: "Mike Rapoport (IBM)" Cc: Muchun Song Cc: Rik van Riel Cc: Vlastimil Babka Cc: Yang Shi Signed-off-by: Andrew Morton --- mm/gup.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) --- a/mm/gup.c~mm-gup-refactor-record_subpages-to-find-1st-small-page +++ a/mm/gup.c @@ -2789,13 +2789,16 @@ static int __gup_device_huge_pud(pud_t p } #endif -static int record_subpages(struct page *page, unsigned long addr, - unsigned long end, struct page **pages) +static int record_subpages(struct page *page, unsigned long sz, + unsigned long addr, unsigned long end, + struct page **pages) { + struct page *start_page; int nr; + start_page = nth_page(page, (addr & (sz - 1)) >> PAGE_SHIFT); for (nr = 0; addr != end; nr++, addr += PAGE_SIZE) - pages[nr] = nth_page(page, nr); + pages[nr] = nth_page(start_page, nr); return nr; } @@ -2830,8 +2833,8 @@ static int gup_hugepte(pte_t *ptep, unsi /* hugepages are never "special" */ VM_BUG_ON(!pfn_valid(pte_pfn(pte))); - page = nth_page(pte_page(pte), (addr & (sz - 1)) >> PAGE_SHIFT); - refs = record_subpages(page, addr, end, pages + *nr); + page = pte_page(pte); + refs = record_subpages(page, sz, addr, end, pages + *nr); folio = try_grab_folio(page, refs, flags); if (!folio) @@ -2904,8 +2907,8 @@ static int gup_huge_pmd(pmd_t orig, pmd_ pages, nr); } - page = nth_page(pmd_page(orig), (addr & ~PMD_MASK) >> PAGE_SHIFT); - refs = record_subpages(page, addr, end, pages + *nr); + page = pmd_page(orig); + refs = record_subpages(page, PMD_SIZE, addr, end, pages + *nr); folio = try_grab_folio(page, refs, flags); if (!folio) @@ -2948,8 +2951,8 @@ static int gup_huge_pud(pud_t orig, pud_ pages, nr); } - page = nth_page(pud_page(orig), (addr & ~PUD_MASK) >> PAGE_SHIFT); - refs = record_subpages(page, addr, end, pages + *nr); + page = pud_page(orig); + refs = record_subpages(page, PUD_SIZE, addr, end, pages + *nr); folio = try_grab_folio(page, refs, flags); if (!folio) @@ -2988,8 +2991,8 @@ static int gup_huge_pgd(pgd_t orig, pgd_ BUILD_BUG_ON(pgd_devmap(orig)); - page = nth_page(pgd_page(orig), (addr & ~PGDIR_MASK) >> PAGE_SHIFT); - refs = record_subpages(page, addr, end, pages + *nr); + page = pgd_page(orig); + refs = record_subpages(page, PGDIR_SIZE, addr, end, pages + *nr); folio = try_grab_folio(page, refs, flags); if (!folio) _ Patches currently in -mm which might be from peterx@redhat.com are mm-userfaultfd-reset-ptes-when-close-for-wr-protected-ones.patch mm-hugetlb-assert-hugetlb_lock-in-__hugetlb_cgroup_commit_charge.patch mm-page_table_check-support-userfault-wr-protect-entries.patch