From patchwork Tue Dec 11 14:27:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10723895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 30E3391E for ; Tue, 11 Dec 2018 14:27:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20BCE28587 for ; Tue, 11 Dec 2018 14:27:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 134CB2883D; Tue, 11 Dec 2018 14:27:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 951CA28587 for ; Tue, 11 Dec 2018 14:27:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4BD1F8E0090; Tue, 11 Dec 2018 09:27:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3A0B08E004D; Tue, 11 Dec 2018 09:27:53 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 291028E0090; Tue, 11 Dec 2018 09:27:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id C36FF8E004D for ; Tue, 11 Dec 2018 09:27:52 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id d41so6860422eda.12 for ; Tue, 11 Dec 2018 06:27:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xXwaJmog1/oEX/6A1+e5tKGx5C0bRqEwCwR2BHwUQq8=; b=G+w7zFFCQU63kBRSZGmx5YiN/ZzQmNs0kR5rCtUIjA7MQJKRfcfAM+82pL4LQHzXN2 UBblzuxyeUI5AfXhLOqeTDU8wVRVa9G6Dv/BIia+dKdESV0QdVN40UfMnRtAj80SfEfi 3Nhanzfy+lJKLd38Xhstu0qUm6GRu65w/7RuteLjgvXF6/uCnFXmOTsiiqYumD64Nowj h+s67UtYd3f6bGB8dLyMLp5xrWU123Zbwknw8nSvkjkM1eULDA9rEqMolMmwh59ATmZc pK7exMb4zApESp7XEOVv3kBogIKETUt0aWgCc/4akCcBuIV+g2PHAGG55vSTDtsoO2+E vW5g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: AA+aEWYCqZKZTvwwaJhrqv4NKSUpP+EthIuE7iF9HDl9IexK+sOOsvM6 9qiFJm8Dn2lgqf8/mlDt4pM1R0Pub1N4+gPM4qNUpIiGU57Dvjz8IygSxVzWDAxSGuDW/0n9OvT EFVRrtSjnXGjdrJk/xJ04rtaoKkjRN3zavXFu7UrUJa5VumqSzkqwPWc6op6PhWyWHiSos4ENaR h87g7B9BhY5+XufdVpUDwRXEBpY04pN9LebZCR5IORSBz+vpYlHXZXVTxLuzO+/o8446yQLYXkW zvos1CqoqCoUhrAvrwbZcTYSNAPrve0eqaBM3bXvt5VNlMr+OAyskJmX6t68D1THDIKvaob4Cet ySSHlxgLBwYH7UgvFhMp10cTYmAzc1Oi8lyrzL1kpoLATQOcI1KV9BbH1UI/WA2HNSEsEiuRRg= = X-Received: by 2002:a17:906:7a4e:: with SMTP id i14-v6mr12652401ejo.16.1544538472303; Tue, 11 Dec 2018 06:27:52 -0800 (PST) X-Received: by 2002:a17:906:7a4e:: with SMTP id i14-v6mr12652355ejo.16.1544538471165; Tue, 11 Dec 2018 06:27:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544538471; cv=none; d=google.com; s=arc-20160816; b=o3PJUL2LwCHleVbax/oEsBSy5aJsz0r7mxz8qqj5P10/ovZOYx5g67smXEsZqDZR+A 4x8DWTB2GQEDr8ZhWzpsM9BeruUvU3PidsYAHA9Lt9UQRmadCINpHjej2rnLyIsogoMX tYHlwIVK5+YZgRK3fgLOmVffNtjtBg2edJBm5OllaTSbuAefmzNHt2lVKOaWNSvUhc5w oCUAVsWVRY6X3o/navF5pRhG49nRMh5D0XGSEBe/R/j1jdjtaZn0UXj6gfC3bX2BLb3I QdLIXlQL7hKb508v8U7nMjWzFWKkGK8MlJehWMTffduLgGYWhoGjhFoAhFW6866xM6VO Il2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=xXwaJmog1/oEX/6A1+e5tKGx5C0bRqEwCwR2BHwUQq8=; b=rtiC2ykV9nRknHs7Fz4M9EpiX5yNQcIgtcUx7GW4XlVp0ehbVsW/HVb8wFRFfK2da/ NSJ1vwDjrZymtYdmsFo09F1NdPuVSN8Z6jRx+3Qr+fDAhadHBfArCDID45RGu0zmZGzJ hSILnXKZWb5lHDXpKJ1hVcRLjd4PZKag2ZSoJsxE+iWXyECp4SKJuFCRFcnDh2SvULHf 0HldwAeF+DLCYdffcNDziOZFDlsP2zDmdJf/fvKV2npddLmX+hpyopVRK8Z1ez3zR1hF 11KTyWC3L8jawGRGzvEGLqxvdx8Nrhkr2jc9eQrwJ9GIx8jVP9aSlgh91j0FTu+yWRxI JQtw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id s23-v6sor3747414eju.43.2018.12.11.06.27.51 for (Google Transport Security); Tue, 11 Dec 2018 06:27:51 -0800 (PST) Received-SPF: pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Google-Smtp-Source: AFSGD/WU5eBB4mLDzkmMW5SXZsrmL9erDeMhxzG1pm5Jdw/nZ0jvoqQoYpuRcJhGY3RoLQMZAwf91Q== X-Received: by 2002:a17:906:7252:: with SMTP id n18-v6mr4309738ejk.192.1544538470766; Tue, 11 Dec 2018 06:27:50 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id g31sm4073975eda.96.2018.12.11.06.27.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 06:27:50 -0800 (PST) From: Michal Hocko To: Andrew Morton Cc: , LKML , Michal Hocko , David Hildenbrand , Oscar Salvador , Pavel Tatashin Subject: [PATCH 1/3] mm, memory_hotplug: try to migrate full pfn range Date: Tue, 11 Dec 2018 15:27:39 +0100 Message-Id: <20181211142741.2607-2-mhocko@kernel.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181211142741.2607-1-mhocko@kernel.org> References: <20181211142741.2607-1-mhocko@kernel.org> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Michal Hocko do_migrate_range has been limiting the number of pages to migrate to 256 for some reason which is not documented. Even if the limit made some sense back then when it was introduced it doesn't really serve a good purpose these days. If the range contains huge pages then we break out of the loop too early and go through LRU and pcp caches draining and scan_movable_pages is quite suboptimal. The only reason to limit the number of pages I can think of is to reduce the potential time to react on the fatal signal. But even then the number of pages is a questionable metric because even a single page might migration block in a non-killable state (e.g. __unmap_and_move). Remove the limit and offline the full requested range (this is one membblock worth of pages with the current code). Should we ever get a report that offlining takes too long to react on fatal signal then we should rather fix the core migration to use killable waits and bailout on a signal. Reviewed-by: David Hildenbrand Reviewed-by: Pavel Tatashin Reviewed-by: Oscar Salvador Signed-off-by: Michal Hocko --- mm/memory_hotplug.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index c82193db4be6..6263c8cd4491 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1339,18 +1339,16 @@ static struct page *new_node_page(struct page *page, unsigned long private) return new_page_nodemask(page, nid, &nmask); } -#define NR_OFFLINE_AT_ONCE_PAGES (256) static int do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) { unsigned long pfn; struct page *page; - int move_pages = NR_OFFLINE_AT_ONCE_PAGES; int not_managed = 0; int ret = 0; LIST_HEAD(source); - for (pfn = start_pfn; pfn < end_pfn && move_pages > 0; pfn++) { + for (pfn = start_pfn; pfn < end_pfn; pfn++) { if (!pfn_valid(pfn)) continue; page = pfn_to_page(pfn); @@ -1362,8 +1360,7 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) ret = -EBUSY; break; } - if (isolate_huge_page(page, &source)) - move_pages -= 1 << compound_order(head); + isolate_huge_page(page, &source); continue; } else if (PageTransHuge(page)) pfn = page_to_pfn(compound_head(page)) @@ -1382,7 +1379,6 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) if (!ret) { /* Success */ put_page(page); list_add_tail(&page->lru, &source); - move_pages--; if (!__PageMovable(page)) inc_node_page_state(page, NR_ISOLATED_ANON + page_is_file_cache(page)); From patchwork Tue Dec 11 14:27:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10723897 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED3F291E for ; Tue, 11 Dec 2018 14:27:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDB2C28587 for ; Tue, 11 Dec 2018 14:27:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CED942883D; Tue, 11 Dec 2018 14:27:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C1AE28587 for ; Tue, 11 Dec 2018 14:27:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2BC88E0091; Tue, 11 Dec 2018 09:27:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DD9FD8E004D; Tue, 11 Dec 2018 09:27:53 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA4B08E0091; Tue, 11 Dec 2018 09:27:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 6D63D8E004D for ; Tue, 11 Dec 2018 09:27:53 -0500 (EST) Received: by mail-ed1-f71.google.com with SMTP id y35so7044193edb.5 for ; Tue, 11 Dec 2018 06:27:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Q8sh+9FkpWv6DFNlPPgKqUlqTEtJzBvplK2abR1KP7U=; b=muDJiy2BE4yKmBNnC9tqO9CohJgC2EriEqCeJYgKuK71HUu9kv2LaNAjePf8H7hA8L xczgqkcxy47MzdVnjuT98fCdr64dHil2wh5zbyhM5yL+1t2kpIsz9MScqQpO9uvDVyeW TgOLbL0W0LN5JQ2N7x8sceCSUPKVG/N2meEUHR6QnqrkgFUabePfpLXbjXhgjpDW0omM ObuDQBVLNj9sZ0FNM1B93lqTUq/hLZb8gasF14HccgK33z5CBBFgBCBw0Zhl59Pr7Hh1 HwgraJ4yagMNpTf7wVQ3ZB4JAOZt53DoPqxlnllo4BUJJf2SkAQhso+rUrx+mKujRc4Z 6A8Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: AA+aEWZR3XHwU8gzXwvj0RuXEuS+ui+wCRTqjzKnpGp51yx9JRWRmE4N UAMEnLr4GvyVpwqAdB2hTWlaavD+d7eDqst4YIRyeGxpT9Coozvy8+OGj+q9XJOhkal9yzcrUWd y3hT1iowdtvogOAT7P2BhrEKawbhul4L3X8zmQ2qgzvj8sc6nd6StZwJmu6tHjRpUKxLxyiViCY 7Bof1lYDXXV+W1QebolF+zvtuhfzlSAnULoIuMdwHR/RshGPcWVxbEqKCF0QJSWKJ0XqCgm1WLM +DA42p6IQlrkT06IQWb3XXCkaklr/ls0PxLkW6QkrvzfI63uh/PHHMuB1g01hZvaUuDmtwh5rBP Mp6gbWi1wfsjVAavSNC8h+W57BXdnJRJaXVkuRFaaa7eQNGWX4FUqI6/E9zhZ7rAy4ZoVhTW2Q= = X-Received: by 2002:a50:9226:: with SMTP id i35mr15710252eda.8.1544538472927; Tue, 11 Dec 2018 06:27:52 -0800 (PST) X-Received: by 2002:a50:9226:: with SMTP id i35mr15710206eda.8.1544538472001; Tue, 11 Dec 2018 06:27:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544538471; cv=none; d=google.com; s=arc-20160816; b=Cc4WP/RKq8Di6LhDIieNZz/5F3AhbyPQGKGSpUi9fJBV9OPCVoeAttk4r6CUcstIji x1REztgcpstXs/g51sVz+YEGq+Onc/TLokdfM1IjZ4R0FCqchmAtMkOB8sWfbUenBVSk ww4LSu877K+poVIo3w3jmQZyIyfXwfBk/gf+p/P/JRJ5QYoRKmHNb/0Fz+lObTrjhX4W D3ynzl3i3/3guujaFb64+tdLIzHMTrtVqNbiqt4ODREGe6MwVCHmqYA6vF0F0bJ+Ctgo Xm0np01oGhjPDG7vHsgRuk46fV2lTuPSANx00mxCNPN7apmhH45d/BvPEjCy7pdwNKaD f7fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Q8sh+9FkpWv6DFNlPPgKqUlqTEtJzBvplK2abR1KP7U=; b=DUcHKHtqg2FaoHdl8t8uitcQP316/kjq9fICv9eTIzcoq1rPe+gw2yTW48WI+xlwxJ 6KVFDf4WlhmcVqZoz4WI5t08eUNtSMgr0pCpwuY7E3GNgyvWHWD2xHYkKGSQPFXp4OYN SuTdzBZ+LmUJfBmQSmAk313nKOEJampyPeyIuKuZNovwbbNyCHVFovOWpJu/Kv8pWKlN Ikd5/KgQF7EWlqSb057v8kxI5JvaSH26sjCHZ8pOGncjB1hciGMp8qNMtpfq7WbRXrui 3cQE2Ahi/rP7Vo7mHkrD/Xpr/1K3UUFL/DOwYKZLfkaD51nxn+07xkuxrzOlsKBhkvqL m42w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p7-v6sor4051488ejb.30.2018.12.11.06.27.51 for (Google Transport Security); Tue, 11 Dec 2018 06:27:51 -0800 (PST) Received-SPF: pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Google-Smtp-Source: AFSGD/Xb/9v/+9EOR4DQqoxgTxgYu4+WFUeAMf/WERoa5tPJYu2EQVJWRavObQF6AqoNGie3Iwhl5g== X-Received: by 2002:a17:906:590a:: with SMTP id h10-v6mr13068100ejq.102.1544538471623; Tue, 11 Dec 2018 06:27:51 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id g31sm4073975eda.96.2018.12.11.06.27.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 06:27:51 -0800 (PST) From: Michal Hocko To: Andrew Morton Cc: , LKML , Michal Hocko , David Hildenbrand , Oscar Salvador Subject: [PATCH 2/3] mm, memory_hotplug: deobfuscate migration part of offlining Date: Tue, 11 Dec 2018 15:27:40 +0100 Message-Id: <20181211142741.2607-3-mhocko@kernel.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181211142741.2607-1-mhocko@kernel.org> References: <20181211142741.2607-1-mhocko@kernel.org> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Michal Hocko Memory migration might fail during offlining and we keep retrying in that case. This is currently obfuscate by goto retry loop. The code is hard to follow and as a result it is even suboptimal becase each retry round scans the full range from start_pfn even though we have successfully scanned/migrated [start_pfn, pfn] range already. This is all only because check_pages_isolated failure has to rescan the full range again. De-obfuscate the migration retry loop by promoting it to a real for loop. In fact remove the goto altogether by making it a proper double loop (yeah, gotos are nasty in this specific case). In the end we will get a slightly more optimal code which is better readable. Reviewed-by: David Hildenbrand Reviewed-by: Oscar Salvador Signed-off-by: Michal Hocko --- mm/memory_hotplug.c | 58 ++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 6263c8cd4491..c6c42a7425e5 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1591,38 +1591,38 @@ static int __ref __offline_pages(unsigned long start_pfn, goto failed_removal_isolated; } - pfn = start_pfn; -repeat: - /* start memory hot removal */ - ret = -EINTR; - if (signal_pending(current)) { - reason = "signal backoff"; - goto failed_removal_isolated; - } + do { + for (pfn = start_pfn; pfn;) { + if (signal_pending(current)) { + ret = -EINTR; + reason = "signal backoff"; + goto failed_removal_isolated; + } - cond_resched(); - lru_add_drain_all(); - drain_all_pages(zone); + cond_resched(); + lru_add_drain_all(); + drain_all_pages(zone); - pfn = scan_movable_pages(start_pfn, end_pfn); - if (pfn) { /* We have movable pages */ - ret = do_migrate_range(pfn, end_pfn); - goto repeat; - } + pfn = scan_movable_pages(pfn, end_pfn); + if (pfn) { + /* TODO fatal migration failures should bail out */ + do_migrate_range(pfn, end_pfn); + } + } + + /* + * dissolve free hugepages in the memory block before doing offlining + * actually in order to make hugetlbfs's object counting consistent. + */ + ret = dissolve_free_huge_pages(start_pfn, end_pfn); + if (ret) { + reason = "failure to dissolve huge pages"; + goto failed_removal_isolated; + } + /* check again */ + offlined_pages = check_pages_isolated(start_pfn, end_pfn); + } while (offlined_pages < 0); - /* - * dissolve free hugepages in the memory block before doing offlining - * actually in order to make hugetlbfs's object counting consistent. - */ - ret = dissolve_free_huge_pages(start_pfn, end_pfn); - if (ret) { - reason = "failure to dissolve huge pages"; - goto failed_removal_isolated; - } - /* check again */ - offlined_pages = check_pages_isolated(start_pfn, end_pfn); - if (offlined_pages < 0) - goto repeat; pr_info("Offlined Pages %ld\n", offlined_pages); /* Ok, all of our target is isolated. We cannot do rollback at this point. */ From patchwork Tue Dec 11 14:27:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10723899 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AD5914E2 for ; Tue, 11 Dec 2018 14:28:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B7E428587 for ; Tue, 11 Dec 2018 14:28:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F39562883D; Tue, 11 Dec 2018 14:28:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E11E28587 for ; Tue, 11 Dec 2018 14:28:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B923A8E0092; Tue, 11 Dec 2018 09:27:54 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B19838E004D; Tue, 11 Dec 2018 09:27:54 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0A688E0092; Tue, 11 Dec 2018 09:27:54 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 442FB8E004D for ; Tue, 11 Dec 2018 09:27:54 -0500 (EST) Received: by mail-ed1-f72.google.com with SMTP id e29so7120426ede.19 for ; Tue, 11 Dec 2018 06:27:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Iw/C/mJloVWnnEeI9hr/rFUfYtnu/dchJcsf1iUtKds=; b=U8wYOdbtK50VmjIiIUS2Nljkyp26DeYrSdrFS9M7mOB3gXa6IF0X763VcGiBX9TXlg ewOMYcv6rTHjqGL7wAZ4qpjLaRxQwZksg06GYoyCT3YZ2B/VSi1teXb5pSkkQzlvng1n OB9kBq1B4oqZchs5aoRGmMvKdpJRvYQ7QXpGz2iCchMvUz22lW15Sq6XjUSKwgHr5xNZ oJCXodxpPhIHF/LxUYNizAfMOTBPEhAX4VQqYi5imvEzOymX0Nw+2PFml4ILiJwIoAjB 5Uh7nMcOkK2DzahsqGFvOiBb7dl4F+xwxRsXwLYIohi+spF4QzJ40oOKE3A2nedtUH8W aeaw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: AA+aEWYDWhlTh5gcF80YT1ClD2tHz5aUrVNk34m6LLC7TantQnMhnOTa fPUq8dRL98mWcKyt6z2eYLmQ/Xp4U45AA6pJlr8mQ2Y9gO9ACk0WgqSOxL2tYJSohNCH1FsMt8O tkjsGpGYcrr4UnyjPj8+7zaKUoDzRBvs7jPUMN0U9wO/NCN2mh1UMxHAIayY67163cTmV9i03S5 K/FlIElbgjveZgWB1WDEu4Y7hrQhOOc8bqlmTZrwUMysBxcWiRoHUPBo+1r8psd7f4KjqR2FBfv eG6kl0TKsGUMfnlEVpZCbI4Hb3qWTmyy7RXBWug5ba5nkEKZ/vy84oodtbQiMxofy9LMv1PtbOF N5gyJRrDjHHAUGaRBePfGhxO5Ho3C93hih2ZBZhjn/TkneiXglI7T2OalhwoUB6IsEqCJ5lArg= = X-Received: by 2002:a17:906:753:: with SMTP id z19-v6mr12681096ejb.175.1544538473787; Tue, 11 Dec 2018 06:27:53 -0800 (PST) X-Received: by 2002:a17:906:753:: with SMTP id z19-v6mr12681052ejb.175.1544538472928; Tue, 11 Dec 2018 06:27:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544538472; cv=none; d=google.com; s=arc-20160816; b=c7ELiuNh/PiWSWdsndXYRaSCWoj0dHCNSga/pjOr7jUu9wn93szhAo5jSzaJ28FMZb 85jQbSCAsmfXMz+rY6KbSqLWCYpbiE3q+mkwj7kZ3aqaK7HxT5vQDdufxzzqvhWdiMXj kBRgwYJZ4gwBHAhciBgSVmYH6dPQFsM6cNFR+3VdNIUPZJbYDvCTtGx+D3fsJsKxamzv 0Ha2haRFoqZgNjKzb5gpxNE/LDOn257Yb/HOGfd/+tw8QqG9mf6YEOc1g7bwNEOOmFb3 esK7UOF1favTI1m+pLbkz9RhiJXRCQlEX+1mHa8hNMr3rRaH0mN38HLf3/l9a5hbCqGQ QqPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Iw/C/mJloVWnnEeI9hr/rFUfYtnu/dchJcsf1iUtKds=; b=jULepHh3R5XYTfMqdsFFknHR+6fC0wtukJiIzPbmSbwZ9E9pIMAyb+Du0ZM3nCB25G NW2Nqwp/f7aPLFRdGvN9oDSZf9yJmtdROjebZgjbiHDgcPpaEF0ZP6+1azXCZh1DudMc XAP77wj8Ev6tihOsxbdYSs6wu1ghjFXRjb+IVll1EocspkbcKh6k5BENAn3WTis8CBP5 bv/Vj8emLQIPULEYx8ymhXCZUSV73pBE8uyTsez9iHrFGtHQCdPfBu5gfUajx2vRoPgw DhSBSjb/r2dvWTjaAY8GUavNtQaFabaCK3ll+uHNOG58gz+UVfiZcoIVXfVRoGYxkPWl 708Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id ge18-v6sor4064756ejb.16.2018.12.11.06.27.52 for (Google Transport Security); Tue, 11 Dec 2018 06:27:52 -0800 (PST) Received-SPF: pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Google-Smtp-Source: AFSGD/XXN9QZ5mxhdmzoODH6Q4JaQhc6thIwufE8ejAEFt0+2ubdCDlKdqiYc8LyAOjtVAPtFl91Kg== X-Received: by 2002:a17:906:22ca:: with SMTP id q10-v6mr12699179eja.66.1544538472657; Tue, 11 Dec 2018 06:27:52 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id g31sm4073975eda.96.2018.12.11.06.27.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 06:27:52 -0800 (PST) From: Michal Hocko To: Andrew Morton Cc: , LKML , Michal Hocko , David Hildenbrand , Hugh Dickins , Jan Kara , "Kirill A. Shutemov" , William Kucharski Subject: [PATCH 3/3] mm, fault_around: do not take a reference to a locked page Date: Tue, 11 Dec 2018 15:27:41 +0100 Message-Id: <20181211142741.2607-4-mhocko@kernel.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181211142741.2607-1-mhocko@kernel.org> References: <20181211142741.2607-1-mhocko@kernel.org> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Michal Hocko filemap_map_pages takes a speculative reference to each page in the range before it tries to lock that page. While this is correct it also can influence page migration which will bail out when seeing an elevated reference count. The faultaround code would bail on seeing a locked page so we can pro-actively check the PageLocked bit before page_cache_get_speculative and prevent from pointless reference count churn. Suggested-by: Jan Kara Acked-by: Kirill A. Shutemov Reviewed-by: David Hildenbrand Acked-by: Hugh Dickins Reviewed-by: William Kucharski Signed-off-by: Michal Hocko --- mm/filemap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 81adec8ee02c..a87f71fff879 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2553,6 +2553,13 @@ void filemap_map_pages(struct vm_fault *vmf, goto next; head = compound_head(page); + + /* + * Check for a locked page first, as a speculative + * reference may adversely influence page migration. + */ + if (PageLocked(head)) + goto next; if (!page_cache_get_speculative(head)) goto next;