Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2597947pxb; Thu, 10 Feb 2022 00:55:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEYvXBumHlTQQJZfnvnisB6/9RQjg4jKsTBk9vxPWd+hZVqS6PfndEu1X7jBx/RkdxS+tr X-Received: by 2002:a17:907:7f0d:: with SMTP id qf13mr5623151ejc.446.1644483346010; Thu, 10 Feb 2022 00:55:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644483346; cv=none; d=google.com; s=arc-20160816; b=ARuE2CeQpClzipVT9kEM2geds4cL3stoo5eq7MS/7wtBOIpa6h8UDi8ZAGF8OA5Twy ql2JPgkD/RcMVsvynVsWAEZaSwZGwAVqyGhquAu/yB7e/DwFh1r9hbjvIreZrQp0JoKh 3/gY3uANMkStYcN2FA+KUNWkPGLvEs5kKIduRXvdfGMNTw6XRJ9YTAOCPwg/4ZVzP6OW VNGEKI4CKHDD9IrGmiPLUhSQ6StTSeqNOXoehbQAOdVs1+C9WBe/FbzFFqIg0zYJGx/i zrO4pQxcq0gx6BEyEb9GKLJoGEUsQjzUVJSWv2Vgu6dF3bN/EiDszA+7Y/j0yoAY0Rcr YNsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=fKwV65Fx615k5LuIXkLcfiAVy//BhvLpTdyb0R61khg=; b=mzwz2ScFi8LINtJvrWykViLJaHhqX0VGV6QwsCns/uXpYsylzR2IOo0ymaUYBGn3lv lnQuROLuYL+xHLn0M735NyfbTSVK9I20O9DJfs8RBAqHs7M8QGnAYg9R6iF6rGn6A8xQ pNP4tlxyzaN6uXsmFyuK1Xh9L9qokSaIFAS90T/3RXpdJ0/CQXdLIsijxgxp6rLtI3Fi eNLNP92H+F64Lm9wVSoKyg39IKBeyo4CgNhr7TtPEVlvU5RZU5QC0334pSQlLUPh/wc8 pziiR8R/55vnVa8QUDZEgZfc040FiVNbtHJ7hG1BWcccs5iUdnOxOO2P9UxAn+bYKtAU D6tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=UBIrT7SY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fy1si5633721ejc.779.2022.02.10.00.55.20; Thu, 10 Feb 2022 00:55:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=UBIrT7SY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235970AbiBJH2p (ORCPT + 99 others); Thu, 10 Feb 2022 02:28:45 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235948AbiBJH2n (ORCPT ); Thu, 10 Feb 2022 02:28:43 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 866F726E for ; Wed, 9 Feb 2022 23:28:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=fKwV65Fx615k5LuIXkLcfiAVy//BhvLpTdyb0R61khg=; b=UBIrT7SYvmrOGapKs/IMJGZMJP rULomygyaaC55QDvs3eY68CeMZN8/C+Un5dhwOktX57xJXfoja7le1xanp8IT24T92jgKNogsi73U Vs9CL78FLc7OFzeln9OiPi/7vaiOEWqV6C55F6pZVXdbLeEo8ldf619JOUh2kLdEvFbEbfs4LZxZ3 5qvQi9MVLtXFESagqUxWxaF5WV+V5JcZMy4pHRWVG/clCxw7rfcEHb30WuSh5pYSBuzRIj8PeF+Sn rhE6DpzHH+K5CChoU7tggXhlh61KLf/GmLxZLyL2cNDul5XrR+6rl7Cq4CkAIe4DZ9r8zj1m7ij2G Wyu4LoIQ==; Received: from [2001:4bb8:188:3efc:8014:b2f2:fdfd:57ea] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nI3sV-002rks-4y; Thu, 10 Feb 2022 07:28:31 +0000 From: Christoph Hellwig To: Andrew Morton , Dan Williams Cc: Felix Kuehling , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , Ben Skeggs , Karol Herbst , Lyude Paul , Jason Gunthorpe , Alistair Popple , Logan Gunthorpe , Ralph Campbell , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, nvdimm@lists.linux.dev, linux-mm@kvack.org Subject: start sorting out the ZONE_DEVICE refcount mess v2 Date: Thu, 10 Feb 2022 08:28:01 +0100 Message-Id: <20220210072828.2930359-1-hch@lst.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, this series removes the offset by one refcount for ZONE_DEVICE pages that are freed back to the driver owning them, which is just device private ones for now, but also the planned device coherent pages and the ehanced p2p ones pending. It does not address the fsdax pages yet, which will be attacked in a follow on series. Note that if we want to get the p2p series rebased on top of this we'll need a git branch for this series. I could offer to host one. A git tree is available here: git://git.infradead.org/users/hch/misc.git pgmap-refcount Gitweb: http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/pgmap-refcount Changes since v1: - add a missing memremap.h include in memcontrol.c - include rebased versions of the device coherent support and device coherent migration support series as well as additional cleanup patches Diffstt: arch/arm64/mm/mmu.c | 1 arch/powerpc/kvm/book3s_hv_uvmem.c | 1 drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 35 - drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 1 drivers/gpu/drm/drm_cache.c | 2 drivers/gpu/drm/nouveau/nouveau_dmem.c | 3 drivers/gpu/drm/nouveau/nouveau_svm.c | 1 drivers/infiniband/core/rw.c | 1 drivers/nvdimm/pmem.h | 1 drivers/nvme/host/pci.c | 1 drivers/nvme/target/io-cmd-bdev.c | 1 fs/Kconfig | 2 fs/fuse/virtio_fs.c | 1 include/linux/hmm.h | 9 include/linux/memremap.h | 36 + include/linux/migrate.h | 1 include/linux/mm.h | 59 -- lib/test_hmm.c | 353 ++++++++++--- lib/test_hmm_uapi.h | 22 mm/Kconfig | 7 mm/Makefile | 1 mm/gup.c | 127 +++- mm/internal.h | 3 mm/memcontrol.c | 19 mm/memory-failure.c | 8 mm/memremap.c | 75 +- mm/migrate.c | 763 ---------------------------- mm/migrate_device.c | 822 +++++++++++++++++++++++++++++++ mm/rmap.c | 5 mm/swap.c | 49 - tools/testing/selftests/vm/Makefile | 2 tools/testing/selftests/vm/hmm-tests.c | 204 ++++++- tools/testing/selftests/vm/test_hmm.sh | 24 33 files changed, 1552 insertions(+), 1088 deletions(-)