Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1752936pxu; Sun, 13 Dec 2020 02:18:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwM0BmWvrVMKgeN9tpETtPY/yHXcGwRT5mrGX1hv80HBPJjtpLrpi4DeB0NpmVt8ZNh9Jmp X-Received: by 2002:a05:6402:1155:: with SMTP id g21mr20681275edw.53.1607854704846; Sun, 13 Dec 2020 02:18:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607854704; cv=none; d=google.com; s=arc-20160816; b=CD8ot1WkGBvfUNY9brRr86abElZ6OsXgTUBDmyD9h3SNthx7ywYjgQqN2sW7hAAbFH cYay4oR4yHSaevu9ODg9Q/87d8/hKdQY8DFiVXE1SAdwgj43huj2ZZntSPweIdWHMz/K eFNwaxuIhyDv827f78geeHFBR62D97ZD9UFVZBzjZiKFNrb0BIArHYWbSH/UkIlEyyyg aT2UuKYDKIXDG2khAsPqX2wHVdERFcp3ety5G7NZpwASW6cr+Qyat0xeY4OyreLvYYrT HrT3USLNRGzFBsHFGOAoNcTeDk5qwrCGbE1oJJQxrX1Sy5wsnS6hy0C8iR2u9Z09TANg nwJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Ao7xOAmYaX/ywGJg0iG/Mh6Kx1f1ZcL87diFd+Y1lgA=; b=XChAW32GUyrwf+dEYhv/xkHcjEZkzSBmt18wS/99s5YptCV3EoVrkKUOK2fJFTM/oV HUc7T5SzuzM/Dv3dOU+s11ETJtOTMbwF7+DT/27WJ4BAXwwMzIOGhVfnwXu98bgKfSZs H9Mx1dtbyL8Jn2M3GsDV7Te3mX9qbd5Lg5IqDT8RzmHUoic5ydJK1MU4ez8Bsh1bL3M5 s3NXUgs7GpQ+I6VB2cvDiHfGWyAULyukDha7HZZRUREQWvhWRG/JTgSqcz+J96CnDZIk Up1w0Tb1O9+uHCJxB3l2lV2XPpuempU3aFheawWrlbzP31cFqEZkHeqLCzpb6mEpxu1E GeBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=aAfGSlEU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y23si7779541ejc.508.2020.12.13.02.17.48; Sun, 13 Dec 2020 02:18:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=aAfGSlEU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395170AbgLKVK4 (ORCPT + 99 others); Fri, 11 Dec 2020 16:10:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391366AbgLKVKT (ORCPT ); Fri, 11 Dec 2020 16:10:19 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78149C0613CF for ; Fri, 11 Dec 2020 13:09:39 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id v22so10793090edt.9 for ; Fri, 11 Dec 2020 13:09:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ao7xOAmYaX/ywGJg0iG/Mh6Kx1f1ZcL87diFd+Y1lgA=; b=aAfGSlEUgcDLpXRNkXIwp3DHZUaleYjADDcGxmniPbgCxhcNtqJwGP/McXAsdM/BAJ m9xejVVYuVGT+X0oCTQc5OkBSfq4uYXO1r0vnIGX6iznyDLybhsStAqQ8nE+VTYvT41/ Q4AzJl/Rj5EBBtSby6Bvg346cED2t0FBYmJ1URTPm8E51HEVUW0ZlkLZ5mCMQ2HSZucZ nEm1DGQ0qOiATOM2Oc5DpmESg938oYmpTdtoJ8KTNWhi2qVmXaFEWcaFR8F4hLAn+D81 B7LILJrvJvcZF/0nUbkByJepMPWl2TJXBXZ0L76aSvoQ0s31nM2o5dO4av6j9PkDHbjK YybQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ao7xOAmYaX/ywGJg0iG/Mh6Kx1f1ZcL87diFd+Y1lgA=; b=Je8kcDBQeEZC1869h2SMMbCeh3t1OXEgtPIzgruTgVe+JAxNCcYIrTH89zeRGqZ9SL 5bX2kr/bI7arnDnIuD8F4gV4PzNDvABh3XJLWAcT8/f3fx1yjyl3XfHanxG6q0qT7zjk EVcFxYRphDHu3UBamEb8poR/WPEl39YjYUeP3YoJ/VIibQ+L2x3CYmekSf2qbIB+wZyg vQHCk0Xg1VP2Non/oX9FKXIu+XbENcU4JfDwBnmaKH30vMlGvo1snZfU59rb0DzeU47f m8YWt3myif1/W+wVK57c47R38iVkZxq/2EjU5Bz0AZ0zc1dQzLZevHZNcG4jGYKXdjFe RjvA== X-Gm-Message-State: AOAM5330cjikJJbVBw9SyOCFyKrs4qniM3m3gLwZsbqL9NmYz1En7GOB WJbd+bR7jlTvp7v9YmsUO1kXR+I0UpXMgFjg4Yeo3w== X-Received: by 2002:a50:f404:: with SMTP id r4mr975568edm.62.1607720978232; Fri, 11 Dec 2020 13:09:38 -0800 (PST) MIME-Version: 1.0 References: <20201211202140.396852-1-pasha.tatashin@soleen.com> <20201211202140.396852-6-pasha.tatashin@soleen.com> <20201211202354.GA2225686@ziepe.ca> <20201211204600.GD5487@ziepe.ca> In-Reply-To: <20201211204600.GD5487@ziepe.ca> From: Pavel Tatashin Date: Fri, 11 Dec 2020 16:09:02 -0500 Message-ID: Subject: Re: [PATCH v3 5/6] mm/gup: migrate pinned pages out of movable zone To: Jason Gunthorpe Cc: LKML , linux-mm , Andrew Morton , Vlastimil Babka , Michal Hocko , David Hildenbrand , Oscar Salvador , Dan Williams , Sasha Levin , Tyler Hicks , Joonsoo Kim , mike.kravetz@oracle.com, Steven Rostedt , Ingo Molnar , Peter Zijlstra , Mel Gorman , Matthew Wilcox , David Rientjes , John Hubbard , Linux Doc Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 11, 2020 at 3:46 PM Jason Gunthorpe wrote: > > On Fri, Dec 11, 2020 at 03:40:57PM -0500, Pavel Tatashin wrote: > > On Fri, Dec 11, 2020 at 3:23 PM Jason Gunthorpe wrote: > > > > > > On Fri, Dec 11, 2020 at 03:21:39PM -0500, Pavel Tatashin wrote: > > > > @@ -1593,7 +1592,7 @@ static long check_and_migrate_cma_pages(struct mm_struct *mm, > > > > } > > > > > > > > if (!isolate_lru_page(head)) { > > > > - list_add_tail(&head->lru, &cma_page_list); > > > > + list_add_tail(&head->lru, &movable_page_list); > > > > mod_node_page_state(page_pgdat(head), > > > > NR_ISOLATED_ANON + > > > > page_is_file_lru(head), > > > > @@ -1605,7 +1604,7 @@ static long check_and_migrate_cma_pages(struct mm_struct *mm, > > > > i += step; > > > > } > > > > > > > > - if (!list_empty(&cma_page_list)) { > > > > + if (!list_empty(&movable_page_list)) { > > > > > > You didn't answer my earlier question, is it OK that ZONE_MOVABLE > > > pages leak out here if ioslate_lru_page() fails but the > > > moval_page_list is empty? > > > > > > I think the answer is no, right? > > In my opinion it is OK. We are doing our best to not pin movable > > pages, but if isolate_lru_page() fails because pages are currently > > locked by someone else, we will end up long-term pinning them. > > See comment in this patch: > > + * 1. Pinned pages: (long-term) pinning of movable pages is avoided > > + * when pages are pinned and faulted, but it is still possible that > > + * address space already has pages in ZONE_MOVABLE at the time when > > + * pages are pinned (i.e. user has touches that memory before > > + * pinning). In such case we try to migrate them to a different zone, > > + * but if migration fails the pages can still end-up pinned in > > + * ZONE_MOVABLE. In such case, memory offlining might retry a long > > + * time and will only succeed once user application unpins pages. > > It is not "retry a long time" it is "might never complete" because > userspace will hold the DMA pin indefinitely. > > Confused what the point of all this is then ?? > > I thought to goal here is to make memory unplug reliable, if you leave > a hole like this then any hostile userspace can block it forever. You are right, I used a wording from the previous comment, and it should be made clear that pin may be forever. Without these patches it is guaranteed that hot-remove will fail if there are pinned pages as ZONE_MOVABLE is actually the first to be searched. Now, it will fail only due to exceptions listed in ZONE_MOVABLE comment: 1. pin + migration/isolation failure 2. memblock allocation due to limited amount of space for kernelcore 3. memory holes 4. hwpoison 5. Unmovable PG_offline pages (? need to study why this is a scenario). Do you think we should unconditionally unpin pages, and return error when isolation/migration fails? Pasha > > Jason