From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA98515B135 for ; Wed, 9 Sep 2026 10:03:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788948221; cv=none; b=VreSebB+eDTKp4C1O+ZcyjZUSw43OujKG20Ol+c509jw3L27B9geWQHdMe/oUm+TZC/M4K71HDbDgoBai2AuO9f1LWXG3bBxkAyve9xxSnGdM6d73HNXnikkwWmjmbkXPxMI3h9uZKJn8XsvafVQjp2rCcqr8Iddb/j9SHkWZNM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788948221; c=relaxed/simple; bh=haV5ijKKeNFA+cVGf0/itoGu5pSxbzf5S7kuITcT64g=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=J+iliNVfrArnj8PjT/B/SnPFpXIFG0scad9diheLkstR8Uh6huweQlFZDyC3rKxhZOgOa+KpyfzcB7QdyS9XkLRO8UseP7NUtBkTbUwqESXrUiY+mitBz/n/06f/M8JaftPcXqxPtjAWQeg/7raxGsS0oVV2XRHOvGylD7aOEVI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SE9CepmM; arc=none smtp.client-ip=209.85.128.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SE9CepmM" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-861f30636f9so84871917b3.0 for ; Wed, 09 Sep 2026 03:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1788948217; x=1789553017; darn=vger.kernel.org; h=content-type:mime-version:references:message-id:in-reply-to:subject :cc:to:from:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=OZLYBDT0mJ+F0yYdyxDNynq3EZCGij4ebq9WOsT9s4c=; b=SE9CepmMPaMBUxXW9zwLm5VleuwwDDnZs5aoA/3cHA99HTqzSrYaHCkyA4mwA0PaUO IW56pnPa4ZrK+KgkGF/gJABWCv9tL04f3tg9ZUtLbcMKg3ecVXVPkn3uzAIM5s4jv07Z Vny3d6oSrB0xtGUwknVbuMY5gVK61X8YO6EMFddtk3wzY+GhS07f9q1teS1N9M7V5EHv Pyn65qz1PJd0JxOg2kHxsdM3ffsGUJs/pJH1br5Xd6Jaeci4tYTxdpdXl0VHPe5flF5F RMdUJ0CTitLvnvLhcnpKwz70fcXNQs3ZUKTZ9zUCCC8Ltp1XJ/diErqyIK+pXhI+TqCx Qehg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788948217; x=1789553017; h=content-type:mime-version:references:message-id:in-reply-to:subject :cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OZLYBDT0mJ+F0yYdyxDNynq3EZCGij4ebq9WOsT9s4c=; b=NuUo0B6jgTzqyfHMA0h1pZsVS/Mbk+uJCNV4ayLaqcZ3jqliYBZ4Cx9/KkfUrN0KbU XnKhw4iQqKLA00XAYy9Po13iP7qhtKUlJf2+Ix5EkwiCXGkkTzNmdOEG/acbgLb8EabT 05OM+2CKDhfYVlkHmuNyjvjaQT95kns9YQF7UZTpTQNcNkQqG8o2n4PyWja441yqoIMb BtRcIUEARHKILPi/+/2idU5mtlDGll7MuKfb3DIgZt/TGHP4LWICWL2eozIhRF3VUBfd XOCuQvSp/DU4McJ+Ev5Q4B8bQBEThA3rNCz5dNmpXZNxBwVIH9Yk6H6VS/ROaLR1+oDG m4pQ== X-Forwarded-Encrypted: i=1; AKwUvBwJt0hnQVa13yl1xpAt8f1gtLlD2FTAdyTGcgZAw1/TdKC6zJF4eWJhY9RPm4bUiwR1sUy7zPGtMkMQOJW+@vger.kernel.org X-Gm-Message-State: AFuF++mBOlr3O+n5oVkhhig7/r/AkrFWFOWx/gWi8yUPs1WYAaGSdYE7 P2DoJ2QYBHKIKg/YyL1e3shg5ya8snFvAcQte34fuH4LIOiJaeXBRsrZrKGchSG72Q== X-Gm-Gg: AYBFou10cL9tTB9ZTB7NX3Pu8+XXw9nPDBZcJnxIVEgcu3QV2WiwZ47JRcmTl3HbGG7 694S3ZkEY8sO2Z34IEJUwIxZbHN6vHCuBY8J7oU7lHgxepthmnBuNc4PdVIlAI9r/dh+LEqrIhQ a6CsjWiB2I0NrFBYAB8nhimiStGwSdFYAEarqSpjQ0l5pKpJiL2EBt/vjUyyA6q7S/YacTvDm7A DW5gM7A32kUaiZOXJuStI9Bn0sF1+LnuSy8wmJ/QIMMRv85coucEcZmiZX/xnoGkSLiMxqUiaIz 9GaXAb2y9JnaZLF5EhqdxnihqgyI620qT0obYqfik7VLCxVYXrfy23HkgySsywyAAMhxlsjce99 Ti++q1SUXJg6OmEWt5iOYAyXoeqUv9u5MMCR4eyYrJ1KR1yWTamX2DBgiNaqM1xoct4Q87sTBDX IDMhko0bdZIvpSkbzPKiaqnVaDR1/QHgCOECXWIF/uM6nN9oh4+oZTMR23/nFYDTiIKjaqvInvo TwRlDZSRBuQ09bm54dtfFAo2xouk/A99kFMxus73Olhmbqk2toCoCujHiHEeOCQ4SEY7g== X-Received: by 2002:a05:690e:4384:b0:66f:8b35:dedd with SMTP id 956f58d0204a3-66fb58f2dd2mr7477525d50.6.1788948216887; Wed, 09 Sep 2026 03:03:36 -0700 (PDT) Received: from darker.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-66fb48ee9easm11934983d50.8.2026.09.09.03.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 03:03:35 -0700 (PDT) Date: Wed, 9 Sep 2026 03:03:30 -0700 (PDT) From: Hugh Dickins To: Andrew Morton cc: Ackerley Tng , Alexander Viro , Alexandre Ghiti , Baolin Wang , Barry Song , Binbin Wu , Christian Brauner , Christoph Hellwig , Christoph Lameter , Claudio Imbrenda , David Hildenbrand , JP Kobryn , Jan Kara , Jens Axboe , Johannes Weiner , Kairui Song , Kiryl Shutsemau , Lance Yang , Leonardo Bras , Lorenzo Stoakes , Marcelo Tosatti , Matthew Wilcox , Mel Gorman , Miaohe Lin , Michal Hocko , Minchan Kim , Muchun Song , Oscar Salvador , Peter Zijlstra , Qi Zheng , Rik van Riel , Sebastian Andrzej Siewior , Shakeel Butt , Suren Baghdasaryan , Vlastimil Babka , Yang Shi , Yu Zhao , Zach O'Keefe , Zi Yan , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 11/26] mm/fbatch: remove migration's PAGE_WAS_MLOCKED lru_add_drain() In-Reply-To: Message-ID: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII A welcome side-effect of mm/mlock.c's mod_mlock_count() succeeding on folios on the per-cpu lru_add fbatch, is that migrate_folio_move() no longer has to lru_add_drain() before remove_migration_ptes() restores a PAGE_WAS_MLOCKED mlock_count: so remove PAGE_WAS_MLOCKED altogether. (Re the "We would like to do something similar for the old page, when unsuccessful" comment above it: that may be easier now, but involve some rearrangement: not researched, so just leave the comment as is.) However: it was uncommon before, for isolate_migratepages_block() to meet a folio on LRU, with suitable refcount, marked mlocked but not yet unevictable: so that got missed when sysctl_compact_unevictable_allowed should not allow it. But now it's a more common case, so check if the folio will become unevictable, by using !folio_evictable() instead. That is more expensive than testing mlocked and unevictable bits: but it is consistent with the decision made once the fbatch gets drained, and is_inaccessible further down depends on the right is_unevictable. Optimize those checks better if they show a regression in practice. Signed-off-by: Hugh Dickins --- mm/compaction.c | 2 +- mm/migrate.c | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 9e045a90ba21..1290b9170cb2 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1113,7 +1113,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, if (!folio_test_lru(folio)) goto isolate_fail_put; - is_unevictable = folio_test_unevictable(folio); + is_unevictable = !folio_evictable(folio); /* Compaction might skip unevictable pages but CMA takes them */ if (!(mode & ISOLATE_UNEVICTABLE) && is_unevictable) diff --git a/mm/migrate.c b/mm/migrate.c index 1939d6ed19c9..364015cbef33 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1147,8 +1147,7 @@ static int move_to_new_folio(struct folio *dst, struct folio *src, */ enum { FOLIO_WAS_MAPPED = BIT(0), - FOLIO_WAS_MLOCKED = BIT(1), - FOLIO_OLD_STATES = FOLIO_WAS_MAPPED | FOLIO_WAS_MLOCKED, + FOLIO_OLD_STATES = FOLIO_WAS_MAPPED, }; static void __migrate_folio_record(struct folio *dst, @@ -1258,8 +1257,6 @@ static int migrate_folio_unmap(new_folio_t get_new_folio, folio_lock(src); } locked = true; - if (folio_test_mlocked(src)) - old_folio_state |= FOLIO_WAS_MLOCKED; if (folio_test_writeback(src)) { /* @@ -1410,9 +1407,6 @@ static int migrate_folio_move(free_folio_t put_new_folio, unsigned long private, * isolated from the unevictable LRU: but this case is the easiest. */ folio_add_lru(dst); - if (old_folio_state & FOLIO_WAS_MLOCKED) - lru_add_drain(); - if (old_folio_state & FOLIO_WAS_MAPPED) remove_migration_ptes(src, dst, 0); -- 2.51.0