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=-3.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 2795AC433E2 for ; Thu, 17 Sep 2020 00:33:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7D9BA221EF for ; Thu, 17 Sep 2020 00:32:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b="Nyn3bRg6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D9BA221EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C6F306B005D; Wed, 16 Sep 2020 20:32:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C1FCA6B0062; Wed, 16 Sep 2020 20:32:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B361E900006; Wed, 16 Sep 2020 20:32:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0032.hostedemail.com [216.40.44.32]) by kanga.kvack.org (Postfix) with ESMTP id 9B57F6B005D for ; Wed, 16 Sep 2020 20:32:58 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 55F7C246E for ; Thu, 17 Sep 2020 00:32:58 +0000 (UTC) X-FDA: 77270678436.21.toys93_4410f7e2711e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 275D6180442EB for ; Thu, 17 Sep 2020 00:32:58 +0000 (UTC) X-HE-Tag: toys93_4410f7e2711e X-Filterd-Recvd-Size: 5474 Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com [209.85.218.68]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Thu, 17 Sep 2020 00:32:56 +0000 (UTC) Received: by mail-ej1-f68.google.com with SMTP id u21so736400eja.2 for ; Wed, 16 Sep 2020 17:32:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7Mv7tExlpUblwPxLiVpXmkZ8FmM1lPrmg1IaKwA589A=; b=Nyn3bRg6PHcnF7IuwL/gRVkBgDaad/CL/2NSJZ0OutWVN+rLpFcTmjBIwmdnvS7L1f KpcGPsPoNcqBSERqX6KNUU2oY3DDWJAysYSBs/+GNwOWa7iO3mu2Cuu1tL3HZGhiiF7U aDeRTy4URUfTy8YCLNz26Og1BmAZVMoBYFFlFlpyirDo1mox6qHLIwmStC0FIZiiwbwR HQFYKUdlVDk2Z43AObV/K7iA21j7phnPbKo9hBoswiWiZuzKOUASgRCeBAq3FpkpdePv tAixWxs/DLtrXqENpjRjy3BuinknZ/U9iFZz5rjVlc+VGP1yqGG7+c/XpXyX3YmsMzRy w6QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7Mv7tExlpUblwPxLiVpXmkZ8FmM1lPrmg1IaKwA589A=; b=D8Dfl+PWDggVG1AbHSykK69HMyclLYyXgiLsEMrniwKDx1MM+PpimCRwYqiV8HqkoX /f0YnrBZCFqN1JfrtwvevcP1SkYOaQ6EAYDzn/MwTVLEQV3Qfhmc4ndtbC3T/muSrNlL 9jsqPaiE+pT+pJ7NQ0bywStOsBhohjgn4bSMvCiFSY6Z1RXORe5fW4kNYzf52efoZNCL KzUFDg6zdOJR1oKW+6TwmDegE/wyd/KdcnYzU3HtBmSz8jDcUEnnhjOvObCua0kkNRQX O/JcHgOiGJhjU2X5oAnESd+I1QWlqWmLu+24BaSUKj0RVwbFBZGOjTLlBvdT0SyXz72h RUOw== X-Gm-Message-State: AOAM532lifMsO76BBqHi2x/XVXZip+IV8sChebvUFDZz5EM0tQNJiYW9 DEKxN5cv4cBkt4kP077DXsFV9g3nV+rlOLX/PxNHig== X-Google-Smtp-Source: ABdhPJy/lCk/syWt2cUyaBBnBYt0rGos8cgelGTbE0LkeTPJKrWQ68aUyhQaP5VfsnlhpQpt3kFMUBVG5Q3xTQrQUd0= X-Received: by 2002:a17:906:8143:: with SMTP id z3mr27697015ejw.323.1600302775371; Wed, 16 Sep 2020 17:32:55 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: Dan Williams Date: Wed, 16 Sep 2020 17:32:43 -0700 Message-ID: Subject: Re: [PATCH] mm: remove extra ZONE_DEVICE struct page refcount To: Ralph Campbell Cc: Christoph Hellwig , Christoph Hellwig , 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 , Jason Gunthorpe , Bharata B Rao , Zi Yan , "Kirill A . Shutemov" , Yang Shi , Paul Mackerras , Ben Skeggs , Andrew Morton Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 275D6180442EB X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 Wed, Sep 16, 2020 at 5:29 PM Ralph Campbell wrote: > > > 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. IIUC, isn't what Christoph recommending is that drivers handle set_page_count() directly rather than the core since some are prepared for it to be zero on entry?