Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2791139imu; Mon, 19 Nov 2018 06:13:02 -0800 (PST) X-Google-Smtp-Source: AJdET5fzDk7Hk9vqO7DEdO50eTYvAlihWQWd4Q9DkUiCkg23s2TC4Z3RhywTpmjGUGKYrDr5Ht5Y X-Received: by 2002:a17:902:622:: with SMTP id 31-v6mr22694128plg.310.1542636782069; Mon, 19 Nov 2018 06:13:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542636782; cv=none; d=google.com; s=arc-20160816; b=D0lEMSXpX4iyf8PLzbx082J3QRnvWEqaUHHy68PFbQw8XDXW/w5POfmQogE29rz2sq XiHixD4rN9CfREquKvszR8tvruSyGEsV+RHy3HIOj3tjzF5bR7dH2+5pPe4iSR1F5bpU q9lZQ2GX9cQdrSJdQ7uwlVuAKkfGF7bRsEXPGh3kDrshhARS+hjf1/laWwLOEJ8bqauy 5wcdhfj2hePK2UtQoTJhJ489purwbn1VXWQ4Ao8oK4PVspMdgxe7+2cw71NpFM9oGknw xS7lEFPrBUUXK54/xV4JfFmTBLNu6j4/RHnX7Qn+CCQnw6HTXrl847Zj5fKUWOikPycp EAAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=PdA2B5r6sEIKFBkKUCg4ujngsvrsvyImS2r3kheKvAU=; b=cM9jaaBgRP0y+tGhU0tHDXUXrFw4uqCsQNPpIX9/wwEHXS93fdEInzeQ3/x9KHtUQb Huqpl1QnS2Lkpp1JnHYwTH58GQvtvdgFdEqP4yAom9V0BZvN8yODQHyMh49txlcUSN3F WwMIcc2Sd9cNx+PB06zuPqp0BYbzdJ5HlXu4D8Kht0NIV4/jtd6cGZpE3Or4q7+ZFbGb wOvGZFX9X13BH3wm/eO9deaD4k9RSergfKQoHiMhtU++oFFob0UDZ9v9KRd0q1xjGmK3 PjnijbyDJVoXixJSRUOJ2mUQ5O1Lku+jQApM5dwQVYkpY/F+iVCC8sDkaltIUGtiBQR6 8Jxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si6556178pld.331.2018.11.19.06.12.46; Mon, 19 Nov 2018 06:13:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729480AbeKTAeD (ORCPT + 99 others); Mon, 19 Nov 2018 19:34:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:55352 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727324AbeKTAeD (ORCPT ); Mon, 19 Nov 2018 19:34:03 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 65821AF68; Mon, 19 Nov 2018 14:10:17 +0000 (UTC) Date: Mon, 19 Nov 2018 15:10:16 +0100 From: Michal Hocko To: Baoquan He Cc: David Hildenbrand , linux-mm@kvack.org, pifang@redhat.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, aarcange@redhat.com, Mel Gorman , Vlastimil Babka , Hugh Dickins Subject: Re: Memory hotplug softlock issue Message-ID: <20181119141016.GO22247@dhcp22.suse.cz> References: <20181115083055.GD23831@dhcp22.suse.cz> <20181115131211.GP2653@MiWiFi-R3L-srv> <20181115131927.GT23831@dhcp22.suse.cz> <20181115133840.GR2653@MiWiFi-R3L-srv> <20181115143204.GV23831@dhcp22.suse.cz> <20181116012433.GU2653@MiWiFi-R3L-srv> <20181116091409.GD14706@dhcp22.suse.cz> <20181119105202.GE18471@MiWiFi-R3L-srv> <20181119124033.GJ22247@dhcp22.suse.cz> <20181119125121.GK22247@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181119125121.GK22247@dhcp22.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 19-11-18 13:51:21, Michal Hocko wrote: > On Mon 19-11-18 13:40:33, Michal Hocko wrote: > > On Mon 19-11-18 18:52:02, Baoquan He wrote: > > [...] > > > > There are few stacks directly in the offline path but those should be > > OK. > > The real culprit seems to be the swap in code > > > > > [ +1.734416] CPU: 255 PID: 5558 Comm: stress Tainted: G L 4.20.0-rc2+ #7 > > > [ +0.007927] Hardware name: 9008/IT91SMUB, BIOS BLXSV512 03/22/2018 > > > [ +0.006297] Call Trace: > > > [ +0.002537] dump_stack+0x46/0x60 > > > [ +0.003386] __migration_entry_wait.cold.65+0x5/0x14 > > > [ +0.005043] do_swap_page+0x84e/0x960 > > > [ +0.003727] ? arch_tlb_finish_mmu+0x29/0xc0 > > > [ +0.006412] __handle_mm_fault+0x933/0x1330 > > > [ +0.004265] handle_mm_fault+0xc4/0x250 > > > [ +0.003915] __do_page_fault+0x2b7/0x510 > > > [ +0.003990] do_page_fault+0x2c/0x110 > > > [ +0.003729] ? page_fault+0x8/0x30 > > > [ +0.003462] page_fault+0x1e/0x30 > > > > There are many traces to this path. We are > > /* > > * Once page cache replacement of page migration started, page_count > > * *must* be zero. And, we don't want to call wait_on_page_locked() > > * against a page without get_page(). > > * So, we use get_page_unless_zero(), here. Even failed, page fault > > * will occur again. > > */ > > if (!get_page_unless_zero(page)) > > goto out; > > pte_unmap_unlock(ptep, ptl); > > wait_on_page_locked(page); > > > > taking a reference to the page under the migration. I have to think > > about this much more but I suspec this is just calling for a problem. > > > > Cc migration experts. For you background information. We are seeing > > memory offline not being able to converge because few heavily used pages > > fail to migrate away - e.g. http://lkml.kernel.org/r/20181116012433.GU2653@MiWiFi-R3L-srv > > A debugging page to dump stack for these pages http://lkml.kernel.org/r/20181116091409.GD14706@dhcp22.suse.cz > > shows that references are taken from the swap in code (above). How are > > we supposed to converge when the swapin code waits for the migration to > > finish with the reference count elevated? > > Just to clarify. This is not only about swapin obviously. Any caller of > __migration_entry_wait is affected the same way AFAICS. In other words. Why cannot we do the following? diff --git a/mm/migrate.c b/mm/migrate.c index f7e4bfdc13b7..7ccab29bcf9a 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -324,19 +324,9 @@ void __migration_entry_wait(struct mm_struct *mm, pte_t *ptep, goto out; page = migration_entry_to_page(entry); - - /* - * Once page cache replacement of page migration started, page_count - * *must* be zero. And, we don't want to call wait_on_page_locked() - * against a page without get_page(). - * So, we use get_page_unless_zero(), here. Even failed, page fault - * will occur again. - */ - if (!get_page_unless_zero(page)) - goto out; pte_unmap_unlock(ptep, ptl); - wait_on_page_locked(page); - put_page(page); + page_lock(page); + page_unlock(page); return; out: pte_unmap_unlock(ptep, ptl); -- Michal Hocko SUSE Labs