Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1598394pxu; Sat, 12 Dec 2020 19:35:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrg08GQvecx3jp+LJ6GZsnacJyaeek/Y+37W7bKBfrxCq9h+m2SahsjOO8Ui9bm2lLVUpg X-Received: by 2002:a17:907:720e:: with SMTP id dr14mr8235987ejc.303.1607830511004; Sat, 12 Dec 2020 19:35:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607830510; cv=none; d=google.com; s=arc-20160816; b=Wzvu+bl1jxHQ9xEShcTQtQu7UdI3uEMkRlFrJeZStWt5ABJSLgfBIHNUqGeuphRxn+ 7aOdP9VwoglObnZDlnC4gQ/vVOBq/fXObwnRfnxhgHNX/CY2RfLKMvkEoldM/fHXjr53 vK+Fi5aUnG2x1lIr13d3qdNxr6yUQtfdkB/0Xfbr9ukPrkkdopa6MvRZKe7gfUT15RQ7 zUcufcRdzbRYh85Ed1OkEmYaKuLQ9wIEaEpR+F5pZqi0hzmLCRzt6nypnXKy+S94fdZo uSHbhNhoOOgKACKSE8WtlMdBF8DjOrjYV1uoGCMfHWFnjKKGbZKQhA6NWFdsKG0Cq02u 7gcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=9Rl5EtIOs03CVOerY2+wVTiaDIkcXc+bBp/8wnzmHJM=; b=o+1lhV6atr8HtQ9CavYBDPvRbzKX+xGcLyKcVFlV7ua42f3BvMMBB8P09jIEK+lpZJ aMVhXMFpqlrsppD2x2JOo0i5AckyQumF6homKdlIPLR0m3lH44FmN0VNYT+jjI+YXPeV kY67gby6i6bObjv+yOL2dzAdhnRYWBeAT6BGyvvxe6+AICdwGCCDIlJABNy7eY/K+BJl aZO3SquVL0xuDHwFrXKuJFAGj7RMUSjbZ6OikLwJwPcuurV19ootZ9Vt/meb8aVR6BXP k5c95wujcAywLTi2wiSPVfjhPtQ6oSLMrUvw90HPuo6ky+SOE/+xAPrW+IAzGVcAZIx4 wN0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="IycrZ4/E"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k5si8345351edl.83.2020.12.12.19.34.48; Sat, 12 Dec 2020 19:35:10 -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=@redhat.com header.s=mimecast20190719 header.b="IycrZ4/E"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392380AbgLKVbC (ORCPT + 99 others); Fri, 11 Dec 2020 16:31:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35884 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405984AbgLKVak (ORCPT ); Fri, 11 Dec 2020 16:30:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607722152; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9Rl5EtIOs03CVOerY2+wVTiaDIkcXc+bBp/8wnzmHJM=; b=IycrZ4/EYEc7YY66bAlajurt3dR6GhiO5Z61TV9F7gY+2f7Atl1Y1QN0rmB+24OJ4ymlhE FLk+ka3D6Z294+XMj5V7inKPiQjVzlDDIu5Ym750j7mdg+RsbpVuHjcRN5NVDb5r6aBKZ6 +JUzKJoAwgZwnSFCnpmQTK0jzDAmJLY= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-517-C4916xAUNLCMdkFPMfApqg-1; Fri, 11 Dec 2020 16:29:11 -0500 X-MC-Unique: C4916xAUNLCMdkFPMfApqg-1 Received: by mail-wr1-f69.google.com with SMTP id o17so3807172wra.8 for ; Fri, 11 Dec 2020 13:29:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=9Rl5EtIOs03CVOerY2+wVTiaDIkcXc+bBp/8wnzmHJM=; b=AF4jAUQFxSRglnvzbZe0Eu7+XwAcxus6N4EZqVItU3sBxUthXSATEgDZ3FAkALTbKm jlpbSRF4/KJqyOD34vIlOP2HttOTooAE+3eUwnq7XDO8Ubw++ADsIeuwHW3oEU9IyapL Hy+ma1xqXXslqpqanY8cVfJo7qaj7xL6yLsWeHFmH3ryoje8/IXxjUWonyqv621vtIeO qLTmNzTu6m4cwVNj+4efFbTXiLb0A9glIWcoKJcR4yLtfkLmTTqTyzg1skw0mVPoeJj3 QNXgTO2RNKbB0S3vXD62esWUNyd0OSyDWkVdSYBIjzfiP2I+njKlHpR8gPl90BaA5WEE 1apw== X-Gm-Message-State: AOAM5337CQfkS/8B0AchaA6i0tG0crl8f5/zdTK/lyTG8A0Y9Esr+ZCl petRaLPprX8Io3iH0AQWYP/JNfe203bOK3aOpC4aarYGgsK6dJ2O/JbrLvvQBYxTpfOL9uCVuO6 Bik6qtenXmBsOzksOwjMeKJ6f X-Received: by 2002:adf:9cca:: with SMTP id h10mr8782006wre.77.1607722149875; Fri, 11 Dec 2020 13:29:09 -0800 (PST) X-Received: by 2002:adf:9cca:: with SMTP id h10mr8781992wre.77.1607722149677; Fri, 11 Dec 2020 13:29:09 -0800 (PST) Received: from [192.168.3.114] (p4ff23c7c.dip0.t-ipconnect.de. [79.242.60.124]) by smtp.gmail.com with ESMTPSA id n189sm15862735wmf.20.2020.12.11.13.29.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Dec 2020 13:29:09 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: David Hildenbrand Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v3 5/6] mm/gup: migrate pinned pages out of movable zone Date: Fri, 11 Dec 2020 22:29:08 +0100 Message-Id: <10F682D5-0654-4C42-9989-F999D4434295@redhat.com> References: Cc: Jason Gunthorpe , 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 In-Reply-To: To: Pavel Tatashin X-Mailer: iPhone Mail (18B92) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Am 11.12.2020 um 22:09 schrieb Pavel Tatashin := >=20 > =EF=BB=BFOn Fri, Dec 11, 2020 at 3:46 PM Jason Gunthorpe wr= ote: >>=20 >>> 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: >>>>=20 >>>> 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 m= m_struct *mm, >>>>> } >>>>>=20 >>>>> if (!isolate_lru_page(head)) { >>>>> - list_add_tail(&head->lru, &cma_p= age_list); >>>>> + list_add_tail(&head->lru, &movab= le_page_list); >>>>> mod_node_page_state(page_pgdat(he= ad), >>>>> NR_ISOLATED_A= NON + >>>>> page_is_file_= lru(head), >>>>> @@ -1605,7 +1604,7 @@ static long check_and_migrate_cma_pages(struct m= m_struct *mm, >>>>> i +=3D step; >>>>> } >>>>>=20 >>>>> - if (!list_empty(&cma_page_list)) { >>>>> + if (!list_empty(&movable_page_list)) { >>>>=20 >>>> 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? >>>>=20 >>>> 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 avoi= ded >>> + * when pages are pinned and faulted, but it is still possibl= e that >>> + * address space already has pages in ZONE_MOVABLE at the tim= e when >>> + * pages are pinned (i.e. user has touches that memory before= >>> + * pinning). In such case we try to migrate them to a differe= nt zone, >>> + * but if migration fails the pages can still end-up pinned i= n >>> + * ZONE_MOVABLE. In such case, memory offlining might retry a= long >>> + * time and will only succeed once user application unpins pa= ges. >>=20 >> It is not "retry a long time" it is "might never complete" because >> userspace will hold the DMA pin indefinitely. >>=20 >> Confused what the point of all this is then ?? >>=20 >> 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. >=20 > 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: >=20 > 1. pin + migration/isolation failure Not sure what that really means. We have short-term pinnings (although we mi= ght have a better term for =E2=80=9Epinning=E2=80=9C here) for example, when= a process dies (IIRC). There is a period where pages cannot get migrated an= d offlining code has to retry (which might take a while). This still applies= after your change - are you referring to that? > 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). Virtio-mem is the primary user in this context. > Do you think we should unconditionally unpin pages, and return error > when isolation/migration fails? I=E2=80=98m not sure what you mean here. Who=E2=80=99s supposed to unpin whi= ch pages? >=20 > Pasha >=20 >>=20 >> Jason >=20