From patchwork Tue Nov 20 13:43:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10690401 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 4701614BD for ; Tue, 20 Nov 2018 13:43:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 371D226E82 for ; Tue, 20 Nov 2018 13:43:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 296B626E97; Tue, 20 Nov 2018 13:43:41 +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 A76EF26E56 for ; Tue, 20 Nov 2018 13:43:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A714A6B1FCC; Tue, 20 Nov 2018 08:43:38 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 95A7D6B203D; Tue, 20 Nov 2018 08:43:38 -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 75E806B203E; Tue, 20 Nov 2018 08:43:38 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 1F8886B1FCC for ; Tue, 20 Nov 2018 08:43:38 -0500 (EST) Received: by mail-ed1-f69.google.com with SMTP id x15so1307403edd.2 for ; Tue, 20 Nov 2018 05:43:38 -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=JPA8FPoPMv+gmc6SS8CXiLWc7PLkSqS/f1EA6JDY91M=; b=dvLsXLPTudy8yWuTFCaxlOR0//KiKmxHEE1nMFW2CCXd9K8Y0eq3GHaEmvjKHBup6f sA9tmf8iD4uRxdwzOyHc0+Z+XuHo0CpQGHsi8M/2Bb9A+HNZWX0R1KKNpHbj9WON4ltv yMUCYu6L5U6WPNRS8pBPMGIYEHyaJbBBRXBkb7OIx39sANCc+nV1mkO3aaTjjNOzkF44 hX89qTaVvCj9bz2HeoXZaQRWavOd5wZvyQCSFI28oyrU6h9Tjf9UbP0KZhV4XIPC/2LO oGwtsCXBvznuv7VwgaRr3BX5No7Lbw6UT8BDz8KduasrG8pOJyHWKmoWUDUUyNHqX+dw cJ3g== 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+aEWYxM0lE9cKPOvQixyXR3rmM9whUFVo9caCDE9/ngUP6AHjh1j8F eEIxk50p5R/fUGJ0bMupHcDmsbxjAre5EVoBNcj34O9QRX6JUziP6mFRhxB1MuTnpeHXpdrgOq8 +R6WBfOLbtHFHfJnVnp8Ex8G6MzU3dyi65i4V8gTqkpNhVhmf/IT+hky/O5nc5csaVRaIDoQ+pJ FRYze6G1chFUpidzDSFf2jgveHHNhZdTJYY+z3S6VT8ludz9FOd0d8uG4R2RNbjNpsCkagi9aDQ JGpZ5/4PcV1k9Bvuir9AXklYjJeO4PEqXrlpKlswD/V/x+UAFPi3UNHz9WOjDI4B3xIR9c1/6VS a1OUtRovmWq9U6k0K4rvjtGuSBRbqMfwgDRiBitX77cathP/ilN+syZxe7KAlBn/gOLD/o4AWQ= = X-Received: by 2002:a50:9770:: with SMTP id d45mr2188556edb.49.1542721417629; Tue, 20 Nov 2018 05:43:37 -0800 (PST) X-Received: by 2002:a50:9770:: with SMTP id d45mr2188522edb.49.1542721416670; Tue, 20 Nov 2018 05:43:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542721416; cv=none; d=google.com; s=arc-20160816; b=H8F8DQ9Gg0M1gprcQbJBsbjtE38HvzAJaasBsJerrVVVCBJwlHEwEQQJGdTvbOxBE1 8kJNxKFIGq/GjeAnL2ctOdROK+o59WL9gLc3vwH1Zx9j/e+ulZl4JlobU4ANQBiMyJ+t /y3wZ3wvcPzWsmjayJpBHf5c+6Qid8uyIgZJmGeqLK+aGSZDo9CarY7d77FGHYLqg/rb byZtBj6li5TEGBVChF1v3jsMDk7kllsX0H0MapzFeke5uuWCdvJTFk0HtPm/BT9+DKtO gXhuo9mV9pVHF9uQOS3GtPA2BvuDD/2IGgkTRqvv5aSmcGKd37Oc7FGvBd87O0AVmlRX 0X2w== 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=JPA8FPoPMv+gmc6SS8CXiLWc7PLkSqS/f1EA6JDY91M=; b=lSNujudqHTkQZAq3JFjO+QWShHp9aYcHAyvUzm39Ykt/ztNlQ9uvOEUx19IFJVWozD OOSuVXRpfWcWOJmDIIcCAB8OYn8GEicApOT0toXwy/bnYgihDbg2QanMO82Qg13L+0V0 WpMIPzgdcXwQK8+HiTIYD4nbTFyr7152Khc4BadraGro9jAcStabzr642JHsiaIeg45/ O/ehpiayO+B3AcEPLOcMeOKggElQW5zvnGGmDC/5T0AGL5NuPzyUsEnUnkzYTT/nv9rw CaAlS2K/d6WMF7fN1dhGvIN+WNJPQqYb0XE8H+/P10FCLsOOwzjoFtYmP+39sEXIq2x5 fGCA== 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 k6sor21397135edx.21.2018.11.20.05.43.36 for (Google Transport Security); Tue, 20 Nov 2018 05:43:36 -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/UXIyPh/3c7XVeJ+kNuWyZkxIcVYxxw03A3PtUVq8tllJKzM6JPgEjUx2ox3Ct5oBx7q6ySfg== X-Received: by 2002:a50:a4fc:: with SMTP id x57mr2265364edb.229.1542721415966; Tue, 20 Nov 2018 05:43:35 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id 49sm8428786edz.59.2018.11.20.05.43.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 05:43:35 -0800 (PST) From: Michal Hocko To: Cc: Andrew Morton , Oscar Salvador , Pavel Tatashin , David Hildenbrand , LKML , Michal Hocko Subject: [RFC PATCH 1/3] mm, memory_hotplug: try to migrate full section worth of pages Date: Tue, 20 Nov 2018 14:43:21 +0100 Message-Id: <20181120134323.13007-2-mhocko@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120134323.13007-1-mhocko@kernel.org> References: <20181120134323.13007-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. Signed-off-by: Michal Hocko Reviewed-by: David Hildenbrand Reviewed-by: Pavel Tatashin Reviewed-by: Oscar Salvador --- 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 Nov 20 13:43:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10690403 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 9E4BE1709 for ; Tue, 20 Nov 2018 13:43:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D94226E97 for ; Tue, 20 Nov 2018 13:43:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81B2F26222; Tue, 20 Nov 2018 13:43:43 +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 0735826222 for ; Tue, 20 Nov 2018 13:43:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 062EC6B203E; Tue, 20 Nov 2018 08:43:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EB20D6B203F; Tue, 20 Nov 2018 08:43:39 -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 C190F6B2040; Tue, 20 Nov 2018 08:43:39 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 56A996B203E for ; Tue, 20 Nov 2018 08:43:39 -0500 (EST) Received: by mail-ed1-f69.google.com with SMTP id w15so1282167edl.21 for ; Tue, 20 Nov 2018 05:43:39 -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=Fk6j1qjZGqSUR1ucZm8jmR3zRWMJFCwmZwWK+RSH3Lk=; b=CTHpUAU4TTHCmzdHVugDi5iOFXGCLPDILnYAjLGT2z3twdd0ngy8NOryxmrkgLjJ0U GiM55GPkW0P2Pnr46TTQPnn1X30/ePCLQRQAWOyKu+uXGQ5IZnMUWEFT/51pXxVyle4F ue30LLMdzFOMH1/jmcbfNQ9c20eO+5IbkWQFDhw/Ssrowdy76KSRQj4CfHNFDJucgJ86 fC6NL+JKAFQr8i9GCumyaFbmT5b/HDwcUjIYsT/9w7Nt0PjFcjYcBamQ5/5Z0DZe3/qr yw1n+i5PPrNbd2ymaOPmV7AYktU+75nhLYfcPICzGp+9ohH5T7MsCn70QVAG0mDGHWca uXlQ== 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: AGRZ1gIHZzGh5xvPwaqlau7puXn7qnX3HyWf6NTpTYMXE5nGFGtVxBDl znNHs1V7cD2jy59/J2pArIKwcE/iZ3KMKcEvmT6KLWoQNbJxj035jL9VZUnZKafItG89lX4IYz6 tmpPWkeh6p1ArxQivw0QSnwIsPSpqE6jagFe++gNUv9wP7NWNwe9z7ONLCT4wQ398N1VNZ9LWzE CvmCiCr2koGpO/7kzN5asj2VCdd29vwhka3VCYXdbVQjhnaBV/mAp3bo/1slS6BCVUmucwh8+Mh yPo4bmo7IniJNIXOshsLsj3yhIjF8SwlTDtDHcRZuHcNiB2Jc3KJlohkkGjKJ7hT1+Zk4HfNWt5 +CuqLLIDttMRHRZ8MAzIyI1AcV1G5Zm7gzo2SmHxmy1tMmvWQIO+jy5Kw68dQGfhFcFBguonEw= = X-Received: by 2002:a17:906:1c86:: with SMTP id g6-v6mr1938382ejh.195.1542721418844; Tue, 20 Nov 2018 05:43:38 -0800 (PST) X-Received: by 2002:a17:906:1c86:: with SMTP id g6-v6mr1938343ejh.195.1542721417808; Tue, 20 Nov 2018 05:43:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542721417; cv=none; d=google.com; s=arc-20160816; b=iM1FUgL18z7wU8tQEw/zSaaHgElPknjS45kUwpRzoLoDQEh0PbV3ZOHL6pKHZYJHcj x0e6PGJQhFtfu2gXdu/ssyap8Tyl5Vhw66w+WeWXggupmfwtSajQYyAs+3G4kx15giWN XbuH3hmaoNnWPd6S5jq+O2p5h3Vai1xFVGINhMlp3nVRQXXYAdGQ3pVwLb9QVj80NpcJ NA49aTnD0GB+XbrtxPMy+3YkttwXYv7a1hgpGtUi9+GqbJYy94VCXhR65CI8yNjDryDa /F+MxJzdt0IX8wwJRQxUI+nmyncadBc0FITtQFJ5oSo/hgKh9smAu6gDCyNmQQfrPrdF QHJQ== 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=Fk6j1qjZGqSUR1ucZm8jmR3zRWMJFCwmZwWK+RSH3Lk=; b=xPswOB0GVck2kCihLzin3SlpXLE2iZHNUSpn+mRW3lmm4IhWxAKuXW61i6bfwfbIgQ gX0uOwkaho9odIGpXZiZikIG+lBqx4iCjArwJ97FbP2S5fqhlQNr6/TErd0J1cHvVGTj scyZ5VYEye/15hgHy0Y3igrzFXrl5OU3ajN1GmDw41fEHvoAlIyGjBrQwxjfr1GFn7iB /VfkEbsLEbx6mBhcydHV9rJIAh/ay+MzgEHgy271ltmipZRD2hDziT9u2yjwYwPkregE 02WQxVcWn2mg7RA5r8tISffGinQ7dbcZIWLfnxgWVegtmXGdu1xZdRbUrN0+j1TZoYJI 279A== 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 p16-v6sor21836215eds.29.2018.11.20.05.43.37 for (Google Transport Security); Tue, 20 Nov 2018 05:43:37 -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/V88S+hp74RyOZiVbXiGkCC3tC4E36Kd6sMvYipIRhe1zFoyL3SLdmM9ZVuyhkZxyHOOZp7Kw== X-Received: by 2002:a50:9226:: with SMTP id i35mr2392413eda.8.1542721417077; Tue, 20 Nov 2018 05:43:37 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id 49sm8428786edz.59.2018.11.20.05.43.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 05:43:36 -0800 (PST) From: Michal Hocko To: Cc: Andrew Morton , Oscar Salvador , Pavel Tatashin , David Hildenbrand , LKML , Michal Hocko Subject: [RFC PATCH 2/3] mm, memory_hotplug: deobfuscate migration part of offlining Date: Tue, 20 Nov 2018 14:43:22 +0100 Message-Id: <20181120134323.13007-3-mhocko@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120134323.13007-1-mhocko@kernel.org> References: <20181120134323.13007-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. Signed-off-by: Michal Hocko Reviewed-by: David Hildenbrand Reviewed-by: Oscar Salvador --- mm/memory_hotplug.c | 60 +++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 6263c8cd4491..9cd161db3061 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1591,38 +1591,40 @@ 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;) + { + /* start memory hot removal */ + ret = -EINTR; + if (signal_pending(current)) { + 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 Nov 20 13:43:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10690405 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 DC7341709 for ; Tue, 20 Nov 2018 13:43:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD0E121C9A for ; Tue, 20 Nov 2018 13:43:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1707277D9; Tue, 20 Nov 2018 13:43:45 +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 4CA2721C9A for ; Tue, 20 Nov 2018 13:43:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D30636B203F; Tue, 20 Nov 2018 08:43:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C1DF26B2040; Tue, 20 Nov 2018 08:43:40 -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 A496D6B2041; Tue, 20 Nov 2018 08:43:40 -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 303116B203F for ; Tue, 20 Nov 2018 08:43:40 -0500 (EST) Received: by mail-ed1-f72.google.com with SMTP id t2so1272280edb.22 for ; Tue, 20 Nov 2018 05:43:40 -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=/sEYolIbYeBRlPTEJk3IyaZRfhMjojYPi0YASgHfRGI=; b=MfPVpRZiFcBQxgbak5Inpev/ytvdNmjQEhzaA4o+LAwxu3omoW/tnc7wHhqXnR7Wgi hrkhZTwBYrjTQJaic7BNBUe3dx+5b0K05yu2qXVs2WI1sGRQJOIgKt8QN8H9/uHbnYL5 25C9MexglfxB+kcfO+6qTJNi66T257ifhp0AN45v7dxsi0IBXigdHoYtW1XbnHGCLWNH KjEse0lxeZcElGVRR/b5d7cHL6QfUpWq+RzEpLvzc6dVgTN0PmmHZgvvCNbO0yA4JYHL qyOpJ26+6WY7FQjVwjJUV7nEbYkUaB9X1G3VPzV6psGIUzqV+nQc2WWYPaeWHtEKfhnt NWkA== 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: AGRZ1gLScqBl4t7tHAbf1dZZHsjwUELNzUW2gN/dWh0s33/8X61EjLe9 R2soEM2fE7OZBEAVCcph1I+6S5LbJym72ERGGoCsrYH/5GWL/z/cXLtZgt3XBwr55zBe7yEGula tXT0UbH3BdZrhu7nTAQi0k5pHzAURyodJ4YLuMWCCPsHFgqqA/3ej2Od3EKBmoUvfK5FNMAH1b3 yLBPIFGe7iupMA9s7yCE7jNFOsoIP1cYjnfZFAsaM5rr9cNGSR+/Ku7PlJvNxkwXNxG6ehrKxs/ h7jgtxQE/S7+rMosdOQ8oSi62s8TSHADwBLzpSt+pUZ7zygZ0e0l2tpfeglo1Vb3Qn72z33EeE0 IWFEUB06Vhyg6Vnn/XfiHSbcx29vcd5VPjThYiOnJTjK1T1cCL27C0OEZWyp3RdfWurS8qDl3Q= = X-Received: by 2002:a17:906:858c:: with SMTP id v12-v6mr2028704ejx.172.1542721419688; Tue, 20 Nov 2018 05:43:39 -0800 (PST) X-Received: by 2002:a17:906:858c:: with SMTP id v12-v6mr2028673ejx.172.1542721418750; Tue, 20 Nov 2018 05:43:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542721418; cv=none; d=google.com; s=arc-20160816; b=JRfZO2o+oUGSUPu6l1sjQW8l7ngVQlLswuC5QGrupCq1nFw5cMK2y7Wv79VC6zVrL9 SVvjWmPUMO/m3CXyK+0XPztewpFEiKoU/QCEck0IATW5JjtQag/1ke5eqt1VfjOL1C/z k1KNHReFSkhrSxjtI5O+FQbwQufi2JIGHirvh5AykWq6CwxTi4s1rnsQ74DzUyZ3FUQ+ 7lB6+HAI40T+MzlgkFxDI6GyACaLiGABqsuJDOnUDFtUm5TuxmJ28GJdyPHeyNVTdAWJ 4av6NBpFss/fOvoaX3Uw57RdbLSKRmK4ltflpITn4F4JWGIx83TKakgSTxQ0cHnEDzw4 dzpw== 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=/sEYolIbYeBRlPTEJk3IyaZRfhMjojYPi0YASgHfRGI=; b=OzEmUVnw3yAi1wKXjkknu/z4Y0ObbVJqwHi+YmlGO+sLO8cgvZp4/cVCtynpTil0bV IXXqfyXObPBoxCvYM/Phjfao/DmRpzsGkEKSNt6L57m8oyUcUP23i+O1BupwzaaU25tN EASkZH6CHIyhmJITFhajiv8ujbv1rxjcbseeWcADuM6wzjI84yxIsQyHxdBBfRYgIlUi qZ6wrIYBrYSqREvzSnqy1aZw1aGpoGHsD3+W2+KdafCd9dN8jnpXDyPEvKJhZRk1D5F1 /RsjcbP0mCCRbXOdBRnTls0cGEQjCes66aF2SIPo36xj/TeGegFtYhrp9Yd0Z45GKMir GhNg== 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 s4sor6858427edx.12.2018.11.20.05.43.38 for (Google Transport Security); Tue, 20 Nov 2018 05:43:38 -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/Xq+FylGFMKZlo0fPRxIfOZYXl+3i3vcWbXu5KuTcyyuMAc1+bVUL4AAeeLNkbOPYEcxvkmwQ== X-Received: by 2002:a50:a6cf:: with SMTP id f15mr2266604edc.97.1542721418061; Tue, 20 Nov 2018 05:43:38 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id 49sm8428786edz.59.2018.11.20.05.43.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 05:43:37 -0800 (PST) From: Michal Hocko To: Cc: Andrew Morton , Oscar Salvador , Pavel Tatashin , David Hildenbrand , LKML , Michal Hocko , "Kirill A. Shutemov" Subject: [RFC PATCH 3/3] mm, fault_around: do not take a reference to a locked page Date: Tue, 20 Nov 2018 14:43:23 +0100 Message-Id: <20181120134323.13007-4-mhocko@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120134323.13007-1-mhocko@kernel.org> References: <20181120134323.13007-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. Cc: "Kirill A. Shutemov" Suggested-by: Jan Kara Signed-off-by: Michal Hocko Acked-by: Kirill A. Shutemov Reviewed-by: David Hildenbrand Acked-by: Hugh Dickins Reviewed-by: William Kucharski --- mm/filemap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 81adec8ee02c..c76d6a251770 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2553,6 +2553,9 @@ void filemap_map_pages(struct vm_fault *vmf, goto next; head = compound_head(page); + + if (PageLocked(head)) + goto next; if (!page_cache_get_speculative(head)) goto next;