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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C03C1C433EF for ; Mon, 7 Feb 2022 19:21:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 377006B0074; Mon, 7 Feb 2022 14:21:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 325BB6B0075; Mon, 7 Feb 2022 14:21:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 179BD6B0078; Mon, 7 Feb 2022 14:21:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id 035616B0074 for ; Mon, 7 Feb 2022 14:21:59 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A8E0D9366C for ; Mon, 7 Feb 2022 19:21:58 +0000 (UTC) X-FDA: 79116953916.22.41A151C Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) by imf26.hostedemail.com (Postfix) with ESMTP id 308C6140006 for ; Mon, 7 Feb 2022 19:21:58 +0000 (UTC) Received: by mail-qv1-f48.google.com with SMTP id a28so5030170qvb.10 for ; Mon, 07 Feb 2022 11:21:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MpROwmI6Qnm2emkziisG5aDXgeJvPxSLNV0Lic7ckQs=; b=OaiSuWRoTh89hqFli2OaM/99731kyVjifGW/6GRnhqIbNkn4rqP5cCBkUjKmhiONGA DRfaWqoDUSS3IuMSZybn6CxVSz9gReIWR5zHG2jjk1KjqYVDa/9CCxg0tFF3xZ3AN4KM IWW23EV/8VVY2qGl9kiFU+8+HFL3FZ5X6K6By2RBakx/Ghc4c95TqRKVwgL78FFsnybj gOmsu8PRvUOA7lJpZIzHdbR6U2MiJsL97ZsWs6lb+AZn8w27xJatWjWCvHlr0v+nfzrq 5FEXre/2zFc0NgKQwTEa1qY6KjXxjGFFZdTM7G5gNDX+6knlEUNvM1LWH4Y4kbABTlQ9 MW3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MpROwmI6Qnm2emkziisG5aDXgeJvPxSLNV0Lic7ckQs=; b=dJP8SuqD5KCyT0f3Zys9e2jaiQC7HGD0FHSUBP55gilfH8JgI6X9Icof37e85bp0Dd Y8e0nwV2T6ZJnqRoVI0i2UaRIIjXLRzJaYlX1fBkXmv8iJCwd1PC59gzlF6Q/R30Pv+a y7SUr0UhI+mEnWhU2xk1oko7mC9r1CBXTfO/gz7O7Xt+PL5F08ICDGEe78+znhXChn/F wplMjYH0Hif08vVTC/jkayLbPgR27shEJsaGx5VBHN7HchW+bZ7wnxGBhc+y+3p8+LmI C9OcyyEcT+Z5aFZo2dO4IkfyavEl9cztTSMNTfXZzuztcG2F/cfa4Eice2mb4u7imTNd 9Mog== X-Gm-Message-State: AOAM531aKqe7n9TSGtigZDs/aeKCvvTaSX1hpn0D0qRCXafWsO/B4WMj ig84BqmWeXZeOnfMKXuNoCJBuQ== X-Google-Smtp-Source: ABdhPJxhzWQ+13BW3b7rMAkbC+gsglkVidW/xLtoMpCgPLxkDjpi1/nh8Ncg8X/Gh7aVJ+bLlWGexw== X-Received: by 2002:a05:6214:248a:: with SMTP id gi10mr727781qvb.99.1644261717527; Mon, 07 Feb 2022 11:21:57 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-113-129.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.129]) by smtp.gmail.com with ESMTPSA id y20sm5819031qta.9.2022.02.07.11.21.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 11:21:56 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1nH9aF-000Hph-TJ; Mon, 07 Feb 2022 15:21:55 -0400 Date: Mon, 7 Feb 2022 15:21:55 -0400 From: Jason Gunthorpe To: Christoph Hellwig Cc: Andrew Morton , Dan Williams , Felix Kuehling , Alex Deucher , Christian =?utf-8?B?S8O2bmln?= , "Pan, Xinhui" , Ben Skeggs , Karol Herbst , Lyude Paul , 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: Re: [PATCH 7/8] mm: remove the extra ZONE_DEVICE struct page refcount Message-ID: <20220207192155.GB49147@ziepe.ca> References: <20220207063249.1833066-1-hch@lst.de> <20220207063249.1833066-8-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220207063249.1833066-8-hch@lst.de> Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b=OaiSuWRo; spf=pass (imf26.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.219.48 as permitted sender) smtp.mailfrom=jgg@ziepe.ca; dmarc=none X-Rspam-User: nil X-Rspamd-Queue-Id: 308C6140006 X-Stat-Signature: wspagsyawd96z4zztze3jn5d5gxamfci X-Rspamd-Server: rspam12 X-HE-Tag: 1644261718-851779 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: On Mon, Feb 07, 2022 at 07:32:48AM +0100, Christoph Hellwig wrote: > ZONE_DEVICE struct pages have an extra reference count that complicates > the code for put_page() and several places in the kernel that need to > check the reference count to see that a page is not being used (gup, > compaction, migration, etc.). Clean up the code so the reference count > doesn't need to be treated specially for ZONE_DEVICE pages. > > Note that this excludes the special idle page wakeup for fsdax pages, > which still happens at refcount 1. This is a separate issue and will > be sorted out later. Given that only fsdax pages require the > notifiacation when the refcount hits 1 now, the PAGEMAP_OPS Kconfig > symbol can go away and be replaced with a FS_DAX check for this hook > in the put_page fastpath. > > Based on an earlier patch from Ralph Campbell . > > Signed-off-by: Christoph Hellwig > --- > arch/powerpc/kvm/book3s_hv_uvmem.c | 1 - > drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 1 - > drivers/gpu/drm/nouveau/nouveau_dmem.c | 1 - > fs/Kconfig | 1 - > include/linux/memremap.h | 12 +++-- > include/linux/mm.h | 6 +-- > lib/test_hmm.c | 1 - > mm/Kconfig | 4 -- > mm/internal.h | 2 + > mm/memcontrol.c | 11 ++--- > mm/memremap.c | 57 ++++++++---------------- > mm/migrate.c | 6 --- > mm/swap.c | 16 ++----- > 13 files changed, 36 insertions(+), 83 deletions(-) It looks like a good next step to me Reviewed-by: Jason Gunthorpe > struct dev_pagemap_ops { > /* > - * Called once the page refcount reaches 1. (ZONE_DEVICE pages never > - * reach 0 refcount unless there is a refcount bug. This allows the > - * device driver to implement its own memory management.) > + * Called once the page refcount reaches 0. The reference count will be > + * reset to one by the core code after the method is called to prepare > + * for handing out the page again. I did prefer Ralph's version of this that kept the refcount at 0 while the page was on the free-list. I hope we can get there again after later series :) Jason