From patchwork Thu Nov 7 23:56:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13867336 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 644AAD5D695 for ; Thu, 7 Nov 2024 23:56:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4425A6B00AB; Thu, 7 Nov 2024 18:56:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A3F96B00AC; Thu, 7 Nov 2024 18:56:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CC8B6B00AD; Thu, 7 Nov 2024 18:56:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E98176B00AB for ; Thu, 7 Nov 2024 18:56:36 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 93C4C14060E for ; Thu, 7 Nov 2024 23:56:36 +0000 (UTC) X-FDA: 82760960100.23.00DAB57 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) by imf28.hostedemail.com (Postfix) with ESMTP id 050CBC000A for ; Thu, 7 Nov 2024 23:55:57 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="bQrlBYi/"; spf=pass (imf28.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.182 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731023607; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=u2CBAn6giMXXiKhPOgLeKDCo9Vrjd3aYf+IrGQBfRgc=; b=aH90anb35MTHtquH17yrkZRcgyvxZKJbH0eHi/2lrfqnSKYV7l2zJ8zqk/XFITt8Ry4FKi ean6LrUFPvvsq8SgkiW+s43eqW5jdQ3uSCPWAvhtAakIvRQL22JQs1V0JBarwSG9zGPAxp VXr3vBmXnlxXTjf/YW8DEIhBbziwppk= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="bQrlBYi/"; spf=pass (imf28.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.182 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731023607; a=rsa-sha256; cv=none; b=vGEUHzM2b38z2Exfo1vAPdb+lqhUy2aMWIJPu2a0s/VliWqHwq4v0YtpNGux4e8+IjGwAs blLb2bHl9/Qxul0k+QaRrr2K7JLv9qmWYA0PszbidXzgVPiiLzosHIF0gJPcNzT3y83Q+m zeU08oevs1+tV/aW4+4NG1TMrvjAt/w= Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-6e34339d41bso13495917b3.0 for ; Thu, 07 Nov 2024 15:56:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731023794; x=1731628594; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u2CBAn6giMXXiKhPOgLeKDCo9Vrjd3aYf+IrGQBfRgc=; b=bQrlBYi/QAkUvF9w42JNRIANR/z00Tvo794yKwzpWmdHqoUKNy8+JhHbmAJvEFwrHM 7SA/D3xFyi9aTP6PzT3xiLL/zVJeIyoVe12uPG4GAHivCcuPuCtPgyQITd1rA8/tvT1D M1CA15KUwTAKg8fkv8RQWoUKF2bS45mYBl0TJ7j5/5ER5fWY3qP8ZkgXKSyARWLT5fL+ v5OD9awzPA8FJdmmTBeREQH0MgORMZfau+r5qQlupNj7kOHaKfOhqzXLBFpXQqVbIvyn jVcPNaZjUzRZ8+lDyPtPbjQQeOJ3CfRn9CANDUccBvIFxQnN/f+krVRF/kOKxNDuelrV Pb8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731023794; x=1731628594; 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=u2CBAn6giMXXiKhPOgLeKDCo9Vrjd3aYf+IrGQBfRgc=; b=jh2xdPt6YKZzLlBUfng3Arm0SpfYL4EeDKt8m88AxAtKmpRfmi5bvYEJkPnivWkSDs YhEKW15Zrxt1m/i1Ah2xyz3aDIVQKyjBmRS+aoFEOjfSQXDZgu72aURWUtQx1iXGHiPP WvHCfN/hKze06eYpKAQLd7SS6aE5q0+ey8ODB/jeEjW6bsqxWRD5nZbSBcB/beGnn4IW +LWK0I5twxlOf2M0xXU8xNkO8sQ5W5s6IW1VXNZgb6/hJD70Si1af141fCSiyJA8O3oc hGCxMZIqe07+/FHI4swmzczHmv5jRklhQkCCcRdZX6ihg8z0SrcXwkBFNauUvqXhI2uD 71eA== X-Forwarded-Encrypted: i=1; AJvYcCXMnNeSDNSOYQ1ICij5FsO1Ph9y4/vYUl8qoH7TrAGX0K+le6xNpFJOQq+6KKpcHfvUhOAgNzHXxQ==@kvack.org X-Gm-Message-State: AOJu0YwY582LDy4xgeIqATIOxbhYAnFLAVewm59u0CWhElfz3BsGIoOg 4KJnGxAglUZtHGONHeNrW4b7pzBuhvYWP72zAc4Nu9DC1sxKqL0t X-Google-Smtp-Source: AGHT+IEFzO2Zgam/gnWf8Abfux5tkvxODQuWALP1dfzNCjLg2EJGoSDqARXu4PrQApxNEjREq7Rfug== X-Received: by 2002:a05:690c:46c6:b0:6ea:95f5:25fb with SMTP id 00721157ae682-6eaddd704c0mr12260067b3.3.1731023793872; Thu, 07 Nov 2024 15:56:33 -0800 (PST) Received: from localhost (fwdproxy-nha-014.fbsv.net. [2a03:2880:25ff:e::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eaceb09a6fsm5009617b3.68.2024.11.07.15.56.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 15:56:33 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: shakeel.butt@linux.dev, jefflexu@linux.alibaba.com, josef@toxicpanda.com, linux-mm@kvack.org, bernd.schubert@fastmail.fm, kernel-team@meta.com Subject: [PATCH v4 4/6] mm/memory-hotplug: add finite retries in offline_pages() if migration fails Date: Thu, 7 Nov 2024 15:56:12 -0800 Message-ID: <20241107235614.3637221-5-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241107235614.3637221-1-joannelkoong@gmail.com> References: <20241107235614.3637221-1-joannelkoong@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 050CBC000A X-Stat-Signature: rqw7ocab59iiesrod4gm4zmsraznfwdm X-Rspam-User: X-HE-Tag: 1731023757-436086 X-HE-Meta: U2FsdGVkX1/PLpJWemJR1X1xSh1ZXuRl6eJe/KXO5qtCFS+Qrwwu++AN49ag75e34FC7OADHFoslNadDs2AOWMUnqXBXSL8X2GAmEVsovjXIQZ6FPbs4KqeQJo54a6gqGXykVqYYrdsQxX516twtjmEcBzDVFyjPm/A80QpJkMY7qha0pGg8jiTKg6qndbrWv0V7AfoqrHiCL5B9GjN5KRXizJqldKkY2N0frlizVQ6ZLiO2b2H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VsOVMXF0O3x7VQ0pMtJhWFi+u1omYA4gF/6mnIHlwIcU5LBdrYJoPgNI4rye8+Q3jAY/+wdw3QUJujWBUx/BrDKXxQIRk2bXvj5w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In offline_pages(), do_migrate_range() may potentially retry forever if the migration fails. Add a return value for do_migrate_range(), and allow offline_page() to try migrating pages 5 times before erroring out, similar to how migration failures in __alloc_contig_migrate_range() is handled. Signed-off-by: Joanne Koong --- mm/memory_hotplug.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 621ae1015106..49402442ea3b 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1770,13 +1770,14 @@ static int scan_movable_pages(unsigned long start, unsigned long end, return 0; } -static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) +static int do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) { struct folio *folio; unsigned long pfn; LIST_HEAD(source); static DEFINE_RATELIMIT_STATE(migrate_rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); + int ret = 0; for (pfn = start_pfn; pfn < end_pfn; pfn++) { struct page *page; @@ -1833,7 +1834,6 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, .reason = MR_MEMORY_HOTPLUG, }; - int ret; /* * We have checked that migration range is on a single zone so @@ -1863,6 +1863,7 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) putback_movable_pages(&source); } } + return ret; } static int __init cmdline_parse_movable_node(char *p) @@ -1940,6 +1941,7 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages, const int node = zone_to_nid(zone); unsigned long flags; struct memory_notify arg; + unsigned int tries = 0; char *reason; int ret; @@ -2028,11 +2030,8 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages, ret = scan_movable_pages(pfn, end_pfn, &pfn); if (!ret) { - /* - * TODO: fatal migration failures should bail - * out - */ - do_migrate_range(pfn, end_pfn); + if (do_migrate_range(pfn, end_pfn) && ++tries == 5) + ret = -EBUSY; } } while (!ret);