From nobody Sun Oct 5 00:07:09 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 896A627877B for ; Mon, 11 Aug 2025 14:39:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754923200; cv=none; b=EGJrriH1tEDsr8PBy462fH43Cj9MMGZTLSz+wVWx1XrzKc/FtX5nL/KdyaSh4A+duX8+cY4WWIRWYmIf30TCyK8UjJ+XT9gHbwucw8adweWOMjYRhte2L6QvZvl05HZAV8dM6+W780KN5mkdBp0pCmBqNyceAP5j4/7OIxmEShY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754923200; c=relaxed/simple; bh=/RkJtjEV80XxhNf5as20u3EFMwDFY27Gb0v/Rq5JlbA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jYzoXkDoVhFWgZ988G7iSJ/8c1S9zvzEwMr4U+KNIW30dYLPnPT8mwIizLIALNoQ2ZpOOva6/HWaDVQgY2QkuWTEJpx7krABj2AuugrudI/uC2+pxgWN2V6tuqHlysntrfk+Gt7NSz8nYZg3Xv6mDTow+J+x82vBsBmy+yPYqao= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PkayUyg9; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PkayUyg9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1754923197; 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=xm0iYFfBOfajjEoxheRfcdwl0u9A+taNg4Dew7papsc=; b=PkayUyg9xwuO0gq3Iip+vFP2EBfR8K9mq66WdTxJaz3ZPaaFTnty9QABPxDj5i/4ETjuR+ ehyemP/ozAK19swpvFRTWV7RnDwfxgW+dllrtxG3Fr1Z8ErfuAfMU1ZKVPqCi4ENJkZ6LH cRIvqa+vUKPiC8apGDW9XpHSLKyInOg= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-138-PLZ8N_9NOxOxvTiH3QI99A-1; Mon, 11 Aug 2025 10:39:56 -0400 X-MC-Unique: PLZ8N_9NOxOxvTiH3QI99A-1 X-Mimecast-MFC-AGG-ID: PLZ8N_9NOxOxvTiH3QI99A_1754923195 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4595cfed9f4so20642235e9.1 for ; Mon, 11 Aug 2025 07:39:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754923195; x=1755527995; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xm0iYFfBOfajjEoxheRfcdwl0u9A+taNg4Dew7papsc=; b=iBxpd8k8vQxfOch8XgCyVuioI8bEJo9F128MJH0/scibxLd9d/btb7b/zNfjqhG2Ju Zmi9dDT0RapH0Hn0ebwrcCq63jthEK6q3N8BPSU5twGW6MI5ea7SRz6ypr/3UsACMNQk o+5HehJxXNcSjupH8euBesxzsVXpigRu9/zXAW5QglfywvYxaaChqmubx0HGQ3lu6agC d4960xF13FJqmsL9lIN88r/4U+4LoV3Cyoh7U6Ab/wTAttrw0F+TmAvNRs95rDjFvk0P lP8KNq6139/cAM9uoLrzBCB5FUC7HDoCY6EKuxl7tizo8mkguvaPvboh/XrN2wJiurSI RPrw== X-Gm-Message-State: AOJu0YwnrmwaYBhtMBF+27eDJBisMIEoOIPqqN17TkAyeGoTU7vY6JMi lE5xOHXGsC15ku2KDV3rLpbO3yUCc9EvLz3gLOQBi1e+PB9R0XPmiUKo+POCpwzVe8AwcTdHvOQ +xpxwZel5TcFoV5Zuf9NJpPCO2mIiy6nHy80bnI1rJoZ2xOj3cL2S6Hefigh+khf6Ocrp5iKtX8 n3B10uEGVBH+GJBxCt/EFOMA9vN5oXPSMuyoLhBkEMaiUh4A== X-Gm-Gg: ASbGncux621f5JYCPrshH1IGVOwKa0h5ktmyc04LthAnmiq0yN2T5qDwfC2dEcVEyP2 xIY12v/1Wpij5hVO27Q0FDqr1qhoOKUgfJsWL1KvUzlcow9b5yQeLmgVGU90iIphtJhmG33vTi4 qlqf1HExCB8bHfZUQcOQ4PebhlGyfo/cr3dVu3lsyyzWgDvVjRUdpzqzbd9h2MusH5/pq9BGS8z ieciZl2SjuPewaz/mIUGtMuhY25375pBzjW8U9byd+2zAh0n1XmU/ZDrdWSfoNC2TRtkRpSfOZf KgJic3IPaJ8LjQBKxJblbQS3KuoxOGzxdt5XwfGbEWjmnOBK+pLv+g/k0cSKEmFWcNiXavMfhwb ebIoqcPr+IkRFJqwA6asGhDxh X-Received: by 2002:a05:600c:1d01:b0:458:be62:dcd3 with SMTP id 5b1f17b1804b1-459f4f9bd34mr130468655e9.17.1754923195053; Mon, 11 Aug 2025 07:39:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHiigg+0PNvGEb3wRzSSq9JM70VE9hLMIH2EVbNkuJbtlZWW3Ch7GW5N/kbNcHDKqZhLgst/w== X-Received: by 2002:a05:600c:1d01:b0:458:be62:dcd3 with SMTP id 5b1f17b1804b1-459f4f9bd34mr130467845e9.17.1754923194477; Mon, 11 Aug 2025 07:39:54 -0700 (PDT) Received: from localhost (p200300d82f06a600a397de1d2f8bb66f.dip0.t-ipconnect.de. [2003:d8:2f06:a600:a397:de1d:2f8b:b66f]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-459fb43b491sm120611835e9.3.2025.08.11.07.39.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Aug 2025 07:39:54 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-btrfs@vger.kernel.org, jfs-discussion@lists.sourceforge.net, David Hildenbrand , Andrew Morton , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Benjamin LaHaise , Chris Mason , Josef Bacik , David Sterba , Muchun Song , Oscar Salvador , Dave Kleikamp , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Minchan Kim , Sergey Senozhatsky Subject: [PATCH v1 1/2] mm/migrate: remove MIGRATEPAGE_UNMAP Date: Mon, 11 Aug 2025 16:39:47 +0200 Message-ID: <20250811143949.1117439-2-david@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250811143949.1117439-1-david@redhat.com> References: <20250811143949.1117439-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" migrate_folio_unmap() is the only user of MIGRATEPAGE_UNMAP. We want to remove MIGRATEPAGE_* completely. It's rather weird to have a generic MIGRATEPAGE_UNMAP, documented to be returned from address-space callbacks, when it's only used for an internal helper. Let's start by having only a single "success" return value for migrate_folio_unmap() -- 0 -- by moving the "folio was already freed" check into the single caller. There is a remaining comment for PG_isolated, which we renamed to PG_movable_ops_isolated recently and forgot to update. While we might still run into that case with zsmalloc, it's something we want to get rid of soon. So let's just focus that optimization on real folios only for now by excluding movable_ops pages. Note that concurrent freeing can happen at any time and this "already freed" check is not relevant for correctness. Signed-off-by: David Hildenbrand Reviewed-by: Huang Ying Reviewed-by: Lance Yang --- include/linux/migrate.h | 1 - mm/migrate.c | 40 ++++++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index acadd41e0b5cf..40f2b5a37efbb 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -18,7 +18,6 @@ struct migration_target_control; * - zero on page migration success; */ #define MIGRATEPAGE_SUCCESS 0 -#define MIGRATEPAGE_UNMAP 1 =20 /** * struct movable_operations - Driver page migration diff --git a/mm/migrate.c b/mm/migrate.c index 425401b2d4e14..e9dacf1028dc7 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1176,16 +1176,6 @@ static int migrate_folio_unmap(new_folio_t get_new_f= olio, bool locked =3D false; bool dst_locked =3D false; =20 - if (folio_ref_count(src) =3D=3D 1) { - /* Folio was freed from under us. So we are done. */ - folio_clear_active(src); - folio_clear_unevictable(src); - /* free_pages_prepare() will clear PG_isolated. */ - list_del(&src->lru); - migrate_folio_done(src, reason); - return MIGRATEPAGE_SUCCESS; - } - dst =3D get_new_folio(src, private); if (!dst) return -ENOMEM; @@ -1275,7 +1265,7 @@ static int migrate_folio_unmap(new_folio_t get_new_fo= lio, =20 if (unlikely(page_has_movable_ops(&src->page))) { __migrate_folio_record(dst, old_page_state, anon_vma); - return MIGRATEPAGE_UNMAP; + return 0; } =20 /* @@ -1305,7 +1295,7 @@ static int migrate_folio_unmap(new_folio_t get_new_fo= lio, =20 if (!folio_mapped(src)) { __migrate_folio_record(dst, old_page_state, anon_vma); - return MIGRATEPAGE_UNMAP; + return 0; } =20 out: @@ -1848,14 +1838,28 @@ static int migrate_pages_batch(struct list_head *fr= om, continue; } =20 + /* + * If we are holding the last folio reference, the folio + * was freed from under us, so just drop our reference. + */ + if (likely(!page_has_movable_ops(&folio->page)) && + folio_ref_count(folio) =3D=3D 1) { + folio_clear_active(folio); + folio_clear_unevictable(folio); + list_del(&folio->lru); + migrate_folio_done(folio, reason); + stats->nr_succeeded +=3D nr_pages; + stats->nr_thp_succeeded +=3D is_thp; + continue; + } + rc =3D migrate_folio_unmap(get_new_folio, put_new_folio, private, folio, &dst, mode, reason, ret_folios); /* * The rules are: - * Success: folio will be freed - * Unmap: folio will be put on unmap_folios list, - * dst folio put on dst_folios list + * 0: folio will be put on unmap_folios list, + * dst folio put on dst_folios list * -EAGAIN: stay on the from list * -ENOMEM: stay on the from list * Other errno: put on ret_folios list @@ -1905,11 +1909,7 @@ static int migrate_pages_batch(struct list_head *fro= m, thp_retry +=3D is_thp; nr_retry_pages +=3D nr_pages; break; - case MIGRATEPAGE_SUCCESS: - stats->nr_succeeded +=3D nr_pages; - stats->nr_thp_succeeded +=3D is_thp; - break; - case MIGRATEPAGE_UNMAP: + case 0: list_move_tail(&folio->lru, &unmap_folios); list_add_tail(&dst->lru, &dst_folios); break; --=20 2.50.1 From nobody Sun Oct 5 00:07:09 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 18BA4264A60 for ; Mon, 11 Aug 2025 14:40:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754923203; cv=none; b=ZQ2yPE0Lgr5DwKZwm+WmfHfpcPvQDCoy3g0HhCdxG8fAPV1PPouAuMUn7RzSTWw/H3uU/6adGckIMn9dTkQiQt0f9UqetCAS4f6RAO4L8AlQf9fKOZQTa7yVgeVJaop3d7XFKmk2kViDFgmaYN4e/VLSV0SaGjybPR0zNU2eqTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754923203; c=relaxed/simple; bh=8WrMXaATum1+Vfy/MIWeS3UGke6MZg9bbi0gb3hBSoY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r3f/f7ycCWMq/QZVdrzSnYzEZPELXawfQS1ker3H+4YUU2GavTetXRKm3sF/G/7pd81N2mC7DzAt/10tH3tAUGYA8ZNsgrMOLfqQ2nb0pf9BE+adCuNyM+xoVk+AipfkcE0TTCz7UQOPKEqIQQSDp7isQ3pU7+QWYT3d7+9/U58= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BwgUFcdV; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BwgUFcdV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1754923200; 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=K9pQ6cfOAd6CYMjiXktr++2RllUSiQ1vZU8nA2VfkG0=; b=BwgUFcdVKYsFvunt+j9LnKFkospVeU1/ngiurJTDW+2AEXN+Qvzv9/VhlFxWLYtospohIL XZWasxQZFDhjMfCfFx2PoBAlwi/zflz0lWub+TEENeMPD8mjmJ9Wfzw8I41I3eCuMh7TaX 3YM8kP9iB0iGI6+DCXMWrSMX35NRFxU= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-tV2Zht2JOh6I3yPeRwvGPA-1; Mon, 11 Aug 2025 10:39:59 -0400 X-MC-Unique: tV2Zht2JOh6I3yPeRwvGPA-1 X-Mimecast-MFC-AGG-ID: tV2Zht2JOh6I3yPeRwvGPA_1754923198 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4595cfed9f4so20642525e9.1 for ; Mon, 11 Aug 2025 07:39:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754923198; x=1755527998; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K9pQ6cfOAd6CYMjiXktr++2RllUSiQ1vZU8nA2VfkG0=; b=ht5ObthWlN/BxP/bu9qNPADtC5UN1tDGlFq5nYwG05fZrpfQ/FYX2JJRy+xO1thT+L KFhH63rJ79hEtJHGZZcW+KWspgsYoFZJx9R7rZc3xyjaDs8XCM2UABGAMdIpI1FZPwU6 +R/o5xPLPUm7MQGsUffwJN2h+hpJuJXdEGrq8klm3vMQ9BZoWPOBS/cFxEiVLK1FqFgg AecwpxVStP2DS6E8OeKWS/YE+dSKwuGbYOJpke71mRN66oT8i22A+8vSABv2XjuinvUJ J3FaRdEmz1JfHVy88QYzL2BGSV/F+KL2ijKtlIoTjVPStJpPyAsTn915BMYPgcxoapnF 38Jw== X-Gm-Message-State: AOJu0YzZ+/8QuARxCcEsqa7QWVM12GUIQECRUt15hhnCtwPBda1Zu3Ua L7lFo2WrPZXYshiaWAPL9GJXJV2ObsBlaX3cTlE98CTretgfJbOHkysR8tJ7f98orZE/g0/O2xn 2BwOnPXVzznl/+Cu6shwhglZSCsNx1nfyjrWGUGx5UD8nIhAD/VegEDmONQ4U2YcpI+eQz3XCZ0 Y5WER7uN7+1rqzfiyKDRLE+xwvqhiMf8xYZxqLvw+50fP+Og== X-Gm-Gg: ASbGncuNWLEUVUz/jfFlCJpb2/QdEqO/M0kVzB7p8xFf9AvXz9XSFwDSfFylTMJH95A 41GgkVD2r/YN8KZAY/r4w6CmtliuohbVDRe+Gi5KVjn8ffH0Oj/RQR6VvHQ+jXAU0SDp1cQ5fvW 8/I0iMd0mqsLFIb27uxeW4Q4Cfo5LmTrrTAOsoUWndqUHe0oSJPuCkf5heprRUmIjN/289lcJsp QO69oS58+aaVol+IlVIyNxGhJCQKjDvk6+6k95bDEfhoyKpBgd46QSeTS3wRy3cQdSirEjXayNS S7a4ma+s+2z6EViXNY/pmOlmMzc6URVedYP1BYK5qKp9pzngRI/Bh4QXe85jI1pm1CNIsbLV/E5 nToYSkqaSPt6eIQl44025SMu2 X-Received: by 2002:a05:600c:190c:b0:43c:ec4c:25b4 with SMTP id 5b1f17b1804b1-459f4f5292fmr128225655e9.10.1754923197586; Mon, 11 Aug 2025 07:39:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHeJPd1Ge6IawGRqjGvoUIijF7grEq/r+WrWgIGNnqFvFWWeyhF+SV2vqhPS2/Wm5uHjhsRGA== X-Received: by 2002:a05:600c:190c:b0:43c:ec4c:25b4 with SMTP id 5b1f17b1804b1-459f4f5292fmr128224855e9.10.1754923196896; Mon, 11 Aug 2025 07:39:56 -0700 (PDT) Received: from localhost (p200300d82f06a600a397de1d2f8bb66f.dip0.t-ipconnect.de. [2003:d8:2f06:a600:a397:de1d:2f8b:b66f]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-459e5868fd7sm275562255e9.18.2025.08.11.07.39.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Aug 2025 07:39:56 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-btrfs@vger.kernel.org, jfs-discussion@lists.sourceforge.net, David Hildenbrand , Andrew Morton , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Benjamin LaHaise , Chris Mason , Josef Bacik , David Sterba , Muchun Song , Oscar Salvador , Dave Kleikamp , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Minchan Kim , Sergey Senozhatsky Subject: [PATCH v1 2/2] treewide: remove MIGRATEPAGE_SUCCESS Date: Mon, 11 Aug 2025 16:39:48 +0200 Message-ID: <20250811143949.1117439-3-david@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250811143949.1117439-1-david@redhat.com> References: <20250811143949.1117439-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" At this point MIGRATEPAGE_SUCCESS is misnamed for all folio users, and now that we remove MIGRATEPAGE_UNMAP, it's really the only "success" return value that the code uses and expects. Let's just get rid of MIGRATEPAGE_SUCCESS completely and just use "0" for success. Signed-off-by: David Hildenbrand Acked-by: Dave Kleikamp Acked-by: David Sterba Acked-by: Greg Kroah-Hartman Acked-by: Sergey Senozhatsky [zsmalloc] Reviewed-by: Byungchul Park Reviewed-by: Huang Ying --- arch/powerpc/platforms/pseries/cmm.c | 2 +- drivers/misc/vmw_balloon.c | 4 +-- drivers/virtio/virtio_balloon.c | 2 +- fs/aio.c | 2 +- fs/btrfs/inode.c | 4 +-- fs/hugetlbfs/inode.c | 4 +-- fs/jfs/jfs_metapage.c | 8 +++--- include/linux/migrate.h | 10 +------ mm/migrate.c | 40 +++++++++++++--------------- mm/migrate_device.c | 2 +- mm/zsmalloc.c | 4 +-- 11 files changed, 36 insertions(+), 46 deletions(-) diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/= pseries/cmm.c index 5e0a718d1be7b..0823fa2da1516 100644 --- a/arch/powerpc/platforms/pseries/cmm.c +++ b/arch/powerpc/platforms/pseries/cmm.c @@ -545,7 +545,7 @@ static int cmm_migratepage(struct balloon_dev_info *b_d= ev_info, /* balloon page list reference */ put_page(page); =20 - return MIGRATEPAGE_SUCCESS; + return 0; } =20 static void cmm_balloon_compaction_init(void) diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index 6653fc53c951c..6df51ee8db621 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -1806,7 +1806,7 @@ static int vmballoon_migratepage(struct balloon_dev_i= nfo *b_dev_info, * the list after acquiring the lock. */ get_page(newpage); - ret =3D MIGRATEPAGE_SUCCESS; + ret =3D 0; } =20 /* Update the balloon list under the @pages_lock */ @@ -1817,7 +1817,7 @@ static int vmballoon_migratepage(struct balloon_dev_i= nfo *b_dev_info, * If we succeed just insert it to the list and update the statistics * under the lock. */ - if (ret =3D=3D MIGRATEPAGE_SUCCESS) { + if (!ret) { balloon_page_insert(&b->b_dev_info, newpage); __count_vm_event(BALLOON_MIGRATE); } diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloo= n.c index e299e18346a30..eae65136cdfb5 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -875,7 +875,7 @@ static int virtballoon_migratepage(struct balloon_dev_i= nfo *vb_dev_info, balloon_page_finalize(page); put_page(page); /* balloon reference */ =20 - return MIGRATEPAGE_SUCCESS; + return 0; } #endif /* CONFIG_BALLOON_COMPACTION */ =20 diff --git a/fs/aio.c b/fs/aio.c index 7fc7b6221312c..059e03cfa088c 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -445,7 +445,7 @@ static int aio_migrate_folio(struct address_space *mapp= ing, struct folio *dst, folio_get(dst); =20 rc =3D folio_migrate_mapping(mapping, dst, src, 1); - if (rc !=3D MIGRATEPAGE_SUCCESS) { + if (rc) { folio_put(dst); goto out_unlock; } diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index b77dd22b8cdbe..1d64fee6f59e6 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7411,7 +7411,7 @@ static int btrfs_migrate_folio(struct address_space *= mapping, { int ret =3D filemap_migrate_folio(mapping, dst, src, mode); =20 - if (ret !=3D MIGRATEPAGE_SUCCESS) + if (ret) return ret; =20 if (folio_test_ordered(src)) { @@ -7419,7 +7419,7 @@ static int btrfs_migrate_folio(struct address_space *= mapping, folio_set_ordered(dst); } =20 - return MIGRATEPAGE_SUCCESS; + return 0; } #else #define btrfs_migrate_folio NULL diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 09d4baef29cf9..34d496a2b7de6 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1052,7 +1052,7 @@ static int hugetlbfs_migrate_folio(struct address_spa= ce *mapping, int rc; =20 rc =3D migrate_huge_page_move_mapping(mapping, dst, src); - if (rc !=3D MIGRATEPAGE_SUCCESS) + if (rc) return rc; =20 if (hugetlb_folio_subpool(src)) { @@ -1063,7 +1063,7 @@ static int hugetlbfs_migrate_folio(struct address_spa= ce *mapping, =20 folio_migrate_flags(dst, src); =20 - return MIGRATEPAGE_SUCCESS; + return 0; } #else #define hugetlbfs_migrate_folio NULL diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c index b98cf3bb6c1fe..871cf4fb36366 100644 --- a/fs/jfs/jfs_metapage.c +++ b/fs/jfs/jfs_metapage.c @@ -169,7 +169,7 @@ static int __metapage_migrate_folio(struct address_spac= e *mapping, } =20 rc =3D filemap_migrate_folio(mapping, dst, src, mode); - if (rc !=3D MIGRATEPAGE_SUCCESS) + if (rc) return rc; =20 for (i =3D 0; i < MPS_PER_PAGE; i++) { @@ -199,7 +199,7 @@ static int __metapage_migrate_folio(struct address_spac= e *mapping, } } =20 - return MIGRATEPAGE_SUCCESS; + return 0; } #endif /* CONFIG_MIGRATION */ =20 @@ -242,7 +242,7 @@ static int __metapage_migrate_folio(struct address_spac= e *mapping, return -EAGAIN; =20 rc =3D filemap_migrate_folio(mapping, dst, src, mode); - if (rc !=3D MIGRATEPAGE_SUCCESS) + if (rc) return rc; =20 if (unlikely(insert_metapage(dst, mp))) @@ -253,7 +253,7 @@ static int __metapage_migrate_folio(struct address_spac= e *mapping, mp->folio =3D dst; remove_metapage(src, mp); =20 - return MIGRATEPAGE_SUCCESS; + return 0; } #endif /* CONFIG_MIGRATION */ =20 diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 40f2b5a37efbb..02f11704fb686 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -12,13 +12,6 @@ typedef void free_folio_t(struct folio *folio, unsigned = long private); =20 struct migration_target_control; =20 -/* - * Return values from addresss_space_operations.migratepage(): - * - negative errno on page migration failure; - * - zero on page migration success; - */ -#define MIGRATEPAGE_SUCCESS 0 - /** * struct movable_operations - Driver page migration * @isolate_page: @@ -34,8 +27,7 @@ struct migration_target_control; * @src page. The driver should copy the contents of the * @src page to the @dst page and set up the fields of @dst page. * Both pages are locked. - * If page migration is successful, the driver should - * return MIGRATEPAGE_SUCCESS. + * If page migration is successful, the driver should return 0. * If the driver cannot migrate the page at the moment, it can return * -EAGAIN. The VM interprets this as a temporary migration failure and * will retry it later. Any other error value is a permanent migration diff --git a/mm/migrate.c b/mm/migrate.c index e9dacf1028dc7..2db4974178e6a 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -209,18 +209,17 @@ static void putback_movable_ops_page(struct page *pag= e) * src and dst are also released by migration core. These pages will not be * folios in the future, so that must be reworked. * - * Returns MIGRATEPAGE_SUCCESS on success, otherwise a negative error - * code. + * Returns 0 on success, otherwise a negative error code. */ static int migrate_movable_ops_page(struct page *dst, struct page *src, enum migrate_mode mode) { - int rc =3D MIGRATEPAGE_SUCCESS; + int rc; =20 VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(src), src); VM_WARN_ON_ONCE_PAGE(!PageMovableOpsIsolated(src), src); rc =3D page_movable_ops(src)->migrate_page(dst, src, mode); - if (rc =3D=3D MIGRATEPAGE_SUCCESS) + if (!rc) ClearPageMovableOpsIsolated(src); return rc; } @@ -565,7 +564,7 @@ static int __folio_migrate_mapping(struct address_space= *mapping, if (folio_test_swapbacked(folio)) __folio_set_swapbacked(newfolio); =20 - return MIGRATEPAGE_SUCCESS; + return 0; } =20 oldzone =3D folio_zone(folio); @@ -666,7 +665,7 @@ static int __folio_migrate_mapping(struct address_space= *mapping, } local_irq_enable(); =20 - return MIGRATEPAGE_SUCCESS; + return 0; } =20 int folio_migrate_mapping(struct address_space *mapping, @@ -715,7 +714,7 @@ int migrate_huge_page_move_mapping(struct address_space= *mapping, =20 xas_unlock_irq(&xas); =20 - return MIGRATEPAGE_SUCCESS; + return 0; } =20 /* @@ -831,14 +830,14 @@ static int __migrate_folio(struct address_space *mapp= ing, struct folio *dst, return rc; =20 rc =3D __folio_migrate_mapping(mapping, dst, src, expected_count); - if (rc !=3D MIGRATEPAGE_SUCCESS) + if (rc) return rc; =20 if (src_private) folio_attach_private(dst, folio_detach_private(src)); =20 folio_migrate_flags(dst, src); - return MIGRATEPAGE_SUCCESS; + return 0; } =20 /** @@ -945,7 +944,7 @@ static int __buffer_migrate_folio(struct address_space = *mapping, } =20 rc =3D filemap_migrate_folio(mapping, dst, src, mode); - if (rc !=3D MIGRATEPAGE_SUCCESS) + if (rc) goto unlock_buffers; =20 bh =3D head; @@ -1049,7 +1048,7 @@ static int fallback_migrate_folio(struct address_spac= e *mapping, * * Return value: * < 0 - error code - * MIGRATEPAGE_SUCCESS - success + * 0 - success */ static int move_to_new_folio(struct folio *dst, struct folio *src, enum migrate_mode mode) @@ -1077,7 +1076,7 @@ static int move_to_new_folio(struct folio *dst, struc= t folio *src, else rc =3D fallback_migrate_folio(mapping, dst, src, mode); =20 - if (rc =3D=3D MIGRATEPAGE_SUCCESS) { + if (!rc) { /* * For pagecache folios, src->mapping must be cleared before src * is freed. Anonymous folios must stay anonymous until freed. @@ -1427,7 +1426,7 @@ static int unmap_and_move_huge_page(new_folio_t get_n= ew_folio, if (folio_ref_count(src) =3D=3D 1) { /* page was freed from under us. So we are done. */ folio_putback_hugetlb(src); - return MIGRATEPAGE_SUCCESS; + return 0; } =20 dst =3D get_new_folio(src, private); @@ -1490,8 +1489,7 @@ static int unmap_and_move_huge_page(new_folio_t get_n= ew_folio, rc =3D move_to_new_folio(dst, src, mode); =20 if (page_was_mapped) - remove_migration_ptes(src, - rc =3D=3D MIGRATEPAGE_SUCCESS ? dst : src, 0); + remove_migration_ptes(src, !rc ? dst : src, 0); =20 unlock_put_anon: folio_unlock(dst); @@ -1500,7 +1498,7 @@ static int unmap_and_move_huge_page(new_folio_t get_n= ew_folio, if (anon_vma) put_anon_vma(anon_vma); =20 - if (rc =3D=3D MIGRATEPAGE_SUCCESS) { + if (!rc) { move_hugetlb_state(src, dst, reason); put_new_folio =3D NULL; } @@ -1508,7 +1506,7 @@ static int unmap_and_move_huge_page(new_folio_t get_n= ew_folio, out_unlock: folio_unlock(src); out: - if (rc =3D=3D MIGRATEPAGE_SUCCESS) + if (!rc) folio_putback_hugetlb(src); else if (rc !=3D -EAGAIN) list_move_tail(&src->lru, ret); @@ -1618,7 +1616,7 @@ static int migrate_hugetlbs(struct list_head *from, n= ew_folio_t get_new_folio, reason, ret_folios); /* * The rules are: - * Success: hugetlb folio will be put back + * 0: hugetlb folio will be put back * -EAGAIN: stay on the from list * -ENOMEM: stay on the from list * Other errno: put on ret_folios list @@ -1635,7 +1633,7 @@ static int migrate_hugetlbs(struct list_head *from, n= ew_folio_t get_new_folio, retry++; nr_retry_pages +=3D nr_pages; break; - case MIGRATEPAGE_SUCCESS: + case 0: stats->nr_succeeded +=3D nr_pages; break; default: @@ -1689,7 +1687,7 @@ static void migrate_folios_move(struct list_head *src= _folios, reason, ret_folios); /* * The rules are: - * Success: folio will be freed + * 0: folio will be freed * -EAGAIN: stay on the unmap_folios list * Other errno: put on ret_folios list */ @@ -1699,7 +1697,7 @@ static void migrate_folios_move(struct list_head *src= _folios, *thp_retry +=3D is_thp; *nr_retry_pages +=3D nr_pages; break; - case MIGRATEPAGE_SUCCESS: + case 0: stats->nr_succeeded +=3D nr_pages; stats->nr_thp_succeeded +=3D is_thp; break; diff --git a/mm/migrate_device.c b/mm/migrate_device.c index e05e14d6eacdb..abd9f6850db65 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -778,7 +778,7 @@ static void __migrate_device_pages(unsigned long *src_p= fns, if (migrate && migrate->fault_page =3D=3D page) extra_cnt =3D 1; r =3D folio_migrate_mapping(mapping, newfolio, folio, extra_cnt); - if (r !=3D MIGRATEPAGE_SUCCESS) + if (r) src_pfns[i] &=3D ~MIGRATE_PFN_MIGRATE; else folio_migrate_flags(newfolio, folio); diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 2c5e56a653544..84eb91d47a226 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1746,7 +1746,7 @@ static int zs_page_migrate(struct page *newpage, stru= ct page *page, * instead. */ if (!zpdesc->zspage) - return MIGRATEPAGE_SUCCESS; + return 0; =20 /* The page is locked, so this pointer must remain valid */ zspage =3D get_zspage(zpdesc); @@ -1813,7 +1813,7 @@ static int zs_page_migrate(struct page *newpage, stru= ct page *page, reset_zpdesc(zpdesc); zpdesc_put(zpdesc); =20 - return MIGRATEPAGE_SUCCESS; + return 0; } =20 static void zs_page_putback(struct page *page) --=20 2.50.1