From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63ACD3E073D for ; Thu, 23 Jul 2026 07:10:20 +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=1784790624; cv=none; b=APTBCjZwiPzhItn9NOmikRz7GgWxF9Kdos67QAvRTR87kBUJgSHVeeoqfRGVlO9IzTeqmv39etDWndh0NtQONiYgX0SsuC37F0oBP2M/f3J0OX1PAge5/FqddAS06AJkM+2x3bH7CK45FTfhivjnbQuKzz+8Dv/9Yu52JmdNy00= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784790624; c=relaxed/simple; bh=B0Ateg28ZulVYTvLgCnS5RzZ0jyHIGM6ERhGQEjXq6k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VMbeKkg2yGY0Pv6N+xpHNn/cIXJnrSdrlMOjpo+nAYemOGcJT4eedIyOQu+5qNf3O/vgrxv4h3DAyIac+zx/amaTA4lb8la5nx+MRFPoUpJDmz39kuHF0ZxYK8xkN/PyVMownq7L8zvbbQBDfCgOcfwT62fsnX81wMo1cpiGuzs= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=iFRumHWB; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="iFRumHWB" 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 69DDF1A2D; Thu, 23 Jul 2026 00:10:07 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-01.blr.arm.com (cesw-amp-gbt-1s-m12830-01.blr.arm.com [10.164.195.33]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AEA743F66F; Thu, 23 Jul 2026 00:10:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784790611; bh=B0Ateg28ZulVYTvLgCnS5RzZ0jyHIGM6ERhGQEjXq6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iFRumHWB5p0fFec+k2QbiSGOLO8WXPV4fh5pFjnkU0ZowQ544zEoCYX4jVUygKkCK cUCxM60AIbb+qISG2r03haAvJPteCnFY5HKieL8paJoD4twRbEWh3aMh6OsMRal2Fg CvMRllLQzVbwpMAXyeh8OcoqF1WwtR3PLAeCfR+0= From: Dev Jain To: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, hughd@google.com, chrisl@kernel.org, kasong@tencent.com Cc: Dev Jain , riel@surriel.com, liam@infradead.org, vbabka@kernel.org, harry@kernel.org, jannh@google.com, lance.yang@linux.dev, baolin.wang@linux.alibaba.com, shikemeng@huaweicloud.com, nphamcs@gmail.com, baoquan.he@linux.dev, baohua@kernel.org, youngjun.park@lge.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, pfalcato@suse.de, ryan.roberts@arm.com, anshuman.khandual@arm.com Subject: [PATCH 7/8] mm: move anon-exclusive batch helper to internal.h Date: Thu, 23 Jul 2026 07:09:03 +0000 Message-ID: <20260723070905.3422276-8-dev.jain@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260723070905.3422276-1-dev.jain@arm.com> References: <20260723070905.3422276-1-dev.jain@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In preparation for optimizing large folio unmapping, we need to reuse the page_anon_exclusive_batch helper in rmap.c. Therefore, move it from mprotect.c to internal.h. Signed-off-by: Dev Jain --- mm/internal.h | 17 +++++++++++++++++ mm/mprotect.c | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 3fc1c1c776ca3..df799d0c24e0b 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -474,6 +474,23 @@ static inline unsigned int folio_pte_batch_flags(struct folio *folio, unsigned int folio_pte_batch(struct folio *folio, pte_t *ptep, pte_t pte, unsigned int max_nr); +/* + * Get max length of consecutive PTEs pointing to PageAnonExclusive() pages or + * !PageAnonExclusive() pages, starting from start_idx. Caller must enforce + * that the PTEs point to consecutive pages of the same anon large folio. + */ +static __always_inline int page_anon_exclusive_batch(int start_idx, int max_len, + struct page *first_page, bool expected_anon_exclusive) +{ + int idx; + + for (idx = start_idx + 1; idx < start_idx + max_len; ++idx) { + if (expected_anon_exclusive != PageAnonExclusive(first_page + idx)) + break; + } + return idx - start_idx; +} + /** * pte_move_softleaf_offset - Move the softleaf entry offset field of a * softleaf pte forward or backward by delta diff --git a/mm/mprotect.c b/mm/mprotect.c index 2888ee638d872..75c2b1a00eb36 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -138,23 +138,6 @@ static __always_inline void prot_commit_flush_ptes(struct vm_area_struct *vma, tlb_flush_pte_range(tlb, addr, nr_ptes * PAGE_SIZE); } -/* - * Get max length of consecutive ptes pointing to PageAnonExclusive() pages or - * !PageAnonExclusive() pages, starting from start_idx. Caller must enforce - * that the ptes point to consecutive pages of the same anon large folio. - */ -static __always_inline int page_anon_exclusive_batch(int start_idx, int max_len, - struct page *first_page, bool expected_anon_exclusive) -{ - int idx; - - for (idx = start_idx + 1; idx < start_idx + max_len; ++idx) { - if (expected_anon_exclusive != PageAnonExclusive(first_page + idx)) - break; - } - return idx - start_idx; -} - /* * This function is a result of trying our very best to retain the * "avoid the write-fault handler" optimization. In can_change_pte_writable(), -- 2.43.0