Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp360495ybe; Wed, 4 Sep 2019 00:28:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCazIfR8E4LOn22emtZLSY8iha0jkfVRlgOzejSoPW19wKt6TmTRrqoWwC1V41qZUNLZ4e X-Received: by 2002:a17:902:7588:: with SMTP id j8mr21984985pll.280.1567582123456; Wed, 04 Sep 2019 00:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567582123; cv=none; d=google.com; s=arc-20160816; b=Sof9G8e7RblYIOaHVUUU+trFu88pvPsOu+XQ+86xxbFYFTf50S6JeMe/v7zs/Q6uhM aFwckq21hoMEtHRIgo7jNY+bCZ/JFknxtqRj7aJdsxwuwAzBnNdjtGVHk0y1SteIvBh2 oasZ9BQxIJnspTGVXPwnDR/8haaT2yGUVJyftmu99JOJCW/C8+bpl1KmcpZFhU3HTX6Y JEFbuVrz68LJEQh/FSDgZfgMV0MnXa4AS8eHq1PVCBxIef/MnVnwvn6g6LHmLW8sunRv PVsVVVf0RX2D+oKOYpVVtbHE7wsIlCbtONYYgPim+rLwKkB1853wr42oREUJMHbFC1vk RqEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=byIXB/NblM2yug5Ng5uJBjjUVq/OvKpXC+hRh3oLIt0=; b=Xd+hfXQnHD4eDco8MhztaxcW0uvo+67jZwekwqT1AjypbJ42a1Mc7KyW36oabfi4H8 MnTTSAa34UsSHXU+tXwNyW1YldAgro7Uo0Aty7vg/jsmpM3Mbnd8V7/7vVvfIoFnZ5ti zx/+tB64vi5an4OyRG4/uIdGfP/L0XukfaTBFjt4lQgbfxqrOd+WPQFpZo8XD4mkDX0p CsQN2yZaqB59oGCoFuJyCG1JK2sBgB/jXiXExAaJ2Ul8Kypj002XrDtBbIIIentepWAc be3EJXeVgjXm8M1GU+Jx8THH+YxjbpEYgd2bKLGAK6EO3hO8fuOGfFTC6tBH7lMtbjDX wo8Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4si16519350pgv.464.2019.09.04.00.28.28; Wed, 04 Sep 2019 00:28:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729099AbfIDH13 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 4 Sep 2019 03:27:29 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:3555 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725840AbfIDH12 (ORCPT ); Wed, 4 Sep 2019 03:27:28 -0400 Received: from dggeml406-hub.china.huawei.com (unknown [172.30.72.56]) by Forcepoint Email with ESMTP id 09746421599CFEE9ECB1; Wed, 4 Sep 2019 15:27:27 +0800 (CST) Received: from DGGEML422-HUB.china.huawei.com (10.1.199.39) by dggeml406-hub.china.huawei.com (10.3.17.50) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 4 Sep 2019 15:27:26 +0800 Received: from DGGEML512-MBX.china.huawei.com ([169.254.2.60]) by dggeml422-hub.china.huawei.com ([10.1.199.39]) with mapi id 14.03.0439.000; Wed, 4 Sep 2019 15:27:25 +0800 From: sunqiuyang To: Michal Hocko 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 Thread-Topic: [PATCH 1/1] mm/migrate: fix list corruption in migration of non-LRU movable pages Thread-Index: AQHVYi7CKRiSaGuZ20KJAhdeZXNZ4qcZaW+AgAFf/lT//8LbAIAAjGWd Date: Wed, 4 Sep 2019 07:27:25 +0000 Message-ID: <157FC541501A9C4C862B2F16FFE316DC190C2EBD@dggeml512-mbx.china.huawei.com> References: <20190903082746.20736-1-sunqiuyang@huawei.com> <20190903131737.GB18939@dhcp22.suse.cz> <157FC541501A9C4C862B2F16FFE316DC190C1B09@dggeml512-mbx.china.huawei.com>,<20190904063836.GD3838@dhcp22.suse.cz> In-Reply-To: <20190904063836.GD3838@dhcp22.suse.cz> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.177.249.127] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? ________________________________________ From: Michal Hocko [mhocko@kernel.org] Sent: Wednesday, September 04, 2019 14:38 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 02:18:38, sunqiuyang wrote: > The isolate path of non-lru movable pages: > > isolate_migratepages_block > isolate_movable_page > trylock_page > // if PageIsolated, goto out_no_isolated > a_ops->isolate_page > __SetPageIsolated > unlock_page > list_add(&page->lru, &cc->migratepages) > > The migration path: > > unmap_and_move > __unmap_and_move > lock_page > move_to_new_page > a_ops->migratepage > __ClearPageIsolated > unlock_page > /* here, the page could be isolated again by another thread, and added into another cc->migratepages, > since PG_Isolated has been cleared, and not protected by page_lock */ > list_del(&page->lru) But the page has been migrated already and not freed yet because there is still a pin on it. So nobody should be touching it at this stage. Or do I still miss something? -- Michal Hocko SUSE Labs