Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp17530pxk; Wed, 16 Sep 2020 17:36:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxieKUtXQ+61Xe7tqWyIVeSk1GPA9ffeRh8kCVDz3uLJm/c/kcRyFct/vjacg6Wh9WkfAHr X-Received: by 2002:a17:906:24d6:: with SMTP id f22mr27506504ejb.85.1600302998739; Wed, 16 Sep 2020 17:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600302998; cv=none; d=google.com; s=arc-20160816; b=n6McY3EyqqQiDmFkOgqTw2r6iAlP9Koo6+CtwOicHotd8W/DlLf0EflIkaXOLvmcpd ODsTOm6HQfgQmY+23rD3GLQI/3vfyLhzjXu4rWKP7mKwJcS/wiSgWAA7IRsOK/TXOdUJ ee+6yWd5WKMiLgfA+fNyUtO5EN4qJ5D+q3yroVH5S4R4xvCYKtO9GP/wnyjCFchPc9Nt ffvfyWOtPz2PaqH9DrZ9gEtBCzktMOzQ6+4azOiQuc0eKILn0nC099VaFXAF+PjZFOWE 1m1kynSylwlK2N2oUCc4KknGornc7NeN3EU3HA0xBWDOu2JIkfWeOk2iZ8/0i6GFDehD paVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=1i3pq4DrsfAWDVtR8cFn1IB1tfsEr058q9gpy2HuS9Q=; b=Psu8vkFKnVxwB5aZdzLP+yGK+BWGdefid++ck+tOMb5NZ9OIdDGx6Lbu6eKVhdt0ZI zXTDWDxx58vpWabdRoPo/9oDlnxVQdsWT/xKpyAspSlrhJsMpxF4PIly2L32dlsnU9XN UMMFIkLfDDoVmIYkC2NQgMkNcowrfpoidhA40fxt0BvWSrFoGycNVWfVgRSX/VTAWA2H ojKU6lKXNN8EWQdqCt2ew28tte+qutGPZO3+brL3uOI1JBmXOXKGcA7HlCC51vIsv94I tmQp72FMC159M0/8Q4iJkLhZm5/x2YAfUxnRfBJCb/3qx6pns406iTXaueju94OuuZbH BDLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=caAwSctd; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ha1si12992597ejb.406.2020.09.16.17.35.51; Wed, 16 Sep 2020 17:36:38 -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; dkim=pass header.i=@nvidia.com header.s=n1 header.b=caAwSctd; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726098AbgIQAej (ORCPT + 99 others); Wed, 16 Sep 2020 20:34:39 -0400 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:3835 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726007AbgIQAei (ORCPT ); Wed, 16 Sep 2020 20:34:38 -0400 X-Greylist: delayed 300 seconds by postgrey-1.27 at vger.kernel.org; Wed, 16 Sep 2020 20:34:38 EDT Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 16 Sep 2020 17:29:24 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 16 Sep 2020 17:29:37 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 16 Sep 2020 17:29:37 -0700 Received: from rcampbell-dev.nvidia.com (172.20.13.39) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 17 Sep 2020 00:29:35 +0000 Subject: Re: [PATCH] mm: remove extra ZONE_DEVICE struct page refcount To: Christoph Hellwig CC: Christoph Hellwig , Dan Williams , Linux MM , , , "Linux Kernel Mailing List" , Ira Weiny , Matthew Wilcox , Jerome Glisse , John Hubbard , Alistair Popple , Jason Gunthorpe , Bharata B Rao , Zi Yan , "Kirill A . Shutemov" , Yang Shi , Paul Mackerras , Ben Skeggs , "Andrew Morton" 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> <20200916053653.GA7321@lst.de> From: Ralph Campbell Message-ID: Date: Wed, 16 Sep 2020 17:29:35 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20200916053653.GA7321@lst.de> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1600302564; bh=1i3pq4DrsfAWDVtR8cFn1IB1tfsEr058q9gpy2HuS9Q=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=caAwSctdzbWEenNN1UGAJD9cndTHHMtPdIvHnfYyy9NCs4UYoesgLmsKAX4pplK+S jHX0wsG3bOReVssA5a6DPV6yEId91gR1f43cs1k+jXF11gfHrHlWmkBzK1HDnboHTj 0X02RdTOqyy2psmjgcVknwVliDeAKXIc35Kvs9PkBNgRnanLccOaSYkxgcz32kxeZQ 8gMhUoRj7cjyV5fYtImJdKvIF1Xva6DsQVBRHg47x8mBnFiVeLGoFjF0Wt502JwWOW 5B1HVD/KTNyqCQvzslx2owOZ+33Veswqt8/NCmz2inGyrgvGOoRZiZWv3ZoJ0chyXh i9TR2Pn+gH8gw== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/15/20 10:36 PM, Christoph Hellwig wrote: > 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. Dan Williams thought that having the ZONE_DEVICE struct pages be on a free list with a refcount of one was a bit strange and that the driver should handle the zero to one transition. But, that would mean a bit more invasive change to the 3 drivers to set the reference count to zero after calling memremap_pages() and setting the reference count to one when allocating a struct page. What you are suggesting is what I also proposed in v1.