From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4F03C2D0E4 for ; Fri, 20 Nov 2020 21:34:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3D49F2237B for ; Fri, 20 Nov 2020 21:34:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BM3LDvMd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D49F2237B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7D6A36B005C; Fri, 20 Nov 2020 16:34:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 786976B005D; Fri, 20 Nov 2020 16:34:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 64EBE6B0068; Fri, 20 Nov 2020 16:34:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0140.hostedemail.com [216.40.44.140]) by kanga.kvack.org (Postfix) with ESMTP id 3701B6B005C for ; Fri, 20 Nov 2020 16:34:57 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D2FB78249980 for ; Fri, 20 Nov 2020 21:34:56 +0000 (UTC) X-FDA: 77506101792.11.hair22_4d080bc2734e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id B3F5A180F8B82 for ; Fri, 20 Nov 2020 21:34:56 +0000 (UTC) X-HE-Tag: hair22_4d080bc2734e X-Filterd-Recvd-Size: 6502 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Nov 2020 21:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605908095; 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=Cel/yyyp4FZ5fSQaB9eS2W5gmaNtnlei3ih5t0uvjBE=; b=BM3LDvMdL4bMYvCq3C4krZYugGDID3+w6FGOOU+1rLYDIjIIEriwkjttTS31PUK2ZRlSCX JxwFgdVoXLgkdRkNixpMNy3xVkcQODRKrU8YJcMzh/b/JZxmTDqYW539OBL0Dahhcpj00k VMpJ4vAMR7kbjHT8OV0SHdibAtnt70M= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-338-UAZTg_h5O-OeeOyAGZRHYw-1; Fri, 20 Nov 2020 16:34:54 -0500 X-MC-Unique: UAZTg_h5O-OeeOyAGZRHYw-1 Received: by mail-wr1-f70.google.com with SMTP id l5so3849543wrn.18 for ; Fri, 20 Nov 2020 13:34:52 -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=5aUMWdjt8NVidkZhMPjXUDGGPBhWxvoJByLecsN7Rc4=; b=hNkQIDyVeaGVU3IPF/XQu+OKnVhQafU4dVtkadOnPpi1a1Cb1TA747ZcD4Fl18OdCP qpIqLI3iy7yqL58GnhfspBcCUGAjmlzA+shgg9mxIH3DE64aT9vFP1D1fPqGh6hO6FZg mB+Byipxk5H/XvvENiFGFVqFgiwqwebfQZYQr6ve2Znbw888pS8FTLVxI7TFnmjP5vnY ye7iPDRzogkMnmq92Tl1EpbUnB6x0+Hl9TB7+AsEWr6rGMq9Oc05bHJSF910T5mbxAG7 S90uUuAJC6fLLEJeBsjtXaFjpeE3MKV1wRxg9M08q+LCY/K3vQeq1rutA/yPdXFH01Am +6mw== X-Gm-Message-State: AOAM531JTGxpPzSSMhF+R2Wzt2p4wj/SyzYDiTlhaRYGAkjnWC/I2sDG lqoBEyTEKVxFsChvFrMuJEj98wfLRiQ+U5BpRNxwg3LLKvJwnCUsJeLx7vNB7mA8y/0+y8vP5bT C4XbpBGRQozU= X-Received: by 2002:adf:ea03:: with SMTP id q3mr17402816wrm.141.1605908091752; Fri, 20 Nov 2020 13:34:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxecvW/iJw52Oq3XaFaHXe3IG/dsUhTmxrUXFu6xAkfe45n2PoZMFzgnGJYtxW/ezeiYRptcw== X-Received: by 2002:adf:ea03:: with SMTP id q3mr17402796wrm.141.1605908091521; Fri, 20 Nov 2020 13:34:51 -0800 (PST) Received: from [192.168.3.114] (p5b0c6104.dip0.t-ipconnect.de. [91.12.97.4]) by smtp.gmail.com with ESMTPSA id g11sm6774100wrq.7.2020.11.20.13.34.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Nov 2020 13:34:50 -0800 (PST) From: David Hildenbrand Mime-Version: 1.0 (1.0) Subject: Re: Pinning ZONE_MOVABLE pages Date: Fri, 20 Nov 2020 22:34:49 +0100 Message-Id: <9C8F0E5D-2D42-4BA5-A5B5-9E049E1BE862@redhat.com> References: <20201120211707.GC4327@casper.infradead.org> Cc: David Hildenbrand , Pavel Tatashin , linux-mm , Andrew Morton , Vlastimil Babka , LKML , Michal Hocko , Oscar Salvador , Dan Williams , Sasha Levin , Tyler Hicks , Joonsoo Kim , sthemmin@microsoft.com In-Reply-To: <20201120211707.GC4327@casper.infradead.org> To: Matthew Wilcox X-Mailer: iPhone Mail (18A8395) Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: > Am 20.11.2020 um 22:17 schrieb Matthew Wilcox : >=20 > =EF=BB=BFOn Fri, Nov 20, 2020 at 09:59:24PM +0100, David Hildenbrand wrot= e: >>=20 >>>> Am 20.11.2020 um 21:28 schrieb Pavel Tatashin : >>>=20 >>> =EF=BB=BFRecently, I encountered a hang that is happening during memory= hot >>> remove operation. It turns out that the hang is caused by pinned user >>> pages in ZONE_MOVABLE. >>>=20 >>> Kernel expects that all pages in ZONE_MOVABLE can be migrated, but >>> this is not the case if a user applications such as through dpdk >>> libraries pinned them via vfio dma map. Kernel keeps trying to >>> hot-remove them, but refcnt never gets to zero, so we are looping >>> until the hardware watchdog kicks in. >>>=20 >>> We cannot do dma unmaps before hot-remove, because hot-remove is a >>> slow operation, and we have thousands for network flows handled by >>> dpdk that we just cannot suspend for the duration of hot-remove >>> operation. >>>=20 >>=20 >> Hi! >>=20 >> It=E2=80=98s a known problem also for VMs using vfio. I thought about th= is some while ago an came to the same conclusion: before performing long-te= rm pinnings, we have to migrate pages off the movable zone. After that, it= =E2=80=98s too late. >=20 > We can't, though. VMs using vfio pin their entire address space (right?) > so we end up with basically all of the !MOVABLE memory used for VMs and > the MOVABLE memory goes unused (I'm thinking about the case of a machine > which only hosts VMs and has nothing else to do with its memory). In > that case, the sysadmin is going to reconfigure ZONE_MOVABLE away, and > now we just don't have any ZONE_MOVABLE. So what's the point? When the guest is using an vIOMMU, it will only pin what=E2=80=98s currentl= y mapped by the guest into the vIOMMU. Otherwise: yes. If you assume all memory will be used for VMs with vfio, then yes: no ZONE_= MOVABLE, no memory hotunplug. If its=E2=80=98s only some VMs, it=E2=80=98s = a different story. >=20 > ZONE_MOVABLE can also be pinned by mlock() and other such system calls. Mlocked pages can be migrated, no? They are simply not swappable iirc. > The kernel needs to understand that ZONE_MOVABLE memory may not actually > be movable, and skip the unmovable stuff. >=20 Then you don=E2=80=98t have unplug guarantees. Memory unplug broken by desi= gn. Then there is no point in optimizing that case at all and tell customer= s =E2=80=9Evfio and memory hotunplug is incompatible=E2=80=9C. The only ugl= y thing is the endless loop.