From patchwork Thu Nov 7 19:16:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13866969 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 8A1B8D5D683 for ; Thu, 7 Nov 2024 19:17:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE5286B008A; Thu, 7 Nov 2024 14:17:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C43CA6B008C; Thu, 7 Nov 2024 14:17:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FA976B0096; Thu, 7 Nov 2024 14:17:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7BBF86B008A for ; Thu, 7 Nov 2024 14:17:30 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F16441C622D for ; Thu, 7 Nov 2024 19:17:29 +0000 (UTC) X-FDA: 82760256012.07.80BEF11 Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) by imf01.hostedemail.com (Postfix) with ESMTP id 166D640007 for ; Thu, 7 Nov 2024 19:16:59 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=AVWdyhcU; spf=pass (imf01.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.219.176 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=1731006861; 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=tpY7G7HZyMQ925tY2MOVzqmuZ6ZpdF5L2I8ZthD5Qt2laA/GgyXpHW8nnKCh5cPbOLdyDd swBoL0FziAzzmMN9wv23obNoBlA04OgAfB28pavThgs5GDyRTEzFSyoufax8dB/qqrcn5N HEzdQYzBEHUqYUHJ85j6EGv6qeLq3oU= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=AVWdyhcU; spf=pass (imf01.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.219.176 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=1731006861; a=rsa-sha256; cv=none; b=KJ4NoxZH0p7bclTjVXrDR3+gUPt0wtWfwVO8Pim9yb/NFZV2+HFxxr8V1wurGyc3Xb7RN/ VRiXxtKq4cjYypHSDNGe66aTZoA2twV3JG1npkzdo/HLqQkeDhIUj8eW576l/bTRk1nYSS xmDwAHoGeBtZCRcWm46+zH3Ns+0ng+I= Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-e2e444e355fso1999902276.1 for ; Thu, 07 Nov 2024 11:17:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731007047; x=1731611847; 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=AVWdyhcUBlMWdgXq+nzaeC/XweaM6YF7NzpThKkZE/Lqyxjeag/pF/3MApSlIODobT HLeMDwEvgZlh9WPPAKMjNI5Locvx7+mQYMNORPXx3/ZiSRAo0/u9x7OzNfTwsL+Bt4ng FpwvPNRwS1Lm8E+qj0pP3YyThMtKo1SSBT6CKiBFk3uQLwA0q5dlmPWqGIyLcxiV1nUD q7lpV/TYxINLenW62ueRGvRdZlFPj9lSeWwrAlL1L+VUm9EjZVkWjIMoFZVOj/hPsQfU rgIw1G3s3HO9g9GydkOXGv3ZIAD2MmxkLRzdhmw6+tMgko5tQkW0XaAYmI21y1Bh6hSE 60ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731007047; x=1731611847; 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=uW6MpJe1sw+Jp2f2pzaTgykXJ33aQjswPtRXF/Erl1U0Q/7x69mXM0NC6oD9d2KoNm OvFoREPacCB/AVYSRiVQzogd7DQahRMrCL1JC6Nw2vyoZpO5f6DhUyA+u6tjvITnm4HB FGioaCfdYMl6P+kEtwj1X5qSSlVJ6OJSmzbojEdBubfDnhXwLvPESikajL9f81ZU4W4V xvXkHQ48mrFg88BaPjboFi4TudV2+jHx2tvXzrNSgArx2OBdwEstLpAdlmY6wxQESfpt 7hQzBgd2dUTMShCjDhMJTKsQKshfjPQllpXiHNBsVcyzqqCZylBEb2Rf5feELAuPOD5M d+WQ== X-Forwarded-Encrypted: i=1; AJvYcCX9LThpNDEOsElskZbnp8J6BH/GNCmH7PpfbKN9ynogJZOrQpg4i4iqkjVO/oQv373vrdaFBAKewA==@kvack.org X-Gm-Message-State: AOJu0YyNLIUBGNE057qg2P59VJi4cy2FPF6Q70gZpzcI9Tc/it4XGyw4 Kk69NkWiYGqXuDeAqhjI5pqp2E+2LFxWzQ9yDsWqFLRxubWRDlSk1s7Hfw== X-Google-Smtp-Source: AGHT+IEkpWzZirMthRa1KIppd+IoM2B6ZQrYg1W/sBImn83Wn53xX/nxsQKorMCpOKraG2RVdoxyYg== X-Received: by 2002:a05:690c:fd2:b0:6db:e1e0:bf6a with SMTP id 00721157ae682-6eadc0a0bbemr9007977b3.7.1731007047220; Thu, 07 Nov 2024 11:17:27 -0800 (PST) Received: from localhost (fwdproxy-nha-008.fbsv.net. [2a03:2880:25ff:8::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eace8f1c74sm4067837b3.31.2024.11.07.11.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 11:17:27 -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 v3 4/6] mm/memory-hotplug: add finite retries in offline_pages() if migration fails Date: Thu, 7 Nov 2024 11:16:15 -0800 Message-ID: <20241107191618.2011146-5-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241107191618.2011146-1-joannelkoong@gmail.com> References: <20241107191618.2011146-1-joannelkoong@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 166D640007 X-Stat-Signature: 6x36hmjdpwfrn1fzugxnn9jocfojtpci X-Rspam-User: X-HE-Tag: 1731007019-448224 X-HE-Meta: U2FsdGVkX1/AHDXDpoXnqDN3cTwA2m6lp8BcT8ysBmFo9lJWVwTw1zNT9U0P/L+3VKV2jceTgbQVrnZnP1bREQXwjCJ3Mn5IeOSWtIqrQ/cQ4qQOpkFzyzkrSaLhyLh+21DEkG5mNMfaLGz7AKN1NVeKYKFUN9GRvDWqGdH5SOQW7BwwNGxJKmo9jxRNM3RZn6w2dwJdBMH4mwCMwfEcRTwq5G6u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JVj//nuK0B1yAHhm3vJs/0E3XQk96eCtNkRIIN/l+LKbK4dvxYVK6PqLhj4JgoPh7xKA4VXk6wfKMeOPofjvypsg== 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);