Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp110827pxk; Tue, 15 Sep 2020 22:39:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxJRk2p04FQUVBX+vqpUvdLlOrqNO2DIZuw34c/Y9QM5vE2POKv7rv22Pa3Wy69Bfy0ZqN X-Received: by 2002:a17:906:3ad0:: with SMTP id z16mr24636842ejd.193.1600234771637; Tue, 15 Sep 2020 22:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600234771; cv=none; d=google.com; s=arc-20160816; b=nvOOfSOoyEhYyWGc+bfdxbiDPOpD7+2gU3CAzYO5DC7PPrlljN7oHjp+UzLhDTtH/E YclnHfTAVH4BX//8Di7TLM7InGAhZYewHu1/2DxSnc9DG7PZ9Xqm3pF4OFbhDtnH4sPh aLAfjrDNY/wkH7aKxvaaU4HUtbbXVkLSRSj8jtmxggx1EmyJtMlh5O5P5KXFQ07RRu2G nJr0rUKiQKy9Tryf+ei9LGPIPyUxNyYjIA36lcbm/yzNwvobsWElOcq8PnhccEj62IZr k+borE6hP+g5tu/j8tEHk4SUaCwZxAFZMydYEeZHIkfrsq6sPY3Amee1cR7E1OqxZIrN wyfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=GDvm9u954DmGGF+lgdvlVminz5H8m8ChKm4XCdk25+c=; b=Y6JPvrmGHUErLxvNUKlOkaBKHnZtTDGHenCf2T8k3qVoHTmkSrBAT04acNtIPDcvdO 9lUREZHbRx+jUs7PM2N6wKGpAY28F+l1GUyitjyEB0NL9LSOu5alHjXBYUjX2GGXPOhJ GFM16X6y571WWkfGXFyt+7BxyyUywg0L0F2FwC5bMiwyaWYabtsNNh8z3yNtVtx5QAh8 gZBj3gpDZF0yJPQt05X5ZMoj+Fg9438/MKt8FoUMFKDEvx/8joTmC31ZE8PNH4D0xN3L z8UPGJf1GRp316gDIhD69DOghFwCoada4yYGOe4CssrUzzqFN2k611ImBWRJqQwG/ktf s0VQ== ARC-Authentication-Results: i=1; mx.google.com; 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 c10si11614797edn.316.2020.09.15.22.39.08; Tue, 15 Sep 2020 22:39:31 -0700 (PDT) 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; 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 S1726178AbgIPFhB (ORCPT + 99 others); Wed, 16 Sep 2020 01:37:01 -0400 Received: from verein.lst.de ([213.95.11.211]:50829 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726068AbgIPFhB (ORCPT ); Wed, 16 Sep 2020 01:37:01 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 4C02568BFE; Wed, 16 Sep 2020 07:36:54 +0200 (CEST) Date: Wed, 16 Sep 2020 07:36:53 +0200 From: Christoph Hellwig To: Ralph Campbell Cc: Christoph Hellwig , Dan Williams , Linux MM , kvm-ppc@vger.kernel.org, nouveau@lists.freedesktop.org, Linux Kernel Mailing List , Ira Weiny , Matthew Wilcox , Jerome Glisse , John Hubbard , Alistair Popple , Christoph Hellwig , Jason Gunthorpe , Bharata B Rao , Zi Yan , "Kirill A . Shutemov" , Yang Shi , Paul Mackerras , Ben Skeggs , Andrew Morton Subject: Re: [PATCH] mm: remove extra ZONE_DEVICE struct page refcount Message-ID: <20200916053653.GA7321@lst.de> References: <20200914224509.17699-1-rcampbell@nvidia.com> <10b4b85c-f1e9-b6b5-74cd-6190ee0aca5d@nvidia.com> <20200915162956.GA21990@infradead.org> <6dff5231-26d5-1aec-0c05-6880cf747642@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6dff5231-26d5-1aec-0c05-6880cf747642@nvidia.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 15, 2020 at 09:39:47AM -0700, Ralph Campbell wrote: >> I don't think any of the three ->page_free instances even cares about >> the page refcount. >> > Not true. The page_free() callback records the page is free by setting > a bit or putting the page on a free list but when it allocates a free > device private struct page to be used with migrate_vma_setup(), it needs to > increment the refcount. > > For the ZONE_DEVICE MEMORY_DEVICE_GENERIC and MEMORY_DEVICE_PCI_P2PDMA > struct pages, I think you are correct because they don't define page_free() > and from what I can see, don't decrement the page refcount to zero. Umm, the whole point of ZONE_DEVICE is to have a struct page for something that is not system memory. For both the ppc kvm case (magic hypervisor pool) and Noveau (device internal) memory that clear is the case. But looks like test_hmm uses normal pages to fake this up, so I was wrong about the third caller. But I think we can just call set_page_count just before freeing the page there with a comment explaining what is goin on.