Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2620491ybe; Thu, 12 Sep 2019 12:11:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqy60zOpFqVIfYhTfR/LUPANW4eFxpFAVaYdLvEj3Uranbf63X1YXyHXekgJvvMKkUspdp9c X-Received: by 2002:a50:cfc7:: with SMTP id i7mr34841056edk.89.1568315500431; Thu, 12 Sep 2019 12:11:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568315500; cv=none; d=google.com; s=arc-20160816; b=mFXtOhkJcjNCsSnOUo5OpzsDIMbMeWjpMIemyqXSSOC/2UGmYg5xlgBC8TYJxEWeOy 5z5IsodeBKdpY3P3ujL5lCFlMaAxk+8mqn4xg8zWUxLPY7OohJUAs/JWVB+mlgX6CXG+ 5S7tBDaSCMN4XwaTb71yvaGxA9hvPXzjjecSYH6WKORAh4XP9WkQ6yIijHOtySrexxPs 2hviJVWFtFF5e4CYN1JqeuB65kWb+A8dfmKVo9NSYW5aJjtf/2DeQjyvrISM7dytJF9h WLuA4v6XxMtGndKlx/jnLoJ7drJphNUm11MuSd6COQVagsHnRHHjnfc8i5XIBr+Cg/0q AB3w== 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:dkim-signature; bh=7ELatS+qNwcqZFlGpoKi7iobXH6c8V+qxrhRPOrjs54=; b=L5jYytNo6OZah0BcAC0/9svX92IcjgVKjAmm9N6HKkdCbKy/3QH6OpKTUTb+ME4vsI 76D3+PTUXO4NQ7ki73p4lk6TNmy1Bq2i3OID9qkOgLgoY4zrO21ZhBPwh+bIewIcTYRW QA4r0A0I7ImewN6SAODOMcdtNykQgc9smInrYhtXIlXQ3CwVCX9AHR2C5iFOeeg2Owya B9ol2fcyHBX9SJbbJhgdsj/ATX1Saa3y9bNv8Oed5z1tZsZmh53bhEganiWmpdlYgI1b ixOnNPH3660VZoZNjZwLSse/8CApV4U/o0eue2PC+d6PTMHRXBlICzxsMDHkm8S47wnM 1zpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="fic/yNRo"; 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 cf7si13541084ejb.14.2019.09.12.12.11.15; Thu, 12 Sep 2019 12:11:40 -0700 (PDT) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b="fic/yNRo"; 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 S2387425AbfILRVa (ORCPT + 99 others); Thu, 12 Sep 2019 13:21:30 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:47076 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730023AbfILRV3 (ORCPT ); Thu, 12 Sep 2019 13:21:29 -0400 Received: by mail-pf1-f196.google.com with SMTP id q5so16395360pfg.13 for ; Thu, 12 Sep 2019 10:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=7ELatS+qNwcqZFlGpoKi7iobXH6c8V+qxrhRPOrjs54=; b=fic/yNRoUbOshKf70uCLRttuKIFyNPCwbkyjVy7IaAkeyp9nOiqYEb2H5J8G6Hs3AH SaT2pHiD0cJBkcvWfdj5QRvUVKfC3uTwKIMrmxRMQnJ6QtDtZ9fK8cNcQCnDCk6OWL0r ie25/fC0n7gs7E2KLdSIX/xwj+GBedVQPOYJK2gYcmy2lY7U/sjaK1Bn28yF+aZUnG15 ji0c6d/gqdBPDKYhKET84p010KEYjswZ6Kee8LyX2fb/sbgGFLsbvDjJ05gmyDOEdnt3 f0SqN0YffMqViC6+4yTyNq9QHPeyvyasDNthkbw+tILxKD4/KLTEYPTflwMgrI7CvdLW /tXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=7ELatS+qNwcqZFlGpoKi7iobXH6c8V+qxrhRPOrjs54=; b=XL0YlmXy0LYvMfmaCYstXFj7+IxsBQlV6NOiEurhtf7up7LOsGJ369v5o09FLShtzp 0nfzR0uB+5+Ab6m6K2yy1E7uy7Zf7AhvXkzJBGwln+X85g0ZdX4gjoy0i47ashlzpj4L QiO+40n5HQ3RP6qPLby0kGGobCbtwnoYtc2yP2jWTBJrOQA/Cv1XVepEwsN3lhqdyuDk lWkp9A+Tx/Z94+pNYxmQDFqsGqc9mk09kKXQAn9NJMdK8xgxuCXdISuF24cLNgHOWZiz eStbgA/ezJsCKrvoSQRVQcu05qgBDu2e31VEHWbEI3H2zsRk2TmlnPz80GdcusHS8jEq GvIw== X-Gm-Message-State: APjAAAUfan11SbezZ/mpQHvxopJTwbpFyTT2uAOhZTCXi7wLjo00QTIC /ETBTWDcs5TiUfXw7pR14Vs= X-Received: by 2002:a62:5ac1:: with SMTP id o184mr49440519pfb.67.1568308888895; Thu, 12 Sep 2019 10:21:28 -0700 (PDT) Received: from google.com ([2620:15c:211:1:3e01:2939:5992:52da]) by smtp.gmail.com with ESMTPSA id h70sm22082955pgc.36.2019.09.12.10.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2019 10:21:27 -0700 (PDT) Date: Thu, 12 Sep 2019 10:21:25 -0700 From: Minchan Kim To: Michal Hocko Cc: sunqiuyang , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" Subject: Re: [PATCH 1/1] mm/migrate: fix list corruption in migration of non-LRU movable pages Message-ID: <20190912172125.GB119788@google.com> References: <20190903082746.20736-1-sunqiuyang@huawei.com> <20190903131737.GB18939@dhcp22.suse.cz> <157FC541501A9C4C862B2F16FFE316DC190C1B09@dggeml512-mbx.china.huawei.com> <20190904063836.GD3838@dhcp22.suse.cz> <157FC541501A9C4C862B2F16FFE316DC190C2EBD@dggeml512-mbx.china.huawei.com> <20190904081408.GF3838@dhcp22.suse.cz> <157FC541501A9C4C862B2F16FFE316DC190C3402@dggeml512-mbx.china.huawei.com> <20190904125226.GV3838@dhcp22.suse.cz> <157FC541501A9C4C862B2F16FFE316DC190C5990@dggeml512-mbx.china.huawei.com> <20190909084029.GE27159@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190909084029.GE27159@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, Sep 09, 2019 at 10:40:29AM +0200, Michal Hocko wrote: > On Thu 05-09-19 01:44:12, sunqiuyang wrote: > > > > > > ________________________________________ > > > From: Michal Hocko [mhocko@kernel.org] > > > Sent: Wednesday, September 04, 2019 20:52 > > > To: sunqiuyang > > > Cc: linux-kernel@vger.kernel.org; linux-mm@kvack.org > > > Subject: Re: [PATCH 1/1] mm/migrate: fix list corruption in migration of non-LRU movable pages > > > > > > On Wed 04-09-19 12:19:11, sunqiuyang wrote: > > > > > Do not top post please > > > > > > > > > > On Wed 04-09-19 07:27:25, sunqiuyang wrote: > > > > > > isolate_migratepages_block() from another thread may try to isolate the page again: > > > > > > > > > > > > for (; low_pfn < end_pfn; low_pfn++) { > > > > > > /* ... */ > > > > > > page = pfn_to_page(low_pfn); > > > > > > /* ... */ > > > > > > if (!PageLRU(page)) { > > > > > > if (unlikely(__PageMovable(page)) && !PageIsolated(page)) { > > > > > > /* ... */ > > > > > > if (!isolate_movable_page(page, isolate_mode)) > > > > > > goto isolate_success; > > > > > > /*... */ > > > > > > isolate_success: > > > > > > list_add(&page->lru, &cc->migratepages); > > > > > > > > > > > > And this page will be added to another list. > > > > > > Or, do you see any reason that the page cannot go through this path? > > > > > > > > > > The page shouldn't be __PageMovable after the migration is done. All the > > > > > state should have been transfered to the new page IIUC. > > > > > > > > > > > > > I don't see where page->mapping is modified after the migration is done. Look at __ClearPageMovable which modify page->mapping. Once driver is migrated the page successfully, it should call __ClearPageMovable. To not consume new a page flag at that time, this flag is stored at page->mapping since we already have squeezed several flags in there. > > > > > > > > Actually, the last comment in move_to_new_page() says, > > > > "Anonymous and movable page->mapping will be cleard by > > > > free_pages_prepare so don't reset it here for keeping > > > > the type to work PageAnon, for example. " > > > > > > > > Or did I miss something? Thanks, > > > > > > This talks about mapping rather than flags stored in the mapping. > > > I can see that in tree migration handlers (z3fold_page_migrate, > > > vmballoon_migratepage via balloon_page_delete, zs_page_migrate via > > > reset_page) all reset the movable flag. I am not sure whether that is a > > > documented requirement or just a coincidence. Maybe it should be > > > documented. I would like to hear from Minchan. It is intended. See Documentation/vm/page_migration.rst After isolation, VM calls migratepage of driver with isolated page. The function of migratepage is to move content of the old page to new page and set up fields of struct page newpage. Keep in mind that you should indicate to the VM the oldpage is no longer movable via __ClearPageMovable() under page_lock if you migrated the oldpage successfully and returns MIGRATEPAGE_SUCCESS. Thanks.