Commit f7f9c00d authored by Baolin Wang's avatar Baolin Wang Committed by Andrew Morton
Browse files

mm: change to return bool for isolate_lru_page()

The isolate_lru_page() can only return 0 or -EBUSY, and most users did not
care about the negative error of isolate_lru_page(), except one user in
add_page_for_migration().  So we can convert the isolate_lru_page() to
return a boolean value, which can help to make the code more clear when
checking the return value of isolate_lru_page().

Also convert all users' logic of checking the isolation state.

No functional changes intended.

Link: https://lkml.kernel.org/r/3074c1ab628d9dbf139b33f248a8bc253a3f95f0.1676424378.git.baolin.wang@linux.alibaba.com


Signed-off-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: default avatarSeongJae Park <sj@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent be2d5756
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -113,17 +113,11 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping,
}
EXPORT_SYMBOL(grab_cache_page_write_begin);

int isolate_lru_page(struct page *page)
bool isolate_lru_page(struct page *page)
{
	bool ret;

	if (WARN_RATELIMIT(PageTail(page), "trying to isolate tail page"))
		return -EBUSY;
	ret = folio_isolate_lru((struct folio *)page);
	if (ret)
		return 0;

	return -EBUSY;
		return false;
	return folio_isolate_lru((struct folio *)page);
}

void putback_lru_page(struct page *page)
+1 −1
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ pgprot_t __init early_memremap_pgprot_adjust(resource_size_t phys_addr,
/*
 * in mm/vmscan.c:
 */
int isolate_lru_page(struct page *page);
bool isolate_lru_page(struct page *page);
bool folio_isolate_lru(struct folio *folio);
void putback_lru_page(struct page *page);
void folio_putback_lru(struct folio *folio);
+1 −1
Original line number Diff line number Diff line
@@ -636,7 +636,7 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
		 * Isolate the page to avoid collapsing an hugepage
		 * currently in use by the VM.
		 */
		if (isolate_lru_page(page)) {
		if (!isolate_lru_page(page)) {
			unlock_page(page);
			result = SCAN_DEL_PAGE_LRU;
			goto out;
+2 −2
Original line number Diff line number Diff line
@@ -6176,7 +6176,7 @@ static int mem_cgroup_move_charge_pte_range(pmd_t *pmd,
		target_type = get_mctgt_type_thp(vma, addr, *pmd, &target);
		if (target_type == MC_TARGET_PAGE) {
			page = target.page;
			if (!isolate_lru_page(page)) {
			if (isolate_lru_page(page)) {
				if (!mem_cgroup_move_account(page, true,
							     mc.from, mc.to)) {
					mc.precharge -= HPAGE_PMD_NR;
@@ -6226,7 +6226,7 @@ static int mem_cgroup_move_charge_pte_range(pmd_t *pmd,
			 */
			if (PageTransCompound(page))
				goto put;
			if (!device && isolate_lru_page(page))
			if (!device && !isolate_lru_page(page))
				goto put;
			if (!mem_cgroup_move_account(page, false,
						mc.from, mc.to)) {
+2 −2
Original line number Diff line number Diff line
@@ -846,7 +846,7 @@ static const char * const action_page_types[] = {
 */
static int delete_from_lru_cache(struct page *p)
{
	if (!isolate_lru_page(p)) {
	if (isolate_lru_page(p)) {
		/*
		 * Clear sensible page flags, so that the buddy system won't
		 * complain when the page is unpoison-and-freed.
@@ -2513,7 +2513,7 @@ static bool isolate_page(struct page *page, struct list_head *pagelist)
		bool lru = !__PageMovable(page);

		if (lru)
			isolated = !isolate_lru_page(page);
			isolated = isolate_lru_page(page);
		else
			isolated = !isolate_movable_page(page,
							 ISOLATE_UNEVICTABLE);
Loading