Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3554041imu; Mon, 28 Jan 2019 06:55:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN5RwVSzI9xBFjisVAnKXVcUnkL1lhnq8ss/0fJBM+y2sCgjmq19wUAiV9bpxZU9XPcwS//g X-Received: by 2002:a62:3603:: with SMTP id d3mr22976371pfa.146.1548687356274; Mon, 28 Jan 2019 06:55:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548687356; cv=none; d=google.com; s=arc-20160816; b=P0eqfdMbxBLLFBU+ajMjSTLwccNfzMuI17C2/YiNm8FOFaxMJLf//v8Ip8mCQd3/wy wbBNhggIlc+fBOcRFuNRxr8wf6ONOzJMfFVIIj6YOf3DDnAX1uJfmFLWnEpJeDOpq8mS au3UD/cxn9vOZEZrTm4FnF0Iua0sJ3ZHO8ME9hP1Z/w/vIfF8yLJRdMsbGUazd7AIdao h3XSm5otuVGRAOYAFHGUV7RxskGGJS67worAN1qohv2+GYBvpvZXoygv0Za2g6fJyA0R YB2Ub8tKKYo0MEawnIa7uhCTJZH5yz18ImtP/6CwJWlFUuei2sAq1DMbHJbRXdyT5bOf ONag== 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=e9SPGk2h+AgFkUqOSxLOjL6fuIdjdZdUCLnYacN4ouY=; b=b+fG0nks18p+4+GhU6qw4gVsXX7Uph5EuHuiL9iDlVz/Kc965bOCpUi/qLzzruZPI5 NduKkqStk29NX0GBJaFqT5VXHTykzVOc4fVV8UFzICAnIC4B7XHRmSsHj4eJYYH39q22 EJL14fA6IiYYqkAIQv4/0gHRJr2B8CsJw8uhhPC3/Lvsuq6CBfBIT0TlLlFTMLLuABf+ 2HoXsDBJMdMQtQahrvrh0TLpaAk/tndPATHDrEBV70oEZB8A3AAXn7o82qCIDqJ/3eHh eVAqD6ooChZgodhPheybXEEAJDFToGOjaqA3Xh2tdSDdo5+xZJ0yOQW72Fb9wL7ti/uw 1OuQ== 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 m75si32162317pga.432.2019.01.28.06.55.39; Mon, 28 Jan 2019 06:55:56 -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 S1727146AbfA1Ox0 (ORCPT + 99 others); Mon, 28 Jan 2019 09:53:26 -0500 Received: from mx2.suse.de ([195.135.220.15]:57880 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727132AbfA1Ox0 (ORCPT ); Mon, 28 Jan 2019 09:53:26 -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 A7BDFAF0C; Mon, 28 Jan 2019 14:53:24 +0000 (UTC) Date: Mon, 28 Jan 2019 15:53:23 +0100 From: Michal Hocko To: David Hildenbrand Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Mel Gorman , "Kirill A. Shutemov" , Naoya Horiguchi , Jan Kara , Andrea Arcangeli , Dominik Brodowski , Matthew Wilcox , Vratislav Bendel , Rafael Aquini Subject: Re: [PATCH RFC] mm: migrate: don't rely on PageMovable() of newpage after unlocking it Message-ID: <20190128145323.GN18811@dhcp22.suse.cz> References: <20190128121609.9528-1-david@redhat.com> <20190128130709.GJ18811@dhcp22.suse.cz> <20190128132146.GK18811@dhcp22.suse.cz> <17e7d7e4-f4ca-a681-93e5-92a0c285be14@redhat.com> <20190128133514.GL18811@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 28-01-19 15:38:38, David Hildenbrand wrote: > On 28.01.19 14:35, Michal Hocko wrote: > > On Mon 28-01-19 14:22:52, David Hildenbrand wrote: > >> On 28.01.19 14:21, Michal Hocko wrote: > >>> On Mon 28-01-19 14:14:28, David Hildenbrand wrote: > >>>> On 28.01.19 14:07, Michal Hocko wrote: > >>>>> On Mon 28-01-19 13:16:09, David Hildenbrand wrote: > >>>>> [...] > >>>>>> My theory: > >>>>>> > >>>>>> In __unmap_and_move(), we lock the old and newpage and perform the > >>>>>> migration. In case of vitio-balloon, the new page will become > >>>>>> movable, the old page will no longer be movable. > >>>>>> > >>>>>> However, after unlocking newpage, I think there is nothing stopping > >>>>>> the newpage from getting dequeued and freed by virtio-balloon. This > >>>>>> will result in the newpage > >>>>>> 1. No longer having PageMovable() > >>>>>> 2. Getting moved to the local list before finally freeing it (using > >>>>>> page->lru) > >>>>> > >>>>> Does that mean that the virtio-balloon can change the Movable state > >>>>> while there are other users of the page? Can you point to the code that > >>>>> does it? How come this can be safe at all? Or is the PageMovable stable > >>>>> only under the page lock? > >>>>> > >>>> > >>>> PageMovable is stable under the lock. The relevant instructions are in > >>>> > >>>> mm/balloon_compaction.c and include/linux/balloon_compaction.h > >>> > >>> OK, I have just checked __ClearPageMovable and it indeed requires > >>> PageLock. Then we also have to move is_lru = __PageMovable(page) after > >>> the page lock. > >>> > >> > >> I assume that is fine as is as the page is isolated? (yes, it will be > >> modified later when moving but we are interested in the original state) > > > > OK, I've missed that the page is indeed isolated. Then the patch makes > > sense to me. > > > > Thanks Michal. I assume this has broken ever since balloon compaction > was introduced. I'll wait a little more and then resend as !RFC with a > cc-stable tag. Please make sure to CC Minchan when reposting. Btw. Acked-by: Michal Hocko -- Michal Hocko SUSE Labs