From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f198.google.com (mail-wr0-f198.google.com [209.85.128.198]) by kanga.kvack.org (Postfix) with ESMTP id CB1F66B03BD for ; Mon, 4 Sep 2017 04:21:57 -0400 (EDT) Received: by mail-wr0-f198.google.com with SMTP id b9so6126154wra.3 for ; Mon, 04 Sep 2017 01:21:57 -0700 (PDT) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j2sor1574wmd.38.2017.09.04.01.21.56 for (Google Transport Security); Mon, 04 Sep 2017 01:21:56 -0700 (PDT) From: Michal Hocko Subject: [PATCH 0/2] mm, memory_hotplug: redefine memory offline retry logic Date: Mon, 4 Sep 2017 10:21:46 +0200 Message-Id: <20170904082148.23131-1-mhocko@kernel.org> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML Hi, while testing memory hotplug on a large 4TB machine we have noticed that memory offlining is just too eager to fail. The primary reason is that the retry logic is just too easy to give up. We have 4 ways out of the offline - we have a permanent failure (isolation or memory notifiers fail, or hugetlb pages cannot be dropped) - userspace sends a signal - a hardcoded 120s timeout expires - page migration fails 5 times This is way too convoluted and it doesn't scale very well. We have seen both temporary migration failures as well as 120s being triggered. After removing those restrictions we were able to pass stress testing during memory hot remove without any other negative side effects observed. Therefore I suggest dropping both hard coded policies. I couldn't have found any specific reason for them in the changelog. I neither didn't get any response [1] from Kamezawa. If we need some upper bound - e.g. timeout based - then we should have a proper and user defined policy for that. In any case there should be a clear use case when introducing it. Any comments, objections? Shortlog Michal Hocko (2): mm, memory_hotplug: do not fail offlining too early mm, memory_hotplug: remove timeout from __offline_memory Diffstat mm/memory_hotplug.c | 48 ++++++++++++------------------------------------ 1 file changed, 12 insertions(+), 36 deletions(-) [1] http://lkml.kernel.org/r/20170828094316.GF17097@dhcp22.suse.cz -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f69.google.com (mail-wm0-f69.google.com [74.125.82.69]) by kanga.kvack.org (Postfix) with ESMTP id 9B1F46B03C1 for ; Mon, 4 Sep 2017 04:21:58 -0400 (EDT) Received: by mail-wm0-f69.google.com with SMTP id r75so2522677wmf.6 for ; Mon, 04 Sep 2017 01:21:58 -0700 (PDT) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m2sor640421wmg.69.2017.09.04.01.21.57 for (Google Transport Security); Mon, 04 Sep 2017 01:21:57 -0700 (PDT) From: Michal Hocko Subject: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early Date: Mon, 4 Sep 2017 10:21:47 +0200 Message-Id: <20170904082148.23131-2-mhocko@kernel.org> In-Reply-To: <20170904082148.23131-1-mhocko@kernel.org> References: <20170904082148.23131-1-mhocko@kernel.org> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Michal Hocko From: Michal Hocko Memory offlining can fail just too eagerly under a heavy memory pressure. [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) [ 5410.336811] page dumped because: isolation failed [ 5410.336813] page->mem_cgroup:ffff8801cd662000 [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed Isolation has failed here because the page is not on LRU. Most probably because it was on the pcp LRU cache or it has been removed from the LRU already but it hasn't been freed yet. In both cases the page doesn't look non-migrable so retrying more makes sense. __offline_pages seems rather cluttered when it comes to the retry logic. We have 5 retries at maximum and a timeout. We could argue whether the timeout makes sense but failing just because of a race when somebody isoltes a page from LRU or puts it on a pcp LRU lists is just wrong. It only takes it to race with a process which unmaps some pages and remove them from the LRU list and we can fail the whole offline because of something that is a temporary condition and actually not harmful for the offline. Please note that unmovable pages should be already excluded during start_isolate_page_range. Fix this by removing the max retry count and only rely on the timeout resp. interruption by a signal from the userspace. Also retry rather than fail when check_pages_isolated sees some !free pages because those could be a result of the race as well. Signed-off-by: Michal Hocko --- mm/memory_hotplug.c | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 459bbc182d10..c9dcbe6d2ac6 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1597,7 +1597,7 @@ static int __ref __offline_pages(unsigned long start_pfn, { unsigned long pfn, nr_pages, expire; long offlined_pages; - int ret, drain, retry_max, node; + int ret, node; unsigned long flags; unsigned long valid_start, valid_end; struct zone *zone; @@ -1634,43 +1634,25 @@ static int __ref __offline_pages(unsigned long start_pfn, pfn = start_pfn; expire = jiffies + timeout; - drain = 0; - retry_max = 5; repeat: /* start memory hot removal */ - ret = -EAGAIN; + ret = -EBUSY; if (time_after(jiffies, expire)) goto failed_removal; ret = -EINTR; if (signal_pending(current)) goto failed_removal; - ret = 0; - if (drain) { - lru_add_drain_all_cpuslocked(); - cond_resched(); - drain_all_pages(zone); - } + + cond_resched(); + lru_add_drain_all_cpuslocked(); + 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); - if (!ret) { - drain = 1; - goto repeat; - } else { - if (ret < 0) - if (--retry_max == 0) - goto failed_removal; - yield(); - drain = 1; - goto repeat; - } + goto repeat; } - /* drain all zone's lru pagevec, this is asynchronous... */ - lru_add_drain_all_cpuslocked(); - yield(); - /* drain pcp pages, this is synchronous. */ - drain_all_pages(zone); + /* * dissolve free hugepages in the memory block before doing offlining * actually in order to make hugetlbfs's object counting consistent. @@ -1680,10 +1662,8 @@ static int __ref __offline_pages(unsigned long start_pfn, goto failed_removal; /* check again */ offlined_pages = check_pages_isolated(start_pfn, end_pfn); - if (offlined_pages < 0) { - ret = -EBUSY; - goto failed_removal; - } + 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. */ -- 2.14.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f199.google.com (mail-wr0-f199.google.com [209.85.128.199]) by kanga.kvack.org (Postfix) with ESMTP id 8B8FC6B0491 for ; Mon, 4 Sep 2017 04:21:59 -0400 (EDT) Received: by mail-wr0-f199.google.com with SMTP id n33so3875178wrn.6 for ; Mon, 04 Sep 2017 01:21:59 -0700 (PDT) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b8sor770574wrf.5.2017.09.04.01.21.58 for (Google Transport Security); Mon, 04 Sep 2017 01:21:58 -0700 (PDT) From: Michal Hocko Subject: [PATCH 2/2] mm, memory_hotplug: remove timeout from __offline_memory Date: Mon, 4 Sep 2017 10:21:48 +0200 Message-Id: <20170904082148.23131-3-mhocko@kernel.org> In-Reply-To: <20170904082148.23131-1-mhocko@kernel.org> References: <20170904082148.23131-1-mhocko@kernel.org> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Michal Hocko From: Michal Hocko We have a hardcoded 120s timeout after which the memory offline fails basically since the hot remove has been introduced. This is essentially a policy implemented in the kernel. Moreover there is no way to adjust the timeout and so we are sometimes facing memory offline failures if the system is under a heavy memory pressure or very intensive CPU workload on large machines. It is not very clear what purpose the timeout actually serves. The offline operation is interruptible by a signal so if userspace wants some timeout based termination this can be done trivially by sending a signal. If there is a strong usecase to do this from the kernel then we should do it properly and have a it tunable from the userspace with the timeout disabled by default along with the explanation who uses it and for what purporse. Signed-off-by: Michal Hocko --- mm/memory_hotplug.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index c9dcbe6d2ac6..b8a85c11360e 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1593,9 +1593,9 @@ static void node_states_clear_node(int node, struct memory_notify *arg) } static int __ref __offline_pages(unsigned long start_pfn, - unsigned long end_pfn, unsigned long timeout) + unsigned long end_pfn) { - unsigned long pfn, nr_pages, expire; + unsigned long pfn, nr_pages; long offlined_pages; int ret, node; unsigned long flags; @@ -1633,12 +1633,8 @@ static int __ref __offline_pages(unsigned long start_pfn, goto failed_removal; pfn = start_pfn; - expire = jiffies + timeout; repeat: /* start memory hot removal */ - ret = -EBUSY; - if (time_after(jiffies, expire)) - goto failed_removal; ret = -EINTR; if (signal_pending(current)) goto failed_removal; @@ -1711,7 +1707,7 @@ static int __ref __offline_pages(unsigned long start_pfn, /* Must be protected by mem_hotplug_begin() or a device_lock */ int offline_pages(unsigned long start_pfn, unsigned long nr_pages) { - return __offline_pages(start_pfn, start_pfn + nr_pages, 120 * HZ); + return __offline_pages(start_pfn, start_pfn + nr_pages); } #endif /* CONFIG_MEMORY_HOTREMOVE */ -- 2.14.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by kanga.kvack.org (Postfix) with ESMTP id B6F286B049D for ; Mon, 4 Sep 2017 05:01:18 -0400 (EDT) Received: by mail-wm0-f72.google.com with SMTP id l19so8851742wmi.1 for ; Mon, 04 Sep 2017 02:01:18 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id c2si4801614wrf.192.2017.09.04.02.01.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 02:01:17 -0700 (PDT) Date: Mon, 4 Sep 2017 11:01:14 +0200 From: Michal Hocko Subject: Re: [PATCH 2/2] mm, memory_hotplug: remove timeout from __offline_memory Message-ID: <20170904090114.mrjxipvucieadxa6@dhcp22.suse.cz> References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-3-mhocko@kernel.org> <59AD15B6.7080304@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <59AD15B6.7080304@huawei.com> Sender: owner-linux-mm@kvack.org List-ID: To: Xishi Qiu Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On Mon 04-09-17 16:58:30, Xishi Qiu wrote: > On 2017/9/4 16:21, Michal Hocko wrote: > > > From: Michal Hocko > > > > We have a hardcoded 120s timeout after which the memory offline fails > > basically since the hot remove has been introduced. This is essentially > > a policy implemented in the kernel. Moreover there is no way to adjust > > the timeout and so we are sometimes facing memory offline failures if > > the system is under a heavy memory pressure or very intensive CPU > > workload on large machines. > > > > It is not very clear what purpose the timeout actually serves. The > > offline operation is interruptible by a signal so if userspace wants > > Hi Michal, > > If the user know what he should do if migration for a long time, > it is OK, but I don't think all the users know this operation > (e.g. ctrl + c) and the affect. How is this operation any different from other potentially long interruptible syscalls? -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by kanga.kvack.org (Postfix) with ESMTP id 3E98D6B049F for ; Mon, 4 Sep 2017 05:03:19 -0400 (EDT) Received: by mail-oi0-f70.google.com with SMTP id f138so3025650oih.1 for ; Mon, 04 Sep 2017 02:03:19 -0700 (PDT) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com. [45.249.212.191]) by mx.google.com with ESMTPS id p125si4425248oih.148.2017.09.04.02.03.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 02:03:18 -0700 (PDT) Message-ID: <59AD15B6.7080304@huawei.com> Date: Mon, 4 Sep 2017 16:58:30 +0800 From: Xishi Qiu MIME-Version: 1.0 Subject: Re: [PATCH 2/2] mm, memory_hotplug: remove timeout from __offline_memory References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-3-mhocko@kernel.org> In-Reply-To: <20170904082148.23131-3-mhocko@kernel.org> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Michal Hocko On 2017/9/4 16:21, Michal Hocko wrote: > From: Michal Hocko > > We have a hardcoded 120s timeout after which the memory offline fails > basically since the hot remove has been introduced. This is essentially > a policy implemented in the kernel. Moreover there is no way to adjust > the timeout and so we are sometimes facing memory offline failures if > the system is under a heavy memory pressure or very intensive CPU > workload on large machines. > > It is not very clear what purpose the timeout actually serves. The > offline operation is interruptible by a signal so if userspace wants Hi Michal, If the user know what he should do if migration for a long time, it is OK, but I don't think all the users know this operation (e.g. ctrl + c) and the affect. Thanks, Xishi Qiu > some timeout based termination this can be done trivially by sending a > signal. > > If there is a strong usecase to do this from the kernel then we should > do it properly and have a it tunable from the userspace with the timeout > disabled by default along with the explanation who uses it and for what > purporse. > > Signed-off-by: Michal Hocko > --- > mm/memory_hotplug.c | 10 +++------- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index c9dcbe6d2ac6..b8a85c11360e 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1593,9 +1593,9 @@ static void node_states_clear_node(int node, struct memory_notify *arg) > } > > static int __ref __offline_pages(unsigned long start_pfn, > - unsigned long end_pfn, unsigned long timeout) > + unsigned long end_pfn) > { > - unsigned long pfn, nr_pages, expire; > + unsigned long pfn, nr_pages; > long offlined_pages; > int ret, node; > unsigned long flags; > @@ -1633,12 +1633,8 @@ static int __ref __offline_pages(unsigned long start_pfn, > goto failed_removal; > > pfn = start_pfn; > - expire = jiffies + timeout; > repeat: > /* start memory hot removal */ > - ret = -EBUSY; > - if (time_after(jiffies, expire)) > - goto failed_removal; > ret = -EINTR; > if (signal_pending(current)) > goto failed_removal; > @@ -1711,7 +1707,7 @@ static int __ref __offline_pages(unsigned long start_pfn, > /* Must be protected by mem_hotplug_begin() or a device_lock */ > int offline_pages(unsigned long start_pfn, unsigned long nr_pages) > { > - return __offline_pages(start_pfn, start_pfn + nr_pages, 120 * HZ); > + return __offline_pages(start_pfn, start_pfn + nr_pages); > } > #endif /* CONFIG_MEMORY_HOTREMOVE */ > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f70.google.com (mail-it0-f70.google.com [209.85.214.70]) by kanga.kvack.org (Postfix) with ESMTP id 9A78D6B04A1 for ; Mon, 4 Sep 2017 05:10:03 -0400 (EDT) Received: by mail-it0-f70.google.com with SMTP id s132so8616949ita.6 for ; Mon, 04 Sep 2017 02:10:03 -0700 (PDT) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com. [45.249.212.191]) by mx.google.com with ESMTPS id c79si5790139itc.195.2017.09.04.02.10.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 02:10:02 -0700 (PDT) Message-ID: <59AD174B.4020807@huawei.com> Date: Mon, 4 Sep 2017 17:05:15 +0800 From: Xishi Qiu MIME-Version: 1.0 Subject: Re: [PATCH 2/2] mm, memory_hotplug: remove timeout from __offline_memory References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-3-mhocko@kernel.org> <59AD15B6.7080304@huawei.com> <20170904090114.mrjxipvucieadxa6@dhcp22.suse.cz> In-Reply-To: <20170904090114.mrjxipvucieadxa6@dhcp22.suse.cz> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On 2017/9/4 17:01, Michal Hocko wrote: > On Mon 04-09-17 16:58:30, Xishi Qiu wrote: >> On 2017/9/4 16:21, Michal Hocko wrote: >> >>> From: Michal Hocko >>> >>> We have a hardcoded 120s timeout after which the memory offline fails >>> basically since the hot remove has been introduced. This is essentially >>> a policy implemented in the kernel. Moreover there is no way to adjust >>> the timeout and so we are sometimes facing memory offline failures if >>> the system is under a heavy memory pressure or very intensive CPU >>> workload on large machines. >>> >>> It is not very clear what purpose the timeout actually serves. The >>> offline operation is interruptible by a signal so if userspace wants >> >> Hi Michal, >> >> If the user know what he should do if migration for a long time, >> it is OK, but I don't think all the users know this operation >> (e.g. ctrl + c) and the affect. > > How is this operation any different from other potentially long > interruptible syscalls? > Hi Michal, I means the user should stop it by himself if migration always retry in endless. Thanks, Xishi Qiu -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 15F826B04A3 for ; Mon, 4 Sep 2017 05:15:09 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id u26so8879488wma.3 for ; Mon, 04 Sep 2017 02:15:09 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id c136si85177wmh.22.2017.09.04.02.15.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 02:15:07 -0700 (PDT) Date: Mon, 4 Sep 2017 11:15:05 +0200 From: Michal Hocko Subject: Re: [PATCH 2/2] mm, memory_hotplug: remove timeout from __offline_memory Message-ID: <20170904091505.xffd7orldpwlmrlx@dhcp22.suse.cz> References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-3-mhocko@kernel.org> <59AD15B6.7080304@huawei.com> <20170904090114.mrjxipvucieadxa6@dhcp22.suse.cz> <59AD174B.4020807@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <59AD174B.4020807@huawei.com> Sender: owner-linux-mm@kvack.org List-ID: To: Xishi Qiu Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On Mon 04-09-17 17:05:15, Xishi Qiu wrote: > On 2017/9/4 17:01, Michal Hocko wrote: > > > On Mon 04-09-17 16:58:30, Xishi Qiu wrote: > >> On 2017/9/4 16:21, Michal Hocko wrote: > >> > >>> From: Michal Hocko > >>> > >>> We have a hardcoded 120s timeout after which the memory offline fails > >>> basically since the hot remove has been introduced. This is essentially > >>> a policy implemented in the kernel. Moreover there is no way to adjust > >>> the timeout and so we are sometimes facing memory offline failures if > >>> the system is under a heavy memory pressure or very intensive CPU > >>> workload on large machines. > >>> > >>> It is not very clear what purpose the timeout actually serves. The > >>> offline operation is interruptible by a signal so if userspace wants > >> > >> Hi Michal, > >> > >> If the user know what he should do if migration for a long time, > >> it is OK, but I don't think all the users know this operation > >> (e.g. ctrl + c) and the affect. > > > > How is this operation any different from other potentially long > > interruptible syscalls? > > > > Hi Michal, > > I means the user should stop it by himself if migration always retry in endless. If the memory is migrateable then the migration should finish eventually. It can take some time but it shouldn't be an endless loop. -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by kanga.kvack.org (Postfix) with ESMTP id 082C16B04C9 for ; Tue, 5 Sep 2017 01:48:26 -0400 (EDT) Received: by mail-wm0-f70.google.com with SMTP id x189so2724930wmg.5 for ; Mon, 04 Sep 2017 22:48:25 -0700 (PDT) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id 5si6645841wry.0.2017.09.04.22.48.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Sep 2017 22:48:24 -0700 (PDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v855i7eb136656 for ; Tue, 5 Sep 2017 01:48:23 -0400 Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) by mx0b-001b2d01.pphosted.com with ESMTP id 2csnjh1a74-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 05 Sep 2017 01:48:23 -0400 Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Sep 2017 15:48:20 +1000 Received: from d23av06.au.ibm.com (d23av06.au.ibm.com [9.190.235.151]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v855l39938928442 for ; Tue, 5 Sep 2017 15:47:03 +1000 Received: from d23av06.au.ibm.com (localhost [127.0.0.1]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v855l2wF010652 for ; Tue, 5 Sep 2017 15:47:03 +1000 Subject: Re: [PATCH 2/2] mm, memory_hotplug: remove timeout from __offline_memory References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-3-mhocko@kernel.org> <59AD15B6.7080304@huawei.com> <20170904090114.mrjxipvucieadxa6@dhcp22.suse.cz> <59AD174B.4020807@huawei.com> <20170904091505.xffd7orldpwlmrlx@dhcp22.suse.cz> From: Anshuman Khandual Date: Tue, 5 Sep 2017 11:16:57 +0530 MIME-Version: 1.0 In-Reply-To: <20170904091505.xffd7orldpwlmrlx@dhcp22.suse.cz> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Message-Id: Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko , Xishi Qiu Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On 09/04/2017 02:45 PM, Michal Hocko wrote: > On Mon 04-09-17 17:05:15, Xishi Qiu wrote: >> On 2017/9/4 17:01, Michal Hocko wrote: >> >>> On Mon 04-09-17 16:58:30, Xishi Qiu wrote: >>>> On 2017/9/4 16:21, Michal Hocko wrote: >>>> >>>>> From: Michal Hocko >>>>> >>>>> We have a hardcoded 120s timeout after which the memory offline fails >>>>> basically since the hot remove has been introduced. This is essentially >>>>> a policy implemented in the kernel. Moreover there is no way to adjust >>>>> the timeout and so we are sometimes facing memory offline failures if >>>>> the system is under a heavy memory pressure or very intensive CPU >>>>> workload on large machines. >>>>> >>>>> It is not very clear what purpose the timeout actually serves. The >>>>> offline operation is interruptible by a signal so if userspace wants >>>> Hi Michal, >>>> >>>> If the user know what he should do if migration for a long time, >>>> it is OK, but I don't think all the users know this operation >>>> (e.g. ctrl + c) and the affect. >>> How is this operation any different from other potentially long >>> interruptible syscalls? >>> >> Hi Michal, >> >> I means the user should stop it by himself if migration always retry in endless. > If the memory is migrateable then the migration should finish > eventually. It can take some time but it shouldn't be an endless loop. But what if some how the temporary condition (page removed from the PCP LRU list and has not been freed yet to the buddy) happens again and again. I understand we have schedule() and yield() to make sure that the context does not hold the CPU for ever but it can take theoretically very long time if not endless to finish. In that case sending signal to the user space process who initiated the offline request is the only way to stop this retry loop. I think this is still a better approach than the 120 second timeout which was kind of arbitrary. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by kanga.kvack.org (Postfix) with ESMTP id BD6C66B04D1 for ; Tue, 5 Sep 2017 02:29:51 -0400 (EDT) Received: by mail-wm0-f70.google.com with SMTP id r75so2834798wmf.6 for ; Mon, 04 Sep 2017 23:29:51 -0700 (PDT) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id d30si2376469wra.79.2017.09.04.23.29.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Sep 2017 23:29:50 -0700 (PDT) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v856ScNG004535 for ; Tue, 5 Sep 2017 02:29:48 -0400 Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cshw8bh8t-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 05 Sep 2017 02:29:48 -0400 Received: from localhost by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Sep 2017 16:29:45 +1000 Received: from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v856TgPs39452826 for ; Tue, 5 Sep 2017 16:29:43 +1000 Received: from d23av05.au.ibm.com (localhost [127.0.0.1]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v856Tg5L013743 for ; Tue, 5 Sep 2017 16:29:42 +1000 Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-2-mhocko@kernel.org> From: Anshuman Khandual Date: Tue, 5 Sep 2017 11:59:36 +0530 MIME-Version: 1.0 In-Reply-To: <20170904082148.23131-2-mhocko@kernel.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Message-Id: Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko , Andrew Morton Cc: KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Michal Hocko On 09/04/2017 01:51 PM, Michal Hocko wrote: > From: Michal Hocko > > Memory offlining can fail just too eagerly under a heavy memory pressure. > > [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 > [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) > [ 5410.336811] page dumped because: isolation failed > [ 5410.336813] page->mem_cgroup:ffff8801cd662000 > [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed > > Isolation has failed here because the page is not on LRU. Most probably > because it was on the pcp LRU cache or it has been removed from the LRU > already but it hasn't been freed yet. In both cases the page doesn't look > non-migrable so retrying more makes sense. > > __offline_pages seems rather cluttered when it comes to the retry > logic. We have 5 retries at maximum and a timeout. We could argue > whether the timeout makes sense but failing just because of a race when > somebody isoltes a page from LRU or puts it on a pcp LRU lists is just > wrong. It only takes it to race with a process which unmaps some pages > and remove them from the LRU list and we can fail the whole offline > because of something that is a temporary condition and actually not > harmful for the offline. Please note that unmovable pages should be > already excluded during start_isolate_page_range. > > Fix this by removing the max retry count and only rely on the timeout > resp. interruption by a signal from the userspace. Also retry rather > than fail when check_pages_isolated sees some !free pages because those > could be a result of the race as well. > > Signed-off-by: Michal Hocko > --- > mm/memory_hotplug.c | 40 ++++++++++------------------------------ > 1 file changed, 10 insertions(+), 30 deletions(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 459bbc182d10..c9dcbe6d2ac6 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1597,7 +1597,7 @@ static int __ref __offline_pages(unsigned long start_pfn, > { > unsigned long pfn, nr_pages, expire; > long offlined_pages; > - int ret, drain, retry_max, node; > + int ret, node; > unsigned long flags; > unsigned long valid_start, valid_end; > struct zone *zone; > @@ -1634,43 +1634,25 @@ static int __ref __offline_pages(unsigned long start_pfn, > > pfn = start_pfn; > expire = jiffies + timeout; > - drain = 0; > - retry_max = 5; > repeat: > /* start memory hot removal */ > - ret = -EAGAIN; > + ret = -EBUSY; > if (time_after(jiffies, expire)) > goto failed_removal; > ret = -EINTR; > if (signal_pending(current)) > goto failed_removal; > - ret = 0; > - if (drain) { > - lru_add_drain_all_cpuslocked(); > - cond_resched(); > - drain_all_pages(zone); > - } Why we had this condition before that only when we fail in migration later in do_migrate_range function, drain the lru lists in the next attempt. Why not from the first attempt itself ? Just being curious. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by kanga.kvack.org (Postfix) with ESMTP id EB29028030E for ; Tue, 5 Sep 2017 03:13:11 -0400 (EDT) Received: by mail-wm0-f72.google.com with SMTP id x189so2959268wmg.5 for ; Tue, 05 Sep 2017 00:13:11 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id k128si27743wmb.185.2017.09.05.00.13.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Sep 2017 00:13:10 -0700 (PDT) Date: Tue, 5 Sep 2017 09:13:07 +0200 From: Michal Hocko Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early Message-ID: <20170905071307.7aggprk66r3cem4p@dhcp22.suse.cz> References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-2-mhocko@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Anshuman Khandual Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On Tue 05-09-17 11:59:36, Anshuman Khandual wrote: [...] > > @@ -1634,43 +1634,25 @@ static int __ref __offline_pages(unsigned long start_pfn, > > > > pfn = start_pfn; > > expire = jiffies + timeout; > > - drain = 0; > > - retry_max = 5; > > repeat: > > /* start memory hot removal */ > > - ret = -EAGAIN; > > + ret = -EBUSY; > > if (time_after(jiffies, expire)) > > goto failed_removal; > > ret = -EINTR; > > if (signal_pending(current)) > > goto failed_removal; > > - ret = 0; > > - if (drain) { > > - lru_add_drain_all_cpuslocked(); > > - cond_resched(); > > - drain_all_pages(zone); > > - } > > Why we had this condition before that only when we fail in migration > later in do_migrate_range function, drain the lru lists in the next > attempt. Why not from the first attempt itself ? Just being curious. I can only guess but draining used to invoke IPIs and that is really costly so an optimistic attempt could try without draining and do that only if the migration fails. Now that we have it all done in WQ context there shouldn't be any reason to optimize for draining. -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by kanga.kvack.org (Postfix) with ESMTP id 6A42828030E for ; Tue, 5 Sep 2017 03:23:14 -0400 (EDT) Received: by mail-wm0-f70.google.com with SMTP id e64so3008862wmi.0 for ; Tue, 05 Sep 2017 00:23:14 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id l4si19608wml.66.2017.09.05.00.23.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Sep 2017 00:23:13 -0700 (PDT) Date: Tue, 5 Sep 2017 09:23:10 +0200 From: Michal Hocko Subject: Re: [PATCH 2/2] mm, memory_hotplug: remove timeout from __offline_memory Message-ID: <20170905072310.6iuui7h7rwrrnxdy@dhcp22.suse.cz> References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-3-mhocko@kernel.org> <59AD15B6.7080304@huawei.com> <20170904090114.mrjxipvucieadxa6@dhcp22.suse.cz> <59AD174B.4020807@huawei.com> <20170904091505.xffd7orldpwlmrlx@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Anshuman Khandual Cc: Xishi Qiu , Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On Tue 05-09-17 11:16:57, Anshuman Khandual wrote: > On 09/04/2017 02:45 PM, Michal Hocko wrote: > > On Mon 04-09-17 17:05:15, Xishi Qiu wrote: > >> On 2017/9/4 17:01, Michal Hocko wrote: > >> > >>> On Mon 04-09-17 16:58:30, Xishi Qiu wrote: > >>>> On 2017/9/4 16:21, Michal Hocko wrote: > >>>> > >>>>> From: Michal Hocko > >>>>> > >>>>> We have a hardcoded 120s timeout after which the memory offline fails > >>>>> basically since the hot remove has been introduced. This is essentially > >>>>> a policy implemented in the kernel. Moreover there is no way to adjust > >>>>> the timeout and so we are sometimes facing memory offline failures if > >>>>> the system is under a heavy memory pressure or very intensive CPU > >>>>> workload on large machines. > >>>>> > >>>>> It is not very clear what purpose the timeout actually serves. The > >>>>> offline operation is interruptible by a signal so if userspace wants > >>>> Hi Michal, > >>>> > >>>> If the user know what he should do if migration for a long time, > >>>> it is OK, but I don't think all the users know this operation > >>>> (e.g. ctrl + c) and the affect. > >>> How is this operation any different from other potentially long > >>> interruptible syscalls? > >>> > >> Hi Michal, > >> > >> I means the user should stop it by himself if migration always retry in endless. > > If the memory is migrateable then the migration should finish > > eventually. It can take some time but it shouldn't be an endless loop. > > But what if some how the temporary condition (page removed from the PCP > LRU list and has not been freed yet to the buddy) happens again and again. How would that happen? We have all pages in the range MIGRATE_ISOLATE so no pages will get reallocated and we know that there are no unmigratable pages in the range. So we only should have temporary failures for migration. If that is not the case then we have a bug somewhere. > I understand we have schedule() and yield() to make sure that the context > does not hold the CPU for ever but it can take theoretically very long > time if not endless to finish. In that case sending signal to the user I guess you meant to say signal from the user space... > space process who initiated the offline request is the only way to stop > this retry loop. I think this is still a better approach than the 120 > second timeout which was kind of arbitrary. Yeah the context is interruptible so if the operation takes unbearably too long then a watchdog can be setup trivially and to the user defined value. There is a good reason we do not add hardocded timeouts to the kernel. -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f69.google.com (mail-pg0-f69.google.com [74.125.83.69]) by kanga.kvack.org (Postfix) with ESMTP id 8E1F228039D for ; Tue, 5 Sep 2017 04:54:40 -0400 (EDT) Received: by mail-pg0-f69.google.com with SMTP id m9so6358846pgd.2 for ; Tue, 05 Sep 2017 01:54:40 -0700 (PDT) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id f30si8242plj.230.2017.09.05.01.54.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Sep 2017 01:54:39 -0700 (PDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v858s4Bn048360 for ; Tue, 5 Sep 2017 04:54:39 -0400 Received: from e23smtp04.au.ibm.com (e23smtp04.au.ibm.com [202.81.31.146]) by mx0a-001b2d01.pphosted.com with ESMTP id 2csnv1srf7-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 05 Sep 2017 04:54:38 -0400 Received: from localhost by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Sep 2017 18:54:35 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v858sXWG41680922 for ; Tue, 5 Sep 2017 18:54:33 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v858sWfu022093 for ; Tue, 5 Sep 2017 18:54:32 +1000 Subject: Re: [PATCH 2/2] mm, memory_hotplug: remove timeout from __offline_memory References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-3-mhocko@kernel.org> <59AD15B6.7080304@huawei.com> <20170904090114.mrjxipvucieadxa6@dhcp22.suse.cz> <59AD174B.4020807@huawei.com> <20170904091505.xffd7orldpwlmrlx@dhcp22.suse.cz> <20170905072310.6iuui7h7rwrrnxdy@dhcp22.suse.cz> From: Anshuman Khandual Date: Tue, 5 Sep 2017 14:24:26 +0530 MIME-Version: 1.0 In-Reply-To: <20170905072310.6iuui7h7rwrrnxdy@dhcp22.suse.cz> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Message-Id: <9a43dffa-0e0a-ed53-63a2-677cd162a1a7@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko , Anshuman Khandual Cc: Xishi Qiu , Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On 09/05/2017 12:53 PM, Michal Hocko wrote: > On Tue 05-09-17 11:16:57, Anshuman Khandual wrote: >> On 09/04/2017 02:45 PM, Michal Hocko wrote: >>> On Mon 04-09-17 17:05:15, Xishi Qiu wrote: >>>> On 2017/9/4 17:01, Michal Hocko wrote: >>>> >>>>> On Mon 04-09-17 16:58:30, Xishi Qiu wrote: >>>>>> On 2017/9/4 16:21, Michal Hocko wrote: >>>>>> >>>>>>> From: Michal Hocko >>>>>>> >>>>>>> We have a hardcoded 120s timeout after which the memory offline fails >>>>>>> basically since the hot remove has been introduced. This is essentially >>>>>>> a policy implemented in the kernel. Moreover there is no way to adjust >>>>>>> the timeout and so we are sometimes facing memory offline failures if >>>>>>> the system is under a heavy memory pressure or very intensive CPU >>>>>>> workload on large machines. >>>>>>> >>>>>>> It is not very clear what purpose the timeout actually serves. The >>>>>>> offline operation is interruptible by a signal so if userspace wants >>>>>> Hi Michal, >>>>>> >>>>>> If the user know what he should do if migration for a long time, >>>>>> it is OK, but I don't think all the users know this operation >>>>>> (e.g. ctrl + c) and the affect. >>>>> How is this operation any different from other potentially long >>>>> interruptible syscalls? >>>>> >>>> Hi Michal, >>>> >>>> I means the user should stop it by himself if migration always retry in endless. >>> If the memory is migrateable then the migration should finish >>> eventually. It can take some time but it shouldn't be an endless loop. >> >> But what if some how the temporary condition (page removed from the PCP >> LRU list and has not been freed yet to the buddy) happens again and again. > > How would that happen? We have all pages in the range MIGRATE_ISOLATE so > no pages will get reallocated and we know that there are no unmigratable > pages in the range. So we only should have temporary failures for > migration. If that is not the case then we have a bug somewhere. Right. > >> I understand we have schedule() and yield() to make sure that the context >> does not hold the CPU for ever but it can take theoretically very long >> time if not endless to finish. In that case sending signal to the user > > I guess you meant to say signal from the user space... Yes. > >> space process who initiated the offline request is the only way to stop >> this retry loop. I think this is still a better approach than the 120 >> second timeout which was kind of arbitrary. > > Yeah the context is interruptible so if the operation takes unbearably > too long then a watchdog can be setup trivially and to the user defined > value. There is a good reason we do not add hardocded timeouts to the > kernel. > Right. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f198.google.com (mail-wr0-f198.google.com [209.85.128.198]) by kanga.kvack.org (Postfix) with ESMTP id D63E46B0342 for ; Fri, 8 Sep 2017 13:26:09 -0400 (EDT) Received: by mail-wr0-f198.google.com with SMTP id b9so3032367wra.3 for ; Fri, 08 Sep 2017 10:26:09 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id i71si1920002wme.59.2017.09.08.10.26.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Sep 2017 10:26:08 -0700 (PDT) Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-2-mhocko@kernel.org> From: Vlastimil Babka Message-ID: Date: Fri, 8 Sep 2017 19:26:06 +0200 MIME-Version: 1.0 In-Reply-To: <20170904082148.23131-2-mhocko@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko , Andrew Morton Cc: KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Michal Hocko On 09/04/2017 10:21 AM, Michal Hocko wrote: > From: Michal Hocko > > Memory offlining can fail just too eagerly under a heavy memory pressure. > > [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 > [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) > [ 5410.336811] page dumped because: isolation failed > [ 5410.336813] page->mem_cgroup:ffff8801cd662000 > [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed > > Isolation has failed here because the page is not on LRU. Most probably > because it was on the pcp LRU cache or it has been removed from the LRU > already but it hasn't been freed yet. In both cases the page doesn't look > non-migrable so retrying more makes sense. > > __offline_pages seems rather cluttered when it comes to the retry > logic. We have 5 retries at maximum and a timeout. We could argue > whether the timeout makes sense but failing just because of a race when > somebody isoltes a page from LRU or puts it on a pcp LRU lists is just > wrong. It only takes it to race with a process which unmaps some pages > and remove them from the LRU list and we can fail the whole offline > because of something that is a temporary condition and actually not > harmful for the offline. Please note that unmovable pages should be > already excluded during start_isolate_page_range. Hmm, the has_unmovable_pages() check doesn't offer any strict guarantees due to races, per its comment. Also at the very quick glance, I see a check where it assumes that MIGRATE_MOVABLE pageblock will have no unmovable pages. There is no such guarantee even without races. > Fix this by removing the max retry count and only rely on the timeout > resp. interruption by a signal from the userspace. Also retry rather > than fail when check_pages_isolated sees some !free pages because those > could be a result of the race as well. > > Signed-off-by: Michal Hocko Even within a movable node where has_unmovable_pages() is a non-issue, you could have pinned movable pages where the pinning is not temporary. So after this patch, this will really keep retrying forever. I'm not saying it's wrong, just pointing it out, since the changelog seems to assume there would be only temporary failures possible and thus unbound retries are always correct. The obvious problem if we wanted to avoid this, is how to recognize non-temporary failures... > --- > mm/memory_hotplug.c | 40 ++++++++++------------------------------ > 1 file changed, 10 insertions(+), 30 deletions(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 459bbc182d10..c9dcbe6d2ac6 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1597,7 +1597,7 @@ static int __ref __offline_pages(unsigned long start_pfn, > { > unsigned long pfn, nr_pages, expire; > long offlined_pages; > - int ret, drain, retry_max, node; > + int ret, node; > unsigned long flags; > unsigned long valid_start, valid_end; > struct zone *zone; > @@ -1634,43 +1634,25 @@ static int __ref __offline_pages(unsigned long start_pfn, > > pfn = start_pfn; > expire = jiffies + timeout; > - drain = 0; > - retry_max = 5; > repeat: > /* start memory hot removal */ > - ret = -EAGAIN; > + ret = -EBUSY; > if (time_after(jiffies, expire)) > goto failed_removal; > ret = -EINTR; > if (signal_pending(current)) > goto failed_removal; > - ret = 0; > - if (drain) { > - lru_add_drain_all_cpuslocked(); > - cond_resched(); > - drain_all_pages(zone); > - } > + > + cond_resched(); > + lru_add_drain_all_cpuslocked(); > + 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); > - if (!ret) { > - drain = 1; > - goto repeat; > - } else { > - if (ret < 0) > - if (--retry_max == 0) > - goto failed_removal; > - yield(); > - drain = 1; > - goto repeat; > - } > + goto repeat; > } > - /* drain all zone's lru pagevec, this is asynchronous... */ > - lru_add_drain_all_cpuslocked(); > - yield(); > - /* drain pcp pages, this is synchronous. */ > - drain_all_pages(zone); > + > /* > * dissolve free hugepages in the memory block before doing offlining > * actually in order to make hugetlbfs's object counting consistent. > @@ -1680,10 +1662,8 @@ static int __ref __offline_pages(unsigned long start_pfn, > goto failed_removal; > /* check again */ > offlined_pages = check_pages_isolated(start_pfn, end_pfn); > - if (offlined_pages < 0) { > - ret = -EBUSY; > - goto failed_removal; > - } > + 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. */ > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f199.google.com (mail-wr0-f199.google.com [209.85.128.199]) by kanga.kvack.org (Postfix) with ESMTP id 1B1176B0347 for ; Fri, 8 Sep 2017 13:27:31 -0400 (EDT) Received: by mail-wr0-f199.google.com with SMTP id k20so3022842wre.6 for ; Fri, 08 Sep 2017 10:27:31 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id n9si1811113wre.227.2017.09.08.10.27.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Sep 2017 10:27:29 -0700 (PDT) Subject: Re: [PATCH 2/2] mm, memory_hotplug: remove timeout from __offline_memory References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-3-mhocko@kernel.org> From: Vlastimil Babka Message-ID: Date: Fri, 8 Sep 2017 19:27:28 +0200 MIME-Version: 1.0 In-Reply-To: <20170904082148.23131-3-mhocko@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko , Andrew Morton Cc: KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Michal Hocko On 09/04/2017 10:21 AM, Michal Hocko wrote: > From: Michal Hocko > > We have a hardcoded 120s timeout after which the memory offline fails > basically since the hot remove has been introduced. This is essentially > a policy implemented in the kernel. Moreover there is no way to adjust > the timeout and so we are sometimes facing memory offline failures if > the system is under a heavy memory pressure or very intensive CPU > workload on large machines. > > It is not very clear what purpose the timeout actually serves. The > offline operation is interruptible by a signal so if userspace wants > some timeout based termination this can be done trivially by sending a > signal. > > If there is a strong usecase to do this from the kernel then we should > do it properly and have a it tunable from the userspace with the timeout > disabled by default along with the explanation who uses it and for what > purporse. > > Signed-off-by: Michal Hocko Makes sense to me. Acked-by: Vlastimil Babka > --- > mm/memory_hotplug.c | 10 +++------- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index c9dcbe6d2ac6..b8a85c11360e 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1593,9 +1593,9 @@ static void node_states_clear_node(int node, struct memory_notify *arg) > } > > static int __ref __offline_pages(unsigned long start_pfn, > - unsigned long end_pfn, unsigned long timeout) > + unsigned long end_pfn) > { > - unsigned long pfn, nr_pages, expire; > + unsigned long pfn, nr_pages; > long offlined_pages; > int ret, node; > unsigned long flags; > @@ -1633,12 +1633,8 @@ static int __ref __offline_pages(unsigned long start_pfn, > goto failed_removal; > > pfn = start_pfn; > - expire = jiffies + timeout; > repeat: > /* start memory hot removal */ > - ret = -EBUSY; > - if (time_after(jiffies, expire)) > - goto failed_removal; > ret = -EINTR; > if (signal_pending(current)) > goto failed_removal; > @@ -1711,7 +1707,7 @@ static int __ref __offline_pages(unsigned long start_pfn, > /* Must be protected by mem_hotplug_begin() or a device_lock */ > int offline_pages(unsigned long start_pfn, unsigned long nr_pages) > { > - return __offline_pages(start_pfn, start_pfn + nr_pages, 120 * HZ); > + return __offline_pages(start_pfn, start_pfn + nr_pages); > } > #endif /* CONFIG_MEMORY_HOTREMOVE */ > > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f69.google.com (mail-wm0-f69.google.com [74.125.82.69]) by kanga.kvack.org (Postfix) with ESMTP id 6BAB86B02AA for ; Mon, 11 Sep 2017 04:17:17 -0400 (EDT) Received: by mail-wm0-f69.google.com with SMTP id l19so6780624wmi.1 for ; Mon, 11 Sep 2017 01:17:17 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id b130si6153988wmh.126.2017.09.11.01.17.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 11 Sep 2017 01:17:16 -0700 (PDT) Date: Mon, 11 Sep 2017 10:17:14 +0200 From: Michal Hocko Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early Message-ID: <20170911081714.4zc33r7wlj2nnbho@dhcp22.suse.cz> References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-2-mhocko@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On Fri 08-09-17 19:26:06, Vlastimil Babka wrote: > On 09/04/2017 10:21 AM, Michal Hocko wrote: > > From: Michal Hocko > > > > Memory offlining can fail just too eagerly under a heavy memory pressure. > > > > [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 > > [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) > > [ 5410.336811] page dumped because: isolation failed > > [ 5410.336813] page->mem_cgroup:ffff8801cd662000 > > [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed > > > > Isolation has failed here because the page is not on LRU. Most probably > > because it was on the pcp LRU cache or it has been removed from the LRU > > already but it hasn't been freed yet. In both cases the page doesn't look > > non-migrable so retrying more makes sense. > > > > __offline_pages seems rather cluttered when it comes to the retry > > logic. We have 5 retries at maximum and a timeout. We could argue > > whether the timeout makes sense but failing just because of a race when > > somebody isoltes a page from LRU or puts it on a pcp LRU lists is just > > wrong. It only takes it to race with a process which unmaps some pages > > and remove them from the LRU list and we can fail the whole offline > > because of something that is a temporary condition and actually not > > harmful for the offline. Please note that unmovable pages should be > > already excluded during start_isolate_page_range. > > Hmm, the has_unmovable_pages() check doesn't offer any strict guarantees due to > races, per its comment. Also at the very quick glance, I see a check where it > assumes that MIGRATE_MOVABLE pageblock will have no unmovable pages. There is no > such guarantee even without races. Yes, you are right that there are races possible but practically speaking non-movable memblocks (in !MOVABLE_ZONE) would be very likely to have reliably unmovable pages and so has_unmovable_pages would bail out. And ZONE_MOVABLE memblocks with permanently pinned pages sound like a bug to me. > > Fix this by removing the max retry count and only rely on the timeout > > resp. interruption by a signal from the userspace. Also retry rather > > than fail when check_pages_isolated sees some !free pages because those > > could be a result of the race as well. > > > > Signed-off-by: Michal Hocko > > Even within a movable node where has_unmovable_pages() is a non-issue, you could > have pinned movable pages where the pinning is not temporary. Who would pin those pages? Such a page would be unreclaimable as well and thus a memory leak and I would argue it would be a bug. > So after this > patch, this will really keep retrying forever. I'm not saying it's wrong, just > pointing it out, since the changelog seems to assume there would be only > temporary failures possible and thus unbound retries are always correct. > The obvious problem if we wanted to avoid this, is how to recognize > non-temporary failures... Yes, we should be able to distinguish the two and hopefully we can teach the migration code to distinguish between EBUSY (likely permanent) and EGAIN (temporal) failure. This sound like something we should aim for longterm I guess. Anyway as I've said in other email. If somebody really wants to have a guaratee of a bounded retry then it is trivial to set up an alarm and send a signal itself to bail out. Do you think that the changelog should be more clear about this? -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id 12BB16B0038 for ; Wed, 13 Sep 2017 07:41:25 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id q76so25121765pfq.5 for ; Wed, 13 Sep 2017 04:41:25 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id v75si9407632pfa.181.2017.09.13.04.41.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Sep 2017 04:41:23 -0700 (PDT) Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-2-mhocko@kernel.org> <20170911081714.4zc33r7wlj2nnbho@dhcp22.suse.cz> From: Vlastimil Babka Message-ID: <9fad7246-c634-18bb-78f9-b95376c009da@suse.cz> Date: Wed, 13 Sep 2017 13:41:20 +0200 MIME-Version: 1.0 In-Reply-To: <20170911081714.4zc33r7wlj2nnbho@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On 09/11/2017 10:17 AM, Michal Hocko wrote: > On Fri 08-09-17 19:26:06, Vlastimil Babka wrote: >> On 09/04/2017 10:21 AM, Michal Hocko wrote: >>> From: Michal Hocko >>> >>> Fix this by removing the max retry count and only rely on the timeout >>> resp. interruption by a signal from the userspace. Also retry rather >>> than fail when check_pages_isolated sees some !free pages because those >>> could be a result of the race as well. >>> >>> Signed-off-by: Michal Hocko >> >> Even within a movable node where has_unmovable_pages() is a non-issue, you could >> have pinned movable pages where the pinning is not temporary. > > Who would pin those pages? Such a page would be unreclaimable as well > and thus a memory leak and I would argue it would be a bug. I don't know who exactly, but generally it's a problem for CMA and a reason why there was some effort from PeterZ to introduce an API for long-term pinning. >> So after this >> patch, this will really keep retrying forever. I'm not saying it's wrong, just >> pointing it out, since the changelog seems to assume there would be only >> temporary failures possible and thus unbound retries are always correct. >> The obvious problem if we wanted to avoid this, is how to recognize >> non-temporary failures... > > Yes, we should be able to distinguish the two and hopefully we can teach > the migration code to distinguish between EBUSY (likely permanent) and > EGAIN (temporal) failure. This sound like something we should aim for > longterm I guess. Anyway as I've said in other email. If somebody really > wants to have a guaratee of a bounded retry then it is trivial to set up > an alarm and send a signal itself to bail out. Sure, I would just be careful about not breaking existing userspace (udev?) when offline triggered via ACPI from some management interface (or whatever the exact mechanism is). > Do you think that the changelog should be more clear about this? It certainly wouldn't hurt :) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f197.google.com (mail-wr0-f197.google.com [209.85.128.197]) by kanga.kvack.org (Postfix) with ESMTP id D64206B0038 for ; Wed, 13 Sep 2017 08:10:07 -0400 (EDT) Received: by mail-wr0-f197.google.com with SMTP id 97so32891wrb.1 for ; Wed, 13 Sep 2017 05:10:07 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id a141si1011169wme.119.2017.09.13.05.10.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Sep 2017 05:10:05 -0700 (PDT) Date: Wed, 13 Sep 2017 14:10:01 +0200 From: Michal Hocko Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early Message-ID: <20170913121001.k3a5tkvunmncc5uj@dhcp22.suse.cz> References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-2-mhocko@kernel.org> <20170911081714.4zc33r7wlj2nnbho@dhcp22.suse.cz> <9fad7246-c634-18bb-78f9-b95376c009da@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9fad7246-c634-18bb-78f9-b95376c009da@suse.cz> Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On Wed 13-09-17 13:41:20, Vlastimil Babka wrote: > On 09/11/2017 10:17 AM, Michal Hocko wrote: [...] > > Yes, we should be able to distinguish the two and hopefully we can teach > > the migration code to distinguish between EBUSY (likely permanent) and > > EGAIN (temporal) failure. This sound like something we should aim for > > longterm I guess. Anyway as I've said in other email. If somebody really > > wants to have a guaratee of a bounded retry then it is trivial to set up > > an alarm and send a signal itself to bail out. > > Sure, I would just be careful about not breaking existing userspace > (udev?) when offline triggered via ACPI from some management interface > (or whatever the exact mechanism is). The thing is that there is absolutely no timing guarantee even with retry limit in place. We are doing allocations, potentially bouncing on locks which can be taken elsewhere etc... So if somebody really depend on this then it is pretty much broken already. > > Do you think that the changelog should be more clear about this? > > It certainly wouldn't hurt :) So what do you think about the following wording: commit 23c4ded55c2ba880165a9f5b8a67694361fb6bc7 Author: Michal Hocko Date: Mon Aug 28 13:13:06 2017 +0200 mm, memory_hotplug: remove timeout from __offline_memory We have a hardcoded 120s timeout after which the memory offline fails basically since the hot remove has been introduced. This is essentially a policy implemented in the kernel. Moreover there is no way to adjust the timeout and so we are sometimes facing memory offline failures if the system is under a heavy memory pressure or very intensive CPU workload on large machines. It is not very clear what purpose the timeout actually serves. The offline operation is interruptible by a signal so if userspace wants some timeout based termination this can be done trivially by sending a signal. If there is a strong usecase to do this from the kernel then we should do it properly and have a it tunable from the userspace with the timeout disabled by default along with the explanation who uses it and for what purporse. Acked-by: Vlastimil Babka Signed-off-by: Michal Hocko -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f199.google.com (mail-wr0-f199.google.com [209.85.128.199]) by kanga.kvack.org (Postfix) with ESMTP id B05676B0033 for ; Wed, 13 Sep 2017 08:14:35 -0400 (EDT) Received: by mail-wr0-f199.google.com with SMTP id d6so12725wrd.7 for ; Wed, 13 Sep 2017 05:14:35 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id p72si1054440wme.267.2017.09.13.05.14.34 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Sep 2017 05:14:34 -0700 (PDT) Date: Wed, 13 Sep 2017 14:14:33 +0200 From: Michal Hocko Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early Message-ID: <20170913121433.yjzloaf6g447zeq2@dhcp22.suse.cz> References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-2-mhocko@kernel.org> <20170911081714.4zc33r7wlj2nnbho@dhcp22.suse.cz> <9fad7246-c634-18bb-78f9-b95376c009da@suse.cz> <20170913121001.k3a5tkvunmncc5uj@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170913121001.k3a5tkvunmncc5uj@dhcp22.suse.cz> Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On Wed 13-09-17 14:10:01, Michal Hocko wrote: > On Wed 13-09-17 13:41:20, Vlastimil Babka wrote: > > On 09/11/2017 10:17 AM, Michal Hocko wrote: > [...] > > > Yes, we should be able to distinguish the two and hopefully we can teach > > > the migration code to distinguish between EBUSY (likely permanent) and > > > EGAIN (temporal) failure. This sound like something we should aim for > > > longterm I guess. Anyway as I've said in other email. If somebody really > > > wants to have a guaratee of a bounded retry then it is trivial to set up > > > an alarm and send a signal itself to bail out. > > > > Sure, I would just be careful about not breaking existing userspace > > (udev?) when offline triggered via ACPI from some management interface > > (or whatever the exact mechanism is). > > The thing is that there is absolutely no timing guarantee even with > retry limit in place. We are doing allocations, potentially bouncing on > locks which can be taken elsewhere etc... So if somebody really depend > on this then it is pretty much broken already. > > > > Do you think that the changelog should be more clear about this? > > > > It certainly wouldn't hurt :) > > So what do you think about the following wording: Ups, wrong patch From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f71.google.com (mail-pg0-f71.google.com [74.125.83.71]) by kanga.kvack.org (Postfix) with ESMTP id 22FCA6B0038 for ; Wed, 13 Sep 2017 08:19:24 -0400 (EDT) Received: by mail-pg0-f71.google.com with SMTP id 6so85585pgh.0 for ; Wed, 13 Sep 2017 05:19:24 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id q13si9125880pgn.679.2017.09.13.05.19.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Sep 2017 05:19:22 -0700 (PDT) Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-2-mhocko@kernel.org> <20170911081714.4zc33r7wlj2nnbho@dhcp22.suse.cz> <9fad7246-c634-18bb-78f9-b95376c009da@suse.cz> <20170913121001.k3a5tkvunmncc5uj@dhcp22.suse.cz> <20170913121433.yjzloaf6g447zeq2@dhcp22.suse.cz> From: Vlastimil Babka Message-ID: <25ffda93-0c0d-28b4-bd0b-7fc9df7d678a@suse.cz> Date: Wed, 13 Sep 2017 14:19:19 +0200 MIME-Version: 1.0 In-Reply-To: <20170913121433.yjzloaf6g447zeq2@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On 09/13/2017 02:14 PM, Michal Hocko wrote: >>>> Do you think that the changelog should be more clear about this? >>> >>> It certainly wouldn't hurt :) >> >> So what do you think about the following wording: > > Ups, wrong patch > > > From 8639496a834b4a7c24972ec23b17e50f0d6a304c Mon Sep 17 00:00:00 2001 > From: Michal Hocko > Date: Mon, 14 Aug 2017 10:46:12 +0200 > Subject: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early > > Memory offlining can fail just too eagerly under a heavy memory pressure. > > [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 > [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) > [ 5410.336811] page dumped because: isolation failed > [ 5410.336813] page->mem_cgroup:ffff8801cd662000 > [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed > > Isolation has failed here because the page is not on LRU. Most probably > because it was on the pcp LRU cache or it has been removed from the LRU > already but it hasn't been freed yet. In both cases the page doesn't look > non-migrable so retrying more makes sense. > > __offline_pages seems rather cluttered when it comes to the retry > logic. We have 5 retries at maximum and a timeout. We could argue > whether the timeout makes sense but failing just because of a race when > somebody isoltes a page from LRU or puts it on a pcp LRU lists is just > wrong. It only takes it to race with a process which unmaps some pages > and remove them from the LRU list and we can fail the whole offline > because of something that is a temporary condition and actually not > harmful for the offline. > > Please note that unmovable pages should be already excluded during > start_isolate_page_range. We could argue that has_unmovable_pages is > racy and MIGRATE_MOVABLE check doesn't provide any hard guarantee either > but kernel zones (aka < ZONE_MOVABLE) will very likely detect unmovable > pages in most cases and movable zone shouldn't contain unmovable pages > at all. Some of those pages might be pinned but not for ever because > that would be a bug on its own. In any case the context is still > interruptible and so the userspace can easily bail out when the > operation takes too long. This is certainly better behavior than a > hardcoded retry loop which is racy. > > Fix this by removing the max retry count and only rely on the timeout > resp. interruption by a signal from the userspace. Also retry rather > than fail when check_pages_isolated sees some !free pages because those > could be a result of the race as well. > > Signed-off-by: Michal Hocko Yeah, that's better, thanks. Acked-by: Vlastimil Babka -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id 114786B0038 for ; Wed, 13 Sep 2017 08:32:15 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id q75so117885pfl.1 for ; Wed, 13 Sep 2017 05:32:15 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id k1si2706693pld.524.2017.09.13.05.32.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Sep 2017 05:32:13 -0700 (PDT) Date: Wed, 13 Sep 2017 14:32:11 +0200 From: Michal Hocko Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early Message-ID: <20170913123211.73ogviibe74wwxnl@dhcp22.suse.cz> References: <20170904082148.23131-1-mhocko@kernel.org> <20170904082148.23131-2-mhocko@kernel.org> <20170911081714.4zc33r7wlj2nnbho@dhcp22.suse.cz> <9fad7246-c634-18bb-78f9-b95376c009da@suse.cz> <20170913121001.k3a5tkvunmncc5uj@dhcp22.suse.cz> <20170913121433.yjzloaf6g447zeq2@dhcp22.suse.cz> <25ffda93-0c0d-28b4-bd0b-7fc9df7d678a@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <25ffda93-0c0d-28b4-bd0b-7fc9df7d678a@suse.cz> Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On Wed 13-09-17 14:19:19, Vlastimil Babka wrote: > On 09/13/2017 02:14 PM, Michal Hocko wrote: > >>>> Do you think that the changelog should be more clear about this? > >>> > >>> It certainly wouldn't hurt :) > >> > >> So what do you think about the following wording: > > > > Ups, wrong patch > > > > > > From 8639496a834b4a7c24972ec23b17e50f0d6a304c Mon Sep 17 00:00:00 2001 > > From: Michal Hocko > > Date: Mon, 14 Aug 2017 10:46:12 +0200 > > Subject: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early > > > > Memory offlining can fail just too eagerly under a heavy memory pressure. > > > > [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 > > [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) > > [ 5410.336811] page dumped because: isolation failed > > [ 5410.336813] page->mem_cgroup:ffff8801cd662000 > > [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed > > > > Isolation has failed here because the page is not on LRU. Most probably > > because it was on the pcp LRU cache or it has been removed from the LRU > > already but it hasn't been freed yet. In both cases the page doesn't look > > non-migrable so retrying more makes sense. > > > > __offline_pages seems rather cluttered when it comes to the retry > > logic. We have 5 retries at maximum and a timeout. We could argue > > whether the timeout makes sense but failing just because of a race when > > somebody isoltes a page from LRU or puts it on a pcp LRU lists is just > > wrong. It only takes it to race with a process which unmaps some pages > > and remove them from the LRU list and we can fail the whole offline > > because of something that is a temporary condition and actually not > > harmful for the offline. > > > > Please note that unmovable pages should be already excluded during > > start_isolate_page_range. We could argue that has_unmovable_pages is > > racy and MIGRATE_MOVABLE check doesn't provide any hard guarantee either > > but kernel zones (aka < ZONE_MOVABLE) will very likely detect unmovable > > pages in most cases and movable zone shouldn't contain unmovable pages > > at all. Some of those pages might be pinned but not for ever because > > that would be a bug on its own. In any case the context is still > > interruptible and so the userspace can easily bail out when the > > operation takes too long. This is certainly better behavior than a > > hardcoded retry loop which is racy. > > > > Fix this by removing the max retry count and only rely on the timeout > > resp. interruption by a signal from the userspace. Also retry rather > > than fail when check_pages_isolated sees some !free pages because those > > could be a result of the race as well. > > > > Signed-off-by: Michal Hocko > > Yeah, that's better, thanks. > > Acked-by: Vlastimil Babka Thanks. I will give it a day and repost the series. If somebody still have some concerns please speak up. -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f200.google.com (mail-wr0-f200.google.com [209.85.128.200]) by kanga.kvack.org (Postfix) with ESMTP id 60B166B025E for ; Mon, 18 Sep 2017 03:10:15 -0400 (EDT) Received: by mail-wr0-f200.google.com with SMTP id v109so8393345wrc.5 for ; Mon, 18 Sep 2017 00:10:15 -0700 (PDT) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d83sor1571392wmc.11.2017.09.18.00.10.14 for (Google Transport Security); Mon, 18 Sep 2017 00:10:14 -0700 (PDT) From: Michal Hocko Subject: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early Date: Mon, 18 Sep 2017 09:08:33 +0200 Message-Id: <20170918070834.13083-2-mhocko@kernel.org> In-Reply-To: <20170918070834.13083-1-mhocko@kernel.org> References: <20170918070834.13083-1-mhocko@kernel.org> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Michal Hocko , Vlastimil Babka From: Michal Hocko Memory offlining can fail just too eagerly under a heavy memory pressure. [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) [ 5410.336811] page dumped because: isolation failed [ 5410.336813] page->mem_cgroup:ffff8801cd662000 [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed Isolation has failed here because the page is not on LRU. Most probably because it was on the pcp LRU cache or it has been removed from the LRU already but it hasn't been freed yet. In both cases the page doesn't look non-migrable so retrying more makes sense. __offline_pages seems rather cluttered when it comes to the retry logic. We have 5 retries at maximum and a timeout. We could argue whether the timeout makes sense but failing just because of a race when somebody isoltes a page from LRU or puts it on a pcp LRU lists is just wrong. It only takes it to race with a process which unmaps some pages and remove them from the LRU list and we can fail the whole offline because of something that is a temporary condition and actually not harmful for the offline. Please note that unmovable pages should be already excluded during start_isolate_page_range. We could argue that has_unmovable_pages is racy and MIGRATE_MOVABLE check doesn't provide any hard guarantee either but kernel zones (aka < ZONE_MOVABLE) will very likely detect unmovable pages in most cases and movable zone shouldn't contain unmovable pages at all. Some of those pages might be pinned but not for ever because that would be a bug on its own. In any case the context is still interruptible and so the userspace can easily bail out when the operation takes too long. This is certainly better behavior than a hardcoded retry loop which is racy. Fix this by removing the max retry count and only rely on the timeout resp. interruption by a signal from the userspace. Also retry rather than fail when check_pages_isolated sees some !free pages because those could be a result of the race as well. Acked-by: Vlastimil Babka Signed-off-by: Michal Hocko --- mm/memory_hotplug.c | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 459bbc182d10..c9dcbe6d2ac6 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1597,7 +1597,7 @@ static int __ref __offline_pages(unsigned long start_pfn, { unsigned long pfn, nr_pages, expire; long offlined_pages; - int ret, drain, retry_max, node; + int ret, node; unsigned long flags; unsigned long valid_start, valid_end; struct zone *zone; @@ -1634,43 +1634,25 @@ static int __ref __offline_pages(unsigned long start_pfn, pfn = start_pfn; expire = jiffies + timeout; - drain = 0; - retry_max = 5; repeat: /* start memory hot removal */ - ret = -EAGAIN; + ret = -EBUSY; if (time_after(jiffies, expire)) goto failed_removal; ret = -EINTR; if (signal_pending(current)) goto failed_removal; - ret = 0; - if (drain) { - lru_add_drain_all_cpuslocked(); - cond_resched(); - drain_all_pages(zone); - } + + cond_resched(); + lru_add_drain_all_cpuslocked(); + 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); - if (!ret) { - drain = 1; - goto repeat; - } else { - if (ret < 0) - if (--retry_max == 0) - goto failed_removal; - yield(); - drain = 1; - goto repeat; - } + goto repeat; } - /* drain all zone's lru pagevec, this is asynchronous... */ - lru_add_drain_all_cpuslocked(); - yield(); - /* drain pcp pages, this is synchronous. */ - drain_all_pages(zone); + /* * dissolve free hugepages in the memory block before doing offlining * actually in order to make hugetlbfs's object counting consistent. @@ -1680,10 +1662,8 @@ static int __ref __offline_pages(unsigned long start_pfn, goto failed_removal; /* check again */ offlined_pages = check_pages_isolated(start_pfn, end_pfn); - if (offlined_pages < 0) { - ret = -EBUSY; - goto failed_removal; - } + 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. */ -- 2.14.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id 0516C6B025E for ; Tue, 10 Oct 2017 08:05:16 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id d28so18328446pfe.2 for ; Tue, 10 Oct 2017 05:05:15 -0700 (PDT) Received: from ozlabs.org (ozlabs.org. [103.22.144.67]) by mx.google.com with ESMTPS id z5si8223770pgr.165.2017.10.10.05.05.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Oct 2017 05:05:13 -0700 (PDT) From: Michael Ellerman Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early In-Reply-To: <20170918070834.13083-2-mhocko@kernel.org> References: <20170918070834.13083-1-mhocko@kernel.org> <20170918070834.13083-2-mhocko@kernel.org> Date: Tue, 10 Oct 2017 23:05:08 +1100 Message-ID: <87bmlfw6mj.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko , Andrew Morton Cc: KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Michal Hocko , Vlastimil Babka Michal Hocko writes: > From: Michal Hocko > > Memory offlining can fail just too eagerly under a heavy memory pressure. > > [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 > [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) > [ 5410.336811] page dumped because: isolation failed > [ 5410.336813] page->mem_cgroup:ffff8801cd662000 > [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed > > Isolation has failed here because the page is not on LRU. Most probably > because it was on the pcp LRU cache or it has been removed from the LRU > already but it hasn't been freed yet. In both cases the page doesn't look > non-migrable so retrying more makes sense. This breaks offline for me. Prior to this commit: /sys/devices/system/memory/memory0# time echo 0 > online -bash: echo: write error: Device or resource busy real 0m0.001s user 0m0.000s sys 0m0.001s After: /sys/devices/system/memory/memory0# time echo 0 > online -bash: echo: write error: Device or resource busy real 2m0.009s user 0m0.000s sys 1m25.035s There's no way that block can be removed, it contains the kernel text, so it should instantly fail - which it used to. With commit 3aa2823fdf66 ("mm, memory_hotplug: remove timeout from __offline_memory") also applied, it appears to just get stuck forever, and I get lots of: [ 1232.112953] INFO: task kworker/3:0:4609 blocked for more than 120 seconds. [ 1232.113067] Not tainted 4.14.0-rc4-gcc6-next-20171009-g49827b9 #1 [ 1232.113183] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 1232.113319] kworker/3:0 D11984 4609 2 0x00000800 [ 1232.113416] Workqueue: memcg_kmem_cache memcg_kmem_cache_create_func [ 1232.113531] Call Trace: [ 1232.113579] [c0000000fb2db7a0] [c0000000fb2db900] 0xc0000000fb2db900 (unreliable) [ 1232.113717] [c0000000fb2db970] [c00000000001c964] __switch_to+0x304/0x6e0 [ 1232.113840] [c0000000fb2dba10] [c000000000a408c0] __schedule+0x2e0/0xa80 [ 1232.113978] [c0000000fb2dbae0] [c000000000a410a8] schedule+0x48/0xc0 [ 1232.114113] [c0000000fb2dbb10] [c000000000a44d88] rwsem_down_read_failed+0x128/0x1b0 [ 1232.114269] [c0000000fb2dbb70] [c0000000001696a8] __percpu_down_read+0x108/0x110 [ 1232.114426] [c0000000fb2dbba0] [c00000000032e498] get_online_mems+0x68/0x80 [ 1232.115487] [c0000000fb2dbbc0] [c0000000002c82ec] memcg_create_kmem_cache+0x4c/0x190 [ 1232.115651] [c0000000fb2dbc60] [c0000000003483b8] memcg_kmem_cache_create_func+0x38/0xf0 [ 1232.115809] [c0000000fb2dbc90] [c000000000121594] process_one_work+0x2b4/0x590 [ 1232.115964] [c0000000fb2dbd20] [c000000000121908] worker_thread+0x98/0x5d0 [ 1232.116095] [c0000000fb2dbdc0] [c00000000012a134] kthread+0x164/0x1b0 [ 1232.116229] [c0000000fb2dbe30] [c00000000000bae0] ret_from_kernel_thread+0x5c/0x7c cheers -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by kanga.kvack.org (Postfix) with ESMTP id 1EE736B025E for ; Tue, 10 Oct 2017 08:27:31 -0400 (EDT) Received: by mail-wm0-f70.google.com with SMTP id b189so5493336wmd.9 for ; Tue, 10 Oct 2017 05:27:31 -0700 (PDT) Received: from mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id x2si9438412wrc.202.2017.10.10.05.27.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 10 Oct 2017 05:27:29 -0700 (PDT) Date: Tue, 10 Oct 2017 14:27:26 +0200 From: Michal Hocko Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early Message-ID: <20171010122726.6jrfdzkscwge6gez@dhcp22.suse.cz> References: <20170918070834.13083-1-mhocko@kernel.org> <20170918070834.13083-2-mhocko@kernel.org> <87bmlfw6mj.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87bmlfw6mj.fsf@concordia.ellerman.id.au> Sender: owner-linux-mm@kvack.org List-ID: To: Michael Ellerman Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Vlastimil Babka On Tue 10-10-17 23:05:08, Michael Ellerman wrote: > Michal Hocko writes: > > > From: Michal Hocko > > > > Memory offlining can fail just too eagerly under a heavy memory pressure. > > > > [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 > > [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) > > [ 5410.336811] page dumped because: isolation failed > > [ 5410.336813] page->mem_cgroup:ffff8801cd662000 > > [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed > > > > Isolation has failed here because the page is not on LRU. Most probably > > because it was on the pcp LRU cache or it has been removed from the LRU > > already but it hasn't been freed yet. In both cases the page doesn't look > > non-migrable so retrying more makes sense. > > This breaks offline for me. > > Prior to this commit: > /sys/devices/system/memory/memory0# time echo 0 > online > -bash: echo: write error: Device or resource busy > > real 0m0.001s > user 0m0.000s > sys 0m0.001s > > After: > /sys/devices/system/memory/memory0# time echo 0 > online > -bash: echo: write error: Device or resource busy > > real 2m0.009s > user 0m0.000s > sys 1m25.035s > > > There's no way that block can be removed, it contains the kernel text, > so it should instantly fail - which it used to. OK, that means that start_isolate_page_range should have failed but it hasn't for some reason. I strongly suspect has_unmovable_pages is doing something wrong. Is the kernel text marked somehow? E.g. PageReserved? In other words, does the diff below helps? diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3badcedf96a7..00d042052501 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7368,6 +7368,9 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, page = pfn_to_page(check); + if (PageReserved(page)) + return true; + /* * Hugepages are not in LRU lists, but they're movable. * We need not scan over tail pages bacause we don't > With commit 3aa2823fdf66 ("mm, memory_hotplug: remove timeout from > __offline_memory") also applied, it appears to just get stuck forever, > and I get lots of: > > [ 1232.112953] INFO: task kworker/3:0:4609 blocked for more than 120 seconds. > [ 1232.113067] Not tainted 4.14.0-rc4-gcc6-next-20171009-g49827b9 #1 > [ 1232.113183] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. > [ 1232.113319] kworker/3:0 D11984 4609 2 0x00000800 > [ 1232.113416] Workqueue: memcg_kmem_cache memcg_kmem_cache_create_func > [ 1232.113531] Call Trace: > [ 1232.113579] [c0000000fb2db7a0] [c0000000fb2db900] 0xc0000000fb2db900 (unreliable) > [ 1232.113717] [c0000000fb2db970] [c00000000001c964] __switch_to+0x304/0x6e0 > [ 1232.113840] [c0000000fb2dba10] [c000000000a408c0] __schedule+0x2e0/0xa80 > [ 1232.113978] [c0000000fb2dbae0] [c000000000a410a8] schedule+0x48/0xc0 > [ 1232.114113] [c0000000fb2dbb10] [c000000000a44d88] rwsem_down_read_failed+0x128/0x1b0 > [ 1232.114269] [c0000000fb2dbb70] [c0000000001696a8] __percpu_down_read+0x108/0x110 > [ 1232.114426] [c0000000fb2dbba0] [c00000000032e498] get_online_mems+0x68/0x80 > [ 1232.115487] [c0000000fb2dbbc0] [c0000000002c82ec] memcg_create_kmem_cache+0x4c/0x190 > [ 1232.115651] [c0000000fb2dbc60] [c0000000003483b8] memcg_kmem_cache_create_func+0x38/0xf0 > [ 1232.115809] [c0000000fb2dbc90] [c000000000121594] process_one_work+0x2b4/0x590 > [ 1232.115964] [c0000000fb2dbd20] [c000000000121908] worker_thread+0x98/0x5d0 > [ 1232.116095] [c0000000fb2dbdc0] [c00000000012a134] kthread+0x164/0x1b0 > [ 1232.116229] [c0000000fb2dbe30] [c00000000000bae0] ret_from_kernel_thread+0x5c/0x7c I do not see how this is related to the offline path. -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id 9C26E6B0253 for ; Tue, 10 Oct 2017 22:37:55 -0400 (EDT) Received: by mail-pg0-f72.google.com with SMTP id u23so999865pgo.7 for ; Tue, 10 Oct 2017 19:37:55 -0700 (PDT) Received: from ozlabs.org (ozlabs.org. [103.22.144.67]) by mx.google.com with ESMTPS id o15si2945041pgq.475.2017.10.10.19.37.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Oct 2017 19:37:54 -0700 (PDT) From: Michael Ellerman Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early In-Reply-To: <20171010122726.6jrfdzkscwge6gez@dhcp22.suse.cz> References: <20170918070834.13083-1-mhocko@kernel.org> <20170918070834.13083-2-mhocko@kernel.org> <87bmlfw6mj.fsf@concordia.ellerman.id.au> <20171010122726.6jrfdzkscwge6gez@dhcp22.suse.cz> Date: Wed, 11 Oct 2017 13:37:50 +1100 Message-ID: <87infmz9xd.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Vlastimil Babka Michal Hocko writes: > On Tue 10-10-17 23:05:08, Michael Ellerman wrote: >> Michal Hocko writes: >> >> > From: Michal Hocko >> > >> > Memory offlining can fail just too eagerly under a heavy memory pressure. >> > >> > [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 >> > [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) >> > [ 5410.336811] page dumped because: isolation failed >> > [ 5410.336813] page->mem_cgroup:ffff8801cd662000 >> > [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed >> > >> > Isolation has failed here because the page is not on LRU. Most probably >> > because it was on the pcp LRU cache or it has been removed from the LRU >> > already but it hasn't been freed yet. In both cases the page doesn't look >> > non-migrable so retrying more makes sense. >> >> This breaks offline for me. >> >> Prior to this commit: >> /sys/devices/system/memory/memory0# time echo 0 > online >> -bash: echo: write error: Device or resource busy >> >> real 0m0.001s >> user 0m0.000s >> sys 0m0.001s >> >> After: >> /sys/devices/system/memory/memory0# time echo 0 > online >> -bash: echo: write error: Device or resource busy >> >> real 2m0.009s >> user 0m0.000s >> sys 1m25.035s >> >> >> There's no way that block can be removed, it contains the kernel text, >> so it should instantly fail - which it used to. > > OK, that means that start_isolate_page_range should have failed but it > hasn't for some reason. I strongly suspect has_unmovable_pages is doing > something wrong. Is the kernel text marked somehow? E.g. PageReserved? I'm not sure how the text is marked, will have to dig into that. > In other words, does the diff below helps? No that doesn't help. > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3badcedf96a7..00d042052501 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -7368,6 +7368,9 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > > page = pfn_to_page(check); > > + if (PageReserved(page)) > + return true; > + > /* > * Hugepages are not in LRU lists, but they're movable. > * We need not scan over tail pages bacause we don't > > >> With commit 3aa2823fdf66 ("mm, memory_hotplug: remove timeout from >> __offline_memory") also applied, it appears to just get stuck forever, >> and I get lots of: >> >> [ 1232.112953] INFO: task kworker/3:0:4609 blocked for more than 120 seconds. >> [ 1232.113067] Not tainted 4.14.0-rc4-gcc6-next-20171009-g49827b9 #1 >> [ 1232.113183] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. >> [ 1232.113319] kworker/3:0 D11984 4609 2 0x00000800 >> [ 1232.113416] Workqueue: memcg_kmem_cache memcg_kmem_cache_create_func >> [ 1232.113531] Call Trace: >> [ 1232.113579] [c0000000fb2db7a0] [c0000000fb2db900] 0xc0000000fb2db900 (unreliable) >> [ 1232.113717] [c0000000fb2db970] [c00000000001c964] __switch_to+0x304/0x6e0 >> [ 1232.113840] [c0000000fb2dba10] [c000000000a408c0] __schedule+0x2e0/0xa80 >> [ 1232.113978] [c0000000fb2dbae0] [c000000000a410a8] schedule+0x48/0xc0 >> [ 1232.114113] [c0000000fb2dbb10] [c000000000a44d88] rwsem_down_read_failed+0x128/0x1b0 >> [ 1232.114269] [c0000000fb2dbb70] [c0000000001696a8] __percpu_down_read+0x108/0x110 >> [ 1232.114426] [c0000000fb2dbba0] [c00000000032e498] get_online_mems+0x68/0x80 >> [ 1232.115487] [c0000000fb2dbbc0] [c0000000002c82ec] memcg_create_kmem_cache+0x4c/0x190 >> [ 1232.115651] [c0000000fb2dbc60] [c0000000003483b8] memcg_kmem_cache_create_func+0x38/0xf0 >> [ 1232.115809] [c0000000fb2dbc90] [c000000000121594] process_one_work+0x2b4/0x590 >> [ 1232.115964] [c0000000fb2dbd20] [c000000000121908] worker_thread+0x98/0x5d0 >> [ 1232.116095] [c0000000fb2dbdc0] [c00000000012a134] kthread+0x164/0x1b0 >> [ 1232.116229] [c0000000fb2dbe30] [c00000000000bae0] ret_from_kernel_thread+0x5c/0x7c > > I do not see how this is related to the offline path. It's blocked doing get_online_mems(). So it's unrelated to the offline, but it can't proceed until the offline finishes, which it never does, IIUIC. cheers -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id 6F8F56B0253 for ; Wed, 11 Oct 2017 01:19:11 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id j64so2314964pfj.6 for ; Tue, 10 Oct 2017 22:19:11 -0700 (PDT) Received: from ozlabs.org (ozlabs.org. [2401:3900:2:1::2]) by mx.google.com with ESMTPS id h68si9324908pgc.508.2017.10.10.22.19.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Oct 2017 22:19:09 -0700 (PDT) From: Michael Ellerman Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early In-Reply-To: <87infmz9xd.fsf@concordia.ellerman.id.au> References: <20170918070834.13083-1-mhocko@kernel.org> <20170918070834.13083-2-mhocko@kernel.org> <87bmlfw6mj.fsf@concordia.ellerman.id.au> <20171010122726.6jrfdzkscwge6gez@dhcp22.suse.cz> <87infmz9xd.fsf@concordia.ellerman.id.au> Date: Wed, 11 Oct 2017 16:19:05 +1100 Message-ID: <87a80yz2gm.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Vlastimil Babka Michael Ellerman writes: > Michal Hocko writes: >> On Tue 10-10-17 23:05:08, Michael Ellerman wrote: >>> Michal Hocko writes: >>> > From: Michal Hocko >>> > Memory offlining can fail just too eagerly under a heavy memory pressure. >>> > >>> > [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 >>> > [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) >>> > [ 5410.336811] page dumped because: isolation failed >>> > [ 5410.336813] page->mem_cgroup:ffff8801cd662000 >>> > [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed >>> > >>> > Isolation has failed here because the page is not on LRU. Most probably >>> > because it was on the pcp LRU cache or it has been removed from the LRU >>> > already but it hasn't been freed yet. In both cases the page doesn't look >>> > non-migrable so retrying more makes sense. >>> >>> This breaks offline for me. >>> >>> Prior to this commit: >>> /sys/devices/system/memory/memory0# time echo 0 > online >>> -bash: echo: write error: Device or resource busy >>> >>> real 0m0.001s >>> user 0m0.000s >>> sys 0m0.001s >>> >>> After: >>> /sys/devices/system/memory/memory0# time echo 0 > online >>> -bash: echo: write error: Device or resource busy >>> >>> real 2m0.009s >>> user 0m0.000s >>> sys 1m25.035s >>> >>> There's no way that block can be removed, it contains the kernel text, >>> so it should instantly fail - which it used to. >> >> OK, that means that start_isolate_page_range should have failed but it >> hasn't for some reason. I strongly suspect has_unmovable_pages is doing >> something wrong. Is the kernel text marked somehow? E.g. PageReserved? > > I'm not sure how the text is marked, will have to dig into that. Yeah it's reserved: $ grep __init_begin /proc/kallsyms c000000000d70000 T __init_begin $ ./page-types -r -a 0x0,0xd7 flags page-count MB symbolic-flags long-symbolic-flags 0x0000000100000000 215 13 __________________________r_______________ reserved total 215 13 I added some printks, we're getting EBUSY from do_migrate_range(pfn, end_pfn). So we seem to just have an infinite loop: repeat: /* start memory hot removal */ ret = -EINTR; if (signal_pending(current)) goto failed_removal; cond_resched(); lru_add_drain_all_cpuslocked(); 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); printk_ratelimited("memory-hotplug: migrate range returned %ld\n", ret); goto repeat; } eg: memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 __offline_pages: 354031 callbacks suppressed memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 memory-hotplug: migrate range returned -16 __offline_pages: 355794 callbacks suppressed cheers -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f199.google.com (mail-wr0-f199.google.com [209.85.128.199]) by kanga.kvack.org (Postfix) with ESMTP id 35A416B0253 for ; Wed, 11 Oct 2017 02:51:30 -0400 (EDT) Received: by mail-wr0-f199.google.com with SMTP id 22so349407wrb.9 for ; Tue, 10 Oct 2017 23:51:30 -0700 (PDT) Received: from mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id v21si11701643wra.442.2017.10.10.23.51.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 10 Oct 2017 23:51:28 -0700 (PDT) Date: Wed, 11 Oct 2017 08:51:23 +0200 From: Michal Hocko Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early Message-ID: <20171011065123.e7jvoftmtso3vcha@dhcp22.suse.cz> References: <20170918070834.13083-1-mhocko@kernel.org> <20170918070834.13083-2-mhocko@kernel.org> <87bmlfw6mj.fsf@concordia.ellerman.id.au> <20171010122726.6jrfdzkscwge6gez@dhcp22.suse.cz> <87infmz9xd.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87infmz9xd.fsf@concordia.ellerman.id.au> Sender: owner-linux-mm@kvack.org List-ID: To: Michael Ellerman Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Vlastimil Babka On Wed 11-10-17 13:37:50, Michael Ellerman wrote: > Michal Hocko writes: > > > On Tue 10-10-17 23:05:08, Michael Ellerman wrote: > >> Michal Hocko writes: > >> > >> > From: Michal Hocko > >> > > >> > Memory offlining can fail just too eagerly under a heavy memory pressure. > >> > > >> > [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 > >> > [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) > >> > [ 5410.336811] page dumped because: isolation failed > >> > [ 5410.336813] page->mem_cgroup:ffff8801cd662000 > >> > [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed > >> > > >> > Isolation has failed here because the page is not on LRU. Most probably > >> > because it was on the pcp LRU cache or it has been removed from the LRU > >> > already but it hasn't been freed yet. In both cases the page doesn't look > >> > non-migrable so retrying more makes sense. > >> > >> This breaks offline for me. > >> > >> Prior to this commit: > >> /sys/devices/system/memory/memory0# time echo 0 > online > >> -bash: echo: write error: Device or resource busy > >> > >> real 0m0.001s > >> user 0m0.000s > >> sys 0m0.001s > >> > >> After: > >> /sys/devices/system/memory/memory0# time echo 0 > online > >> -bash: echo: write error: Device or resource busy > >> > >> real 2m0.009s > >> user 0m0.000s > >> sys 1m25.035s > >> > >> > >> There's no way that block can be removed, it contains the kernel text, > >> so it should instantly fail - which it used to. > > > > OK, that means that start_isolate_page_range should have failed but it > > hasn't for some reason. I strongly suspect has_unmovable_pages is doing > > something wrong. Is the kernel text marked somehow? E.g. PageReserved? > > I'm not sure how the text is marked, will have to dig into that. > > > In other words, does the diff below helps? > > No that doesn't help. This is really strange! As you write in other email the page is reserved. That means that some of the earlier checks if (zone_idx(zone) == ZONE_MOVABLE) return false; mt = get_pageblock_migratetype(page); if (mt == MIGRATE_MOVABLE || is_migrate_cma(mt)) return false; has bailed out early. I would be quite surprised if the kernel text was sitting in the zone movable. The migrate type check is more fishy AFAICS. I can imagine that the kernel text can share the movable or CMA mt block. I am not really familiar with this function but it looks suspicious. So does it help to remove this check? --- diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3badcedf96a7..5b4d85ae445c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7355,9 +7355,6 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, */ if (zone_idx(zone) == ZONE_MOVABLE) return false; - mt = get_pageblock_migratetype(page); - if (mt == MIGRATE_MOVABLE || is_migrate_cma(mt)) - return false; pfn = page_to_pfn(page); for (found = 0, iter = 0; iter < pageblock_nr_pages; iter++) { @@ -7368,6 +7365,9 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, page = pfn_to_page(check); + if (PageReserved(page)) + return true; + /* * Hugepages are not in LRU lists, but they're movable. * We need not scan over tail pages bacause we don't -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id 32AE26B0260 for ; Wed, 11 Oct 2017 04:04:45 -0400 (EDT) Received: by mail-pf0-f200.google.com with SMTP id z80so3191725pff.1 for ; Wed, 11 Oct 2017 01:04:45 -0700 (PDT) Received: from mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id 36si10938776ple.401.2017.10.11.01.04.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 11 Oct 2017 01:04:43 -0700 (PDT) Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early References: <20170918070834.13083-1-mhocko@kernel.org> <20170918070834.13083-2-mhocko@kernel.org> <87bmlfw6mj.fsf@concordia.ellerman.id.au> <20171010122726.6jrfdzkscwge6gez@dhcp22.suse.cz> <87infmz9xd.fsf@concordia.ellerman.id.au> <20171011065123.e7jvoftmtso3vcha@dhcp22.suse.cz> From: Vlastimil Babka Message-ID: Date: Wed, 11 Oct 2017 10:04:39 +0200 MIME-Version: 1.0 In-Reply-To: <20171011065123.e7jvoftmtso3vcha@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko , Michael Ellerman Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On 10/11/2017 08:51 AM, Michal Hocko wrote: > On Wed 11-10-17 13:37:50, Michael Ellerman wrote: >> Michal Hocko writes: >> >>> On Tue 10-10-17 23:05:08, Michael Ellerman wrote: >>>> Michal Hocko writes: >>>> >>>>> From: Michal Hocko >>>>> >>>>> Memory offlining can fail just too eagerly under a heavy memory pressure. >>>>> >>>>> [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 >>>>> [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) >>>>> [ 5410.336811] page dumped because: isolation failed >>>>> [ 5410.336813] page->mem_cgroup:ffff8801cd662000 >>>>> [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed >>>>> >>>>> Isolation has failed here because the page is not on LRU. Most probably >>>>> because it was on the pcp LRU cache or it has been removed from the LRU >>>>> already but it hasn't been freed yet. In both cases the page doesn't look >>>>> non-migrable so retrying more makes sense. >>>> >>>> This breaks offline for me. >>>> >>>> Prior to this commit: >>>> /sys/devices/system/memory/memory0# time echo 0 > online >>>> -bash: echo: write error: Device or resource busy Well, that means offline didn't actually work for that block even before this patch, right? Is it even a movable_node block? I guess not? >>>> real 0m0.001s >>>> user 0m0.000s >>>> sys 0m0.001s >>>> >>>> After: >>>> /sys/devices/system/memory/memory0# time echo 0 > online >>>> -bash: echo: write error: Device or resource busy >>>> >>>> real 2m0.009s >>>> user 0m0.000s >>>> sys 1m25.035s >>>> >>>> >>>> There's no way that block can be removed, it contains the kernel text, >>>> so it should instantly fail - which it used to. Ah, right. So your complain is really about that the failure is not instant anymore for blocks that can't be offlined. >>> OK, that means that start_isolate_page_range should have failed but it >>> hasn't for some reason. I strongly suspect has_unmovable_pages is doing >>> something wrong. Is the kernel text marked somehow? E.g. PageReserved? >> >> I'm not sure how the text is marked, will have to dig into that. >> >>> In other words, does the diff below helps? >> >> No that doesn't help. > > This is really strange! As you write in other email the page is > reserved. That means that some of the earlier checks > if (zone_idx(zone) == ZONE_MOVABLE) > return false; > mt = get_pageblock_migratetype(page); > if (mt == MIGRATE_MOVABLE || is_migrate_cma(mt)) The MIGRATE_MOVABLE check is indeed bogus, because that doesn't guarantee there are no unmovable pages in the block (CMA block OTOH should be a guarantee). > return false; > has bailed out early. I would be quite surprised if the kernel text was > sitting in the zone movable. The migrate type check is more fishy > AFAICS. I can imagine that the kernel text can share the movable or CMA > mt block. I am not really familiar with this function but it looks > suspicious. So does it help to remove this check? > --- > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3badcedf96a7..5b4d85ae445c 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -7355,9 +7355,6 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > */ > if (zone_idx(zone) == ZONE_MOVABLE) > return false; > - mt = get_pageblock_migratetype(page); > - if (mt == MIGRATE_MOVABLE || is_migrate_cma(mt)) > - return false; > > pfn = page_to_pfn(page); > for (found = 0, iter = 0; iter < pageblock_nr_pages; iter++) { > @@ -7368,6 +7365,9 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > > page = pfn_to_page(check); > > + if (PageReserved(page)) > + return true; > + > /* > * Hugepages are not in LRU lists, but they're movable. > * We need not scan over tail pages bacause we don't > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 9988B6B025F for ; Wed, 11 Oct 2017 04:13:21 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id m72so497509wmc.0 for ; Wed, 11 Oct 2017 01:13:21 -0700 (PDT) Received: from mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id m28si10175521wmc.149.2017.10.11.01.13.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 11 Oct 2017 01:13:20 -0700 (PDT) Date: Wed, 11 Oct 2017 10:13:17 +0200 From: Michal Hocko Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early Message-ID: <20171011081317.b2cdnhjdyzgdo3up@dhcp22.suse.cz> References: <20170918070834.13083-1-mhocko@kernel.org> <20170918070834.13083-2-mhocko@kernel.org> <87bmlfw6mj.fsf@concordia.ellerman.id.au> <20171010122726.6jrfdzkscwge6gez@dhcp22.suse.cz> <87infmz9xd.fsf@concordia.ellerman.id.au> <20171011065123.e7jvoftmtso3vcha@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka Cc: Michael Ellerman , Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On Wed 11-10-17 10:04:39, Vlastimil Babka wrote: > On 10/11/2017 08:51 AM, Michal Hocko wrote: [...] > > This is really strange! As you write in other email the page is > > reserved. That means that some of the earlier checks > > if (zone_idx(zone) == ZONE_MOVABLE) > > return false; > > mt = get_pageblock_migratetype(page); > > if (mt == MIGRATE_MOVABLE || is_migrate_cma(mt)) > > The MIGRATE_MOVABLE check is indeed bogus, because that doesn't > guarantee there are no unmovable pages in the block (CMA block OTOH > should be a guarantee). OK, thanks for confirmation. I will remove the MIGRATE_MOVABLE check here. Do you think it is worth removing CMA check as well? This is merely an optimization AFAIU because we do not have to check the full pageblockworth of pfns. Anyway, let's way for Michael to confirm it really helps. If yes I will post a full patch and ask Andrew to add it as a prerequisite for this patch when sending to Linus to prevent the regression. -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 9FB766B0260 for ; Wed, 11 Oct 2017 07:17:18 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id z80so4001739pff.1 for ; Wed, 11 Oct 2017 04:17:18 -0700 (PDT) Received: from mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id w187si10955349pfb.175.2017.10.11.04.17.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 11 Oct 2017 04:17:17 -0700 (PDT) Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early References: <20170918070834.13083-1-mhocko@kernel.org> <20170918070834.13083-2-mhocko@kernel.org> <87bmlfw6mj.fsf@concordia.ellerman.id.au> <20171010122726.6jrfdzkscwge6gez@dhcp22.suse.cz> <87infmz9xd.fsf@concordia.ellerman.id.au> <20171011065123.e7jvoftmtso3vcha@dhcp22.suse.cz> <20171011081317.b2cdnhjdyzgdo3up@dhcp22.suse.cz> From: Vlastimil Babka Message-ID: Date: Wed, 11 Oct 2017 13:17:13 +0200 MIME-Version: 1.0 In-Reply-To: <20171011081317.b2cdnhjdyzgdo3up@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: Michael Ellerman , Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On 10/11/2017 10:13 AM, Michal Hocko wrote: > On Wed 11-10-17 10:04:39, Vlastimil Babka wrote: >> On 10/11/2017 08:51 AM, Michal Hocko wrote: > [...] >>> This is really strange! As you write in other email the page is >>> reserved. That means that some of the earlier checks >>> if (zone_idx(zone) == ZONE_MOVABLE) >>> return false; >>> mt = get_pageblock_migratetype(page); >>> if (mt == MIGRATE_MOVABLE || is_migrate_cma(mt)) >> >> The MIGRATE_MOVABLE check is indeed bogus, because that doesn't >> guarantee there are no unmovable pages in the block (CMA block OTOH >> should be a guarantee). > > OK, thanks for confirmation. I will remove the MIGRATE_MOVABLE check > here. Do you think it is worth removing CMA check as well? This is > merely an optimization AFAIU because we do not have to check the full > pageblockworth of pfns. Actually, we should remove the CMA part as well. It's true that MIGRATE_CMA does guarantee that the *buddy allocator* won't allocate non-MOVABLE pages from the pageblock. But if the memory got allocated as an actual CMA allocation (alloc_contig...) it will almost certainly not be movable. > Anyway, let's way for Michael to confirm it really helps. If yes I will > post a full patch and ask Andrew to add it as a prerequisite for this > patch when sending to Linus to prevent the regression. > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 0159C6B0268 for ; Wed, 11 Oct 2017 07:24:18 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id 136so2328756wmu.3 for ; Wed, 11 Oct 2017 04:24:17 -0700 (PDT) Received: from mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id 129si9856664wme.241.2017.10.11.04.24.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 11 Oct 2017 04:24:16 -0700 (PDT) Date: Wed, 11 Oct 2017 13:24:15 +0200 From: Michal Hocko Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early Message-ID: <20171011112415.6hsudsrqhyuwjffx@dhcp22.suse.cz> References: <20170918070834.13083-1-mhocko@kernel.org> <20170918070834.13083-2-mhocko@kernel.org> <87bmlfw6mj.fsf@concordia.ellerman.id.au> <20171010122726.6jrfdzkscwge6gez@dhcp22.suse.cz> <87infmz9xd.fsf@concordia.ellerman.id.au> <20171011065123.e7jvoftmtso3vcha@dhcp22.suse.cz> <20171011081317.b2cdnhjdyzgdo3up@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka Cc: Michael Ellerman , Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On Wed 11-10-17 13:17:13, Vlastimil Babka wrote: > On 10/11/2017 10:13 AM, Michal Hocko wrote: > > On Wed 11-10-17 10:04:39, Vlastimil Babka wrote: > >> On 10/11/2017 08:51 AM, Michal Hocko wrote: > > [...] > >>> This is really strange! As you write in other email the page is > >>> reserved. That means that some of the earlier checks > >>> if (zone_idx(zone) == ZONE_MOVABLE) > >>> return false; > >>> mt = get_pageblock_migratetype(page); > >>> if (mt == MIGRATE_MOVABLE || is_migrate_cma(mt)) > >> > >> The MIGRATE_MOVABLE check is indeed bogus, because that doesn't > >> guarantee there are no unmovable pages in the block (CMA block OTOH > >> should be a guarantee). > > > > OK, thanks for confirmation. I will remove the MIGRATE_MOVABLE check > > here. Do you think it is worth removing CMA check as well? This is > > merely an optimization AFAIU because we do not have to check the full > > pageblockworth of pfns. > > Actually, we should remove the CMA part as well. It's true that > MIGRATE_CMA does guarantee that the *buddy allocator* won't allocate > non-MOVABLE pages from the pageblock. But if the memory got allocated as > an actual CMA allocation (alloc_contig...) it will almost certainly not > be movable. That was my suspicious. Thanks! -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 27A866B025F for ; Wed, 11 Oct 2017 10:05:23 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id r202so2983132wmd.1 for ; Wed, 11 Oct 2017 07:05:23 -0700 (PDT) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id 65si268353edj.513.2017.10.11.07.05.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Oct 2017 07:05:21 -0700 (PDT) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9BDwhYI143649 for ; Wed, 11 Oct 2017 10:05:20 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2dhhqbvkhd-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 11 Oct 2017 10:05:17 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Oct 2017 15:05:15 +0100 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9BE5CCP24576214 for ; Wed, 11 Oct 2017 14:05:13 GMT Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v9BE54Ej010525 for ; Thu, 12 Oct 2017 01:05:04 +1100 Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early References: <20170918070834.13083-1-mhocko@kernel.org> <20170918070834.13083-2-mhocko@kernel.org> <87bmlfw6mj.fsf@concordia.ellerman.id.au> <20171010122726.6jrfdzkscwge6gez@dhcp22.suse.cz> <87infmz9xd.fsf@concordia.ellerman.id.au> <87a80yz2gm.fsf@concordia.ellerman.id.au> From: Anshuman Khandual Date: Wed, 11 Oct 2017 19:35:04 +0530 MIME-Version: 1.0 In-Reply-To: <87a80yz2gm.fsf@concordia.ellerman.id.au> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Message-Id: Sender: owner-linux-mm@kvack.org List-ID: To: Michael Ellerman , Michal Hocko Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Vlastimil Babka On 10/11/2017 10:49 AM, Michael Ellerman wrote: > Michael Ellerman writes: >> Michal Hocko writes: >>> On Tue 10-10-17 23:05:08, Michael Ellerman wrote: >>>> Michal Hocko writes: >>>>> From: Michal Hocko >>>>> Memory offlining can fail just too eagerly under a heavy memory pressure. >>>>> >>>>> [ 5410.336792] page:ffffea22a646bd00 count:255 mapcount:252 mapping:ffff88ff926c9f38 index:0x3 >>>>> [ 5410.336809] flags: 0x9855fe40010048(uptodate|active|mappedtodisk) >>>>> [ 5410.336811] page dumped because: isolation failed >>>>> [ 5410.336813] page->mem_cgroup:ffff8801cd662000 >>>>> [ 5420.655030] memory offlining [mem 0x18b580000000-0x18b5ffffffff] failed >>>>> >>>>> Isolation has failed here because the page is not on LRU. Most probably >>>>> because it was on the pcp LRU cache or it has been removed from the LRU >>>>> already but it hasn't been freed yet. In both cases the page doesn't look >>>>> non-migrable so retrying more makes sense. >>>> This breaks offline for me. >>>> >>>> Prior to this commit: >>>> /sys/devices/system/memory/memory0# time echo 0 > online >>>> -bash: echo: write error: Device or resource busy >>>> >>>> real 0m0.001s >>>> user 0m0.000s >>>> sys 0m0.001s >>>> >>>> After: >>>> /sys/devices/system/memory/memory0# time echo 0 > online >>>> -bash: echo: write error: Device or resource busy >>>> >>>> real 2m0.009s >>>> user 0m0.000s >>>> sys 1m25.035s >>>> >>>> There's no way that block can be removed, it contains the kernel text, >>>> so it should instantly fail - which it used to. >>> OK, that means that start_isolate_page_range should have failed but it >>> hasn't for some reason. I strongly suspect has_unmovable_pages is doing >>> something wrong. Is the kernel text marked somehow? E.g. PageReserved? >> I'm not sure how the text is marked, will have to dig into that. > Yeah it's reserved: > > $ grep __init_begin /proc/kallsyms > c000000000d70000 T __init_begin > $ ./page-types -r -a 0x0,0xd7 > flags page-count MB symbolic-flags long-symbolic-flags > 0x0000000100000000 215 13 __________________________r_______________ reserved > total 215 13 Hey Michael, What tool is this 'page-types' ? -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f69.google.com (mail-wm0-f69.google.com [74.125.82.69]) by kanga.kvack.org (Postfix) with ESMTP id 5DBBA6B0268 for ; Wed, 11 Oct 2017 10:16:20 -0400 (EDT) Received: by mail-wm0-f69.google.com with SMTP id r68so3009240wmr.6 for ; Wed, 11 Oct 2017 07:16:20 -0700 (PDT) Received: from mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id m28si10586245wmc.149.2017.10.11.07.16.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 11 Oct 2017 07:16:19 -0700 (PDT) Date: Wed, 11 Oct 2017 16:16:16 +0200 From: Michal Hocko Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early Message-ID: <20171011141616.7mo6g7qnd3df7ab5@dhcp22.suse.cz> References: <20170918070834.13083-1-mhocko@kernel.org> <20170918070834.13083-2-mhocko@kernel.org> <87bmlfw6mj.fsf@concordia.ellerman.id.au> <20171010122726.6jrfdzkscwge6gez@dhcp22.suse.cz> <87infmz9xd.fsf@concordia.ellerman.id.au> <87a80yz2gm.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Anshuman Khandual Cc: Michael Ellerman , Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML , Vlastimil Babka On Wed 11-10-17 19:35:04, Anshuman Khandual wrote: [...] > > $ grep __init_begin /proc/kallsyms > > c000000000d70000 T __init_begin > > $ ./page-types -r -a 0x0,0xd7 > > flags page-count MB symbolic-flags long-symbolic-flags > > 0x0000000100000000 215 13 __________________________r_______________ reserved > > total 215 13 > > Hey Michael, > > What tool is this 'page-types' ? tools/vm/page-types.c -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id 4CB706B0033 for ; Fri, 13 Oct 2017 07:42:57 -0400 (EDT) Received: by mail-pf0-f200.google.com with SMTP id e64so8259432pfk.0 for ; Fri, 13 Oct 2017 04:42:57 -0700 (PDT) Received: from ozlabs.org (ozlabs.org. [103.22.144.67]) by mx.google.com with ESMTPS id 69si494423pfh.27.2017.10.13.04.42.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2017 04:42:54 -0700 (PDT) From: Michael Ellerman Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early In-Reply-To: References: <20170918070834.13083-1-mhocko@kernel.org> <20170918070834.13083-2-mhocko@kernel.org> <87bmlfw6mj.fsf@concordia.ellerman.id.au> <20171010122726.6jrfdzkscwge6gez@dhcp22.suse.cz> <87infmz9xd.fsf@concordia.ellerman.id.au> <20171011065123.e7jvoftmtso3vcha@dhcp22.suse.cz> Date: Fri, 13 Oct 2017 22:42:46 +1100 Message-ID: <87bmlbtgsp.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka , Michal Hocko Cc: Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML Vlastimil Babka writes: > On 10/11/2017 08:51 AM, Michal Hocko wrote: >> On Wed 11-10-17 13:37:50, Michael Ellerman wrote: >>> Michal Hocko writes: >>>> On Tue 10-10-17 23:05:08, Michael Ellerman wrote: >>>>> Michal Hocko writes: >>>>>> From: Michal Hocko >>>>>> >>>>>> Memory offlining can fail just too eagerly under a heavy memory pressure. ... >>>>> >>>>> This breaks offline for me. >>>>> >>>>> Prior to this commit: >>>>> /sys/devices/system/memory/memory0# time echo 0 > online >>>>> -bash: echo: write error: Device or resource busy > > Well, that means offline didn't actually work for that block even before > this patch, right? Is it even a movable_node block? I guess not? Correct. It should fail. >>>>> After: >>>>> /sys/devices/system/memory/memory0# time echo 0 > online >>>>> -bash: echo: write error: Device or resource busy >>>>> >>>>> real 2m0.009s >>>>> user 0m0.000s >>>>> sys 1m25.035s >>>>> >>>>> There's no way that block can be removed, it contains the kernel text, >>>>> so it should instantly fail - which it used to. > > Ah, right. So your complain is really about that the failure is not > instant anymore for blocks that can't be offlined. Yes. Previously it failed instantly, now it doesn't fail, and loops infinitely (once the 2 minute limit is removed). >> This is really strange! As you write in other email the page is >> reserved. That means that some of the earlier checks >> if (zone_idx(zone) == ZONE_MOVABLE) >> return false; >> mt = get_pageblock_migratetype(page); >> if (mt == MIGRATE_MOVABLE || is_migrate_cma(mt)) > > The MIGRATE_MOVABLE check is indeed bogus, because that doesn't > guarantee there are no unmovable pages in the block (CMA block OTOH > should be a guarantee). OK I'll try that and get back to you. cheers >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >> index 3badcedf96a7..5b4d85ae445c 100644 >> --- a/mm/page_alloc.c >> +++ b/mm/page_alloc.c >> @@ -7355,9 +7355,6 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, >> */ >> if (zone_idx(zone) == ZONE_MOVABLE) >> return false; >> - mt = get_pageblock_migratetype(page); >> - if (mt == MIGRATE_MOVABLE || is_migrate_cma(mt)) >> - return false; >> >> pfn = page_to_pfn(page); >> for (found = 0, iter = 0; iter < pageblock_nr_pages; iter++) { >> @@ -7368,6 +7365,9 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, >> >> page = pfn_to_page(check); >> >> + if (PageReserved(page)) >> + return true; >> + >> /* >> * Hugepages are not in LRU lists, but they're movable. >> * We need not scan over tail pages bacause we don't >> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 461066B0033 for ; Fri, 13 Oct 2017 07:58:39 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id b189so5891404wmd.9 for ; Fri, 13 Oct 2017 04:58:39 -0700 (PDT) Received: from mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id f134si826502wmd.165.2017.10.13.04.58.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 13 Oct 2017 04:58:37 -0700 (PDT) Date: Fri, 13 Oct 2017 13:58:35 +0200 From: Michal Hocko Subject: Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early Message-ID: <20171013115835.zaehapuucuzl2vlv@dhcp22.suse.cz> References: <20170918070834.13083-1-mhocko@kernel.org> <20170918070834.13083-2-mhocko@kernel.org> <87bmlfw6mj.fsf@concordia.ellerman.id.au> <20171010122726.6jrfdzkscwge6gez@dhcp22.suse.cz> <87infmz9xd.fsf@concordia.ellerman.id.au> <20171011065123.e7jvoftmtso3vcha@dhcp22.suse.cz> <87bmlbtgsp.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87bmlbtgsp.fsf@concordia.ellerman.id.au> Sender: owner-linux-mm@kvack.org List-ID: To: Michael Ellerman Cc: Vlastimil Babka , Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , linux-mm@kvack.org, LKML On Fri 13-10-17 22:42:46, Michael Ellerman wrote: > Vlastimil Babka writes: > > On 10/11/2017 08:51 AM, Michal Hocko wrote: > >> On Wed 11-10-17 13:37:50, Michael Ellerman wrote: > >>> Michal Hocko writes: > >>>> On Tue 10-10-17 23:05:08, Michael Ellerman wrote: > >>>>> Michal Hocko writes: > >>>>>> From: Michal Hocko > >>>>>> > >>>>>> Memory offlining can fail just too eagerly under a heavy memory pressure. > ... > >>>>> > >>>>> This breaks offline for me. > >>>>> > >>>>> Prior to this commit: > >>>>> /sys/devices/system/memory/memory0# time echo 0 > online > >>>>> -bash: echo: write error: Device or resource busy > > > > Well, that means offline didn't actually work for that block even before > > this patch, right? Is it even a movable_node block? I guess not? > > Correct. It should fail. > > >>>>> After: > >>>>> /sys/devices/system/memory/memory0# time echo 0 > online > >>>>> -bash: echo: write error: Device or resource busy > >>>>> > >>>>> real 2m0.009s > >>>>> user 0m0.000s > >>>>> sys 1m25.035s > >>>>> > >>>>> There's no way that block can be removed, it contains the kernel text, > >>>>> so it should instantly fail - which it used to. > > > > Ah, right. So your complain is really about that the failure is not > > instant anymore for blocks that can't be offlined. > > Yes. Previously it failed instantly, now it doesn't fail, and loops > infinitely (once the 2 minute limit is removed). Yeah it failed only because the migration code retried few times and we bailed out which is wrong as well. I will send two patches as a reply to this email. > >> This is really strange! As you write in other email the page is > >> reserved. That means that some of the earlier checks > >> if (zone_idx(zone) == ZONE_MOVABLE) > >> return false; > >> mt = get_pageblock_migratetype(page); > >> if (mt == MIGRATE_MOVABLE || is_migrate_cma(mt)) > > > > The MIGRATE_MOVABLE check is indeed bogus, because that doesn't > > guarantee there are no unmovable pages in the block (CMA block OTOH > > should be a guarantee). > > OK I'll try that and get back to you. Thanks! -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org