From patchwork Thu Jun 13 09:43:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991439 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BEBAF76 for ; Thu, 13 Jun 2019 09:43:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABE3628B11 for ; Thu, 13 Jun 2019 09:43:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F90A28B15; Thu, 13 Jun 2019 09:43:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A13228B1B for ; Thu, 13 Jun 2019 09:43:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 813F86B0005; Thu, 13 Jun 2019 05:43:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7C6166B0006; Thu, 13 Jun 2019 05:43:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 665FD6B0007; Thu, 13 Jun 2019 05:43:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 33E346B0005 for ; Thu, 13 Jun 2019 05:43:38 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id 145so14078503pfv.18 for ; Thu, 13 Jun 2019 02:43:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kaMWV25JLh2oaHk6KDUPHO1aktYAmWaT94i0RYQYzUw=; b=uWqjbscCu0rtf7JCR3ePpCSVtC6rMSxefKz4/6r2ZGVjDJscYmANDJ4rJOrKlmZqdm XE2RgaWqR0PwUXdyvDyN8nF7EGOx6OsTGrIESKDB22whZD2qlfwKbTtZzmwTWg5TmUvb HB2PUSeZ65KCi46i4X9wLC9cN6qTHG6jG0XCA/JHIDlgFugoq9GsQCHdjoXtDP0qUjEK GBlztPgpLC79h3jpQCb3oNd/7x63PTn3WMOo4WU19yTPiAEPoTgVmIKHP+Nk99SAx3nK UVAIuDBD/CLsGaBXldlGUUnQ+7PAdNVIYV09bEhp/tZSaE/HsAosUh6/zRRxjcLRRH+E /AfA== X-Gm-Message-State: APjAAAVDqfkQoK16xEENkqCUiY4y8MeVdN30TYSByyferOvDJgi6zUYJ cNTNsWQeK2IYeyBAJOMQdHmVm5tE1AwC9CkBgHlRz19OgPQ95WAtDKwKmN6NULEB0fkq+mhJLd3 CvECODlpLET8gmGxGl0TfYkQk7QbAo4Plv4qS+Si+GJFx4XgAIwKJHcVIKe26CO8= X-Received: by 2002:a65:624f:: with SMTP id q15mr29518977pgv.436.1560419017772; Thu, 13 Jun 2019 02:43:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVhf+yBHALIj8vG5Tpjhi06GGlRVpl+cdCg8yXqMBL5bU5/3N7nRhPjoPc2RRp9yrxvN0a X-Received: by 2002:a65:624f:: with SMTP id q15mr29518871pgv.436.1560419016683; Thu, 13 Jun 2019 02:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419016; cv=none; d=google.com; s=arc-20160816; b=jq31rAn4uSoP65Zff3hsaRBSgo9vhfxP929+VM0HaoBB+sEef7S+dcEPTXPTEvNi+I AbZGYzE6ieXtMeStp9pi5yChLuK+fpDOmZhFhd5vSc0whB1Qc+NcDxqGInYvZDHNkJhB Px/QpsdFRm4LLF/fYibC8F+7mWF4mitiPzP+KHdEqwqja10Y0d58rTQjHJ3aTKbP/ypY HVxMrc2mAfKtYwsu1VbP1Ogk1MoNj84v55z4uYErM1dpXewSZlEuSk7+Z7yLDQGtXtrX Wd79ahB16GSarCFu9Gq5GU3w0w/j1PQgCqR2kMGbeg9KRsWWxW75O9tggFBBcfZ59xZi pwiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=kaMWV25JLh2oaHk6KDUPHO1aktYAmWaT94i0RYQYzUw=; b=dLUIgC6Q7ex9b927ZG+F3S3ju0kMOsR3T6aqa6kjFCFIpjTL+/GVBqd3yxEFJQVqZZ J5pg9WPFYKz/sgGdmKoUMVsdrGJrlg7BB6s3YKo2LdNID95mjG1kNtnxlkt/nMSPMUwX 7m0+iM+e1bZOBh2fv+/d8Gtj+1iMcjeH8YSDAIiFR4L1R8DmjhkAq3OK75dJCpcXyRBU pwEDc3TJWJPLvDqOdQsbhxd3LVPJ7+BMnRXpK9Tyt/nC+a/qaWH6KBS3RQqnvN9jbNt2 jR4UD2aQ0WujAbFE7CfYfl3qT2295Bl/jXuqxFUGTG9CKZXm4HAqBSXlZYqmTDRSKZHN YNlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=SIOUKYPA; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id c8si2627276pje.30.2019.06.13.02.43.36 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:43:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=SIOUKYPA; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kaMWV25JLh2oaHk6KDUPHO1aktYAmWaT94i0RYQYzUw=; b=SIOUKYPAoDNdv7dWJhGfW0ob9k SLpR4leODIPqaX5ZslP+W4SJcJ9U7DECzPF7id4CLr1TIXVk0TrdeRnB2mSBfkwHV0BwXM9hz+pAg MRIkDGTi/GEKbHR7IahvnzYVCFrGOql4J+HQbbAxBYnBDBvqLJf14fWFUzQPYx6sWG+RncvSxlFHs UVuWutw1NZcBceRsSHnUv96ep8AN6pJSCjApiFhahvIwVDcAXbo2avAu2oiRkulO4cM29bofUBPE/ aJ6WgM8we7zOD5oK498LUnb7YTFkOzfiKswyBFy1ZCZiC3yGAwDX1/fPAToXlZJ0IO1qvMnAWyaKu nuFh1UuA==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMGa-0001jn-7o; Thu, 13 Jun 2019 09:43:32 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/22] mm: remove the unused ARCH_HAS_HMM_DEVICE Kconfig option Date: Thu, 13 Jun 2019 11:43:04 +0200 Message-Id: <20190613094326.24093-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe --- mm/Kconfig | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index f0c76ba47695..0d2ba7e1f43e 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -675,16 +675,6 @@ config ARCH_HAS_HMM_MIRROR depends on (X86_64 || PPC64) depends on MMU && 64BIT -config ARCH_HAS_HMM_DEVICE - bool - default y - depends on (X86_64 || PPC64) - depends on MEMORY_HOTPLUG - depends on MEMORY_HOTREMOVE - depends on SPARSEMEM_VMEMMAP - depends on ARCH_HAS_ZONE_DEVICE - select XARRAY_MULTI - config ARCH_HAS_HMM bool default y From patchwork Thu Jun 13 09:43:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35D9976 for ; Thu, 13 Jun 2019 09:43:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 209F328B11 for ; Thu, 13 Jun 2019 09:43:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14AB928B1B; Thu, 13 Jun 2019 09:43:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8981E28B11 for ; Thu, 13 Jun 2019 09:43:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E08F66B0006; Thu, 13 Jun 2019 05:43:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D1D066B0007; Thu, 13 Jun 2019 05:43:39 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B21006B000A; Thu, 13 Jun 2019 05:43:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 7E7886B0006 for ; Thu, 13 Jun 2019 05:43:39 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id s4so8648693pgr.3 for ; Thu, 13 Jun 2019 02:43:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=EySscp3yKN+jDnjqTeB/vXgNBmJu+8rQ8w0cniT2gLU=; b=OJm9/ZVrt9+mExfi0Buzgte6HdYYyWqNJ3jYC0jd7vZoNkoN1R7L/dHGupap4OnsbL esOHWyjl8thUiFSp9eYrfD8GUCPSopzlztl+hfFGG48j56h3qmYIcshGeoxtLO5Brivn WyyvgDOTnsHEmKu8mh9GZyKWrDBsaBTbOfg+FXkCOogBx0NB2dtt/80HkuTQb75CuZvD od+keT3OiOdXzh+UweFFN4S6IPdFxLh5fQyANE/sFFDYbYiiXt85XByfiGazySMCuLl+ bcNWXYDKVEt0uA9MLL3hNu8Ci63OOieBkTxJzXMkJl6M+yZDDiYTS34FxQzMWSqlFE0Y TrZw== X-Gm-Message-State: APjAAAW86W19ezFFNQGFjTrgs066iR3fryWVUNsKvAoNbVBXFr6P7FmU 0cxxRq1aTTfoy6fJq8zLIUp4XdtsxnN8bTF3XV204iCJkET7bm/o0KifKLCRLk6OjQO2U07a6Vq 5+dfKyLg6NVUKPRD7mwTVY5rQjAAjWTc+IPrEw+tpQd9nQeldJsmZg7DM7BlHUr4= X-Received: by 2002:a17:90a:bb01:: with SMTP id u1mr3400554pjr.92.1560419019120; Thu, 13 Jun 2019 02:43:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLyRlemFFktmGBgyWxpTIuwHlZC1u8gGjgh03/jZVukHCGAmuNW1llIBcSMV31euEQQwX0 X-Received: by 2002:a17:90a:bb01:: with SMTP id u1mr3400453pjr.92.1560419018215; Thu, 13 Jun 2019 02:43:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419018; cv=none; d=google.com; s=arc-20160816; b=kfV2TwUALLKs6ml6qHluEq1dYrTLSPOFKHQkclWTBZ7lLWuCeabaBNN6Tm7nJi5PzB JLD8fdMoVgxN9G0AGlYSZ6q8g/oTpKP7UOjLS2c6i4Lk5f+jqiK1qi/DnPsRHZZYiT8v yIGm4uQaMEel+Grqlc/P44fsyoY4Gu5hyTLxZ8UmnYmWoRHjnqZcoM1KyKgeheSdsHS/ 90O96DzQAprVePcQlVSaqU5tl1b4cdZELjj/SHDp7Iku2D9mb6rhgY9xMrBWKXeiTTXu MvtNebgEyfyoPoyzLxgGUM01K/GMSLlq8lM8K55iYoSBiZdcAb60+Eq9oxjbRzWopwJb 8KFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=EySscp3yKN+jDnjqTeB/vXgNBmJu+8rQ8w0cniT2gLU=; b=RfGna9iO4iPxkS7NGcUCGIAN14wtyY2BI7oGGd0TdEkb8Uv+hd7IY1X3CcnqxnL3Hy zJfkD2ShpZXMgPSazOW2usmhdBpZ7Y8F/s3gvUtn1Eih14RPRvplWhZg0i2Dg143pfmE zD0GzeW1qBsMEiJ2OtLEuh7RINjCi7pFG4y7uq3DCWpXvSdmUzMCoYKVCphsmiNN52PU KzElwlM1uN9fEREt2VtnnOo0Vp9EYmDtAIT1Peo9Dj/wtv53Iyr+PVsVUYV14aucbjqU /huUWnf0wTi9vOY5JzDXDKAuE9VoxxacJHGw5XOzYHV7At7Jc4njMt+Bd5/TneoHjdTq q3bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b="hN3Tg/pf"; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 64si225458ply.399.2019.06.13.02.43.38 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:43:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b="hN3Tg/pf"; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EySscp3yKN+jDnjqTeB/vXgNBmJu+8rQ8w0cniT2gLU=; b=hN3Tg/pfc+DF3o2cE7RN16eAtU DSJVtP39I0bEcArETT1vSti3Crp6Qi6ZMUwozDmHcDkQP6AOPVOaSSisOOKmzApBa5KRd3Fc1dp2r g2XyhbubQhZWdnpR3yZQ12YlHZkEEwfLnzPENVeG2YNLsIJ43CAeQQvZPRB+G30UAOvUcGpwczkNe mnogyEbipMza1tYUKcfQqaQG3/M5pHI887fdLfo7flgv0cPauHj9XEiy7UM73W0JlaNeb622kfoPX R8Nu1l/kCfDiGUY+PLUbgk+PMfKovQLWD4DYNK3g20GKfH1m6doMiSXTnDatQF7W8R9hsse0hbDbU TtnGqz2Q==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMGd-0001kC-6s; Thu, 13 Jun 2019 09:43:35 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/22] mm: remove the struct hmm_device infrastructure Date: Thu, 13 Jun 2019 11:43:05 +0200 Message-Id: <20190613094326.24093-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP This code is a trivial wrapper around device model helpers, which should have been integrated into the driver device model usage from the start. Assuming it actually had users, which it never had since the code was added more than 1 1/2 years ago. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Reviewed-by: John Hubbard --- include/linux/hmm.h | 20 ------------ mm/hmm.c | 80 --------------------------------------------- 2 files changed, 100 deletions(-) diff --git a/include/linux/hmm.h b/include/linux/hmm.h index 0fa8ea34ccef..4867b9da1b6c 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -717,26 +717,6 @@ static inline unsigned long hmm_devmem_page_get_drvdata(const struct page *page) { return page->hmm_data; } - - -/* - * struct hmm_device - fake device to hang device memory onto - * - * @device: device struct - * @minor: device minor number - */ -struct hmm_device { - struct device device; - unsigned int minor; -}; - -/* - * A device driver that wants to handle multiple devices memory through a - * single fake device can use hmm_device to do so. This is purely a helper and - * it is not strictly needed, in order to make use of any HMM functionality. - */ -struct hmm_device *hmm_device_new(void *drvdata); -void hmm_device_put(struct hmm_device *hmm_device); #endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */ #else /* IS_ENABLED(CONFIG_HMM) */ static inline void hmm_mm_destroy(struct mm_struct *mm) {} diff --git a/mm/hmm.c b/mm/hmm.c index 886b18695b97..ff2598eb7377 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -1499,84 +1499,4 @@ struct hmm_devmem *hmm_devmem_add_resource(const struct hmm_devmem_ops *ops, return devmem; } EXPORT_SYMBOL_GPL(hmm_devmem_add_resource); - -/* - * A device driver that wants to handle multiple devices memory through a - * single fake device can use hmm_device to do so. This is purely a helper - * and it is not needed to make use of any HMM functionality. - */ -#define HMM_DEVICE_MAX 256 - -static DECLARE_BITMAP(hmm_device_mask, HMM_DEVICE_MAX); -static DEFINE_SPINLOCK(hmm_device_lock); -static struct class *hmm_device_class; -static dev_t hmm_device_devt; - -static void hmm_device_release(struct device *device) -{ - struct hmm_device *hmm_device; - - hmm_device = container_of(device, struct hmm_device, device); - spin_lock(&hmm_device_lock); - clear_bit(hmm_device->minor, hmm_device_mask); - spin_unlock(&hmm_device_lock); - - kfree(hmm_device); -} - -struct hmm_device *hmm_device_new(void *drvdata) -{ - struct hmm_device *hmm_device; - - hmm_device = kzalloc(sizeof(*hmm_device), GFP_KERNEL); - if (!hmm_device) - return ERR_PTR(-ENOMEM); - - spin_lock(&hmm_device_lock); - hmm_device->minor = find_first_zero_bit(hmm_device_mask, HMM_DEVICE_MAX); - if (hmm_device->minor >= HMM_DEVICE_MAX) { - spin_unlock(&hmm_device_lock); - kfree(hmm_device); - return ERR_PTR(-EBUSY); - } - set_bit(hmm_device->minor, hmm_device_mask); - spin_unlock(&hmm_device_lock); - - dev_set_name(&hmm_device->device, "hmm_device%d", hmm_device->minor); - hmm_device->device.devt = MKDEV(MAJOR(hmm_device_devt), - hmm_device->minor); - hmm_device->device.release = hmm_device_release; - dev_set_drvdata(&hmm_device->device, drvdata); - hmm_device->device.class = hmm_device_class; - device_initialize(&hmm_device->device); - - return hmm_device; -} -EXPORT_SYMBOL(hmm_device_new); - -void hmm_device_put(struct hmm_device *hmm_device) -{ - put_device(&hmm_device->device); -} -EXPORT_SYMBOL(hmm_device_put); - -static int __init hmm_init(void) -{ - int ret; - - ret = alloc_chrdev_region(&hmm_device_devt, 0, - HMM_DEVICE_MAX, - "hmm_device"); - if (ret) - return ret; - - hmm_device_class = class_create(THIS_MODULE, "hmm_device"); - if (IS_ERR(hmm_device_class)) { - unregister_chrdev_region(hmm_device_devt, HMM_DEVICE_MAX); - return PTR_ERR(hmm_device_class); - } - return 0; -} - -device_initcall(hmm_init); #endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */ From patchwork Thu Jun 13 09:43:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE97A14DB for ; Thu, 13 Jun 2019 09:43:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 999AA28B11 for ; Thu, 13 Jun 2019 09:43:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DA4F28B15; Thu, 13 Jun 2019 09:43:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AC7428B17 for ; Thu, 13 Jun 2019 09:43:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF9186B0007; Thu, 13 Jun 2019 05:43:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C80026B000A; Thu, 13 Jun 2019 05:43:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AAACE6B000C; Thu, 13 Jun 2019 05:43:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 787BA6B0007 for ; Thu, 13 Jun 2019 05:43:42 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id j26so13472533pgj.6 for ; Thu, 13 Jun 2019 02:43:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xP52k8PSxiWJA231A7iOWwtNJf1wPwc/yjXMJD2RBtk=; b=kIG0BZkx/cFTvKGpCtvMRJ1uxpTc2Z3bSMk9L0GLwR3jmv73uGICE36b6l/bY1E4aH AylkPYgn6dO+Hy1U84dtzgzHtrhDKU2bOejDoy0h6CvTWxUOVGFs5rGYAu0EVuuVbybZ whmox61ijr1NbsQMgEzOT5SiJOP/dl5Bq15krgYJzh3W+FJwfjNJgi4k5wAMKLUprfcD cYZ93MD8vDG71ajFX8+7t3V7GBO28D6G25y5ukNQfprbkRtHgt6OxoGlXaJA5gDX+Ljh ui9UGUfjC0bsDChopgVlrJqrzQwC1x7PvJunmJwQQ6ZMy64Vo875Hx7VUA8AmdBDDkiY +xFw== X-Gm-Message-State: APjAAAVO1t6hr40eAad+X0zcLDf48aUYrmxXmgj/UBkqQu/y9E82bLqM W2wvCYb4XhnWTnb7B+Z9WE53Ht0YQeP+VPoyMn3ddi374NGgDjJwF/ChqAhP5SqI2tV3h2mKIK2 Mk4/2QeMmQVppoE1a7DN8213tOWbvS1yIEQ9BRi17JvH+2LeF6gVxSMLgJUfWR6o= X-Received: by 2002:a17:90a:1ac5:: with SMTP id p63mr4287371pjp.25.1560419022103; Thu, 13 Jun 2019 02:43:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRj1N0eVFfvsy1phYU+qEbBiqW6EJgxPJr6lv77RlmUU7qsNJrE77qN/qrmgmyDTq37Xn/ X-Received: by 2002:a17:90a:1ac5:: with SMTP id p63mr4287274pjp.25.1560419021267; Thu, 13 Jun 2019 02:43:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419021; cv=none; d=google.com; s=arc-20160816; b=N8Rp263/hPprEOYMj0RS7qrRlRzRb+sTdMLyNBXVFN1G7RoPq2lZSlYoIrSGHq2+46 JbkuczmOTpWmPyh/CSQTCcnT7tXFhgkanLFI8nWRmvlmCe1wpAKzAqZ+ShfyIa+JLUF9 FukNXZQcfjRqxQP2SYUHqxLzO6mjevwDKSAT0GHSNwTA4O5mi3OSDUdMck+pPTOMlmMS 5xsg8dmhr6t3kTjaAr7wF0OOtbeOy1a4izjG3lKmm2usujuiXLKhLQ9s5Z8I3kmzoBQR aDjRT7H8bAn7F64JsZR0qTHe0DeF+PPxmnPuSoflTzs3K87uW1JIyS7b38NW06U8fyOc PaQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=xP52k8PSxiWJA231A7iOWwtNJf1wPwc/yjXMJD2RBtk=; b=E7DYCI4M9/x1UUG8eZ+cTvO0FOdsnMI1bM4Num99OtH2ddKhv5m/HlmkwBGNrsSJSn fQ2M0jgSEwSCN2oM6f94tWCA+irB2SZKz9InksIA9/Q5UaPIlOHW4A2fKeOnilvVHbdR dGyl4LXyyO4yQxfmnSmR00ehJtWua98pJmhqqog/LtN4BomKLL+Q0eWcYNTiont5jmGk 3QhNantwm+gLG+tJkYUu1vbeka0rKpnGWhz4gWIx5+bYt0Qjg1rLVMtqXFjwZTQ2OWJY HhmjFmG6yRz1nwcNKLuNrFITHTagW925NR3Xhq9Ki2XoR21qUq4Lh6xLbqiRlKZ5PzFW wDRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=YfEdLD5C; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id n184si2680587pfn.59.2019.06.13.02.43.40 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:43:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=YfEdLD5C; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xP52k8PSxiWJA231A7iOWwtNJf1wPwc/yjXMJD2RBtk=; b=YfEdLD5CH3U9ysOCwdL2FYmTCm 7+M9qmqGSvaM914U2KnoFaX+n4shPpJhrUd/PvcrkZkqrHimpFDBxMasr7oVEDrDKecmBuTaLZCGM iT/KWUgZgRrB5zdJ/8S6pGh3KqkYgPjzhaOvvfgtZVAUrvCGJ6viIrfd+IFAUOmCbaSXdn3Xqi6dP IyH7Omvq4XCgzsLItQEh8dQn6hfmBqy4TB1udG/rSepK2+eOtVvT3UK4eCYBuVf36OinvPDjaWT7K MXnnYC67WwxGCvY3QR0pM8YGYOMCMRIMWbIz573pF9NwIAyI8Sbpnmm+OJEQEqq7JYkUxrcjdGlkh kmjcQnIg==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMGf-0001kQ-VY; Thu, 13 Jun 2019 09:43:38 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/22] mm: remove hmm_devmem_add_resource Date: Thu, 13 Jun 2019 11:43:06 +0200 Message-Id: <20190613094326.24093-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP This function has never been used since it was first added to the kernel more than a year and a half ago, and if we ever grow a consumer of the MEMORY_DEVICE_PUBLIC infrastructure it can easily use devm_memremap_pages directly now that we've simplified the API for it. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Reviewed-by: John Hubbard Acked-by: Michal Hocko --- include/linux/hmm.h | 3 --- mm/hmm.c | 54 --------------------------------------------- 2 files changed, 57 deletions(-) diff --git a/include/linux/hmm.h b/include/linux/hmm.h index 4867b9da1b6c..5761a39221a6 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -688,9 +688,6 @@ struct hmm_devmem { struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops, struct device *device, unsigned long size); -struct hmm_devmem *hmm_devmem_add_resource(const struct hmm_devmem_ops *ops, - struct device *device, - struct resource *res); /* * hmm_devmem_page_set_drvdata - set per-page driver data field diff --git a/mm/hmm.c b/mm/hmm.c index ff2598eb7377..0c62426d1257 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -1445,58 +1445,4 @@ struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops, return devmem; } EXPORT_SYMBOL_GPL(hmm_devmem_add); - -struct hmm_devmem *hmm_devmem_add_resource(const struct hmm_devmem_ops *ops, - struct device *device, - struct resource *res) -{ - struct hmm_devmem *devmem; - void *result; - int ret; - - if (res->desc != IORES_DESC_DEVICE_PUBLIC_MEMORY) - return ERR_PTR(-EINVAL); - - dev_pagemap_get_ops(); - - devmem = devm_kzalloc(device, sizeof(*devmem), GFP_KERNEL); - if (!devmem) - return ERR_PTR(-ENOMEM); - - init_completion(&devmem->completion); - devmem->pfn_first = -1UL; - devmem->pfn_last = -1UL; - devmem->resource = res; - devmem->device = device; - devmem->ops = ops; - - ret = percpu_ref_init(&devmem->ref, &hmm_devmem_ref_release, - 0, GFP_KERNEL); - if (ret) - return ERR_PTR(ret); - - ret = devm_add_action_or_reset(device, hmm_devmem_ref_exit, - &devmem->ref); - if (ret) - return ERR_PTR(ret); - - devmem->pfn_first = devmem->resource->start >> PAGE_SHIFT; - devmem->pfn_last = devmem->pfn_first + - (resource_size(devmem->resource) >> PAGE_SHIFT); - devmem->page_fault = hmm_devmem_fault; - - devmem->pagemap.type = MEMORY_DEVICE_PUBLIC; - devmem->pagemap.res = *devmem->resource; - devmem->pagemap.page_free = hmm_devmem_free; - devmem->pagemap.altmap_valid = false; - devmem->pagemap.ref = &devmem->ref; - devmem->pagemap.data = devmem; - devmem->pagemap.kill = hmm_devmem_ref_kill; - - result = devm_memremap_pages(devmem->device, &devmem->pagemap); - if (IS_ERR(result)) - return result; - return devmem; -} -EXPORT_SYMBOL_GPL(hmm_devmem_add_resource); #endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */ From patchwork Thu Jun 13 09:43:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5547C76 for ; Thu, 13 Jun 2019 09:43:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4230228B11 for ; Thu, 13 Jun 2019 09:43:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35E7D28B16; Thu, 13 Jun 2019 09:43:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D11FD28B11 for ; Thu, 13 Jun 2019 09:43:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77A4C6B000A; Thu, 13 Jun 2019 05:43:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 729E26B000C; Thu, 13 Jun 2019 05:43:45 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5547C6B000D; Thu, 13 Jun 2019 05:43:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 1DECC6B000A for ; Thu, 13 Jun 2019 05:43:45 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id 145so14078703pfv.18 for ; Thu, 13 Jun 2019 02:43:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=b0eW2dMKelYlLaleRf5bDKha7L0ij82/1V9DJV7UjR4=; b=rmihczVrPdM5XQy+jrHjl/K7UpNNxDgk5QpdmidCVLkEe0OKyR7AFkBppPO6Aff2fX cdSWa92mVTv5sUuRCbeuW72JIWei8TYpAE8Wgo0jFP/jU+S/GuFIIqOfv+Yg3DYfDDvJ D77phtLeHXWmoUAcpQwaA83WyUH0cjnxePJ8jhLrgmTYmjxwxEi/ALfvWlTmubZPeBBi h7g+whHbMA7tdZmXBxWuvS2HvQRn05LNW2Q0p7DznxTWnQpr55/YsmkYeSHk1qy7PVef WoHCtTehUUO1pXJZpNg0419+cmRPM7NkG1z2bPTESckQQcYWocgH5uT4eLMX2Q4rRg2e aGYw== X-Gm-Message-State: APjAAAWsJ5aG9Gpv0+Nk6WjkJ9i2mYNovtZxw79RkN9YjkwNSNPz4wN2 +0uSwLHqShDlWF63YCVmqzZ9y6/STMGSRjISBKWHoyDSzqx6iElp1zNG3e7hb4A2IkShV4Fxbzz rpfpU/AxdMU6O4tf4JVVVjw/sMSVeIH8s4uXK5TwYZ2yhgxSCVtFBINLu4fL+258= X-Received: by 2002:a63:b1d:: with SMTP id 29mr29663069pgl.103.1560419024730; Thu, 13 Jun 2019 02:43:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqycZhiDFWaeYfs2LEdGUGnpbiq/m87gRf+xNgG54MIs0QzA9ATuBQbXaIuDe+m5cNfMhzOy X-Received: by 2002:a63:b1d:: with SMTP id 29mr29662987pgl.103.1560419023919; Thu, 13 Jun 2019 02:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419023; cv=none; d=google.com; s=arc-20160816; b=v65AIzfnBtKZKtF1MybeA15PgBbG6+fOYlsSmxKzND6bihli1u+Gvub3ic5wwP3xP8 VU/HOGWMsrBr3Ezj8i2i0jdm2TmZuoweGnNxeeTZiTyDTySutHHOl6WhOkOFquijsQV0 +j5ExsgGWQElF+jPwy0uoe3NzcAGfnpnoZ4cV2uC3ak77STXf+wYJfV8i1YauQ6wNwBC zNwOXWkeNsIXQQr/iV0WvYlcFaDRj114GRgOKmLOhgDLP085Unij2nWiVeoYDBy/URHX tB6ZjTKEFJBy+a0H5nd46z/YGQXFF3IRu5cmq0MeOGErXJGGQARtZJn/8CkYbrX2OIq6 6x4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=b0eW2dMKelYlLaleRf5bDKha7L0ij82/1V9DJV7UjR4=; b=im3pFPH4rx2qFFqETPsVEp5D2+Pf+G3qg6fkXVeS0u3kBTzSQbZXu4tdwfJu2gcz9c jLkrGzB6QAR6xiVZd14vlp1LynfxHDV5O1K4hP7wTYwJ/5+gwpIGogI8LB5LzJJ+eBIT C6e+bsN3iR7u4ZbmoEm7ECm1gjhTkbE3Yj0uZPOor7tkX7EEzMBpChYo7TGw5pOCwRKM IcJW2UIYtDCi3J0pRfJdAs0W2zD7JkGGIESUESVnLaE+LBBKVwQWMEVWUcyVLxitx2uo oQrrZ1vV/agI2pXm/aPqLsDdQfxT4HJdQjIPhM0vdVtJSe0wVJn9vsSwFwx7HkL4V0zz yc2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=LrHEjG0K; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id q2si2560817pjq.89.2019.06.13.02.43.43 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:43:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=LrHEjG0K; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=b0eW2dMKelYlLaleRf5bDKha7L0ij82/1V9DJV7UjR4=; b=LrHEjG0Kdxjb47axcEbnVJ75Oj CqNf25lmlVLOJfKQkF3m/Ep/P6iJD6MgQry617Z97k4733kia2UZW5iJya7hxNJbAcFnBT8XQs3jc CWcfMFVkye1tAeuYF/JO0acUBeHn7/aMj/pyCQL4Xz4x4RtvNpeoZBzNSKTz/doY+OwHfJZybszCK DxEJpuNXgqckVp+x3E/8EpTeHSGafD299qd+qeRl4D7XeirEUJDqvk16JkpnMnHgojP24ZnE9OVua 8L7QeBf5I1C+3AfNY+yeF9mDvABdV472xMWynVzOzMDJZAQqG1CbAp246zQp9OX7BwYZax0tpQTMs 15lD1mDA==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMGi-0001ki-O6; Thu, 13 Jun 2019 09:43:41 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/22] mm: don't clear ->mapping in hmm_devmem_free Date: Thu, 13 Jun 2019 11:43:07 +0200 Message-Id: <20190613094326.24093-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP ->mapping isn't even used by HMM users, and the field at the same offset in the zone_device part of the union is declared as pad. (Which btw is rather confusing, as DAX uses ->pgmap and ->mapping from two different sides of the union, but DAX doesn't use hmm_devmem_free). Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Reviewed-by: John Hubbard --- mm/hmm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/hmm.c b/mm/hmm.c index 0c62426d1257..e1dc98407e7b 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -1347,8 +1347,6 @@ static void hmm_devmem_free(struct page *page, void *data) { struct hmm_devmem *devmem = data; - page->mapping = NULL; - devmem->ops->free(devmem, page); } From patchwork Thu Jun 13 09:43:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991455 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CABF614DB for ; Thu, 13 Jun 2019 09:43:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6D4028B11 for ; Thu, 13 Jun 2019 09:43:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAF5B28B16; Thu, 13 Jun 2019 09:43:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52C5B28B15 for ; Thu, 13 Jun 2019 09:43:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C10616B000D; Thu, 13 Jun 2019 05:43:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A88E56B000E; Thu, 13 Jun 2019 05:43:47 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83E7B6B0010; Thu, 13 Jun 2019 05:43:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 41F0C6B000D for ; Thu, 13 Jun 2019 05:43:47 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id j21so14098538pff.12 for ; Thu, 13 Jun 2019 02:43:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FEkGt+ty/uGWp0o9n/p7YTGA7bk3QKQR9GKnB3yrWi0=; b=XdwKYWw6TQu2WFLmwZqkJpJ2/nT+RKGuDQj5Vzw+IM/NhsGM8B7t90kYeTb4TGCi2c Cm0RZr97ijYf8cWllmCocHX4qks5QBNFUKkn7yzDb0yj1erCFLmZXTOH8hBH6EzkU/Tq fmE5lfsRdRW+QbRSpyFLFM9+QNhdO9KN4zuWxiOBFdbN56wmFK3++j4SEBLWEBFjje48 JdGnCRR1+L3J/FLm3164UBW3XSc9IwkIN6tqxVomUBWyG3u6Prnwfjhdn2Z3pS0bQjP8 tHXE81ZyZVyB1tliII7uQO0M2Tu6P4wOkiJQ+NG8EMFWd4wyC36ODkJ3N1VLI7MbMf0g ufDQ== X-Gm-Message-State: APjAAAXW1zrQaKNe2vG33HyxTitpjmffNXWGUc4P+RzjrhbpW4FffPmJ jFJSxAV39C5UWPjt5HUVLJ86JXO+IWB+IGCiF4WsKih28OFI4SFFpWfWUyVgNf+GNUgYN5W92xW IwntFQuWbkLne21G6TcOzik98iwPHvL2yRkRUTx1wVgdumXbmpy/t9pCudpQ7RH8= X-Received: by 2002:a17:902:9b81:: with SMTP id y1mr62646796plp.194.1560419026946; Thu, 13 Jun 2019 02:43:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+rdyMeRPLCHteL5Q1CI+wW1V0nnmnyz5EW2QJvmEfuZSHr3aARoObL3Od2xjY7Rw4cwt5 X-Received: by 2002:a17:902:9b81:: with SMTP id y1mr62646722plp.194.1560419026324; Thu, 13 Jun 2019 02:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419026; cv=none; d=google.com; s=arc-20160816; b=TIdPQiBR6DzpXMHvPmF0lll2PBZBUW3Vs6Q2bG4rDGgtIaVH1dkFja2ReGD1j2AyaO wNT439hI+2+rnM3Xex/5hxzxnzD30QqOmldriPGV4QFYAJJFaXmfBV79EfGlu15TfSSn AFSZB22qPYuqOtR3FkB4wj5mW1aI4iUofpkssTUefYR/rUxCW53iSOrpgCxAjO4K8LGw Bk/lvOYTqzXxV7YSsHBAQzeV8SrhEdmHf9JUqMIE6XBuQLuwH4GolAJv7AFFn7h6QYgw pzeC9FxqLVVgFXd7FuxUD0wdA4pnGGd5DY1lL0Ep/sy7xkDP7GCFYQf/o7B3RjV7mHjL c5bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=FEkGt+ty/uGWp0o9n/p7YTGA7bk3QKQR9GKnB3yrWi0=; b=NbzFtNvpnRZHMCnFz63ciqVprEjg+5/c/Y+edvH2ZaoMGtX+FIfyTwHQzq1Lx+RK5M JYoggnyxu77JyIkYD5C9/G838oQIb/HkzwGXcbi0zZ/pzaC2B4SRqFxfBNSbwox6tnWw 29AfJ8IMRdtVt2xyljCo9r+z8jYcqRv2KKByWP7G/KZObrifCZmz2c9nvuReDgmr+buf IZUEB/nVDflJwCPFWVWhAC0ezoWcWGyAXZLqH8e1lJnSJp/3lD0fqSy8rrLqz45LiOfD 5LaUL2M6BpwsYO1cAZSPirG0+tmpcXzm1sq3Lo5ppcLVE8BO5WScvaAz8mbVHGtG72/P STTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=L3WbZ0JS; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id h96si2519259plb.281.2019.06.13.02.43.46 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:43:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=L3WbZ0JS; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FEkGt+ty/uGWp0o9n/p7YTGA7bk3QKQR9GKnB3yrWi0=; b=L3WbZ0JSiDvBXJFsDUCJ02wcbX BVJRpc0UiDSz8hdf9PGCQmrkNO9cC3Ct9Euv83j64Pvqa+bMG7zPftv6Qc47ddagd0apxJ3S9LtxK YL0Gd6JRejUQjbVJguc5cGI104IqQQmLmGxj/QrnU1/8eCRFXHiVtvxgGKwlwToPy+mfQe5RgeuNc 7YyFcHDGYRl8yFp9cwxZhKia1V56GYhuyZqZJ3NB32yZYe7DQM/hr05KkwXqr/uf34lWIk5VMshTf CpMaS4eanmRpQSDsR1G7yDdfQpx78Otwq1ePYvSywGpRHwk4jd2yXAVh0H6em6K2SgA7+4HrNyFnG Se1/PImw==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMGl-0001l6-GH; Thu, 13 Jun 2019 09:43:43 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/22] mm: export alloc_pages_vma Date: Thu, 13 Jun 2019 11:43:08 +0200 Message-Id: <20190613094326.24093-6-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP noveau is currently using this through an odd hmm wrapper, and I plan to switch it to the real thing later in this series. Signed-off-by: Christoph Hellwig Reviewed-by: John Hubbard --- mm/mempolicy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 01600d80ae01..f9023b5fba37 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2098,6 +2098,7 @@ alloc_pages_vma(gfp_t gfp, int order, struct vm_area_struct *vma, out: return page; } +EXPORT_SYMBOL_GPL(alloc_pages_vma); /** * alloc_pages_current - Allocate pages. From patchwork Thu Jun 13 09:43:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4241976 for ; Thu, 13 Jun 2019 09:43:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F63E28B11 for ; Thu, 13 Jun 2019 09:43:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2332128B16; Thu, 13 Jun 2019 09:43:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98A3728B11 for ; Thu, 13 Jun 2019 09:43:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECD7A6B000E; Thu, 13 Jun 2019 05:43:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DE21D6B0010; Thu, 13 Jun 2019 05:43:50 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B730E6B0266; Thu, 13 Jun 2019 05:43:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 705BB6B000E for ; Thu, 13 Jun 2019 05:43:50 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id j26so13472745pgj.6 for ; Thu, 13 Jun 2019 02:43:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=U+naUp6GJ2c/vfJkCwMO0IpliZVzAgQ1geAwtt/0bck=; b=pWs2oiQ8VvYebTpOkS1nCeh30EfRc65w1TpAirZopRuHcOr0BCKDZrcolG9gcko5ex i5GgpVuKCH/9m2smB3DCr3ifqxnCDaDQRx/xRO9/ajGJO29MDPdyrRbIt4+15wxlq9DM MDgPqdUYAyLh5NMqzsmCm8hH/erbP7SA9drGZWmtj0WCyJmg5+q3VHAOaZ+P1ZiKGb5/ YF6hmSU5u+VmZr+JAnjwIEnEAc7g4WiFbLsixYQqBgRwonpZVerLvPVCRPnR9o+20VK+ r1hYRrAVPgJNKUWoaVUlQxevjYSpUID7xfakEZDYx9/nOtMCKfBeYv0qXkGwE1Bew7ZL LkFA== X-Gm-Message-State: APjAAAX1QZgLRytWa9CuRLD/9NA+YUaD2HAOB4//32a56AoPxEx072MK 2HYPs71cWZMohfoUoRbJj7+3OSIe3aGiOkSBnzG2NeTXrueE+IumRk+jbScd7Xp4ZXBKyHvgTRM 2iaQcC7+C16yLSNNHrzt1XZSupk6jesm6YrF+z0nr+lEmFEVb1P6sAe4mhYQcl9w= X-Received: by 2002:a17:902:112c:: with SMTP id d41mr84862002pla.33.1560419030114; Thu, 13 Jun 2019 02:43:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLjnhGgpcjVJuR/9513zF9olHZVP3cA6F0+a6kaBbGaLErXVs5OLucSXr+HAqWxqaNp4XY X-Received: by 2002:a17:902:112c:: with SMTP id d41mr84861915pla.33.1560419029360; Thu, 13 Jun 2019 02:43:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419029; cv=none; d=google.com; s=arc-20160816; b=C0T4sCp1Ukus3qxCQ1EAmpHE9srL0/CeOJ7C9b0JfKBUUBd3pVDt5VLONcJuqjtQ1d gvXpL7W4GH0WwLkOPYJ7yRIbtwpyhp+wAtX3PxsqwlOtec26b+CGE/gLYWHf1H8/JKix HKztxVFhY7HXYlExXZmc0ZEB+2JxfmDbibpQ5qO1sHFeSQw3/sdLQ7NZqoZZ07PJJI5v MMRHbO8GIPh/zqn+ARVmA5ddA+Qn7n0P9srlPcTR5d+fojeOW47flZ8GEeEaYKyFm2fA a8R6IRfe0w9pS3PwezT+2lw2mox/ym+AR2ZrBisK4laG1vrUH3fYy+gMd3kX7xrwHszQ 2JBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=U+naUp6GJ2c/vfJkCwMO0IpliZVzAgQ1geAwtt/0bck=; b=ixPvnUX4uYHgwBoR02m1pE1Id31hyo5nAWgxlZdPTkzvaNXcvBSVtourV/TYgiG5Gw dRjFK2Yk4p7VORRkHfyt9hzgT62R7JoM4SXcWGgA8HqKfVgv5W0P3kwHoFXnfdn02tct DTBDnz8kbIj+Pxt5c1ROwWI9qQ3lpRZHfv3OhqfLabEaFjSt+MnbZ458nFnWwZ5E7No7 mQhcbnDfko8TtpnG9AfFOUIEqRL7jBQAH+e2D8A61l8BovHTWNTs/TdTSLLHI8bblG23 V/bZGlBPfUMOpmgEyagnRXzkP/N05W11Ti99/j0hbpo/tbTyBomvTXhzuN2TnZjEM5QK 1/sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=QwHN3Ivc; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id j59si2483235plb.176.2019.06.13.02.43.49 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:43:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=QwHN3Ivc; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=U+naUp6GJ2c/vfJkCwMO0IpliZVzAgQ1geAwtt/0bck=; b=QwHN3Ivc9/431JjZXwTTSF08rO hXrz9haLO+d9Q3IUHfpmJTWlt7YXy/NmVHDKKTD/S+hOE4Iu0sImh3ze2ah7uPgw3Ei9X4uKveyn/ nsmcYq0LFNlYJpg+2os1UWxfhf/0nIJoqy+Sw+YSOCSsLRjhEfzfdB5pljAfNGKYcC0tMcDPRgbPE fc5wdASA11vbKRHWzIsWFALeW2JqScCVdyapFn6VpyWwynpkuTmK8WBHg8NlvHxlGwpmm3SGTXN+Q yYignYCrY/T0XlMl97q/6sfhwXRxvc26NXzsHK9MeWjhS6x6hjc2xLbTs1LjAwLCYlTdNCmJxrgk4 fOpj7qYg==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMGo-0001lZ-Cj; Thu, 13 Jun 2019 09:43:46 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/22] mm: factor out a devm_request_free_mem_region helper Date: Thu, 13 Jun 2019 11:43:09 +0200 Message-Id: <20190613094326.24093-7-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP Keep the physical address allocation that hmm_add_device does with the rest of the resource code, and allow future reuse of it without the hmm wrapper. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Reviewed-by: John Hubbard --- include/linux/ioport.h | 2 ++ kernel/resource.c | 39 +++++++++++++++++++++++++++++++++++++++ mm/hmm.c | 33 ++++----------------------------- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index da0ebaec25f0..76a33ae3bf6c 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -286,6 +286,8 @@ static inline bool resource_overlaps(struct resource *r1, struct resource *r2) return (r1->start <= r2->end && r1->end >= r2->start); } +struct resource *devm_request_free_mem_region(struct device *dev, + struct resource *base, unsigned long size); #endif /* __ASSEMBLY__ */ #endif /* _LINUX_IOPORT_H */ diff --git a/kernel/resource.c b/kernel/resource.c index 158f04ec1d4f..99c58134ed1c 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -1628,6 +1628,45 @@ void resource_list_free(struct list_head *head) } EXPORT_SYMBOL(resource_list_free); +#ifdef CONFIG_DEVICE_PRIVATE +/** + * devm_request_free_mem_region - find free region for device private memory + * + * @dev: device struct to bind the resource too + * @size: size in bytes of the device memory to add + * @base: resource tree to look in + * + * This function tries to find an empty range of physical address big enough to + * contain the new resource, so that it can later be hotpluged as ZONE_DEVICE + * memory, which in turn allocates struct pages. + */ +struct resource *devm_request_free_mem_region(struct device *dev, + struct resource *base, unsigned long size) +{ + resource_size_t end, addr; + struct resource *res; + + size = ALIGN(size, 1UL << PA_SECTION_SHIFT); + end = min_t(unsigned long, base->end, (1UL << MAX_PHYSMEM_BITS) - 1); + addr = end - size + 1UL; + + for (; addr > size && addr >= base->start; addr -= size) { + if (region_intersects(addr, size, 0, IORES_DESC_NONE) != + REGION_DISJOINT) + continue; + + res = devm_request_mem_region(dev, addr, size, dev_name(dev)); + if (!res) + return ERR_PTR(-ENOMEM); + res->desc = IORES_DESC_DEVICE_PRIVATE_MEMORY; + return res; + } + + return ERR_PTR(-ERANGE); +} +EXPORT_SYMBOL_GPL(devm_request_free_mem_region); +#endif /* CONFIG_DEVICE_PRIVATE */ + static int __init strict_iomem(char *str) { if (strstr(str, "relaxed")) diff --git a/mm/hmm.c b/mm/hmm.c index e1dc98407e7b..13a16faf0a77 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -26,8 +26,6 @@ #include #include -#define PA_SECTION_SIZE (1UL << PA_SECTION_SHIFT) - #if IS_ENABLED(CONFIG_HMM_MIRROR) static const struct mmu_notifier_ops hmm_mmu_notifier_ops; @@ -1372,7 +1370,6 @@ struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops, unsigned long size) { struct hmm_devmem *devmem; - resource_size_t addr; void *result; int ret; @@ -1398,32 +1395,10 @@ struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops, if (ret) return ERR_PTR(ret); - size = ALIGN(size, PA_SECTION_SIZE); - addr = min((unsigned long)iomem_resource.end, - (1UL << MAX_PHYSMEM_BITS) - 1); - addr = addr - size + 1UL; - - /* - * FIXME add a new helper to quickly walk resource tree and find free - * range - * - * FIXME what about ioport_resource resource ? - */ - for (; addr > size && addr >= iomem_resource.start; addr -= size) { - ret = region_intersects(addr, size, 0, IORES_DESC_NONE); - if (ret != REGION_DISJOINT) - continue; - - devmem->resource = devm_request_mem_region(device, addr, size, - dev_name(device)); - if (!devmem->resource) - return ERR_PTR(-ENOMEM); - break; - } - if (!devmem->resource) - return ERR_PTR(-ERANGE); - - devmem->resource->desc = IORES_DESC_DEVICE_PRIVATE_MEMORY; + devmem->resource = devm_request_free_mem_region(device, &iomem_resource, + size); + if (IS_ERR(devmem->resource)) + return ERR_CAST(devmem->resource); devmem->pfn_first = devmem->resource->start >> PAGE_SHIFT; devmem->pfn_last = devmem->pfn_first + (resource_size(devmem->resource) >> PAGE_SHIFT); From patchwork Thu Jun 13 09:43:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68B6213AF for ; Thu, 13 Jun 2019 09:43:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55DC128B11 for ; Thu, 13 Jun 2019 09:43:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A0CA28B17; Thu, 13 Jun 2019 09:43:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52B7428B11 for ; Thu, 13 Jun 2019 09:43:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF6816B0010; Thu, 13 Jun 2019 05:43:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C835C6B0266; Thu, 13 Jun 2019 05:43:54 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A11C06B0269; Thu, 13 Jun 2019 05:43:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 645746B0010 for ; Thu, 13 Jun 2019 05:43:54 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id c3so11609518plr.16 for ; Thu, 13 Jun 2019 02:43:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=TQXVBWfIqlzVbrygyo5vum+QYxG/VVv5jsBwO0qkppA=; b=AZf7NN8akflUMr7xRBZ6VHQ8BzZLODd1y8M5BH6Gxm/OZKxYAytmbapiUUfM5VjKbQ wF9GRANioqiyf4/Xe+uR/+j6P9H+F5JNzhL1o/be7C/IOD6yyE7ud7EjnV53Opq6G1Hy 3HRebP/X6qFTQUI2mynCzWWM/zWJYsZMQt1m1ZM+whHn1oyhWe9rv25FxWJFqcc77322 av8fLBOFNhxROJRVJ+AolAgBmPYccRE0LH9KKXzIk6NP716LzShkfXtgbLV7l4VtKOty G6eg42toBgF87Y49IrkP4a17LT9qf9ffyOtNbH3OWKUE0SDy2bx2ipJqDxRHna30AVYn esfg== X-Gm-Message-State: APjAAAUro+hC6IdbubeeT3lg6a4/d6VxOFBxMCM7LTzvO24rWwlzqHyB 8HRPNEehxd23oqY6+0CRVFxu7jaVv/QSlx3uYkX48dDoC0JTGbQHrgYizXqZeuA0PaWwjTGBUWR rqW30d7cG0g3MBVSiAKW3XPcu7v4ogtvFmq//8ui35dTBHkFgqK0FSkPIiDtFQgE= X-Received: by 2002:a17:902:ba82:: with SMTP id k2mr79301949pls.323.1560419033953; Thu, 13 Jun 2019 02:43:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDiQ9Oa5H5pSzS0G+LefezzQMSt+bHIYwmKzDxYThr+4Py30aax3uFTJdt7m8Myyv68oHd X-Received: by 2002:a17:902:ba82:: with SMTP id k2mr79301837pls.323.1560419033011; Thu, 13 Jun 2019 02:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419033; cv=none; d=google.com; s=arc-20160816; b=yZlPXynIQl35IW8eUyXUep/P51jngEyECweOELhzhnx+YjIiGQlchJntDJudim+SBK 8yKvmE3U4v2b35/RXggbcZDVDoV/L0DgIxLnnjJdqQaxb2zNp9jkeXtnePnpyeQ8JGtA NCGswSBcvbawT3JnT2/bZBEgqny46mNQ5BQY4HP7RToM3UAsYOpzyARWxsKkgNJfqcQP uvNQImXvhwFPsXmbBoXa12g0lDfSDCXf0HaCl8o+WXV8iEpkaBTSBVNw4VtWyx/S3Wgh QiYl8NmAp1HWOFiXufA56HrJByTbTBR+D0WNwsj9p3m3j51U034wrrTp7y9KQKmFObjJ I8bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=TQXVBWfIqlzVbrygyo5vum+QYxG/VVv5jsBwO0qkppA=; b=N90LosHIaFR6PZkRSbODJUEvwYMosaG3SYR8xWsIGKNTpMrRJBStZyu5hdNLDXWKZp +J/O/LfgOc+J7ZacjOr2moBnrvXOcWWm8RtwDpOJ9kQ565EvYPA9jMV6MRjEln2ASu4M yerzq6aowDOcDuhQ7UFzc/YAEc65C8+mQOX/mAxpNAieQWJ5hoVs9FHjaS7JpugP7k5F TnT96XInjIyxKNlPQBxNqC/kLcZUiwm8W0nFYQBendHk5smuX98hMsRQAVn7sY1EEvCO 1OomPppo3lQngHDWv800aZdCs4lwesBptPCpCrWETWqJFs1Ui40m9xKJb2QEq2mGHvEK TYcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=UBMIjgc7; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id y62si2665475pfy.244.2019.06.13.02.43.52 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:43:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=UBMIjgc7; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=TQXVBWfIqlzVbrygyo5vum+QYxG/VVv5jsBwO0qkppA=; b=UBMIjgc7UKwEGwdFQidbjqSnOO sl8tOdzK6YyD4G5gAX8Y9qW4ErlA2S5LnOv3V/cTwqC0ciDilPjy3GsKV03Ip5H8W0p60mg72Z76S BNG3rAkhsaOlVzZ0hl2D58ioxhQrK8e80vptGoxDjtbWc/kWObXljn2ZjiT5hDjKdJfBMLE0lS/kA GH4f//eF48WF9CLrrT6JCnPc7VdA0/lhANIMBoByo6LQ7zb7MVhXGcCBzCdrS1y1uEPmP4WCHNK2O K0g5+PIeHM2mBfTXBdNpnyokz5WzgqLPxYhtUm2Fhu7m57o8aArvGzHFb8zBFrfbuTbjsasXLEHwK rr6EJXyw==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMGr-0001mf-4O; Thu, 13 Jun 2019 09:43:49 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/22] memremap: move dev_pagemap callbacks into a separate structure Date: Thu, 13 Jun 2019 11:43:10 +0200 Message-Id: <20190613094326.24093-8-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP The dev_pagemap is a growing too many callbacks. Move them into a separate ops structure so that they are not duplicated for multiple instances, and an attacker can't easily overwrite them. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Reviewed-by: Logan Gunthorpe --- drivers/dax/device.c | 6 +++++- drivers/nvdimm/pmem.c | 18 +++++++++++++----- drivers/pci/p2pdma.c | 5 ++++- include/linux/memremap.h | 29 +++++++++++++++-------------- kernel/memremap.c | 12 ++++++------ mm/hmm.c | 8 ++++++-- tools/testing/nvdimm/test/iomap.c | 2 +- 7 files changed, 50 insertions(+), 30 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 996d68ff992a..4adab774dade 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -443,6 +443,10 @@ static void dev_dax_kill(void *dev_dax) kill_dev_dax(dev_dax); } +static const struct dev_pagemap_ops dev_dax_pagemap_ops = { + .kill = dev_dax_percpu_kill, +}; + int dev_dax_probe(struct device *dev) { struct dev_dax *dev_dax = to_dev_dax(dev); @@ -471,7 +475,7 @@ int dev_dax_probe(struct device *dev) return rc; dev_dax->pgmap.ref = &dev_dax->ref; - dev_dax->pgmap.kill = dev_dax_percpu_kill; + dev_dax->pgmap.ops = &dev_dax_pagemap_ops; addr = devm_memremap_pages(dev, &dev_dax->pgmap); if (IS_ERR(addr)) { devm_remove_action(dev, dev_dax_percpu_exit, &dev_dax->ref); diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index d9d845077b8b..4efbf184ea68 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -316,7 +316,7 @@ static void pmem_release_queue(void *q) blk_cleanup_queue(q); } -static void pmem_freeze_queue(struct percpu_ref *ref) +static void pmem_kill(struct percpu_ref *ref) { struct request_queue *q; @@ -339,19 +339,27 @@ static void pmem_release_pgmap_ops(void *__pgmap) dev_pagemap_put_ops(); } -static void fsdax_pagefree(struct page *page, void *data) +static void pmem_fsdax_page_free(struct page *page, void *data) { wake_up_var(&page->_refcount); } +static const struct dev_pagemap_ops fsdax_pagemap_ops = { + .page_free = pmem_fsdax_page_free, + .kill = pmem_kill, +}; + +static const struct dev_pagemap_ops pmem_legacy_pagemap_ops = { + .kill = pmem_kill, +}; + static int setup_pagemap_fsdax(struct device *dev, struct dev_pagemap *pgmap) { dev_pagemap_get_ops(); if (devm_add_action_or_reset(dev, pmem_release_pgmap_ops, pgmap)) return -ENOMEM; pgmap->type = MEMORY_DEVICE_FS_DAX; - pgmap->page_free = fsdax_pagefree; - + pgmap->ops = &fsdax_pagemap_ops; return 0; } @@ -412,7 +420,6 @@ static int pmem_attach_disk(struct device *dev, pmem->pfn_flags = PFN_DEV; pmem->pgmap.ref = &q->q_usage_counter; - pmem->pgmap.kill = pmem_freeze_queue; if (is_nd_pfn(dev)) { if (setup_pagemap_fsdax(dev, &pmem->pgmap)) return -ENOMEM; @@ -433,6 +440,7 @@ static int pmem_attach_disk(struct device *dev, pmem->pfn_flags |= PFN_MAP; memcpy(&bb_res, &pmem->pgmap.res, sizeof(bb_res)); } else { + pmem->pgmap.ops = &pmem_legacy_pagemap_ops; addr = devm_memremap(dev, pmem->phys_addr, pmem->size, ARCH_MEMREMAP_PMEM); memcpy(&bb_res, &nsio->res, sizeof(bb_res)); diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 742928d0053e..6e76380f5b97 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -150,6 +150,10 @@ static int pci_p2pdma_setup(struct pci_dev *pdev) return error; } +static const struct dev_pagemap_ops pci_p2pdma_pagemap_ops = { + .kill = pci_p2pdma_percpu_kill, +}; + /** * pci_p2pdma_add_resource - add memory for use as p2p memory * @pdev: the device to add the memory to @@ -196,7 +200,6 @@ int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size, pgmap->type = MEMORY_DEVICE_PCI_P2PDMA; pgmap->pci_p2pdma_bus_offset = pci_bus_address(pdev, bar) - pci_resource_start(pdev, bar); - pgmap->kill = pci_p2pdma_percpu_kill; addr = devm_memremap_pages(&pdev->dev, pgmap); if (IS_ERR(addr)) { diff --git a/include/linux/memremap.h b/include/linux/memremap.h index f0628660d541..5f7f40875b35 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -63,39 +63,40 @@ enum memory_type { MEMORY_DEVICE_PCI_P2PDMA, }; -/* - * Additional notes about MEMORY_DEVICE_PRIVATE may be found in - * include/linux/hmm.h and Documentation/vm/hmm.rst. There is also a brief - * explanation in include/linux/memory_hotplug.h. - * - * The page_free() callback is 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.) - */ -typedef void (*dev_page_free_t)(struct page *page, void *data); +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.) + */ + void (*page_free)(struct page *page, void *data); + + /* + * Transition the percpu_ref in struct dev_pagemap to the dead state. + */ + void (*kill)(struct percpu_ref *ref); +}; /** * struct dev_pagemap - metadata for ZONE_DEVICE mappings - * @page_free: free page callback when page refcount reaches 1 * @altmap: pre-allocated/reserved memory for vmemmap allocations * @res: physical address range covered by @ref * @ref: reference count that pins the devm_memremap_pages() mapping - * @kill: callback to transition @ref to the dead state * @dev: host device of the mapping for debug * @data: private data pointer for page_free() * @type: memory type: see MEMORY_* in memory_hotplug.h + * @ops: method table */ struct dev_pagemap { - dev_page_free_t page_free; struct vmem_altmap altmap; bool altmap_valid; struct resource res; struct percpu_ref *ref; - void (*kill)(struct percpu_ref *ref); struct device *dev; void *data; enum memory_type type; u64 pci_p2pdma_bus_offset; + const struct dev_pagemap_ops *ops; }; #ifdef CONFIG_ZONE_DEVICE diff --git a/kernel/memremap.c b/kernel/memremap.c index 1490e63f69a9..e23286ce0ec4 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -92,7 +92,7 @@ static void devm_memremap_pages_release(void *data) unsigned long pfn; int nid; - pgmap->kill(pgmap->ref); + pgmap->ops->kill(pgmap->ref); for_each_device_pfn(pfn, pgmap) put_page(pfn_to_page(pfn)); @@ -127,8 +127,8 @@ static void devm_memremap_pages_release(void *data) * @pgmap: pointer to a struct dev_pagemap * * Notes: - * 1/ At a minimum the res, ref and type members of @pgmap must be initialized - * by the caller before passing it to this function + * 1/ At a minimum the res, ref and type and ops members of @pgmap must be + * initialized by the caller before passing it to this function * * 2/ The altmap field may optionally be initialized, in which case altmap_valid * must be set to true @@ -156,7 +156,7 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap) pgprot_t pgprot = PAGE_KERNEL; int error, nid, is_ram; - if (!pgmap->ref || !pgmap->kill) + if (!pgmap->ref || !pgmap->ops || !pgmap->ops->kill) return ERR_PTR(-EINVAL); align_start = res->start & ~(SECTION_SIZE - 1); @@ -266,7 +266,7 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap) err_pfn_remap: pgmap_array_delete(res); err_array: - pgmap->kill(pgmap->ref); + pgmap->ops->kill(pgmap->ref); return ERR_PTR(error); } EXPORT_SYMBOL_GPL(devm_memremap_pages); @@ -353,7 +353,7 @@ void __put_devmap_managed_page(struct page *page) mem_cgroup_uncharge(page); - page->pgmap->page_free(page, page->pgmap->data); + page->pgmap->ops->page_free(page, page->pgmap->data); } else if (!count) __put_page(page); } diff --git a/mm/hmm.c b/mm/hmm.c index 13a16faf0a77..2501ac6045d0 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -1348,6 +1348,11 @@ static void hmm_devmem_free(struct page *page, void *data) devmem->ops->free(devmem, page); } +static const struct dev_pagemap_ops hmm_pagemap_ops = { + .page_free = hmm_devmem_free, + .kill = hmm_devmem_ref_kill, +}; + /* * hmm_devmem_add() - hotplug ZONE_DEVICE memory for device memory * @@ -1406,11 +1411,10 @@ struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops, devmem->pagemap.type = MEMORY_DEVICE_PRIVATE; devmem->pagemap.res = *devmem->resource; - devmem->pagemap.page_free = hmm_devmem_free; + devmem->pagemap.ops = &hmm_pagemap_ops; devmem->pagemap.altmap_valid = false; devmem->pagemap.ref = &devmem->ref; devmem->pagemap.data = devmem; - devmem->pagemap.kill = hmm_devmem_ref_kill; result = devm_memremap_pages(devmem->device, &devmem->pagemap); if (IS_ERR(result)) diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c index c6635fee27d8..7f5ece9b5011 100644 --- a/tools/testing/nvdimm/test/iomap.c +++ b/tools/testing/nvdimm/test/iomap.c @@ -108,7 +108,7 @@ static void nfit_test_kill(void *_pgmap) { struct dev_pagemap *pgmap = _pgmap; - pgmap->kill(pgmap->ref); + pgmap->ops->kill(pgmap->ref); } void *__wrap_devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap) From patchwork Thu Jun 13 09:43:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 268C676 for ; Thu, 13 Jun 2019 09:44:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1124928B16 for ; Thu, 13 Jun 2019 09:44:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0570528B17; Thu, 13 Jun 2019 09:44:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72EC828B15 for ; Thu, 13 Jun 2019 09:43:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09D806B0266; Thu, 13 Jun 2019 05:43:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 023A26B0269; Thu, 13 Jun 2019 05:43:57 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E07556B026A; Thu, 13 Jun 2019 05:43:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id A8D426B0266 for ; Thu, 13 Jun 2019 05:43:57 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id a21so13450640pgh.11 for ; Thu, 13 Jun 2019 02:43:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=J6KgL/HbS2N6LTNHClyEsjbtYbBDeWvEUc8ywUokDbM=; b=f5LkD+wm7cyDB8KPN8FEfBAGblEDAChi+rl94hfUAbCOo6VY5/OFHd+DT2SY5B7HgO qHeBdjCafanVQEeksOjGsCIPujwClulnADifG6zsMMsDZGhQwuiMhitAQnsKiuGuHmBk oW+SQ/R7mOKN/lZKKwVMh5qHnQGr5/n9Gi9z2iduT7NPvF7sHD56Rifo7ITS2UNST7Aq mhwSO9L0FpVv+P/d0IaJG8oNaT8NhuU7IFFRPlRqYxtBTSHQ5hIdSSSMXFQDS61/FFFF 7XNC4gXR5OZ7TgrqPBmQk6ZWNL+teLCw+zYmfNP/8AVxQuC1lYa8BUeFbB9931KjCt2c QscA== X-Gm-Message-State: APjAAAV1iHU0Am9WCEpONXRioskCHehNNXBpkDnHdb4mGRIKWOegmwhY 7OhRgAIOL/pRx9tYFiybjgkZ05prIUoWi2UHj8dzpNG7LvomRtE8QhKA/V0RBl6cOzOyFFxan2q N26+vP9K39IEECJFBeBoe89AB+NahGZ09f9/BnTN7G17gXN2btOByDXYevZPZGYo= X-Received: by 2002:a65:4cce:: with SMTP id n14mr10261232pgt.251.1560419037184; Thu, 13 Jun 2019 02:43:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzypqL/LxUrxAEzdoT9bbNBxM5B+a9bAtcbuCEk3j+p6SZFgn18o33kU1RNDe2rZhHM4FAs X-Received: by 2002:a65:4cce:: with SMTP id n14mr10261102pgt.251.1560419035940; Thu, 13 Jun 2019 02:43:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419035; cv=none; d=google.com; s=arc-20160816; b=alHGemeCGWgfCLUfBA0N0EiyLcnOv+/JTFUuiU8bhjX/ms1airPCRnuTK6Y+sLlJfD aJtQOM7JXf4k/PmizS+HwPas+9WOV2BnDgcocbSijFYueTDLqtdVZEKelEt0F9yci6Vy 1IO6V4D1bLc4U/JO1XZUSZu0rCCFKIPYxwUKpxNJBxKpbQCEuCY9FFsDd3ljC3zTCDx6 gblAaAte6bhRvO/uPdOm5uxPdCuoRW+uvOM4Ibyy1nFe1iYowIlrjwe4UFSvh0iz2Lt0 3df4wIo3h5TXDmCkyPu880zGDkcXT3359Y99gkANhNYuSL1ZqNVMzSltfkW0LGI4k4n3 XS/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=J6KgL/HbS2N6LTNHClyEsjbtYbBDeWvEUc8ywUokDbM=; b=dAmi8rRayKDvYwPWM/pX4uQzNNX6FiLNJQ8Q9Is5hmrqGcsNraOCzczew8zKshxCLc y3HcaqjqTO42qt0ySOj1nff7jpNKU78DN207wRj+S9/YtD2ngrkQC+hB/NAWsj6/JoWy KkH44t/ceeY4MBrDQI+K/iVhUL8cKlHW06R5VcqXBw8c9hW1TaahDWa7D0hjBAxgEP9P NJrlTetvYEnm4eUwEHtmesoAhM27urd6wvnvPD8ErR7yW+5pgQnAbV4p2IdIvIlnO3Dl tOPPE2qFfqnB/A6wiLN8K0LL17NPZBFtPRAApZWlnPzY9/r/XvxHxFANdgNF0aCv8jod P6fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Jh8lILEB; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id j100si2585885pje.52.2019.06.13.02.43.55 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:43:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Jh8lILEB; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=J6KgL/HbS2N6LTNHClyEsjbtYbBDeWvEUc8ywUokDbM=; b=Jh8lILEBlkoz7BxZUpZfrk+rPo 5Vv8zvkEs/Fw9OO79N5N/Y0XT5tjZHyEHTWn8eyvOgqXtUXVd1z/SRTfQtsDOkc03rcc8Oqr+0gGj XtkmK2r6kYcloDj/rKBacpiDOED1N5eXx2e3cRHkATAi8m82hHeWGVKkUJ/Fey7N4V9iRL/1FecYK PCRNRhSXbu3d/ofC8c+2tCSbKz0UToD06c23kveqrK8w7bUNKe5YMyLwjfgvyitQrNsCgWTU3bjfC +/5c3xHAUo+nzc8XFEIMoLhoIwvUGPRqZ8AKtA0fnh3a7Vt8YVEbCbjiXL7LVQ5gOLdxh0voFqRRa p1FErRFg==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMGu-0001ni-6t; Thu, 13 Jun 2019 09:43:52 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/22] memremap: pass a struct dev_pagemap to ->kill Date: Thu, 13 Jun 2019 11:43:11 +0200 Message-Id: <20190613094326.24093-9-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP Passing the actual typed structure leads to more understandable code vs the actual references. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Reviewed-by: Logan Gunthorpe Reviewed-by: Dan Williams Reported-by: Logan Gunthorpe :) --- drivers/dax/device.c | 7 +++---- drivers/nvdimm/pmem.c | 6 +++--- drivers/pci/p2pdma.c | 6 +++--- include/linux/memremap.h | 2 +- kernel/memremap.c | 4 ++-- mm/hmm.c | 4 ++-- tools/testing/nvdimm/test/iomap.c | 6 ++---- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 4adab774dade..e23fa1bd8c97 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -37,13 +37,12 @@ static void dev_dax_percpu_exit(void *data) percpu_ref_exit(ref); } -static void dev_dax_percpu_kill(struct percpu_ref *data) +static void dev_dax_percpu_kill(struct dev_pagemap *pgmap) { - struct percpu_ref *ref = data; - struct dev_dax *dev_dax = ref_to_dev_dax(ref); + struct dev_dax *dev_dax = container_of(pgmap, struct dev_dax, pgmap); dev_dbg(&dev_dax->dev, "%s\n", __func__); - percpu_ref_kill(ref); + percpu_ref_kill(pgmap->ref); } static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma, diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 4efbf184ea68..b9638c6553a1 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -316,11 +316,11 @@ static void pmem_release_queue(void *q) blk_cleanup_queue(q); } -static void pmem_kill(struct percpu_ref *ref) +static void pmem_kill(struct dev_pagemap *pgmap) { - struct request_queue *q; + struct request_queue *q = + container_of(pgmap->ref, struct request_queue, q_usage_counter); - q = container_of(ref, typeof(*q), q_usage_counter); blk_freeze_queue_start(q); } diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 6e76380f5b97..3bcacc9222c6 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -82,7 +82,7 @@ static void pci_p2pdma_percpu_release(struct percpu_ref *ref) complete_all(&p2p->devmap_ref_done); } -static void pci_p2pdma_percpu_kill(struct percpu_ref *ref) +static void pci_p2pdma_percpu_kill(struct dev_pagemap *pgmap) { /* * pci_p2pdma_add_resource() may be called multiple times @@ -90,10 +90,10 @@ static void pci_p2pdma_percpu_kill(struct percpu_ref *ref) * times. We only want the first action to actually kill the * percpu_ref. */ - if (percpu_ref_is_dying(ref)) + if (percpu_ref_is_dying(pgmap->ref)) return; - percpu_ref_kill(ref); + percpu_ref_kill(pgmap->ref); } static void pci_p2pdma_release(void *data) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 5f7f40875b35..96a3a6d564ad 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -74,7 +74,7 @@ struct dev_pagemap_ops { /* * Transition the percpu_ref in struct dev_pagemap to the dead state. */ - void (*kill)(struct percpu_ref *ref); + void (*kill)(struct dev_pagemap *pgmap); }; /** diff --git a/kernel/memremap.c b/kernel/memremap.c index e23286ce0ec4..94b830b6eca5 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -92,7 +92,7 @@ static void devm_memremap_pages_release(void *data) unsigned long pfn; int nid; - pgmap->ops->kill(pgmap->ref); + pgmap->ops->kill(pgmap); for_each_device_pfn(pfn, pgmap) put_page(pfn_to_page(pfn)); @@ -266,7 +266,7 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap) err_pfn_remap: pgmap_array_delete(res); err_array: - pgmap->ops->kill(pgmap->ref); + pgmap->ops->kill(pgmap); return ERR_PTR(error); } EXPORT_SYMBOL_GPL(devm_memremap_pages); diff --git a/mm/hmm.c b/mm/hmm.c index 2501ac6045d0..c76a1b5defda 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -1325,9 +1325,9 @@ static void hmm_devmem_ref_exit(void *data) percpu_ref_exit(ref); } -static void hmm_devmem_ref_kill(struct percpu_ref *ref) +static void hmm_devmem_ref_kill(struct dev_pagemap *pgmap) { - percpu_ref_kill(ref); + percpu_ref_kill(pgmap->ref); } static vm_fault_t hmm_devmem_fault(struct vm_area_struct *vma, diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c index 7f5ece9b5011..ee07c4de2b35 100644 --- a/tools/testing/nvdimm/test/iomap.c +++ b/tools/testing/nvdimm/test/iomap.c @@ -104,11 +104,9 @@ void *__wrap_devm_memremap(struct device *dev, resource_size_t offset, } EXPORT_SYMBOL(__wrap_devm_memremap); -static void nfit_test_kill(void *_pgmap) +static void nfit_test_kill(void *pgmap) { - struct dev_pagemap *pgmap = _pgmap; - - pgmap->ops->kill(pgmap->ref); + pgmap->ops->kill(pgmap); } void *__wrap_devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap) From patchwork Thu Jun 13 09:43:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991469 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8B7413AF for ; Thu, 13 Jun 2019 09:44:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D63A928B15 for ; Thu, 13 Jun 2019 09:44:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CACFD28B1B; Thu, 13 Jun 2019 09:44:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A25928B15 for ; Thu, 13 Jun 2019 09:44:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 889516B0269; Thu, 13 Jun 2019 05:43:59 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 812C96B026A; Thu, 13 Jun 2019 05:43:59 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68DFD6B026B; Thu, 13 Jun 2019 05:43:59 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 2E0146B0269 for ; Thu, 13 Jun 2019 05:43:59 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id s22so7617604plp.5 for ; Thu, 13 Jun 2019 02:43:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1BqK80fO4qP585H34EdwQbL6ViSgwKQddKyugyKso9Y=; b=XqEdEH0IYqFQhRwN4PgWSi1yEG0dE9iOOFcVkMt+BfFbEE7ONXuwdlkF3HOVyk0wxY M2ILJMvWGRemm561UOS3+CD0LgmUWtH/f6gCetTcncpOWw9UsC6ZLbkUjlkyAoSJURj6 QQzVBEjuXDN60YVEWiuZWCYIe0SxLDN8nyI6x4YPWq/9MlAXf/vEkQo0vW7JmM4oE5nA 0mMfQ3MVr5ofEx97GCpGFfzK55MlQgu3/bmSZO1LCysNCEo4EvhFbMyIHMXOtZKN245F p/D1YnzA62/GUbuKCCje/6bLl78JlwS12RW23+GpBLh5aDIDZmVmZh5UCH1AKYxaxFhL UicQ== X-Gm-Message-State: APjAAAWKzez1yqG7jLS1Lq+tqu8B57D6CaSBt1TDPaM+11O2Bw3ngoQ5 RAfyt7tIWyKPAT0JucYhrIihHIuSkqitmmiTw4cRatBv/RBomJIZjMx2EOmPqNhq6px52UK+ps/ /sw/FerhxK1lu0g8n7mk5YeLyvD3nVJVPH9PV6e64c1GH7c+llmdsn+TPBuw+V68= X-Received: by 2002:a17:902:148:: with SMTP id 66mr81301463plb.143.1560419038789; Thu, 13 Jun 2019 02:43:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxd4RQBQ1CthvU9Le6010MeJ2eYitSnP8ytcZZp2mTwrceAfS6wOZBT1U1ABDblf20RZ6w2 X-Received: by 2002:a17:902:148:: with SMTP id 66mr81301355plb.143.1560419037913; Thu, 13 Jun 2019 02:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419037; cv=none; d=google.com; s=arc-20160816; b=Oh/b+zO8Qkvedssg8eb4u+/gAapNmV2w92WY2+AANEQr69akFP7GOG0p0vme0dyvPm 89W8hhYfbigtaTMxz8ygZMATnAMdJWsNIwwt6WG69N2cCi1EJAsTChZc09G6rUDQkJuA ScfGUL/mBjY7Na5KrIMUyTLNhYAhT9V5ZLNz83dL/iCvlN8+SanmwlvN++N2rfELIRpd t9ZcBesyNDbQ8d3F27JteKHec41ZDJLTSIAiUBd7WCzTBfIjCKVWjVnXSDg4zRIW49fI tSg9aWebv6FTTwblhCcNDVYUghPOnnOKL62Y64hjGbnqzEafuKDDqyxKpjKt0eltqOlh 1hOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=1BqK80fO4qP585H34EdwQbL6ViSgwKQddKyugyKso9Y=; b=GhPATw0zMM4hjUcuuFzrg5RNPlql3YzLRuOvfBMQluNI/9ewM6earOe/0NlnrcgH5l c6QgWO7NoMSvcKUQoKlVFRwBHnPPUvPiHYtb005PUGQ1NM7NMqXY+IpXGQpwqxf/zsCA T7zlqumhsORYREx64QG/eR+gvS5tFoVVtPodiK027HxCPRLvZiVFfQtrT2MckVsiNHhp izm/Qet3arJirWZ/AFW060aIL6fqeuDXm7cG8KXCWVBnBvIZOyfEGrAoiUu3mRPjPa80 U0r9WmCTrMfw0wQ5cGxrQ54gk34KpInQrz381BODdmKCkLc/O09UpCJmyoqfSfsXgGPX pDNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=TEMANqis; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 206si2711665pga.414.2019.06.13.02.43.57 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:43:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=TEMANqis; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1BqK80fO4qP585H34EdwQbL6ViSgwKQddKyugyKso9Y=; b=TEMANqisnK+/nbUc3UXMfUjlI6 Buayg3mmtOYuYeLGF0JU6+u1jMgokjY3LfM+Kk8hDa7h7fnT1VyFEP0nPB1RNUZWOVQuN3ovu93rh jsl9IqdSDGLWp38ra6Me2Ka5kg8BmNg4Hm/aJRiVyXtzEZPdEGsc+oaWriNBq2Pgyc+yY6y+JVwz9 hiWaWe9czGHjymFZztKABfoCjLkCdLjhKUHvyX+YjY5iFnm8H2PyqDyfQKfS4QNRaaBGWJ6kpu+eC B8kr6+ivmbMx2Ql/Nf6Ttz9lfxd/+jK9BugmMtX7lveZKR7VOZd55VwgHmrGIg3nIz2pCIVHSQPaS k+QbBHsQ==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMGx-0001p4-2R; Thu, 13 Jun 2019 09:43:55 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/22] memremap: lift the devmap_enable manipulation into devm_memremap_pages Date: Thu, 13 Jun 2019 11:43:12 +0200 Message-Id: <20190613094326.24093-10-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP Just check if there is a ->page_free operation set and take care of the static key enable, as well as the put using device managed resources. Signed-off-by: Christoph Hellwig Reviewed-by: Christoph Hellwig --- drivers/nvdimm/pmem.c | 23 +++-------------- include/linux/mm.h | 10 -------- kernel/memremap.c | 59 +++++++++++++++++++++++++++---------------- mm/hmm.c | 2 -- 4 files changed, 41 insertions(+), 53 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index b9638c6553a1..66837eed6375 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -334,11 +334,6 @@ static void pmem_release_disk(void *__pmem) put_disk(pmem->disk); } -static void pmem_release_pgmap_ops(void *__pgmap) -{ - dev_pagemap_put_ops(); -} - static void pmem_fsdax_page_free(struct page *page, void *data) { wake_up_var(&page->_refcount); @@ -353,16 +348,6 @@ static const struct dev_pagemap_ops pmem_legacy_pagemap_ops = { .kill = pmem_kill, }; -static int setup_pagemap_fsdax(struct device *dev, struct dev_pagemap *pgmap) -{ - dev_pagemap_get_ops(); - if (devm_add_action_or_reset(dev, pmem_release_pgmap_ops, pgmap)) - return -ENOMEM; - pgmap->type = MEMORY_DEVICE_FS_DAX; - pgmap->ops = &fsdax_pagemap_ops; - return 0; -} - static int pmem_attach_disk(struct device *dev, struct nd_namespace_common *ndns) { @@ -421,8 +406,8 @@ static int pmem_attach_disk(struct device *dev, pmem->pfn_flags = PFN_DEV; pmem->pgmap.ref = &q->q_usage_counter; if (is_nd_pfn(dev)) { - if (setup_pagemap_fsdax(dev, &pmem->pgmap)) - return -ENOMEM; + pmem->pgmap.type = MEMORY_DEVICE_FS_DAX; + pmem->pgmap.ops = &fsdax_pagemap_ops; addr = devm_memremap_pages(dev, &pmem->pgmap); pfn_sb = nd_pfn->pfn_sb; pmem->data_offset = le64_to_cpu(pfn_sb->dataoff); @@ -434,8 +419,8 @@ static int pmem_attach_disk(struct device *dev, } else if (pmem_should_map_pages(dev)) { memcpy(&pmem->pgmap.res, &nsio->res, sizeof(pmem->pgmap.res)); pmem->pgmap.altmap_valid = false; - if (setup_pagemap_fsdax(dev, &pmem->pgmap)) - return -ENOMEM; + pmem->pgmap.type = MEMORY_DEVICE_FS_DAX; + pmem->pgmap.ops = &fsdax_pagemap_ops; addr = devm_memremap_pages(dev, &pmem->pgmap); pmem->pfn_flags |= PFN_MAP; memcpy(&bb_res, &pmem->pgmap.res, sizeof(bb_res)); diff --git a/include/linux/mm.h b/include/linux/mm.h index 0e8834ac32b7..edcf2b821647 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -921,8 +921,6 @@ static inline bool is_zone_device_page(const struct page *page) #endif #ifdef CONFIG_DEV_PAGEMAP_OPS -void dev_pagemap_get_ops(void); -void dev_pagemap_put_ops(void); void __put_devmap_managed_page(struct page *page); DECLARE_STATIC_KEY_FALSE(devmap_managed_key); static inline bool put_devmap_managed_page(struct page *page) @@ -969,14 +967,6 @@ static inline bool is_pci_p2pdma_page(const struct page *page) #endif /* CONFIG_PCI_P2PDMA */ #else /* CONFIG_DEV_PAGEMAP_OPS */ -static inline void dev_pagemap_get_ops(void) -{ -} - -static inline void dev_pagemap_put_ops(void) -{ -} - static inline bool put_devmap_managed_page(struct page *page) { return false; diff --git a/kernel/memremap.c b/kernel/memremap.c index 94b830b6eca5..6a3183cac764 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -17,6 +17,37 @@ static DEFINE_XARRAY(pgmap_array); #define SECTION_MASK ~((1UL << PA_SECTION_SHIFT) - 1) #define SECTION_SIZE (1UL << PA_SECTION_SHIFT) +#ifdef CONFIG_DEV_PAGEMAP_OPS +DEFINE_STATIC_KEY_FALSE(devmap_managed_key); +EXPORT_SYMBOL(devmap_managed_key); +static atomic_t devmap_enable; + +static void dev_pagemap_put_ops(void *data) +{ + if (atomic_dec_and_test(&devmap_enable)) + static_branch_disable(&devmap_managed_key); +} + +/* + * Toggle the static key for ->page_free() callbacks when dev_pagemap + * pages go idle. + */ +static int dev_pagemap_enable(struct device *dev) +{ + if (atomic_inc_return(&devmap_enable) == 1) + static_branch_enable(&devmap_managed_key); + + if (devm_add_action_or_reset(dev, dev_pagemap_put_ops, NULL)) + return -ENOMEM; + return 0; +} +#else +static inline int dev_pagemap_enable(struct device *dev) +{ + return 0; +} +#endif /* CONFIG_DEV_PAGEMAP_OPS */ + #if IS_ENABLED(CONFIG_DEVICE_PRIVATE) vm_fault_t device_private_entry_fault(struct vm_area_struct *vma, unsigned long addr, @@ -159,6 +190,12 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap) if (!pgmap->ref || !pgmap->ops || !pgmap->ops->kill) return ERR_PTR(-EINVAL); + if (pgmap->ops->page_free) { + error = dev_pagemap_enable(dev); + if (error) + return ERR_PTR(error); + } + align_start = res->start & ~(SECTION_SIZE - 1); align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE) - align_start; @@ -316,28 +353,6 @@ struct dev_pagemap *get_dev_pagemap(unsigned long pfn, EXPORT_SYMBOL_GPL(get_dev_pagemap); #ifdef CONFIG_DEV_PAGEMAP_OPS -DEFINE_STATIC_KEY_FALSE(devmap_managed_key); -EXPORT_SYMBOL(devmap_managed_key); -static atomic_t devmap_enable; - -/* - * Toggle the static key for ->page_free() callbacks when dev_pagemap - * pages go idle. - */ -void dev_pagemap_get_ops(void) -{ - if (atomic_inc_return(&devmap_enable) == 1) - static_branch_enable(&devmap_managed_key); -} -EXPORT_SYMBOL_GPL(dev_pagemap_get_ops); - -void dev_pagemap_put_ops(void) -{ - if (atomic_dec_and_test(&devmap_enable)) - static_branch_disable(&devmap_managed_key); -} -EXPORT_SYMBOL_GPL(dev_pagemap_put_ops); - void __put_devmap_managed_page(struct page *page) { int count = page_ref_dec_return(page); diff --git a/mm/hmm.c b/mm/hmm.c index c76a1b5defda..6dc769feb2e1 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -1378,8 +1378,6 @@ struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops, void *result; int ret; - dev_pagemap_get_ops(); - devmem = devm_kzalloc(device, sizeof(*devmem), GFP_KERNEL); if (!devmem) return ERR_PTR(-ENOMEM); From patchwork Thu Jun 13 09:43:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991475 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA50B13AF for ; Thu, 13 Jun 2019 09:44:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7BF228B15 for ; Thu, 13 Jun 2019 09:44:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC3AD28B16; Thu, 13 Jun 2019 09:44:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1468428B1B for ; Thu, 13 Jun 2019 09:44:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41C5C6B000C; Thu, 13 Jun 2019 05:44:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3D1B66B026A; Thu, 13 Jun 2019 05:44:03 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21FDA6B026B; Thu, 13 Jun 2019 05:44:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id D35BC6B000C for ; Thu, 13 Jun 2019 05:44:02 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id c17so14089559pfb.21 for ; Thu, 13 Jun 2019 02:44:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0g0wuDYxGWA/uLah/sn+BRxeQhPX6KLUiVSrhTXjDEs=; b=SRB9nq95ER79NzCRi5Bko3TRAq617Q/Q/WLFv5jK8BaYnP3GJ00zMllHqCz7VovmCV cOtUyO81plYYLrw0UX35zYxXwzR4hoZoApzkvqpGFOMCBjLyWQVb/9CVovH6gAeWQ6uU SE9d8XkRknmeqjZr71evwXtwaCIp+81u/h7WqqorGlkqL2yKCAzcpf37ygM9O4PE2BMl PF0U0wq80itsP9Hk3zfc9cOPeD/KCk1SJNohQDNXeMjKyMTaYonBqPh693hJSU/abFMb X1x7/7dqqdLN17CDFa4MqV7+rPAVpsFEUlweX3Was65wGaRU2l9pdnNdTutYX3jm/34e EsNw== X-Gm-Message-State: APjAAAVWcxHqVwXr5ADFX3aGvHaoG4PTqqjJN++qrmmj2iXLsGSErhKU NSRD5lkBC1IcT7QBEuiptfil/KXtEeGIIiBOwcPHbEvMLKecWqntLbEZ28tvcP6r+TSCHjgrHc6 cCSn9DpN7RtRbdEXUu7+695WDkxU3BsvivMVVIxNI0qnO1imkSiihdTcYgoU7WB0= X-Received: by 2002:a63:87c8:: with SMTP id i191mr30087839pge.131.1560419042416; Thu, 13 Jun 2019 02:44:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkl4NO+yGdk1wDqv2WaZXqomrhtK5eYtWykaraQmceYm4qxhvnWK0eOWgfcATo2BTh51Iz X-Received: by 2002:a63:87c8:: with SMTP id i191mr30087731pge.131.1560419041318; Thu, 13 Jun 2019 02:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419041; cv=none; d=google.com; s=arc-20160816; b=js/iklAgznsi78zBIlNKMYT2gu/zR678BEw4SkB+ILuH/tdlQw0dgwX6NgSOHHVw6G CrTNSvZcuQTChmHSIFaBfhYBXmbnWwPRPHnhQ4LHtVpYcG+UUi3sLXa3HFECspFbjVX4 OLYV31CBxrAV0C56vYuib73GXPB8e9lXqSfcBe++hBDokvHaKri2UQHIdw0HmmpDOoHU c6uZeKKtivDk6mI3Grg5yyNomNOgOeOKoPUBcPYu+D4yPO41AtXBF52/I8Fys85bMWyP GFtqiaoSOeq/+1b74/sUy8mMl5GHxqCwvgXjlVwhBxH9FiSBgohQ1O6xnqi3AOuVFRwQ pA9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=0g0wuDYxGWA/uLah/sn+BRxeQhPX6KLUiVSrhTXjDEs=; b=JKaWYUWcOgdZ39ufEgSQJcxBECIn7eBLFzBozWXTS/mwwrCLRjRUNQslAJK7s6LpxP /ssSDPEAL/sKTipV9QT2bb9YcPnq4gWZYb/NcQwPgrEjiH/8xPLtwV2n4APuUhWMQbJV l6/qqzpG2xVE40pAlVB8I97P02OrKaPasTLgosjy7vyZCDzXZszzkTE7F/Mv9VzF++Te 1CjFuaATHjSoGiY8FtifwyrkSep46hmT58GQ4ogzsRg6kcciTVt5gucFcej/XfBXMbRS VVCsQlKm5c0uzkzBQZhp0Uw+ajkUYeZakXth99tY9FzmhdNuVVEI7UUi+fwkrS1YmAww T9Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=ZLjh9Yz1; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id t10si2579961pgg.221.2019.06.13.02.44.01 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:44:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=ZLjh9Yz1; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=0g0wuDYxGWA/uLah/sn+BRxeQhPX6KLUiVSrhTXjDEs=; b=ZLjh9Yz1nklcjKdmhxD6xZcbQo QbG27zlG2JdbvoFLZ4goiroQQp5omTY7qsv0f1kkQHlkXOY5mtw4SIZ3UO+qnZZ9g2oWXish4ad26 Y1nN1CTY2P0JV7cX1Vl+D2kXrDd/qJUxIh4ZgoV+i22hzsn25KEeQg91gzlTI4OUSHCCCbtQlxqm0 1ihbJMMVc5tSN8cZILVzBB+hSKj5oUIWFefG9pKBC8SCrRkNz2gPZUlaWM9F73Kc0IiggR7UiyCPx mp0x9Pd7Ji7+hu/alGDMiKM1FIDL88GB6CxBWuAxCM1X94PTiZPav5hG47m7GQq1feotxeQQJsne8 A3rm5Oow==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMH0-0001pk-1S; Thu, 13 Jun 2019 09:43:58 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/22] memremap: add a migrate callback to struct dev_pagemap_ops Date: Thu, 13 Jun 2019 11:43:13 +0200 Message-Id: <20190613094326.24093-11-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP This replaces the hacky ->fault callback, which is currently directly called from common code through a hmm specific data structure as an exercise in layering violations. Signed-off-by: Christoph Hellwig Reviewed-by: Ralph Campbell --- include/linux/hmm.h | 6 ------ include/linux/memremap.h | 6 ++++++ include/linux/swapops.h | 15 --------------- kernel/memremap.c | 31 ------------------------------- mm/hmm.c | 13 +++++-------- mm/memory.c | 9 ++------- 6 files changed, 13 insertions(+), 67 deletions(-) diff --git a/include/linux/hmm.h b/include/linux/hmm.h index 5761a39221a6..3c9a59dbfdb8 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -658,11 +658,6 @@ struct hmm_devmem_ops { * chunk, as an optimization. It must, however, prioritize the faulting address * over all the others. */ -typedef vm_fault_t (*dev_page_fault_t)(struct vm_area_struct *vma, - unsigned long addr, - const struct page *page, - unsigned int flags, - pmd_t *pmdp); struct hmm_devmem { struct completion completion; @@ -673,7 +668,6 @@ struct hmm_devmem { struct dev_pagemap pagemap; const struct hmm_devmem_ops *ops; struct percpu_ref ref; - dev_page_fault_t page_fault; }; /* diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 96a3a6d564ad..03a4099be701 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -75,6 +75,12 @@ struct dev_pagemap_ops { * Transition the percpu_ref in struct dev_pagemap to the dead state. */ void (*kill)(struct dev_pagemap *pgmap); + + /* + * Used for private (un-addressable) device memory only. Must migrate + * the page back to a CPU accessible page. + */ + vm_fault_t (*migrate)(struct vm_fault *vmf); }; /** diff --git a/include/linux/swapops.h b/include/linux/swapops.h index 4d961668e5fc..15bdb6fe71e5 100644 --- a/include/linux/swapops.h +++ b/include/linux/swapops.h @@ -129,12 +129,6 @@ static inline struct page *device_private_entry_to_page(swp_entry_t entry) { return pfn_to_page(swp_offset(entry)); } - -vm_fault_t device_private_entry_fault(struct vm_area_struct *vma, - unsigned long addr, - swp_entry_t entry, - unsigned int flags, - pmd_t *pmdp); #else /* CONFIG_DEVICE_PRIVATE */ static inline swp_entry_t make_device_private_entry(struct page *page, bool write) { @@ -164,15 +158,6 @@ static inline struct page *device_private_entry_to_page(swp_entry_t entry) { return NULL; } - -static inline vm_fault_t device_private_entry_fault(struct vm_area_struct *vma, - unsigned long addr, - swp_entry_t entry, - unsigned int flags, - pmd_t *pmdp) -{ - return VM_FAULT_SIGBUS; -} #endif /* CONFIG_DEVICE_PRIVATE */ #ifdef CONFIG_MIGRATION diff --git a/kernel/memremap.c b/kernel/memremap.c index 6a3183cac764..7167e717647d 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -11,7 +11,6 @@ #include #include #include -#include static DEFINE_XARRAY(pgmap_array); #define SECTION_MASK ~((1UL << PA_SECTION_SHIFT) - 1) @@ -48,36 +47,6 @@ static inline int dev_pagemap_enable(struct device *dev) } #endif /* CONFIG_DEV_PAGEMAP_OPS */ -#if IS_ENABLED(CONFIG_DEVICE_PRIVATE) -vm_fault_t device_private_entry_fault(struct vm_area_struct *vma, - unsigned long addr, - swp_entry_t entry, - unsigned int flags, - pmd_t *pmdp) -{ - struct page *page = device_private_entry_to_page(entry); - struct hmm_devmem *devmem; - - devmem = container_of(page->pgmap, typeof(*devmem), pagemap); - - /* - * The page_fault() callback must migrate page back to system memory - * so that CPU can access it. This might fail for various reasons - * (device issue, device was unsafely unplugged, ...). When such - * error conditions happen, the callback must return VM_FAULT_SIGBUS. - * - * Note that because memory cgroup charges are accounted to the device - * memory, this should never fail because of memory restrictions (but - * allocation of regular system page might still fail because we are - * out of memory). - * - * There is a more in-depth description of what that callback can and - * cannot do, in include/linux/memremap.h - */ - return devmem->page_fault(vma, addr, page, flags, pmdp); -} -#endif /* CONFIG_DEVICE_PRIVATE */ - static void pgmap_array_delete(struct resource *res) { xa_store_range(&pgmap_array, PHYS_PFN(res->start), PHYS_PFN(res->end), diff --git a/mm/hmm.c b/mm/hmm.c index 6dc769feb2e1..aab799677c7d 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -1330,15 +1330,12 @@ static void hmm_devmem_ref_kill(struct dev_pagemap *pgmap) percpu_ref_kill(pgmap->ref); } -static vm_fault_t hmm_devmem_fault(struct vm_area_struct *vma, - unsigned long addr, - const struct page *page, - unsigned int flags, - pmd_t *pmdp) +static vm_fault_t hmm_devmem_migrate(struct vm_fault *vmf) { - struct hmm_devmem *devmem = page->pgmap->data; + struct hmm_devmem *devmem = vmf->page->pgmap->data; - return devmem->ops->fault(devmem, vma, addr, page, flags, pmdp); + return devmem->ops->fault(devmem, vmf->vma, vmf->address, vmf->page, + vmf->flags, vmf->pmd); } static void hmm_devmem_free(struct page *page, void *data) @@ -1351,6 +1348,7 @@ static void hmm_devmem_free(struct page *page, void *data) static const struct dev_pagemap_ops hmm_pagemap_ops = { .page_free = hmm_devmem_free, .kill = hmm_devmem_ref_kill, + .migrate = hmm_devmem_migrate, }; /* @@ -1405,7 +1403,6 @@ struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops, devmem->pfn_first = devmem->resource->start >> PAGE_SHIFT; devmem->pfn_last = devmem->pfn_first + (resource_size(devmem->resource) >> PAGE_SHIFT); - devmem->page_fault = hmm_devmem_fault; devmem->pagemap.type = MEMORY_DEVICE_PRIVATE; devmem->pagemap.res = *devmem->resource; diff --git a/mm/memory.c b/mm/memory.c index ddf20bd0c317..cbf3cb598436 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2782,13 +2782,8 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) migration_entry_wait(vma->vm_mm, vmf->pmd, vmf->address); } else if (is_device_private_entry(entry)) { - /* - * For un-addressable device memory we call the pgmap - * fault handler callback. The callback must migrate - * the page back to some CPU accessible page. - */ - ret = device_private_entry_fault(vma, vmf->address, entry, - vmf->flags, vmf->pmd); + vmf->page = device_private_entry_to_page(entry); + ret = page->pgmap->ops->migrate(vmf); } else if (is_hwpoison_entry(entry)) { ret = VM_FAULT_HWPOISON; } else { From patchwork Thu Jun 13 09:43:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991477 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 721A376 for ; Thu, 13 Jun 2019 09:44:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F3BE28B11 for ; Thu, 13 Jun 2019 09:44:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5312228B16; Thu, 13 Jun 2019 09:44:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4E5828B11 for ; Thu, 13 Jun 2019 09:44:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E4156B026A; Thu, 13 Jun 2019 05:44:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 26EFD6B026B; Thu, 13 Jun 2019 05:44:05 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C45E6B026C; Thu, 13 Jun 2019 05:44:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id BDDE66B026A for ; Thu, 13 Jun 2019 05:44:04 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id i26so14082209pfo.22 for ; Thu, 13 Jun 2019 02:44:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kSl39t9D+nytN/xDZfA4PvUR9mE53ZbXgno/pdognno=; b=p4xfiTRyvca5A3K6FJ05sQeUYv9CBYN/JQSX1gWOTfNZUQDBhFosxyXeD7jyXsg2Z+ EWGsTE+mQjh6LBW5Up4O6zODkCwYD22GZsoCYeWQ6irY1im5kITSOxIbaFIplNuiRtcB qTkgffZyHhJjT1R9v71KoBMEsVTD4E6g9m/xvU+/fCZcORWmWXAvA1E+PhhYoziGh+rE KSuSC/rKt1abxlTIAoKovWKwOz0aihVezvnjecVHsV8iQ12eaSW/iNNJopJuDK0gXHoz g/N6qeWvC+fdNv8IMNX0eQ2B6ydzXth5JVj6hkHARDGSSPoeeaDOsy7fAOKcux82QwpI n/KQ== X-Gm-Message-State: APjAAAVDPzm5iVdvC5C/uTkNT5yjdQl3OuzMZvhMNK9+Zurf7Kj3pzaH 9xeIbDedFaVmZU8Hv1odk3V6uvW/A2Nkys0mBdRy7h3G2OGdh9wDFy2MBWCwxGBMEbnpzcm937l 7UbGkpHlvlofZwjfZvaZrVllXONqm0ehYz/SUjt+g97tWDzC9FqXsvYCz1rjkpbw= X-Received: by 2002:a62:5306:: with SMTP id h6mr93020222pfb.29.1560419044436; Thu, 13 Jun 2019 02:44:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIOdrwa4R8ZZVFNPnv7KH6zJRXMBW6ilAQJKAtoAv3ym0hoYPTptKIQLWuGl0nAokvZ/TO X-Received: by 2002:a62:5306:: with SMTP id h6mr93020122pfb.29.1560419043577; Thu, 13 Jun 2019 02:44:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419043; cv=none; d=google.com; s=arc-20160816; b=Cn3thRoeUkcqOWZB1SzJ8KwaC+16FWy+NQoVva8VTDcgl6vZA+ABmrsjLcNh8en+92 JQcQmtAEYg+tYJ7Oa0qJplDy20ybVKnF8OxU4gUrnXBifcmje8tC+o+/GG7oFA0Kx9Lh oah+I0ADGlP08oitSE3ntgOAPpiSp6D1cBMSzryy00PCJPhk/ilf+QU1VClEMwjkwQlP hTD+9S/SUuqNmJwonij4fZ/fiPTWZEwWePUMMXKoCnuKl93zJI/xR+RZ0j1XBTuLzKFg kdC6N+tzvZea6WgbbO+Uo9IhcmbjvDijCgX664WUEh4MwAgr0qbepyMCH6Bj4oW89Eh0 aBjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=kSl39t9D+nytN/xDZfA4PvUR9mE53ZbXgno/pdognno=; b=EPQeJgYusCjUOU6L/ymPUrn4ABAiLHLaPPFYZmjpdinpm6/L/cb14ZHneS125L6J/7 E5m+s4oEDKtMwnqAi3qGq0V3glb1lr+MlBCNQxFycsaOhXE5rlXigrCcWtCaM/0LAD9O YiFsmKlmbYdgqUE12yGeIxsXEpgSyy52BpXDxIek2JV6ECKVICSKlcWGoUBzdDNo73x/ 0OzYsQ2FcQPubMY1ZSPRzpO4kgy1LaCkr1plSumpEygjfwqXnwkiunRGYFevccE0oSY6 H2yhUTwh2Pljq/TzcMHHF00ek4khIS2mdG30gR/NjIMgpCDEhvmHKHpwFexQA8pNjstl sbDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Pg029Ia8; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id n19si2540414pjo.31.2019.06.13.02.44.03 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:44:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Pg029Ia8; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kSl39t9D+nytN/xDZfA4PvUR9mE53ZbXgno/pdognno=; b=Pg029Ia8KJtlrfMQ0yw+zwPSDw FMI7A9BfUV19MJTx+3Zf9j3PpkbtUVH9VY8m9xQkHd3RwgbOrDoNCA19Qp091FCrZDRM/0CXcP8nf UcjsnWTrsgwuevTVg669Fa8aDofnaMryH2Hun/OYAXB9MiliZSYfJRgooDoNYrLm/pkZ1I6Fkmta8 3k+SKma8EAtOLhmdRAsqEWdWPxuuBzFF8QR3KYnP39oIhc6LMbc7bhLeOsJpfxTdpo1T+14Y3k7Xb SVfxoSvQlltcSayigSX10q/5lD2qbaTFtAlIIb698SdZR9apu5ZPGiQU0jf01KymXFfF+uBXgtK0n kTCNmUFQ==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMH2-0001qR-Mm; Thu, 13 Jun 2019 09:44:01 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/22] memremap: remove the data field in struct dev_pagemap Date: Thu, 13 Jun 2019 11:43:14 +0200 Message-Id: <20190613094326.24093-12-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP struct dev_pagemap is always embedded into a containing structure, so there is no need to an additional private data field. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe --- drivers/nvdimm/pmem.c | 2 +- include/linux/memremap.h | 3 +-- kernel/memremap.c | 2 +- mm/hmm.c | 9 +++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 66837eed6375..847d1b2bc10e 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -334,7 +334,7 @@ static void pmem_release_disk(void *__pmem) put_disk(pmem->disk); } -static void pmem_fsdax_page_free(struct page *page, void *data) +static void pmem_fsdax_page_free(struct page *page) { wake_up_var(&page->_refcount); } diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 03a4099be701..75b80de6394a 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -69,7 +69,7 @@ struct dev_pagemap_ops { * reach 0 refcount unless there is a refcount bug. This allows the * device driver to implement its own memory management.) */ - void (*page_free)(struct page *page, void *data); + void (*page_free)(struct page *page); /* * Transition the percpu_ref in struct dev_pagemap to the dead state. @@ -99,7 +99,6 @@ struct dev_pagemap { struct resource res; struct percpu_ref *ref; struct device *dev; - void *data; enum memory_type type; u64 pci_p2pdma_bus_offset; const struct dev_pagemap_ops *ops; diff --git a/kernel/memremap.c b/kernel/memremap.c index 7167e717647d..5c94ad4f5783 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -337,7 +337,7 @@ void __put_devmap_managed_page(struct page *page) mem_cgroup_uncharge(page); - page->pgmap->ops->page_free(page, page->pgmap->data); + page->pgmap->ops->page_free(page); } else if (!count) __put_page(page); } diff --git a/mm/hmm.c b/mm/hmm.c index aab799677c7d..ff0f9568922b 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -1332,15 +1332,17 @@ static void hmm_devmem_ref_kill(struct dev_pagemap *pgmap) static vm_fault_t hmm_devmem_migrate(struct vm_fault *vmf) { - struct hmm_devmem *devmem = vmf->page->pgmap->data; + struct hmm_devmem *devmem = + container_of(vmf->page->pgmap, struct hmm_devmem, pagemap); return devmem->ops->fault(devmem, vmf->vma, vmf->address, vmf->page, vmf->flags, vmf->pmd); } -static void hmm_devmem_free(struct page *page, void *data) +static void hmm_devmem_free(struct page *page) { - struct hmm_devmem *devmem = data; + struct hmm_devmem *devmem = + container_of(page->pgmap, struct hmm_devmem, pagemap); devmem->ops->free(devmem, page); } @@ -1409,7 +1411,6 @@ struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops, devmem->pagemap.ops = &hmm_pagemap_ops; devmem->pagemap.altmap_valid = false; devmem->pagemap.ref = &devmem->ref; - devmem->pagemap.data = devmem; result = devm_memremap_pages(devmem->device, &devmem->pagemap); if (IS_ERR(result)) From patchwork Thu Jun 13 09:43:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991483 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1A2776 for ; Thu, 13 Jun 2019 09:44:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ED8328B11 for ; Thu, 13 Jun 2019 09:44:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82E4228B16; Thu, 13 Jun 2019 09:44:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB94C28B11 for ; Thu, 13 Jun 2019 09:44:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A10AD6B026B; Thu, 13 Jun 2019 05:44:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 94BB36B026C; Thu, 13 Jun 2019 05:44:08 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C5C06B026D; Thu, 13 Jun 2019 05:44:08 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 3CC946B026B for ; Thu, 13 Jun 2019 05:44:08 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id u21so10989191pfn.15 for ; Thu, 13 Jun 2019 02:44:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+F36Qtp9KNZlJRbFfbQN1eq8EHq+227/7sfzGGclHLw=; b=gO5X9JPQJfoN15ilVkCvcbklXNw6+CIShPiG3h4GadFWATIRhYgCPgc3k7UKeG2W9+ kuAPxTE+J5mmhvcoFBHHFgpiXciIJMKcDf5FdoBZyLwldl31tjRkANgp4Z4xzsfjxmVC A96gaiZHLkSWS2UqO1YWmwaZ+lQAmJqCkQHCKf06W60AUD8Ity53uO347YokfKycG2iY VVSDut7ixn6mXYkXtIWNxHNg6x2vBldhULGYl3QstX+PsGqIFS3r490xxbPN95wv3IXs 5B6J0aMILNijtix8wclcpzIwQuj+hj1iaW69RyVIEDYu1MCm9mvb7cl8vpmrM3lbNHmm pdiA== X-Gm-Message-State: APjAAAVTxVmuiH7jnsGXifxIFpCzeYU52KI0NEMEQOcHAgkNE2d4YAD2 pBYdTpvbQTNHB/1ZVVvqVHke2V0I22zL70TnZq2jK+11/aJUcTN0HEhA/PPTZh2HflwKIQyeonS DCBDwHqj733jxYIrdM8YDk80ItZjBL5jnnn0oXYopsrY7l7N6KQbvKsd3xrnkZQw= X-Received: by 2002:a17:90a:7f02:: with SMTP id k2mr4380174pjl.78.1560419047893; Thu, 13 Jun 2019 02:44:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqySzrQQcDOgwP95BvsVCOVNkBjigqHxvIEiwByaw4e4bjyyJqUDUKlVUC3UwOm9+5xcQF4W X-Received: by 2002:a17:90a:7f02:: with SMTP id k2mr4380057pjl.78.1560419046937; Thu, 13 Jun 2019 02:44:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419046; cv=none; d=google.com; s=arc-20160816; b=I6kqfVFJ7tbRVQKMiR+K5q1fCZbUSiS6vGgCsHv9Dv+YZ6HrlaLbHGMtsSrB/k6a9D NeKaiclDhKka2szzeBir9h3g8QpFu5EoLc3jOLpMeWiIgrKzhFip2nAQgqtxxh5CrxSL Pn5WZPC8lnmR0n+yr+mG6V6ZEaFbea2+dM1kqPJUT4w+mu/jvu0y/Bib7sK6s9EcBkE8 HptggjIJrTe6H9iZZTSmPD6dsXTdJXu/TodlACGep6k5+cf/yvq2vZteRjV4whSCqptZ emInILgQP6PPIxN9e5tHDI+/c7ATvRktLOMRnQxVYYee85hZs4Zacqp4Own4EB9UWQhl lh+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+F36Qtp9KNZlJRbFfbQN1eq8EHq+227/7sfzGGclHLw=; b=EJYvk2mP9uazVEfYTJtif2fjR/AbcaaTsINWf/a1wHKQ27QcYOAYOJBrcp4L3UAokH v0h5UzqK88brIbnULMYeHExk90RtyNhWM62nc+rn53vwdE4tluf07N6rfAzk0O9S8Ca4 jpG7h1OC9nNWzDWr5odWeVMUvdumT3aWDZNyvvWtCnpr1Gi98DnGfq76th5PfOsj6+7d w9zEuKD2nwew1ZMkr2szuZiEBwvw9IqZJqh4j8u9r1NvPRRplZZeJ2ABE1EgHtwHmU9e U1Fy3tvViRxaSwB6QGlLlM8ciG6ScGbb1UmdOS25pzKeOuxSccUtbSJVzB8xJaW1Cyzm s9pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=VblDbKsZ; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id b6si2691531pgq.465.2019.06.13.02.44.06 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:44:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=VblDbKsZ; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+F36Qtp9KNZlJRbFfbQN1eq8EHq+227/7sfzGGclHLw=; b=VblDbKsZb0RRpnPdAvevOdbtuG 06yzYUmtWkiIPsoP1nmvo3AnrsDTuJovv6fNdum1MQwQKL25pb99SXJvc4gW0o62hlT7lLlTc/WjS K8qZKqiBN5WxofN6jGW7fAo3QUQf+dfuCfyvrfo4N272eB6mZoLfEfgv+BoGYRDNyl7Vb5xEuzWlM N6FMty3/n4xFBrIv2BT8kRH14dLL54XD4q2x0fsA6G1rQEvtBsX62S7CCnV4Mt/JdWcLV2XjWf64q xbmSBMtbYVIv7Cq/AJJH58RKU1ONXDRSyMYUcP30T1sQI1wMywIlngAo880SbnoVdXJORn4vkMSFl G7SCcZbA==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMH5-0001qr-IT; Thu, 13 Jun 2019 09:44:03 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/22] memremap: provide an optional internal refcount in struct dev_pagemap Date: Thu, 13 Jun 2019 11:43:15 +0200 Message-Id: <20190613094326.24093-13-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP Provide an internal refcounting logic if no ->ref field is provided in the pagemap passed into devm_memremap_pages so that callers don't have to reinvent it poorly. Signed-off-by: Christoph Hellwig --- include/linux/memremap.h | 4 +++ kernel/memremap.c | 60 ++++++++++++++++++++++++++----- tools/testing/nvdimm/test/iomap.c | 9 +++-- 3 files changed, 62 insertions(+), 11 deletions(-) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 75b80de6394a..b77ed00851ce 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -88,6 +88,8 @@ struct dev_pagemap_ops { * @altmap: pre-allocated/reserved memory for vmemmap allocations * @res: physical address range covered by @ref * @ref: reference count that pins the devm_memremap_pages() mapping + * @internal_ref: internal reference if @ref is not provided by the caller + * @done: completion for @internal_ref * @dev: host device of the mapping for debug * @data: private data pointer for page_free() * @type: memory type: see MEMORY_* in memory_hotplug.h @@ -98,6 +100,8 @@ struct dev_pagemap { bool altmap_valid; struct resource res; struct percpu_ref *ref; + struct percpu_ref internal_ref; + struct completion done; struct device *dev; enum memory_type type; u64 pci_p2pdma_bus_offset; diff --git a/kernel/memremap.c b/kernel/memremap.c index 5c94ad4f5783..edca4389da68 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -83,6 +83,14 @@ static unsigned long pfn_next(unsigned long pfn) #define for_each_device_pfn(pfn, map) \ for (pfn = pfn_first(map); pfn < pfn_end(map); pfn = pfn_next(pfn)) +static void dev_pagemap_kill(struct dev_pagemap *pgmap) +{ + if (pgmap->ops && pgmap->ops->kill) + pgmap->ops->kill(pgmap); + else + percpu_ref_kill(pgmap->ref); +} + static void devm_memremap_pages_release(void *data) { struct dev_pagemap *pgmap = data; @@ -92,7 +100,8 @@ static void devm_memremap_pages_release(void *data) unsigned long pfn; int nid; - pgmap->ops->kill(pgmap); + dev_pagemap_kill(pgmap); + for_each_device_pfn(pfn, pgmap) put_page(pfn_to_page(pfn)); @@ -121,20 +130,37 @@ static void devm_memremap_pages_release(void *data) "%s: failed to free all reserved pages\n", __func__); } +static void dev_pagemap_percpu_release(struct percpu_ref *ref) +{ + struct dev_pagemap *pgmap = + container_of(ref, struct dev_pagemap, internal_ref); + + complete(&pgmap->done); +} + +static void dev_pagemap_percpu_exit(void *data) +{ + struct dev_pagemap *pgmap = data; + + wait_for_completion(&pgmap->done); + percpu_ref_exit(pgmap->ref); +} + /** * devm_memremap_pages - remap and provide memmap backing for the given resource * @dev: hosting device for @res * @pgmap: pointer to a struct dev_pagemap * * Notes: - * 1/ At a minimum the res, ref and type and ops members of @pgmap must be - * initialized by the caller before passing it to this function + * 1/ At a minimum the res and type members of @pgmap must be initialized + * by the caller before passing it to this function * * 2/ The altmap field may optionally be initialized, in which case altmap_valid * must be set to true * - * 3/ pgmap->ref must be 'live' on entry and will be killed at - * devm_memremap_pages_release() time, or if this routine fails. + * 3/ The ref field may optionally be provided, in which pgmap->ref must be + * 'live' on entry and will be killed at devm_memremap_pages_release() time, + * or if this routine fails. * * 4/ res is expected to be a host memory range that could feasibly be * treated as a "System RAM" range, i.e. not a device mmio range, but @@ -156,10 +182,26 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap) pgprot_t pgprot = PAGE_KERNEL; int error, nid, is_ram; - if (!pgmap->ref || !pgmap->ops || !pgmap->ops->kill) - return ERR_PTR(-EINVAL); + if (!pgmap->ref) { + if (pgmap->ops && pgmap->ops->kill) + return ERR_PTR(-EINVAL); + + init_completion(&pgmap->done); + error = percpu_ref_init(&pgmap->internal_ref, + dev_pagemap_percpu_release, 0, GFP_KERNEL); + if (error) + return ERR_PTR(error); + pgmap->ref = &pgmap->internal_ref; + error = devm_add_action_or_reset(dev, dev_pagemap_percpu_exit, + pgmap); + if (error) + return ERR_PTR(error); + } else { + if (!pgmap->ops || !pgmap->ops->kill) + return ERR_PTR(-EINVAL); + } - if (pgmap->ops->page_free) { + if (pgmap->ops && pgmap->ops->page_free) { error = dev_pagemap_enable(dev); if (error) return ERR_PTR(error); @@ -272,7 +314,7 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap) err_pfn_remap: pgmap_array_delete(res); err_array: - pgmap->ops->kill(pgmap); + dev_pagemap_kill(pgmap); return ERR_PTR(error); } EXPORT_SYMBOL_GPL(devm_memremap_pages); diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c index ee07c4de2b35..3d0e916f9fff 100644 --- a/tools/testing/nvdimm/test/iomap.c +++ b/tools/testing/nvdimm/test/iomap.c @@ -104,9 +104,14 @@ void *__wrap_devm_memremap(struct device *dev, resource_size_t offset, } EXPORT_SYMBOL(__wrap_devm_memremap); -static void nfit_test_kill(void *pgmap) +static void nfit_test_kill(void *data) { - pgmap->ops->kill(pgmap); + struct dev_pagemap *pgmap = data; + + if (pgmap->ops && pgmap->ops->kill) + pgmap->ops->kill(pgmap); + else + percpu_ref_kill(pgmap->ref); } void *__wrap_devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap) From patchwork Thu Jun 13 09:43:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991487 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 88D1414DB for ; Thu, 13 Jun 2019 09:44:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7672028B11 for ; Thu, 13 Jun 2019 09:44:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69EA128B1F; Thu, 13 Jun 2019 09:44:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E688028B11 for ; Thu, 13 Jun 2019 09:44:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBE096B026C; Thu, 13 Jun 2019 05:44:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B48456B026D; Thu, 13 Jun 2019 05:44:10 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C15A6B026E; Thu, 13 Jun 2019 05:44:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 5EA0F6B026C for ; Thu, 13 Jun 2019 05:44:10 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id x9so14099547pfm.16 for ; Thu, 13 Jun 2019 02:44:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=wPaWdCIL9H03r8HySQVqow//0jNnHtt/N2MgQJISZ8s=; b=hUY7l1Ez0GPLYc1FJ4M3QLOLDvGueReGdPDq9qbZu20m+olwHTTEtz5E+y0ylm+/nd m0uEueFbOFMFppXdGke2LNYyI9uD8rb6oar6AqeZtl2CAfqrRCutsjH7lah20paYrFed gtyvkktggkqu8ULbeVcl5fvJDwZ5a58VW+chZK1yPHGYhgIXIwaDrgCgXwAw3bETR1Q2 9iUip8bVnBVJVsFktoF6LOh6kfNZbStMu5UTBVoyWWr/EU5BsVsD1aD69BPHgQF9fr0O Zoab0e4u4yTBsFdwLi7zB35p+m2KOf2e1Bmt94HkernlaXXlzSONjI4BvT7fIDhk22m+ +tHg== X-Gm-Message-State: APjAAAXxImFk2XNG8sM2mavCqTHdQ8EwlCiarM/r2NhCiY2u4ZsgKqbp 20frSz6BmmjZ7QpkXwYN+u0RAWO2iqDIjFT6DhOAK0YGW3Sz1nNhnCtVaxPTF/PMp6q9bhbY1+F 3sy4esbm22WluVhTJTaFeluRD4KYkA8qUVgNOdCJnVSRIFFD4mmvC49j9IukJkHc= X-Received: by 2002:a17:902:2bc5:: with SMTP id l63mr86762936plb.221.1560419050048; Thu, 13 Jun 2019 02:44:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFvD6rufV2CfIrA1IRttKsjbRzMac3GjVSH2voefy+brMu6tTlBhl+Dm/RhBWgOkMhZqQF X-Received: by 2002:a17:902:2bc5:: with SMTP id l63mr86762843plb.221.1560419049243; Thu, 13 Jun 2019 02:44:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419049; cv=none; d=google.com; s=arc-20160816; b=jK57diFBAZO+zKqbHDAGrxENXMs/p0y4XSSZdQ/rORVicLlE/+5OnvmFckSFclNl+s QovPCnDiMLZnifT9RmxKrvcoHw/9YZGeiinZ8dhWOhwsmuZ2b3iNgWbnicfLNBmIl2df IXAdBUpS9+FeKxu1ioKiET2w1QSI9TjDxa3Da2yB5Hu657RF8MfCkIPrtXdvqYHK/RPw 2M146RaKjdfMarPDNBgecTILM38csKHcY2OwBe/42GnBFzcaWY1zP1+Q4phdqoFBv3yC 4q6jlR+mbZO6sPlgYR24O79r0F1aghf0NH0Dlvf0XhAljQ+JnqGsSLG5Kk3RG3P883TI ZLBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=wPaWdCIL9H03r8HySQVqow//0jNnHtt/N2MgQJISZ8s=; b=lbh6RhG5xxDql/qkmBApWW6BpAKNWZIok5//rOmomN1nAbshQcrNUzk68Y53cF2kuW bPsjoTFLWO4JEvxfScWkzAi+46ZOI1EdVhgyua5MxbV6RRQL+F05WS3YqxfGBq5dFR16 2KooHPOXVirqAtTEkIC83aYydN5P50MlVQ9mWzD03A/CGp3nzPjLKuabXBFI0Hp9fhwk lnCxrcIPKiO3yHMTjaydpCoJzgNNrDkXziJTWYko2NAxtgEizRqSq+B6miv6ED6A5LR7 mDVFSWu+oEc5Y5TeLtYavKW8BVtOl/s78eAE0+M9x8pB4jBBRdLxG1bhGSTVbkKaod0n lqJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=avKv6xwb; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id n11si2948640pgi.27.2019.06.13.02.44.09 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:44:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=avKv6xwb; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wPaWdCIL9H03r8HySQVqow//0jNnHtt/N2MgQJISZ8s=; b=avKv6xwbjUwP5JnIfmut07FD4E gJPJZ8ZQmWlKJYjAzKHwT0cqU9A36XKIAMssk8gQpq3IhjxldclzNcvSF1zNcI9FEe5J4DrlwynxU BOkf4ZqVPr5yBB+WsSzI5BaGpY9hBxi7Qh2og5bCGOdVDDRSHg1MVKNLMpKkG5YCrQBvTdqcEqdjK BIBwnNK0AKvH4MNtye6T+KQS+ymNK5QfOcLa6VAmU5b2i3i5m5oX14CGYl5bXnH+Ld0nP0t5HEDau tkrt/zZv4j5UrYFMV46EwV5BMV6zPYhoYxnhEc4quUvclTo0SfZwBQ7d4I6wYboawBdk9qACJlW6E gRpSlcmw==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMH8-0001rw-At; Thu, 13 Jun 2019 09:44:06 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/22] device-dax: use the dev_pagemap internal refcount Date: Thu, 13 Jun 2019 11:43:16 +0200 Message-Id: <20190613094326.24093-14-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP The functionality is identical to the one currently open coded in device-dax. Signed-off-by: Christoph Hellwig --- drivers/dax/dax-private.h | 4 --- drivers/dax/device.c | 52 +-------------------------------------- 2 files changed, 1 insertion(+), 55 deletions(-) diff --git a/drivers/dax/dax-private.h b/drivers/dax/dax-private.h index a45612148ca0..ed04a18a35be 100644 --- a/drivers/dax/dax-private.h +++ b/drivers/dax/dax-private.h @@ -51,8 +51,6 @@ struct dax_region { * @target_node: effective numa node if dev_dax memory range is onlined * @dev - device core * @pgmap - pgmap for memmap setup / lifetime (driver owned) - * @ref: pgmap reference count (driver owned) - * @cmp: @ref final put completion (driver owned) */ struct dev_dax { struct dax_region *region; @@ -60,8 +58,6 @@ struct dev_dax { int target_node; struct device dev; struct dev_pagemap pgmap; - struct percpu_ref ref; - struct completion cmp; }; static inline struct dev_dax *to_dev_dax(struct device *dev) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index e23fa1bd8c97..a9d7c90ecf1e 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -14,37 +14,6 @@ #include "dax-private.h" #include "bus.h" -static struct dev_dax *ref_to_dev_dax(struct percpu_ref *ref) -{ - return container_of(ref, struct dev_dax, ref); -} - -static void dev_dax_percpu_release(struct percpu_ref *ref) -{ - struct dev_dax *dev_dax = ref_to_dev_dax(ref); - - dev_dbg(&dev_dax->dev, "%s\n", __func__); - complete(&dev_dax->cmp); -} - -static void dev_dax_percpu_exit(void *data) -{ - struct percpu_ref *ref = data; - struct dev_dax *dev_dax = ref_to_dev_dax(ref); - - dev_dbg(&dev_dax->dev, "%s\n", __func__); - wait_for_completion(&dev_dax->cmp); - percpu_ref_exit(ref); -} - -static void dev_dax_percpu_kill(struct dev_pagemap *pgmap) -{ - struct dev_dax *dev_dax = container_of(pgmap, struct dev_dax, pgmap); - - dev_dbg(&dev_dax->dev, "%s\n", __func__); - percpu_ref_kill(pgmap->ref); -} - static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma, const char *func) { @@ -442,10 +411,6 @@ static void dev_dax_kill(void *dev_dax) kill_dev_dax(dev_dax); } -static const struct dev_pagemap_ops dev_dax_pagemap_ops = { - .kill = dev_dax_percpu_kill, -}; - int dev_dax_probe(struct device *dev) { struct dev_dax *dev_dax = to_dev_dax(dev); @@ -463,24 +428,9 @@ int dev_dax_probe(struct device *dev) return -EBUSY; } - init_completion(&dev_dax->cmp); - rc = percpu_ref_init(&dev_dax->ref, dev_dax_percpu_release, 0, - GFP_KERNEL); - if (rc) - return rc; - - rc = devm_add_action_or_reset(dev, dev_dax_percpu_exit, &dev_dax->ref); - if (rc) - return rc; - - dev_dax->pgmap.ref = &dev_dax->ref; - dev_dax->pgmap.ops = &dev_dax_pagemap_ops; addr = devm_memremap_pages(dev, &dev_dax->pgmap); - if (IS_ERR(addr)) { - devm_remove_action(dev, dev_dax_percpu_exit, &dev_dax->ref); - percpu_ref_exit(&dev_dax->ref); + if (IS_ERR(addr)) return PTR_ERR(addr); - } inode = dax_inode(dax_dev); cdev = inode->i_cdev; From patchwork Thu Jun 13 09:43:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB04276 for ; Thu, 13 Jun 2019 09:44:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B892228B11 for ; Thu, 13 Jun 2019 09:44:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD33228B16; Thu, 13 Jun 2019 09:44:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9BA828B15 for ; Thu, 13 Jun 2019 09:44:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 618916B026D; Thu, 13 Jun 2019 05:44:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 57C946B026E; Thu, 13 Jun 2019 05:44:14 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F6626B026F; Thu, 13 Jun 2019 05:44:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 0070A6B026D for ; Thu, 13 Jun 2019 05:44:14 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id 59so11601271plb.14 for ; Thu, 13 Jun 2019 02:44:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=j5NF6MNZYGnulaE88E08I95IgTMRhrbK2u/HLXeuvXI=; b=unE9ZDX8yCR7riuOEuoidQGSmIrjWeXzyo0xPMUYbX0DyHQ6WeQVFcpeHEYaGPw49n OD+NVRgOayGD6GoXuc6WwEa2hcD9LkpEnc1qzwa3DTABuE9Af2bXv35HPO3pwhd8R99U Fekwg0Krbar2XOmRRcju+YLBcoPJNYZznPvLIxMndrrif1qoPwZf1u04IhV1AmUhAQU1 AvBr4/PiD0wJOfS5pyDMfn9fuCFB0n3Jpp7GCTgsi94hG3oZ039IYaqhwI4oTpLMtwEV IwGrN4L1C1jrXzmAY218uZrcPgW3hqrHEKBanGs6LOq94UIsszZ2A6p0uI54iVPCgZIu jlOQ== X-Gm-Message-State: APjAAAXe5h/Cz5n8Awn7KCFeJ3Wm5/NmtjZlTIWmq2ghu6Xab3PJZxjc BibeMgDSjxsqGKHbBFrDHCHvr8RtJAfw1NJgK7VePafA6qbPueIMxvQ+NyOQyjhPgYCfXbpX0wV R9v2vwNL1YDhO68mu0friqQX9xDVwk5o7YDRBQHfFy6adE47grXWr2Z0hv5drKOQ= X-Received: by 2002:a63:f95d:: with SMTP id q29mr23489510pgk.368.1560419053493; Thu, 13 Jun 2019 02:44:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyReFvVcK2OolvqCtIMr52biS1hnktu+eWU1jVJjweQacRuRJ3nq9cYDjS81UYofMhR9FH X-Received: by 2002:a63:f95d:: with SMTP id q29mr23489401pgk.368.1560419052247; Thu, 13 Jun 2019 02:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419052; cv=none; d=google.com; s=arc-20160816; b=iwOks5kHrS33MfaDdYMtynU5U27TZaS27guKfLoxcii5IsD/LQWqY1rqqiV/Q/1DQP 5YqbfJfNYhdZJkj27NNj3SCf7R5TdJPSKqh5nyKtoUxGMZqp3Iiigqz08Jt6YebKgDdH AtwoMNGvuLSK2d+IzNXSJT5EBcbSaQI9ENsI5CynGPDURdKQf7UG5yjthIsq0Quj2d2b f8Rxt9dOl+fbeSsBI7SEE69E3FPCtDheZVWh8oOaIou4SownnFH7xjMny8TVnAWeyyFL iP7pIY7UQf5ZV1CEs1+IgV2XXIexmJnwbHD8Yr3K/xNxaigoB+fPvWFPnU8LnHbdp4c+ wFgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=j5NF6MNZYGnulaE88E08I95IgTMRhrbK2u/HLXeuvXI=; b=H5D9K132RhWRNqFXpqY3Vmp+CKeKtOWbZ3FukPHr6aEd95Kpvf/3Uu4rTcaEC6SC91 RqWaB/TcdtZOlrz8KO5tJlYQ8WOQ4xVz+O/rGS0JWj/kWGlxqS4S5bKXyHL7JeN/jucL DGtqvLsYk1Q9DCtoz0/vZul7RjSaX90ctZntcfLgO9n1ENBfjLe69VvMPiWqK7wgU6lC ReQCn4udMwPpKwgPVBS/0mtH9mNI+w9Vlvw49zZL0gYi5N30R0sH8Np9ae94qX6KYoE9 ZGQQiACxx4pj1e3IQj+ulzGltynmVcF+FpIVNkMT1RoW3ZFjykUvoHUbAOteq3UynGYQ uCXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Ac6u1kwc; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id q7si2656229pgp.245.2019.06.13.02.44.12 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:44:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Ac6u1kwc; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=j5NF6MNZYGnulaE88E08I95IgTMRhrbK2u/HLXeuvXI=; b=Ac6u1kwcs5Qa+uMIZP26VzBqh1 oBc3B77m8cKbTSEIFPsUyGP6G3FUk3c8E+xk2HZWozHXtClsdTiu2RALXiDqDY43JEV1DWM9l1/Du GMJh/5UGQizxUaLO1dcsKhrvI14c20vJPjJ7jreMh9910F1WY99XI00fTC0entGgeaSQZLCs86xfW 52vn6lM51A13Btvh++2O9/BZ39MqDd/CCOhxXr/jPAHEUNdYFrNi3zls/lufPVZvRZbXCwxBGi+w3 avf91FXeX0uy9xYlvIoYY88p2jQx1BQy8vySwJ/yFSSrfYf9r3j/UGnyKprb+nbDw7XgChANaBwwz q7RSMx1Q==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMHB-0001sa-6c; Thu, 13 Jun 2019 09:44:09 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/22] nouveau: use alloc_page_vma directly Date: Thu, 13 Jun 2019 11:43:17 +0200 Message-Id: <20190613094326.24093-15-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP hmm_vma_alloc_locked_page is scheduled to go away, use the proper mm function directly. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c index 40c47d6a7d78..a50f6fd2fe24 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dmem.c +++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c @@ -148,11 +148,12 @@ nouveau_dmem_fault_alloc_and_copy(struct vm_area_struct *vma, if (!spage || !(src_pfns[i] & MIGRATE_PFN_MIGRATE)) continue; - dpage = hmm_vma_alloc_locked_page(vma, addr); + dpage = alloc_page_vma(GFP_HIGHUSER, vma, addr); if (!dpage) { dst_pfns[i] = MIGRATE_PFN_ERROR; continue; } + lock_page(dpage); dst_pfns[i] = migrate_pfn(page_to_pfn(dpage)) | MIGRATE_PFN_LOCKED; From patchwork Thu Jun 13 09:43:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991495 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3A1614DB for ; Thu, 13 Jun 2019 09:44:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF6EB28B11 for ; Thu, 13 Jun 2019 09:44:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D32DD28B16; Thu, 13 Jun 2019 09:44:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37CFE28B11 for ; Thu, 13 Jun 2019 09:44:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8156B6B026F; Thu, 13 Jun 2019 05:44:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 79FD26B0270; Thu, 13 Jun 2019 05:44:16 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 616EE6B0271; Thu, 13 Jun 2019 05:44:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 1F5086B026F for ; Thu, 13 Jun 2019 05:44:16 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id 5so14093408pff.11 for ; Thu, 13 Jun 2019 02:44:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xYfBteKZe/e5Ckife8ohrecFQV6hfjj2YQprkCVN138=; b=XvmL+oFaNZeNJTQkin5AZJpSxBSiBCq4gvRZeUDSLhsWZQSxvIvrPZxWtONHbqFMEf bH/F2uiq3CnG6p/1wYBkwNJGxTe+vcwLn/XRIe5sW1ncp4raRTc6Yi9ZWeq8pYiVzSgx TCVf5kAf+L6dU5S1CX6IAqv2XM34BAlkJzUJKRBAf9lbTYO31fhL3pkKJ7fWR67D0xJl 13GX9P9S3bgUhsjh4jTemRS2FXPD8dHPXoDNJhAnoSCPtv1NJnOxPVmcBjBijUgh3buz gTh6ol1VU0kPmiu95tb4VGiQ89aQHG1IroiAGerFAtd/DK1xMeZEK6ZUNj3aPA0xtqZ9 BAEw== X-Gm-Message-State: APjAAAXfvSfZ5ETiDkzBD8/kgD0xIDofpQzgcppSApjxM2spg9B13wJi D21GWCKN16OYbCuzhXAL3R0DuA6Bt2F59WVrXEbZS0G2vHDCpbzSdz283WafqWZQtMMIE6RZ749 S0bMwOCUM85jbfUJc4xOefamwNNqj1GKwGBkhTh7rhxhxro7M00ftZa0jVg01hTQ= X-Received: by 2002:a17:90a:8a91:: with SMTP id x17mr4352725pjn.95.1560419055769; Thu, 13 Jun 2019 02:44:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyydGgyi3jmCjmZPf/ZPEVnnGFHjefo/DocGzpyYvBJ1SxqhP6p6cTkHqhh09ZMFQ8OcQA0 X-Received: by 2002:a17:90a:8a91:: with SMTP id x17mr4352618pjn.95.1560419054822; Thu, 13 Jun 2019 02:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419054; cv=none; d=google.com; s=arc-20160816; b=gPt1oap7E5b3aG2AQJ5UPOFk0sw65SyD5bhaHe3U8Jgm9J1ZlxOzSrBcXwiabiHYVY EDiRVCpm0h7o2QZ5lWtbFN816458t8cbLYsMF0NMcKQ+otlPAeHy/VxVR1Pa+nyXBLFk PSuyKQLuQ6k4kih39NMp11YgPc0urJNynYaoBldIjrdsoxabOg5gIEjejvgy+dw6Juib KirINW+iNf+IzhJXUiSEe6ysRfTahFZWmZyMjy/cZEVCVW+4A71mCtD/TPRaxgtWF2nw MzSKj2yhn3fv94A9To/6+HT8bwquiNJaGCALWCp7Uk2gIiFnB/ukjnOh7ymAguOnGPBt 6qjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=xYfBteKZe/e5Ckife8ohrecFQV6hfjj2YQprkCVN138=; b=IBDC87YRZKURNGMGLLWZajx9qe4foGVgC5/L9T8V85dSaOLXyG13Wm3oBaEJRpIT0Y AEJ4ddp5hZlsLg2i6xuUpA1EtL1qX97kKdHSPT01OUzKmeADtDqQabOzrY16lKHO0DQI 0+lJgvHb4qn2v7HRFTMSsiyzucB8meyT/VWAYTl9X0A9ASG2HJP2iadTSqvpfcjB+EjQ xKrBgrDPB85242uBMXYOmvdx5922C6HOrsSgls2ieZnHwLX2ghRPNDUqNJdCG7j2IX4o KD/PVttCS1MFtO+DRKOuezVWGq6UgVXQwK5D8EMD8IjYT9PeTNvhkAfc6VDE8tR9X4R7 IKkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=FHc5fDnC; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id l10si2688248pgk.276.2019.06.13.02.44.14 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:44:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=FHc5fDnC; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xYfBteKZe/e5Ckife8ohrecFQV6hfjj2YQprkCVN138=; b=FHc5fDnCPAlG2X1P5hqmN6BAee WHf3iENBPRs8zYQpDQqPHSt6VFl+W/mC4zAPs7QsvZ5+2/s2LsCURy9tSKz1/q4hFYNZylr+Oqv5B zjYfm+hFE3TcyvD6fP6qk2GNuODPVs4jZRq81oI3rTvaACEI8Km27qsiPAX8JsYZb4lHLwTHE03tG 9d6udUEpc2xY47EFvzzUdk14MpPcrfZ3EMMY7JNQPXp8Sy9a7L35wlI8DB7oV5VASIbgmY0nwXAu1 clBKVjIf19N93xjC8Ygkyyt70lJKIA3r2MZyU8I7YH4B8xSktOWIurHDeOMEjy+T3JRDHMXtyUE8W Q1zQJh1A==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMHD-0001tQ-VU; Thu, 13 Jun 2019 09:44:12 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/22] nouveau: use devm_memremap_pages directly Date: Thu, 13 Jun 2019 11:43:18 +0200 Message-Id: <20190613094326.24093-16-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP Just use devm_memremap_pages instead of hmm_devmem_add pages to allow killing that wrapper which doesn't provide a whole lot of benefits. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 80 ++++++++++++-------------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c index a50f6fd2fe24..9e32bc8ecbc7 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dmem.c +++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c @@ -72,7 +72,8 @@ struct nouveau_dmem_migrate { }; struct nouveau_dmem { - struct hmm_devmem *devmem; + struct nouveau_drm *drm; + struct dev_pagemap pagemap; struct nouveau_dmem_migrate migrate; struct list_head chunk_free; struct list_head chunk_full; @@ -80,6 +81,11 @@ struct nouveau_dmem { struct mutex mutex; }; +static inline struct nouveau_dmem *page_to_dmem(struct page *page) +{ + return container_of(page->pgmap, struct nouveau_dmem, pagemap); +} + struct nouveau_dmem_fault { struct nouveau_drm *drm; struct nouveau_fence *fence; @@ -96,8 +102,7 @@ struct nouveau_migrate { unsigned long dma_nr; }; -static void -nouveau_dmem_free(struct hmm_devmem *devmem, struct page *page) +static void nouveau_dmem_page_free(struct page *page) { struct nouveau_dmem_chunk *chunk; unsigned long idx; @@ -260,29 +265,21 @@ static const struct migrate_vma_ops nouveau_dmem_fault_migrate_ops = { .finalize_and_map = nouveau_dmem_fault_finalize_and_map, }; -static vm_fault_t -nouveau_dmem_fault(struct hmm_devmem *devmem, - struct vm_area_struct *vma, - unsigned long addr, - const struct page *page, - unsigned int flags, - pmd_t *pmdp) +static vm_fault_t nouveau_dmem_devmem_migrate(struct vm_fault *vmf) { - struct drm_device *drm_dev = dev_get_drvdata(devmem->device); + struct nouveau_dmem *dmem = page_to_dmem(vmf->page); unsigned long src[1] = {0}, dst[1] = {0}; - struct nouveau_dmem_fault fault = {0}; + struct nouveau_dmem_fault fault = { .drm = dmem->drm }; int ret; - - /* * FIXME what we really want is to find some heuristic to migrate more * than just one page on CPU fault. When such fault happens it is very * likely that more surrounding page will CPU fault too. */ - fault.drm = nouveau_drm(drm_dev); - ret = migrate_vma(&nouveau_dmem_fault_migrate_ops, vma, addr, - addr + PAGE_SIZE, src, dst, &fault); + ret = migrate_vma(&nouveau_dmem_fault_migrate_ops, vmf->vma, + vmf->address, vmf->address + PAGE_SIZE, + src, dst, &fault); if (ret) return VM_FAULT_SIGBUS; @@ -292,10 +289,9 @@ nouveau_dmem_fault(struct hmm_devmem *devmem, return 0; } -static const struct hmm_devmem_ops -nouveau_dmem_devmem_ops = { - .free = nouveau_dmem_free, - .fault = nouveau_dmem_fault, +static const struct dev_pagemap_ops nouveau_dmem_pagemap_ops = { + .page_free = nouveau_dmem_page_free, + .migrate = nouveau_dmem_devmem_migrate, }; static int @@ -581,7 +577,8 @@ void nouveau_dmem_init(struct nouveau_drm *drm) { struct device *device = drm->dev->dev; - unsigned long i, size; + struct resource *res; + unsigned long i, size, pfn_first; int ret; /* This only make sense on PASCAL or newer */ @@ -591,6 +588,7 @@ nouveau_dmem_init(struct nouveau_drm *drm) if (!(drm->dmem = kzalloc(sizeof(*drm->dmem), GFP_KERNEL))) return; + drm->dmem->drm = drm; mutex_init(&drm->dmem->mutex); INIT_LIST_HEAD(&drm->dmem->chunk_free); INIT_LIST_HEAD(&drm->dmem->chunk_full); @@ -600,11 +598,8 @@ nouveau_dmem_init(struct nouveau_drm *drm) /* Initialize migration dma helpers before registering memory */ ret = nouveau_dmem_migrate_init(drm); - if (ret) { - kfree(drm->dmem); - drm->dmem = NULL; - return; - } + if (ret) + goto out_free; /* * FIXME we need some kind of policy to decide how much VRAM we @@ -612,14 +607,16 @@ nouveau_dmem_init(struct nouveau_drm *drm) * and latter if we want to do thing like over commit then we * could revisit this. */ - drm->dmem->devmem = hmm_devmem_add(&nouveau_dmem_devmem_ops, - device, size); - if (IS_ERR(drm->dmem->devmem)) { - kfree(drm->dmem); - drm->dmem = NULL; - return; - } - + res = devm_request_free_mem_region(device, &iomem_resource, size); + if (IS_ERR(res)) + goto out_free; + drm->dmem->pagemap.type = MEMORY_DEVICE_PRIVATE; + drm->dmem->pagemap.res = *res; + drm->dmem->pagemap.ops = &nouveau_dmem_pagemap_ops; + if (IS_ERR(devm_memremap_pages(device, &drm->dmem->pagemap))) + goto out_free; + + pfn_first = res->start >> PAGE_SHIFT; for (i = 0; i < (size / DMEM_CHUNK_SIZE); ++i) { struct nouveau_dmem_chunk *chunk; struct page *page; @@ -632,8 +629,7 @@ nouveau_dmem_init(struct nouveau_drm *drm) } chunk->drm = drm; - chunk->pfn_first = drm->dmem->devmem->pfn_first; - chunk->pfn_first += (i * DMEM_CHUNK_NPAGES); + chunk->pfn_first = pfn_first + (i * DMEM_CHUNK_NPAGES); list_add_tail(&chunk->list, &drm->dmem->chunk_empty); page = pfn_to_page(chunk->pfn_first); @@ -643,6 +639,10 @@ nouveau_dmem_init(struct nouveau_drm *drm) } NV_INFO(drm, "DMEM: registered %ldMB of device memory\n", size >> 20); + return; +out_free: + kfree(drm->dmem); + drm->dmem = NULL; } static void @@ -835,11 +835,7 @@ nouveau_dmem_page(struct nouveau_drm *drm, struct page *page) { if (!is_device_private_page(page)) return false; - - if (drm->dmem->devmem != page->pgmap->data) - return false; - - return true; + return drm->dmem == page_to_dmem(page); } void From patchwork Thu Jun 13 09:43:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991497 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3B2276 for ; Thu, 13 Jun 2019 09:44:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1F8728B11 for ; Thu, 13 Jun 2019 09:44:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C67A328B17; Thu, 13 Jun 2019 09:44:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5271E28B11 for ; Thu, 13 Jun 2019 09:44:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8FF1D6B0270; Thu, 13 Jun 2019 05:44:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 860CC6B0271; Thu, 13 Jun 2019 05:44:19 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6177C6B0272; Thu, 13 Jun 2019 05:44:19 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 2A5D76B0270 for ; Thu, 13 Jun 2019 05:44:19 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id 71so229331pld.17 for ; Thu, 13 Jun 2019 02:44:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=AuQMTpcqJo62VjhPIKMCZhZk+h6e6THsOZ01qDGPkX8=; b=qONZHfzD19SWQCCIdo0LqtP11aOnmBvHfZJQAE7M6lEi+zc7rzKKuzwghVzWQ2vKXT 7zI9ogjVbMJfKiMBeAWY3Y3MVX+4tOqJY60xoTxauMEJrG+1wV90O9NncGrPEFSnHyD6 zxPWVedX5VXAMDrhcuQxKtYYU3za+whqHkAX/h09/Cu7B5tSWfJWf3oXhZRxCBQLjstz nJr5BY3OvKt6Mcc1Jh7YdvSIJO2JqWwJhx0qTzEH2ZZRD971ROBbNLaUFvIZe4QWC9KO oISCOc9MkrOSWmzKb4YFI6ohPS9m7aj9NbA5uP/nz5EAnEHgcCbivENYQFB5Js0lmSMx lQGw== X-Gm-Message-State: APjAAAXoZIx0ekd5q3fx3FPz7d6nbFawD2Tr1EQufIOVIWIgppemJIa5 NR5t4u8jP7IebQMthR+3o2I6h2fURgt11KWIlr/O1Pr7CdJ+/pztqu93DVQvgbqRUDSAH3gfZc9 h1xV6f4ZoFvH4InwYPa41m9g/XrG3NYRW5xOoovrpVbPETRfzzWIF+KXB0/BNWVM= X-Received: by 2002:a63:af44:: with SMTP id s4mr29593710pgo.411.1560419058763; Thu, 13 Jun 2019 02:44:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyjqcaEUiMTXYZY2sIvdUvuOFIXR2BbAJRXutdilVlZNo64ZZVR17AEm2W4gHtC0Qba7+N X-Received: by 2002:a63:af44:: with SMTP id s4mr29593628pgo.411.1560419057927; Thu, 13 Jun 2019 02:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419057; cv=none; d=google.com; s=arc-20160816; b=d28jkLosv979n7+i7NlTHayG4dxLHPKbk+UH01TWijY4S96wj13z/q5tt/Aqwueu99 ZcslIM6dLDg6HKKYlx8obi05J1Qe9I89+3+wnU0zYqiSZAL7JpwcHKbhMvnyzt4Bq5q8 ZcMiMOEkgJDqbn9sWa0oTZVkZ3yyM/7nuMomDCZFeerUCu60PE1h6IWPUsD2Evp+dQPi LPXvL+22Q9cpXpmArxC1YJ1f6dfFvR6xx3J9S4IVppqQKbIceGmKY+2WdPOOIvm6WJPK BheRD1wblk1mEtj2uQ6zx/aLB5vP9uK4i9znfMk1t2iHvm8asdcgLQfsYvMLZdanHDmR 8ziw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=AuQMTpcqJo62VjhPIKMCZhZk+h6e6THsOZ01qDGPkX8=; b=0h+Dp0mKUu/Lrom38bTNbCJIo+DV5pWjP5jkRfLD1QagnF1pSRFbOIPvoVEm/s2yuZ Lp4SSHmkGHjdtgw+wMvmbBuEFfHiXrcdQlT/p1rDBCFRtV9uWAtnebUBGmOkRAa5/GEv /feLf1sPepkMPi5nrmQ+7e2oBVBnf2pNqAh2pl1tmaUmhrg9Vnth1Ohlx1ifu9nC9pDb XuNrvSlcuZwvIlT/EUqmPgmOR4ja0COoaM1MsyHlEOxeeRc1W2PW2QKDxWZbOsz/3x7c EydBdflAqZ4jlVQI43TUexqXWxvY0xeT5y12j1s0hEAZ15J4zLrKi4cC2+O6O7TeEbRP 1sRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=rUn+qQEr; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id a22si2492987plm.343.2019.06.13.02.44.17 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:44:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=rUn+qQEr; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AuQMTpcqJo62VjhPIKMCZhZk+h6e6THsOZ01qDGPkX8=; b=rUn+qQErmwhgGijTtCS+CPfQfX C6JSAQ1wYIYTWBE1sk8wIkEnTQn0lkCbB5R+ffY6ISa5sjGbOSw0+7bEyC7m+Qij4zcVeeFUifawM Un1Dx3C+QCWSrqmn1w2RLX0JpvUup817a1QufBRSu4NPSt1SswH6b9wJA03REDNoLrDPDc5TclJrr xEr8kX7Hqw6gfUzged3ZKit4eyUFtG+CmH6acz3g27hPRgnBplRhZJoO5JRbm+/AUSeySbU2/KzoK i4uKJlLh0eU/1N6Uuc+zL/fMMHvYHpiCNP22jqmNO+zDGCudBxJG6+3+BI8MnXE1HOXlORblkJtCC FLHmz0jw==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMHG-0001u9-ME; Thu, 13 Jun 2019 09:44:15 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/22] mm: remove hmm_vma_alloc_locked_page Date: Thu, 13 Jun 2019 11:43:19 +0200 Message-Id: <20190613094326.24093-17-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP The only user of it has just been removed, and there wasn't really any need to wrap a basic memory allocator to start with. Signed-off-by: Christoph Hellwig --- include/linux/hmm.h | 3 --- mm/hmm.c | 14 -------------- 2 files changed, 17 deletions(-) diff --git a/include/linux/hmm.h b/include/linux/hmm.h index 3c9a59dbfdb8..0e61d830b0a9 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -553,9 +553,6 @@ static inline void hmm_mm_init(struct mm_struct *mm) {} #if IS_ENABLED(CONFIG_DEVICE_PRIVATE) || IS_ENABLED(CONFIG_DEVICE_PUBLIC) struct hmm_devmem; -struct page *hmm_vma_alloc_locked_page(struct vm_area_struct *vma, - unsigned long addr); - /* * struct hmm_devmem_ops - callback for ZONE_DEVICE memory events * diff --git a/mm/hmm.c b/mm/hmm.c index ff0f9568922b..c15283f9bbf0 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -1293,20 +1293,6 @@ EXPORT_SYMBOL(hmm_range_dma_unmap); #if IS_ENABLED(CONFIG_DEVICE_PRIVATE) || IS_ENABLED(CONFIG_DEVICE_PUBLIC) -struct page *hmm_vma_alloc_locked_page(struct vm_area_struct *vma, - unsigned long addr) -{ - struct page *page; - - page = alloc_page_vma(GFP_HIGHUSER, vma, addr); - if (!page) - return NULL; - lock_page(page); - return page; -} -EXPORT_SYMBOL(hmm_vma_alloc_locked_page); - - static void hmm_devmem_ref_release(struct percpu_ref *ref) { struct hmm_devmem *devmem; From patchwork Thu Jun 13 09:43:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991503 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6BBBE76 for ; Thu, 13 Jun 2019 09:44:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5829828B15 for ; Thu, 13 Jun 2019 09:44:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BDEE28B17; Thu, 13 Jun 2019 09:44:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6426F28B16 for ; Thu, 13 Jun 2019 09:44:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A36A76B0272; Thu, 13 Jun 2019 05:44:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9E9806B0273; Thu, 13 Jun 2019 05:44:23 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 750D16B0274; Thu, 13 Jun 2019 05:44:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 356FB6B0272 for ; Thu, 13 Jun 2019 05:44:23 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id j21so14099429pff.12 for ; Thu, 13 Jun 2019 02:44:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=bHeNfTwD4XAIS0eLeLiZcWglvOw+19Z/Sq7aWx7Y048=; b=LlVhpOAhtMRh7k/XusKW1u69O/HDt1mX9nFhYsjYullevexykT5l/G65vi+evOTy1U AdBG3+AdKAZXvINFBeIdObRasPDl9TwaZtg3NTpfQ3+8U2DuTayKwgp1Ehwi6Rd2Z0Is ICQ1q20fkE0D6yCA/qyMMCZClK1PwHz7ycnyH+853st2CpH+1MgKqFkZ+nNGM9foePwG vztLwTqm/ZCoWcL6ktoDDUNT6ySI31vSLiM7iEjLK13PfBXUxj7to39dxY4fybcUb9YA in43NFra34FBqd+4TuH4N42KXlp2GF5bjRej4i8NHo0KT38Zo9xoEh6GJaUSNP1rfvrB Y+Hg== X-Gm-Message-State: APjAAAXluJ1Gm49fIJOcXpwmZQsNRIjKXbHOBj9MPuJG9ZWRcfvfuQZx 4PS7kYbJHjSSWg/Bj8QFGqMydumY9fx8GegmNkzX/Gdo6lirZlappkN2yzFxYw2My2bhxYHvzSi H/PP05S79ZFMVfOfcYKvkqDsnScD+l+sAgyOy6HzJfBLCdv8XHwYTLkwctnuzCUM= X-Received: by 2002:a65:40cb:: with SMTP id u11mr6661578pgp.333.1560419062740; Thu, 13 Jun 2019 02:44:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5v+363VnDcRr3qDG0gIqr3IrYwLNo197/K8A56BsSPb6AddepQBVXtoNqMDXMNHy2Jt2y X-Received: by 2002:a65:40cb:: with SMTP id u11mr6661428pgp.333.1560419061267; Thu, 13 Jun 2019 02:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419061; cv=none; d=google.com; s=arc-20160816; b=q4k7qTvRItFshXPIYj3OL8/5v9ChcQDVMLZy2cc/Yp7tyQmHjYDYJvw5AD5LsEIsbO wBRTz99avGJ3AMZpWdSyGM/45/mXJ4qyLN6AuLDnykpxrGh+C5yg0/rBdKIoAxfA9PR0 57kospFv2lCK33OjgGYHx6LVI+zHpoNH3solRdVN2+umNctlbWp2s8PpxFN11xb58e6m mgfGVpOcxZsiUXhLnxgjRvZyHn6TMw/SB5/rfbquv83DTBckvLBTo5rTcPgVcVLBQYiJ 0NnDXM2+wp8aDpKJBh5LSc9smXSivJXBnEIYB/GhBYXrxcuBh7Egiplk8M+0z5/oqhFF 6N1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=bHeNfTwD4XAIS0eLeLiZcWglvOw+19Z/Sq7aWx7Y048=; b=Vd50JjEGt964mhodq02DHnlJmLLzD4cmOAPLra3GsKuGPAWr++YPoE3JOOYGdCjtWd NtpX9QRZMdhenx+1OaujHcB++74jJnoc56foqluiB3FQiofQCS/PHNiLFBrzn0qrt5VB acMDGfI7mr0J/DgkQysI/W7wH+nziR74xNmuqT8K3zuGTvxiPAM6g5KDO1rCaF3uIGKH 28ZWnh9wrzn5EaukAeylZ1QLeiKPI5SPpi8q4w+Vt7CdZ9c6ImQlhtixD2M54O5SDDlz WwP9acwm3XH3eIgVi23i1u1VaXMv/Uy5xSiD3Sdm2I51P295yTK7p/n+ugJzXwTKElBp 68Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=udKbgJZR; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id a9si2475307pls.109.2019.06.13.02.44.21 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:44:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=udKbgJZR; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bHeNfTwD4XAIS0eLeLiZcWglvOw+19Z/Sq7aWx7Y048=; b=udKbgJZRJ+SciwR1Pd2q2Ka65G 9Skj/f/gJTQ+G9l3fpEf5dUSUFcYh4QSwiDYZHL2RgWWhVw1acSH3tCYUNAdEMgWjvKo9XmZJKowh ynPRiFcvwNh6m1Qke2wr57eEX6NYF82GOwMdjZuINowQ/aiErhvPQvL+uj9CEzkporjQHs5Iji2lr OdhXwDyPRQt5lyuEIA33C7LIhZVxwjAv+lbGWP3qPVg3XyAWri6plie5WWu1n/mj/M+A76ZBdXqMx zpQCcIA67an3Shb/STrkhn7Fz+6a7GXN3TcVMw1u7P1mN1h2pWvHraQmJn4sm19vwHc16182jf4WO A19H4NrA==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMHK-0001uV-3d; Thu, 13 Jun 2019 09:44:18 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/22] mm: remove hmm_devmem_add Date: Thu, 13 Jun 2019 11:43:20 +0200 Message-Id: <20190613094326.24093-18-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP There isn't really much value add in the hmm_devmem_add wrapper. Just factor out a little helper to find the resource, and otherwise let the driver implement the dev_pagemap_ops directly. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe --- Documentation/vm/hmm.rst | 26 -------- include/linux/hmm.h | 129 --------------------------------------- mm/hmm.c | 115 ---------------------------------- 3 files changed, 270 deletions(-) diff --git a/Documentation/vm/hmm.rst b/Documentation/vm/hmm.rst index 7b6eeda5a7c0..b1c960fe246d 100644 --- a/Documentation/vm/hmm.rst +++ b/Documentation/vm/hmm.rst @@ -336,32 +336,6 @@ directly using struct page for device memory which left most kernel code paths unaware of the difference. We only need to make sure that no one ever tries to map those pages from the CPU side. -HMM provides a set of helpers to register and hotplug device memory as a new -region needing a struct page. This is offered through a very simple API:: - - struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops, - struct device *device, - unsigned long size); - void hmm_devmem_remove(struct hmm_devmem *devmem); - -The hmm_devmem_ops is where most of the important things are:: - - struct hmm_devmem_ops { - void (*free)(struct hmm_devmem *devmem, struct page *page); - vm_fault_t (*fault)(struct hmm_devmem *devmem, - struct vm_area_struct *vma, - unsigned long addr, - struct page *page, - unsigned flags, - pmd_t *pmdp); - }; - -The first callback (free()) happens when the last reference on a device page is -dropped. This means the device page is now free and no longer used by anyone. -The second callback happens whenever the CPU tries to access a device page -which it cannot do. This second callback must trigger a migration back to -system memory. - Migration to and from device memory =================================== diff --git a/include/linux/hmm.h b/include/linux/hmm.h index 0e61d830b0a9..13152ab504ec 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -551,135 +551,6 @@ static inline void hmm_mm_init(struct mm_struct *mm) {} #endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */ #if IS_ENABLED(CONFIG_DEVICE_PRIVATE) || IS_ENABLED(CONFIG_DEVICE_PUBLIC) -struct hmm_devmem; - -/* - * struct hmm_devmem_ops - callback for ZONE_DEVICE memory events - * - * @free: call when refcount on page reach 1 and thus is no longer use - * @fault: call when there is a page fault to unaddressable memory - * - * Both callback happens from page_free() and page_fault() callback of struct - * dev_pagemap respectively. See include/linux/memremap.h for more details on - * those. - * - * The hmm_devmem_ops callback are just here to provide a coherent and - * uniq API to device driver and device driver should not register their - * own page_free() or page_fault() but rely on the hmm_devmem_ops call- - * back. - */ -struct hmm_devmem_ops { - /* - * free() - free a device page - * @devmem: device memory structure (see struct hmm_devmem) - * @page: pointer to struct page being freed - * - * Call back occurs whenever a device page refcount reach 1 which - * means that no one is holding any reference on the page anymore - * (ZONE_DEVICE page have an elevated refcount of 1 as default so - * that they are not release to the general page allocator). - * - * Note that callback has exclusive ownership of the page (as no - * one is holding any reference). - */ - void (*free)(struct hmm_devmem *devmem, struct page *page); - /* - * fault() - CPU page fault or get user page (GUP) - * @devmem: device memory structure (see struct hmm_devmem) - * @vma: virtual memory area containing the virtual address - * @addr: virtual address that faulted or for which there is a GUP - * @page: pointer to struct page backing virtual address (unreliable) - * @flags: FAULT_FLAG_* (see include/linux/mm.h) - * @pmdp: page middle directory - * Return: VM_FAULT_MINOR/MAJOR on success or one of VM_FAULT_ERROR - * on error - * - * The callback occurs whenever there is a CPU page fault or GUP on a - * virtual address. This means that the device driver must migrate the - * page back to regular memory (CPU accessible). - * - * The device driver is free to migrate more than one page from the - * fault() callback as an optimization. However if the device decides - * to migrate more than one page it must always priotirize the faulting - * address over the others. - * - * The struct page pointer is only given as a hint to allow quick - * lookup of internal device driver data. A concurrent migration - * might have already freed that page and the virtual address might - * no longer be backed by it. So it should not be modified by the - * callback. - * - * Note that mmap semaphore is held in read mode at least when this - * callback occurs, hence the vma is valid upon callback entry. - */ - vm_fault_t (*fault)(struct hmm_devmem *devmem, - struct vm_area_struct *vma, - unsigned long addr, - const struct page *page, - unsigned int flags, - pmd_t *pmdp); -}; - -/* - * struct hmm_devmem - track device memory - * - * @completion: completion object for device memory - * @pfn_first: first pfn for this resource (set by hmm_devmem_add()) - * @pfn_last: last pfn for this resource (set by hmm_devmem_add()) - * @resource: IO resource reserved for this chunk of memory - * @pagemap: device page map for that chunk - * @device: device to bind resource to - * @ops: memory operations callback - * @ref: per CPU refcount - * @page_fault: callback when CPU fault on an unaddressable device page - * - * This is a helper structure for device drivers that do not wish to implement - * the gory details related to hotplugging new memoy and allocating struct - * pages. - * - * Device drivers can directly use ZONE_DEVICE memory on their own if they - * wish to do so. - * - * The page_fault() callback must migrate page back, from device memory to - * system memory, so that the CPU can access it. This might fail for various - * reasons (device issues, device have been unplugged, ...). When such error - * conditions happen, the page_fault() callback must return VM_FAULT_SIGBUS and - * set the CPU page table entry to "poisoned". - * - * Note that because memory cgroup charges are transferred to the device memory, - * this should never fail due to memory restrictions. However, allocation - * of a regular system page might still fail because we are out of memory. If - * that happens, the page_fault() callback must return VM_FAULT_OOM. - * - * The page_fault() callback can also try to migrate back multiple pages in one - * chunk, as an optimization. It must, however, prioritize the faulting address - * over all the others. - */ - -struct hmm_devmem { - struct completion completion; - unsigned long pfn_first; - unsigned long pfn_last; - struct resource *resource; - struct device *device; - struct dev_pagemap pagemap; - const struct hmm_devmem_ops *ops; - struct percpu_ref ref; -}; - -/* - * To add (hotplug) device memory, HMM assumes that there is no real resource - * that reserves a range in the physical address space (this is intended to be - * use by unaddressable device memory). It will reserve a physical range big - * enough and allocate struct page for it. - * - * The device driver can wrap the hmm_devmem struct inside a private device - * driver struct. - */ -struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops, - struct device *device, - unsigned long size); - /* * hmm_devmem_page_set_drvdata - set per-page driver data field * diff --git a/mm/hmm.c b/mm/hmm.c index c15283f9bbf0..5b2e9bb6063a 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -1290,118 +1290,3 @@ long hmm_range_dma_unmap(struct hmm_range *range, } EXPORT_SYMBOL(hmm_range_dma_unmap); #endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */ - - -#if IS_ENABLED(CONFIG_DEVICE_PRIVATE) || IS_ENABLED(CONFIG_DEVICE_PUBLIC) -static void hmm_devmem_ref_release(struct percpu_ref *ref) -{ - struct hmm_devmem *devmem; - - devmem = container_of(ref, struct hmm_devmem, ref); - complete(&devmem->completion); -} - -static void hmm_devmem_ref_exit(void *data) -{ - struct percpu_ref *ref = data; - struct hmm_devmem *devmem; - - devmem = container_of(ref, struct hmm_devmem, ref); - wait_for_completion(&devmem->completion); - percpu_ref_exit(ref); -} - -static void hmm_devmem_ref_kill(struct dev_pagemap *pgmap) -{ - percpu_ref_kill(pgmap->ref); -} - -static vm_fault_t hmm_devmem_migrate(struct vm_fault *vmf) -{ - struct hmm_devmem *devmem = - container_of(vmf->page->pgmap, struct hmm_devmem, pagemap); - - return devmem->ops->fault(devmem, vmf->vma, vmf->address, vmf->page, - vmf->flags, vmf->pmd); -} - -static void hmm_devmem_free(struct page *page) -{ - struct hmm_devmem *devmem = - container_of(page->pgmap, struct hmm_devmem, pagemap); - - devmem->ops->free(devmem, page); -} - -static const struct dev_pagemap_ops hmm_pagemap_ops = { - .page_free = hmm_devmem_free, - .kill = hmm_devmem_ref_kill, - .migrate = hmm_devmem_migrate, -}; - -/* - * hmm_devmem_add() - hotplug ZONE_DEVICE memory for device memory - * - * @ops: memory event device driver callback (see struct hmm_devmem_ops) - * @device: device struct to bind the resource too - * @size: size in bytes of the device memory to add - * Return: pointer to new hmm_devmem struct ERR_PTR otherwise - * - * This function first finds an empty range of physical address big enough to - * contain the new resource, and then hotplugs it as ZONE_DEVICE memory, which - * in turn allocates struct pages. It does not do anything beyond that; all - * events affecting the memory will go through the various callbacks provided - * by hmm_devmem_ops struct. - * - * Device driver should call this function during device initialization and - * is then responsible of memory management. HMM only provides helpers. - */ -struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops, - struct device *device, - unsigned long size) -{ - struct hmm_devmem *devmem; - void *result; - int ret; - - devmem = devm_kzalloc(device, sizeof(*devmem), GFP_KERNEL); - if (!devmem) - return ERR_PTR(-ENOMEM); - - init_completion(&devmem->completion); - devmem->pfn_first = -1UL; - devmem->pfn_last = -1UL; - devmem->resource = NULL; - devmem->device = device; - devmem->ops = ops; - - ret = percpu_ref_init(&devmem->ref, &hmm_devmem_ref_release, - 0, GFP_KERNEL); - if (ret) - return ERR_PTR(ret); - - ret = devm_add_action_or_reset(device, hmm_devmem_ref_exit, &devmem->ref); - if (ret) - return ERR_PTR(ret); - - devmem->resource = devm_request_free_mem_region(device, &iomem_resource, - size); - if (IS_ERR(devmem->resource)) - return ERR_CAST(devmem->resource); - devmem->pfn_first = devmem->resource->start >> PAGE_SHIFT; - devmem->pfn_last = devmem->pfn_first + - (resource_size(devmem->resource) >> PAGE_SHIFT); - - devmem->pagemap.type = MEMORY_DEVICE_PRIVATE; - devmem->pagemap.res = *devmem->resource; - devmem->pagemap.ops = &hmm_pagemap_ops; - devmem->pagemap.altmap_valid = false; - devmem->pagemap.ref = &devmem->ref; - - result = devm_memremap_pages(devmem->device, &devmem->pagemap); - if (IS_ERR(result)) - return result; - return devmem; -} -EXPORT_SYMBOL_GPL(hmm_devmem_add); -#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */ From patchwork Thu Jun 13 09:43:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991507 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D701B14DB for ; Thu, 13 Jun 2019 09:44:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C531428B15 for ; Thu, 13 Jun 2019 09:44:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B974028B17; Thu, 13 Jun 2019 09:44:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C43528B15 for ; Thu, 13 Jun 2019 09:44:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAC206B0273; Thu, 13 Jun 2019 05:44:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A35CD6B0274; Thu, 13 Jun 2019 05:44:25 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D5A96B0275; Thu, 13 Jun 2019 05:44:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 56CEC6B0273 for ; Thu, 13 Jun 2019 05:44:25 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id q6so11596595pll.22 for ; Thu, 13 Jun 2019 02:44:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=CRiADhhFQCJg9nNjQAj6fEu4785skzNOaJQJ8kIUJ84=; b=jAqALvcckuRGtpA2NpwSejoMK7oRU+P2jtK15a2xWUPUvpqIWPUqHUjTbsmeGDyyUK x0UyJgTjj+syQZJ/QmScUXV0ZYekMXJ2+XvrbeQ4iAxTl0QXHPyiosV9LxYbCkDoj7Yn 1nsloner2CTdo20ULghR6hH08Pf5EgPDfYZUsKpWG51kZ3ZCuzOC8InxY0DUojbHBaei z+RfY0kIZo5EbsZymzTly8RvITribL+v2w+uN9/YU906VP4i3cZOyd8mdYVaBs3G2ZI+ +Yv/UrYmAgkPvHKM3EJJuWOei3SkaaHXtoKWJSAKvpTe9/4VgCxZjF2KKsFQj899Qwfy BWmg== X-Gm-Message-State: APjAAAWKqfQUXwiGxIoyJgOcFTVH04vpYQymyXqnHGGJYKHza3YjKES+ JHgA5Op/HbnbrfSmp5/jgftXc4dpGSjI+dot2OPK2MvEXSIGysOu2E2f0MZ3vU6oDxeiJv2AW7g BWr4UWXMBZn+DRUcIK0bZf9L12O0W3n3ATyaX6ePl/iGHpzKgajss2uNoI8NXThA= X-Received: by 2002:a17:902:8a87:: with SMTP id p7mr69851672plo.124.1560419065011; Thu, 13 Jun 2019 02:44:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHzTqq3JNNxe8NiEBeuV6lbn0j6jzM5ZtFvWZCiEr0ZetlXmM4GDzmQSRfbLIN7c5atb5j X-Received: by 2002:a17:902:8a87:: with SMTP id p7mr69851602plo.124.1560419064411; Thu, 13 Jun 2019 02:44:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419064; cv=none; d=google.com; s=arc-20160816; b=cesCSlAw57dVs9z3pDWsOCE/b60iKtQztdjlRRQ47XbzbBHW/6/A5AbQ7un4WCnGIY GYONiGX4TAM9Krp+1odAerjSSau8QVPtlojWOUjgyT8Xhp+GB9Tm1/tIN0xDfHhdoxns 7pci0wyMZwoj4CIg9bTcBMURxvH0PrIgriFVZhRaAoUG0mJfi7koH7gCXlT6ibeDWBTM r35AisrNqBzwBawye13WJML4e7MaOu4NYgRJ4e0Ok5sJB6JSneSVzqaW4tcPtF2Sl3oW yLpn/L4seglAFdwOmjC7eo0PB9uZY5MMhjp4+6ChnAYyaCc1ShqnMLbrSr9+CeaxMFAa nSJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=CRiADhhFQCJg9nNjQAj6fEu4785skzNOaJQJ8kIUJ84=; b=mDeibn7AI6HGWMUQTuev2Rl7WXgc6lrxzv7Nzz70o0OOF4vocEp1tLdY4IxG8NmMBu 3HyxpKf2yqp/Jo07wJwwm+H5kcq/NA+HkPkaBsyymKhHUn0T+CKqfs+jyyZl46D+FGCJ ztDUs3YR1T4TwOfBV8XEakNaBG/50k7ZdpdPuUz53KqFxy9Oxjow+3Q2ab/Yq67ALTGP +ehUHY8LDYePeZ43zFsi0lRgbVXXy/ibQZQCFKFD9wgptfKK8dfhDR9BDio4RxYJF9Ro 1nl2jWYPRXMe9apLkdtmelYNyMTHUeIr+kAlzln29fe319GHpzbl9PP3ipV078MUsjwf LEcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=RICVtgPD; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id a2si2716920pgj.54.2019.06.13.02.44.24 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:44:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=RICVtgPD; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CRiADhhFQCJg9nNjQAj6fEu4785skzNOaJQJ8kIUJ84=; b=RICVtgPD9yRZZLP5zsYav1rSx/ 4WdeVXj2hZit21ZRFFahZ0/Xb9mrzF4vFMbjwhHwZzDxsHyjhAYAjmS4CGJjsNQ74TT7TZO+AoiA8 +ykg9PdHRyJwz/zj0+/7ArN0Je2Zw3qhosZvIyWbnFjQtkiduRtXyxNYuw04kKoGUORMz6fHpxLtZ YTsDeVucQ5ychr3mWksaSDMicYxSgVYHcYqX1CuoizhG/ngsFEwRbS6GP4xrZvfELvZso8ubWK1Qy sTIETQwqU64lawnEds6n1N2gMvIX74tlW7hKHlfT8cTH89GLpVOhPBfu2I9eGuksdH2m3MVGivwF/ Hf1LW1Lg==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMHM-0001vf-Vf; Thu, 13 Jun 2019 09:44:21 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/22] mm: mark DEVICE_PUBLIC as broken Date: Thu, 13 Jun 2019 11:43:21 +0200 Message-Id: <20190613094326.24093-19-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP The code hasn't been used since it was added to the tree, and doesn't appear to actually be usable. Mark it as BROKEN until either a user comes along or we finally give up on it. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Acked-by: Michal Hocko --- mm/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/Kconfig b/mm/Kconfig index 0d2ba7e1f43e..406fa45e9ecc 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -721,6 +721,7 @@ config DEVICE_PRIVATE config DEVICE_PUBLIC bool "Addressable device memory (like GPU memory)" depends on ARCH_HAS_HMM + depends on BROKEN select HMM select DEV_PAGEMAP_OPS From patchwork Thu Jun 13 09:43:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991511 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C12F414DB for ; Thu, 13 Jun 2019 09:44:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACA3D28B11 for ; Thu, 13 Jun 2019 09:44:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A09D628B15; Thu, 13 Jun 2019 09:44:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18D3C28B17 for ; Thu, 13 Jun 2019 09:44:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5A256B0276; Thu, 13 Jun 2019 05:44:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DDF1F6B0277; Thu, 13 Jun 2019 05:44:28 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5AA56B0278; Thu, 13 Jun 2019 05:44:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 892746B0276 for ; Thu, 13 Jun 2019 05:44:28 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id 21so13471368pgl.5 for ; Thu, 13 Jun 2019 02:44:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ST5vXDP0wxZAFs+13zRZ2VJKiKZc1CoEKVcbqRs6asg=; b=USNWYmxoizgx4aPCACe3vnZxzIysqBEMGHDYg1ZX/p0sUZbV8vazYvUp7gJ7VqJCMB eHUvHGicuc0fWVUwoGXQT40c9cAzW8HIyd+0+PLPmvlswp7DJgGfvHD8gDSwEgJp0u/c rCEp2Dxpobdy4go5sDFkMILmZe0bVTLZsYbuALPTxyLBUBi5LUXEISOfyTEzhnjZ/exx 0y7QTpS8TNFLY60l+Qby0/WLXdavPrSY23AtExkKNH+Tw3GsgkWtzV+lpfpkWZoD6rtc DHshNSRYQFgHsRf2W3YTElrcG8q422fV9HkrR0sTvewQlbChOikiYnrDdcyX5Bg/oGKp cy6w== X-Gm-Message-State: APjAAAU/X3eZtqOhu/tBFBL7/WEV5TFxUokUYYttwfJrrGj5bNVsunJU Fe4jZXgvE0+qeDr/vJK57qZPNvOYlQPm0MkcubAC2FdEwh+cG0XvyqLl7IxqCwhNp6kDJNatIuW JbT9xIrMl+tOUE14zfS6C0aIofJmHC6O9qZgjgmtejj7QuZnmlBTBgbMIp10Rw1M= X-Received: by 2002:a17:90a:2343:: with SMTP id f61mr4426300pje.130.1560419068203; Thu, 13 Jun 2019 02:44:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1CdVZ9Ybe80xKsLbEM+9aLlGWeU6tb0gIEkJrsAZBiwV9Ctdl81RAVvzm/qaerOECGIJL X-Received: by 2002:a17:90a:2343:: with SMTP id f61mr4426186pje.130.1560419067183; Thu, 13 Jun 2019 02:44:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419067; cv=none; d=google.com; s=arc-20160816; b=j2wg5FKsx8z4zm0aV0FWB8h4vuwYNu3O7PPfU64xry3ZOJL5bZ4Wq3fzkgqr4EZV7J IEIYE8TnIKwaOx4uItmSQnM8vssKLJPEYyIOEoKasGaLgXaJDNZwdC+c76t0ju+M1tAW qTJe6fEyTgz5Rg8i7EI9O/R5dHBQN1Z7LNZSNNwy6JCpcNV4Ob7VJ7qK4eQwemv1ZSEy OSFEbgtQrGK7MSkTsB20aOdhvPrJwvacYs0HFKTkrfmjDw0aPlBbHLdXT0TplIg0Kjlp wbW887QzOgi2NnFm90Mv7bQrqhWqCjxfJ++s1d7z5hxHdmTDtMTi1ghuoLxKK3onkgtX TDgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ST5vXDP0wxZAFs+13zRZ2VJKiKZc1CoEKVcbqRs6asg=; b=r/fyeIlK2xgzvBrfM7/BkW8IE3DVsG1tQUXdW9gOk7i3HMxoxPdX1T3o+EeWkd0pdn ZtmBu6DJ72SVKY/ghDRS8EK+ze40MWmaDTpT+lUzzCZM+sogX4Pl4K3ymFbOKvHZM0HF hUfq82NpDYr21kY3837NfX1LQgdwP3YvvsdB1JS/W6WzFk06LbOC/SSNbdbsmLMJY8Pu Hfji/pUwZ3So3T5a+Avqx9M0r+f2I0pjrccZ5edj6DkVrjlpw38mlcqlJqzIQWBUO4cF krcP/Vj3y+YnxMoAFcp2tDfBAZZ8xO3tmBJen+RWClEO5Vx6ALibg9yQkmjZ4wZDYhQn MG2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=o60fvrdj; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id s24si2632447pgm.327.2019.06.13.02.44.27 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:44:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=o60fvrdj; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ST5vXDP0wxZAFs+13zRZ2VJKiKZc1CoEKVcbqRs6asg=; b=o60fvrdjva6GPXOY7bWBawc6ta 0VTdlbWHmmpNA05wC2tx9zYyp5vxCSFXni3mwAYEo/JBfwXp+ip6D7QSxCyt6RsLm6bkCBG4evj7W uLJKEpwWIrv5wjFFQ+/vT588yk1NuNPnmFI/ifWHUX2+fx93ET4T0o8OjB+Ag5kwwEpG4PAAQ4evQ 5Qmy0oIpRMwn7fkxXQK5/g1paPzm38DzgVl72fd1ZqQ/K8gUf1mi0G9Qv1PWHT0qLuF6X42bqPSGX It5fsP86hUBvvu/gab1CK5Bz5//1Jz5zbVZXS9iFZbny1chkNTg7sqFV9amTjjSAiH8zqxZoqFe7y bMa6st9A==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMHP-0001w6-RZ; Thu, 13 Jun 2019 09:44:24 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/22] mm: simplify ZONE_DEVICE page private data Date: Thu, 13 Jun 2019 11:43:22 +0200 Message-Id: <20190613094326.24093-20-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP Remove the clumsy hmm_devmem_page_{get,set}_drvdata helpers, and instead just access the page directly. Also make the page data a void pointer, and thus much easier to use. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 18 +++++++---------- include/linux/hmm.h | 27 -------------------------- include/linux/mm_types.h | 2 +- mm/page_alloc.c | 8 ++++---- 4 files changed, 12 insertions(+), 43 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c index 9e32bc8ecbc7..27aa4e72abe9 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dmem.c +++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c @@ -104,11 +104,8 @@ struct nouveau_migrate { static void nouveau_dmem_page_free(struct page *page) { - struct nouveau_dmem_chunk *chunk; - unsigned long idx; - - chunk = (void *)hmm_devmem_page_get_drvdata(page); - idx = page_to_pfn(page) - chunk->pfn_first; + struct nouveau_dmem_chunk *chunk = page->zone_device_data; + unsigned long idx = page_to_pfn(page) - chunk->pfn_first; /* * FIXME: @@ -200,7 +197,7 @@ nouveau_dmem_fault_alloc_and_copy(struct vm_area_struct *vma, dst_addr = fault->dma[fault->npages++]; - chunk = (void *)hmm_devmem_page_get_drvdata(spage); + chunk = spage->zone_device_data; src_addr = page_to_pfn(spage) - chunk->pfn_first; src_addr = (src_addr << PAGE_SHIFT) + chunk->bo->bo.offset; @@ -633,9 +630,8 @@ nouveau_dmem_init(struct nouveau_drm *drm) list_add_tail(&chunk->list, &drm->dmem->chunk_empty); page = pfn_to_page(chunk->pfn_first); - for (j = 0; j < DMEM_CHUNK_NPAGES; ++j, ++page) { - hmm_devmem_page_set_drvdata(page, (long)chunk); - } + for (j = 0; j < DMEM_CHUNK_NPAGES; ++j, ++page) + page->zone_device_data = chunk; } NV_INFO(drm, "DMEM: registered %ldMB of device memory\n", size >> 20); @@ -698,7 +694,7 @@ nouveau_dmem_migrate_alloc_and_copy(struct vm_area_struct *vma, if (!dpage || dst_pfns[i] == MIGRATE_PFN_ERROR) continue; - chunk = (void *)hmm_devmem_page_get_drvdata(dpage); + chunk = dpage->zone_device_data; dst_addr = page_to_pfn(dpage) - chunk->pfn_first; dst_addr = (dst_addr << PAGE_SHIFT) + chunk->bo->bo.offset; @@ -864,7 +860,7 @@ nouveau_dmem_convert_pfn(struct nouveau_drm *drm, continue; } - chunk = (void *)hmm_devmem_page_get_drvdata(page); + chunk = page->zone_device_data; addr = page_to_pfn(page) - chunk->pfn_first; addr = (addr + chunk->bo->bo.mem.start) << PAGE_SHIFT; diff --git a/include/linux/hmm.h b/include/linux/hmm.h index 13152ab504ec..e095a8b55dfa 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -550,33 +550,6 @@ static inline void hmm_mm_init(struct mm_struct *mm) static inline void hmm_mm_init(struct mm_struct *mm) {} #endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */ -#if IS_ENABLED(CONFIG_DEVICE_PRIVATE) || IS_ENABLED(CONFIG_DEVICE_PUBLIC) -/* - * hmm_devmem_page_set_drvdata - set per-page driver data field - * - * @page: pointer to struct page - * @data: driver data value to set - * - * Because page can not be on lru we have an unsigned long that driver can use - * to store a per page field. This just a simple helper to do that. - */ -static inline void hmm_devmem_page_set_drvdata(struct page *page, - unsigned long data) -{ - page->hmm_data = data; -} - -/* - * hmm_devmem_page_get_drvdata - get per page driver data field - * - * @page: pointer to struct page - * Return: driver data value - */ -static inline unsigned long hmm_devmem_page_get_drvdata(const struct page *page) -{ - return page->hmm_data; -} -#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */ #else /* IS_ENABLED(CONFIG_HMM) */ static inline void hmm_mm_destroy(struct mm_struct *mm) {} static inline void hmm_mm_init(struct mm_struct *mm) {} diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 8ec38b11b361..f33a1289c101 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -158,7 +158,7 @@ struct page { struct { /* ZONE_DEVICE pages */ /** @pgmap: Points to the hosting device page map. */ struct dev_pagemap *pgmap; - unsigned long hmm_data; + void *zone_device_data; unsigned long _zd_pad_1; /* uses mapping */ }; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d66bc8abe0af..d069ee1f4c2e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5887,12 +5887,12 @@ void __ref memmap_init_zone_device(struct zone *zone, __SetPageReserved(page); /* - * ZONE_DEVICE pages union ->lru with a ->pgmap back - * pointer and hmm_data. It is a bug if a ZONE_DEVICE - * page is ever freed or placed on a driver-private list. + * ZONE_DEVICE pages union ->lru with a ->pgmap back pointer + * and zone_device_data. It is a bug if a ZONE_DEVICE page is + * ever freed or placed on a driver-private list. */ page->pgmap = pgmap; - page->hmm_data = 0; + page->zone_device_data = 0; /* * Mark the block movable so that blocks are reserved for From patchwork Thu Jun 13 09:43:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 586CC76 for ; Thu, 13 Jun 2019 09:44:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45D5828B11 for ; Thu, 13 Jun 2019 09:44:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3946328B1B; Thu, 13 Jun 2019 09:44:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDBD728B11 for ; Thu, 13 Jun 2019 09:44:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1EED6B0278; Thu, 13 Jun 2019 05:44:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CCD7E6B0279; Thu, 13 Jun 2019 05:44:31 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7B9C6B027A; Thu, 13 Jun 2019 05:44:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 73D976B0278 for ; Thu, 13 Jun 2019 05:44:31 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id s22so7618338plp.5 for ; Thu, 13 Jun 2019 02:44:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FtWCNVd4QOpMTthKbNz1MFUxeFEvCSuwTqmj0Q74N1M=; b=hpP1MzufFndfsonGKFVMF9dL5zEmM39yBHpAn6tRFrZ+kDrg2hVV1waJwdjSqiZgLi 9gOm/JVLFQ6xRZTbmh66K/5/aFvnc3Y7Kg4d2nd9iSHgrRgsqpT5/HRVqRJ4/KCSPT0b vsPpA9GFOBJRxXBbQgqt6iUo8TvD3TSsOaVnYExjwuJSltxP80y3uJklQOizvHLcXdnt jd0ZqqV8Rp2UeN7jMWtIQXcVpmogzkyhmkUBI7Kaypa/ReLN/0jdxn4ztqCnh+3QoSIc vUfft2ERfxPMRuH4CBzWm5uaQlu6x++RzndXVK6N/qXoSy0aUZP2AbsVL9BRJRou/pSR +Skg== X-Gm-Message-State: APjAAAU2eFnY4iaK7sFpCzHQIHxAfpPqlTT5+y8L60mIQUvyBdFhpEoE STL3ZiTHSV3bssIRagRNWSKrdJt4zS7p8gO7gFXxWMPTrT3a0kDWdxB3jnsilt4IJjQiQrb10Md JGKyGUssFqVQrQKhOrL++YZ7UKhW1qRp876cRcJoruPkZD2JLVhUIVhNi5WEOoXk= X-Received: by 2002:a17:902:7883:: with SMTP id q3mr85626226pll.89.1560419071130; Thu, 13 Jun 2019 02:44:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjrF0dhI7ZdXYcwQN2TGvAmwUNuOJ6Rsqy/ClWB9/fWHiwjbaTU0VHN/T1zf1fmdI90Z+a X-Received: by 2002:a17:902:7883:: with SMTP id q3mr85626146pll.89.1560419070367; Thu, 13 Jun 2019 02:44:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419070; cv=none; d=google.com; s=arc-20160816; b=d3+IR1enH3wAEZ5+C+Qs/E2Z3BppP9OIV+WyBEpkBx4RA12o6GtZ6fWeYb0Vy1OuGw eQwBz1TR3zMk8U/IZPuChuUiKmpDzKe3+ofliNHAdOSvL8rBA5//KxdftUYWhSEbDJ3w RIRg1OlwAF09ASj+gwVc2ae8+4w6xbdL3szjKIE/HDNtyuvLWtRnaLJZB/PJqERJrJdT dC3j9GqlwRuy/CRUob0n9lwbHv+eCSoAi2PT61dsEoEMPUKewJ4rR3VYlI6GyJ0XkYQw ZPv/ZQduyi56/8y/wjpo6iYCm0WoVbOGtfX8fr/wCtPkoxaYBjKhUlTlUo58OSPfNSja rNzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=FtWCNVd4QOpMTthKbNz1MFUxeFEvCSuwTqmj0Q74N1M=; b=tyd0RP8cJ2RqqEqfFctGk5u/rebEzKTnLTJQWAqd7fS8bPDH93kjNFltP6YpPRzq46 Px+ShK1b3hhnScabMEw5VSiB49RTFtoJeGSsdZdxaTOm7266GysWUi2BSRDPkQlXOg0h dz82mZEFObA8cw7Qc95jmEC059etCuGgP42kix0H8UYLicYkeECHssiPtxMz+sijf606 tJx+QonJ6jjsUxS6V36GWoWKulxCveeF1jrCIwBSYzGzNQq/JVe2dnHJCMpqedYwbpQP TovFi4trXbKdTsrmRJfyFiMkj9S852IJjHdruQa3hy/eB6E+RtbQEPXgVj5Ek+UI8UeT oSVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=lGnynT1H; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id l11si2529786pgp.438.2019.06.13.02.44.30 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:44:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=lGnynT1H; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FtWCNVd4QOpMTthKbNz1MFUxeFEvCSuwTqmj0Q74N1M=; b=lGnynT1HToRc+NaRbBtuR81QYR NemOaLZIDgAQej+KaIa1UxM9jdzyIje1zBDkPe1VX9Ai3Z8hZ/9xJPbgJt4zVuMpEcWMze36SAPe8 jadfF1tnyC53GvHJN+XmEhIe1jarXKgqt4YOPBypOu+e8vTxzEa3yDupP2NKBlUg2R8XoiT+70txr XjVnT4tikVWG9g+QrpVgLj/2IWv0sdZQEPOrc3z1nIk8VZ3R1YxTTaO5R14SWaIYcAO2xKeDnsgkf BG35saHwjH85vx0W3/7W5L524Osw05sNZ5JeAjweKs/0jw6m5MZxo8PHbgl0DcrLc6CYCGDX6R30L Li0+Fu8g==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMHS-0001wn-Qc; Thu, 13 Jun 2019 09:44:27 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 20/22] mm: sort out the DEVICE_PRIVATE Kconfig mess Date: Thu, 13 Jun 2019 11:43:23 +0200 Message-Id: <20190613094326.24093-21-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP The ZONE_DEVICE support doesn't depend on anything HMM related, just on various bits of arch support as indicated by the architecture. Also don't select the option from nouveau as it isn't present in many setups, and depend on it instead. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/Kconfig | 2 +- mm/Kconfig | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig index dba2613f7180..6303d203ab1d 100644 --- a/drivers/gpu/drm/nouveau/Kconfig +++ b/drivers/gpu/drm/nouveau/Kconfig @@ -85,10 +85,10 @@ config DRM_NOUVEAU_BACKLIGHT config DRM_NOUVEAU_SVM bool "(EXPERIMENTAL) Enable SVM (Shared Virtual Memory) support" depends on ARCH_HAS_HMM + depends on DEVICE_PRIVATE depends on DRM_NOUVEAU depends on STAGING select HMM_MIRROR - select DEVICE_PRIVATE default n help Say Y here if you want to enable experimental support for diff --git a/mm/Kconfig b/mm/Kconfig index 406fa45e9ecc..4dbd718c8cf4 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -677,13 +677,13 @@ config ARCH_HAS_HMM_MIRROR config ARCH_HAS_HMM bool - default y depends on (X86_64 || PPC64) depends on ZONE_DEVICE depends on MMU && 64BIT depends on MEMORY_HOTPLUG depends on MEMORY_HOTREMOVE depends on SPARSEMEM_VMEMMAP + default y config MIGRATE_VMA_HELPER bool @@ -709,8 +709,7 @@ config HMM_MIRROR config DEVICE_PRIVATE bool "Unaddressable device memory (GPU memory, ...)" - depends on ARCH_HAS_HMM - select HMM + depends on ZONE_DEVICE select DEV_PAGEMAP_OPS help From patchwork Thu Jun 13 09:43:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0945E13AF for ; Thu, 13 Jun 2019 09:44:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA2FC28B16 for ; Thu, 13 Jun 2019 09:44:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB62728B17; Thu, 13 Jun 2019 09:44:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DB7E28B15 for ; Thu, 13 Jun 2019 09:44:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A39F56B027A; Thu, 13 Jun 2019 05:44:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 923C06B027B; Thu, 13 Jun 2019 05:44:35 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 777096B027C; Thu, 13 Jun 2019 05:44:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 3BAF16B027A for ; Thu, 13 Jun 2019 05:44:35 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id j21so14099692pff.12 for ; Thu, 13 Jun 2019 02:44:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kZ4qxfaugsPBAzNnf2F5+YBv7IsxX/EWqM6pYodKjkw=; b=VfNg2BxPVTaA1LA87swKE/5FEMZPBAVYb04p09+c/b77T3lrxNnoi4JM9NXVgUXlVt oDYBE+z59IS47+pcCIo0PsZzngXeEfxDDpxjN6RAqhIcz3NoRjKCFhqGzEmSCWWNAQp2 bE2AnnW4FylUXtUg/Yx5FElAm/vQdsTfgiG3KWeSU6slL64wT+v70KXYEFU4iRRDEBdE 9r+bM9kioj1A3ioLxMnTqcKgVFpNw8gBdxJXlvrMjjLaHW2O2hIXHIdKPa7njleM7vmv TeYOICmwjUrASlqG95q2p0yvwwfGEpcw0VFuDOan+z2tvJMMVfrG/J+GG1I0UEv18wOw ezrw== X-Gm-Message-State: APjAAAWfF2se7irafRZfj+jbygGA7GlXgyPa02l3BWYH4W3NgXcRAFA8 0Var9ODxfD4KSCPXXKoOmf0gjgub1CvP630wd3X4KftCLilxpkUUDuw2HwenIfAol7wm3TysUTv fh9ioDi7EWGTdpRLS0HLlxQaoK8giAgJoLcYYA5L3D34BxoqvDhPQKTi8PxxBtsc= X-Received: by 2002:a17:90a:206a:: with SMTP id n97mr4399593pjc.10.1560419074455; Thu, 13 Jun 2019 02:44:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQZPnpD8JewElVz/BKcbdkOJXY2vbrUMqQNDcwvJX17gAdie/f/+39qVnCwyd63LCbP4uD X-Received: by 2002:a17:90a:206a:: with SMTP id n97mr4399472pjc.10.1560419073383; Thu, 13 Jun 2019 02:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419073; cv=none; d=google.com; s=arc-20160816; b=UlMg5YiKhryREaPeUDaqEfg3xSnhCmhcHat3Q8R1g+pif1VzGBKBXW6VELPmv0hi0U HOPWY5uqjt0AwY9u0vtS4KhcwIr+oPsat8/02heZPlBpDswVU5aEgFWPf7eXplCkIzGO A5YAOtPCvyBYI9JYOstHnPBW16BYplnbwqSFV4WN23gPI1Fp8OBfujatVkfUr6cdGZgW CSBpT4cBU2Grbk7OpAmvOJ9UnbL7ew1322FU9uFHnHaNUv/GbwewQfyobzcP2sT8r6Gl m0ehBx2M2ejuNhCx+el5ymKaZ5bnPGoAI4cyU/foMiMPpENHWsKwx4fw/Cmh5EyS+yVA OTLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=kZ4qxfaugsPBAzNnf2F5+YBv7IsxX/EWqM6pYodKjkw=; b=0jEVCcmclcyBkXRseD8oMgd7/cvsPvZhXdvFJ6O+o0B1Ug7hw5DJsHgD1qgPh1Mrb5 V0WMwHSXFwscEn8CvIB7gxI+HuUeCsHLLImZGE7+wOjyik2qQf2xf9FaQJzdDtf2D20S DNHyU+r4d8rjXO99LkIM9W/bzh0ilGyTWwaeOuJBhIPn4a5GfPp0YrCiDHGyAQ0a5vTi Fc5O8gpYjUncwodexT4vubKThRI+Jt+QzeLTSpaucTLDK7EAnySB4KWevtzmT63UQUmz KxSU7ALPft9+07OGhn0Z2cSOMb15Qp41FpeTKteuNbz+8YBo2PTUqXKD7R0G53Q5ZwPN RWxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=k97Dd7pL; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id s1si2468618plp.66.2019.06.13.02.44.33 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:44:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=k97Dd7pL; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kZ4qxfaugsPBAzNnf2F5+YBv7IsxX/EWqM6pYodKjkw=; b=k97Dd7pLGeOpmCNCf65fhjYJNc ImDu+Xfy6FCJV49fGpZqtY6ITY20Ga5rfbF1ZP8/+kIAUOmCJaXe/qfHjuLsqZDKoqXq4TdEj5Vp0 jtQNy4yxzFvw8d8X2ge3Dw8edBPvJTaL6od2e2JrfH7Xxbknm4G8HBU9oSnr3E1JnwunI7X3nvPkT gG7E9aumHhR8ixTiSTA9r3AzufEbuqKR9dAa8/cqyW4WBVN++uRv1Vx9WTUDrrW59jnByDhykg/ZP Vn1lViZhnwx6LLeJpNkx+m+iBmbD0cfZ+ta1tZifhaEB9tvPlXBZQ5SA/zqi/MaVwZjAenHCd3+pW jVf38HmA==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMHW-0001xS-3I; Thu, 13 Jun 2019 09:44:30 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 21/22] mm: remove the HMM config option Date: Thu, 13 Jun 2019 11:43:24 +0200 Message-Id: <20190613094326.24093-22-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP All the mm/hmm.c code is better keyed off HMM_MIRROR. Also let nouveau depend on it instead of the mix of a dummy dependency symbol plus the actually selected one. Drop various odd dependencies, as the code is pretty portable. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/Kconfig | 3 +-- include/linux/hmm.h | 14 +++----------- include/linux/mm_types.h | 2 +- mm/Kconfig | 27 +++------------------------ mm/Makefile | 2 +- mm/hmm.c | 2 -- 6 files changed, 9 insertions(+), 41 deletions(-) diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig index 6303d203ab1d..66c839d8e9d1 100644 --- a/drivers/gpu/drm/nouveau/Kconfig +++ b/drivers/gpu/drm/nouveau/Kconfig @@ -84,11 +84,10 @@ config DRM_NOUVEAU_BACKLIGHT config DRM_NOUVEAU_SVM bool "(EXPERIMENTAL) Enable SVM (Shared Virtual Memory) support" - depends on ARCH_HAS_HMM depends on DEVICE_PRIVATE depends on DRM_NOUVEAU + depends on HMM_MIRROR depends on STAGING - select HMM_MIRROR default n help Say Y here if you want to enable experimental support for diff --git a/include/linux/hmm.h b/include/linux/hmm.h index e095a8b55dfa..64ea2fa00872 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -62,7 +62,7 @@ #include #include -#if IS_ENABLED(CONFIG_HMM) +#ifdef CONFIG_HMM_MIRROR #include #include @@ -324,9 +324,6 @@ static inline uint64_t hmm_pfn_from_pfn(const struct hmm_range *range, return hmm_device_entry_from_pfn(range, pfn); } - - -#if IS_ENABLED(CONFIG_HMM_MIRROR) /* * Mirroring: how to synchronize device page table with CPU page table. * @@ -546,13 +543,8 @@ static inline void hmm_mm_init(struct mm_struct *mm) { mm->hmm = NULL; } -#else /* IS_ENABLED(CONFIG_HMM_MIRROR) */ -static inline void hmm_mm_init(struct mm_struct *mm) {} -#endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */ - -#else /* IS_ENABLED(CONFIG_HMM) */ -static inline void hmm_mm_destroy(struct mm_struct *mm) {} +#else /* CONFIG_HMM_MIRROR */ static inline void hmm_mm_init(struct mm_struct *mm) {} -#endif /* IS_ENABLED(CONFIG_HMM) */ +#endif /* CONFIG_HMM_MIRROR */ #endif /* LINUX_HMM_H */ diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index f33a1289c101..8d37182f8dbe 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -501,7 +501,7 @@ struct mm_struct { #endif struct work_struct async_put_work; -#if IS_ENABLED(CONFIG_HMM) +#ifdef CONFIG_HMM_MIRROR /* HMM needs to track a few things per mm */ struct hmm *hmm; #endif diff --git a/mm/Kconfig b/mm/Kconfig index 4dbd718c8cf4..73676cb4693f 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -669,37 +669,17 @@ config ZONE_DEVICE If FS_DAX is enabled, then say Y. -config ARCH_HAS_HMM_MIRROR - bool - default y - depends on (X86_64 || PPC64) - depends on MMU && 64BIT - -config ARCH_HAS_HMM - bool - depends on (X86_64 || PPC64) - depends on ZONE_DEVICE - depends on MMU && 64BIT - depends on MEMORY_HOTPLUG - depends on MEMORY_HOTREMOVE - depends on SPARSEMEM_VMEMMAP - default y - config MIGRATE_VMA_HELPER bool config DEV_PAGEMAP_OPS bool -config HMM - bool - select MMU_NOTIFIER - select MIGRATE_VMA_HELPER - config HMM_MIRROR bool "HMM mirror CPU page table into a device page table" - depends on ARCH_HAS_HMM - select HMM + depends on MMU + select MMU_NOTIFIER + select MIGRATE_VMA_HELPER help Select HMM_MIRROR if you want to mirror range of the CPU page table of a process into a device page table. Here, mirror means "keep synchronized". @@ -721,7 +701,6 @@ config DEVICE_PUBLIC bool "Addressable device memory (like GPU memory)" depends on ARCH_HAS_HMM depends on BROKEN - select HMM select DEV_PAGEMAP_OPS help diff --git a/mm/Makefile b/mm/Makefile index ac5e5ba78874..91c99040065c 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -102,5 +102,5 @@ obj-$(CONFIG_FRAME_VECTOR) += frame_vector.o obj-$(CONFIG_DEBUG_PAGE_REF) += debug_page_ref.o obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o obj-$(CONFIG_PERCPU_STATS) += percpu-stats.o -obj-$(CONFIG_HMM) += hmm.o +obj-$(CONFIG_HMM_MIRROR) += hmm.o obj-$(CONFIG_MEMFD_CREATE) += memfd.o diff --git a/mm/hmm.c b/mm/hmm.c index 5b2e9bb6063a..8d50c482469c 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -26,7 +26,6 @@ #include #include -#if IS_ENABLED(CONFIG_HMM_MIRROR) static const struct mmu_notifier_ops hmm_mmu_notifier_ops; /** @@ -1289,4 +1288,3 @@ long hmm_range_dma_unmap(struct hmm_range *range, return cpages; } EXPORT_SYMBOL(hmm_range_dma_unmap); -#endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */ From patchwork Thu Jun 13 09:43:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10991521 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CF1676 for ; Thu, 13 Jun 2019 09:44:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AC7128B11 for ; Thu, 13 Jun 2019 09:44:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EF0F28B17; Thu, 13 Jun 2019 09:44:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2F7528B11 for ; Thu, 13 Jun 2019 09:44:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAC1A6B027C; Thu, 13 Jun 2019 05:44:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A348D6B027D; Thu, 13 Jun 2019 05:44:37 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 889ED6B027E; Thu, 13 Jun 2019 05:44:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 4D1B86B027C for ; Thu, 13 Jun 2019 05:44:37 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id y7so14120123pfy.9 for ; Thu, 13 Jun 2019 02:44:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0sAfzDlcAsndHKBt75dqqx/GnOCOQqtRdathOjahJzQ=; b=KNzGQ9G2NyXWF4SCd1zGB7Wazh7FsU9OrfkEPz6fI6e9gjAtDRV2FJImYYz3UFz9vN 6X1CaSosjpsmIr+FwsgJCwQmDI5tM2/dCXh0Cb93cOGaLIgmSlnNlxF20aUOvAtk0wlo hk9xbXOT/lHS94/XT3cmt2qS4kdvDWLwzr2oz7jEpSLBurRhxxTymJdxtuliRioZfKCa Jc66n2Ypw7Ey5u5Iq/Hobt+/MIiYc4x3p9h+NoaVwhwELSH6wQZxU+FTNwvPCchawfBr NKSDjyZRTIopaTLW4JltmYbtwVRo0fqH9+uecpRyGVFruS8ECqjuCRhtRB3JXfT6muvA GHww== X-Gm-Message-State: APjAAAULn4ZGOK3nD25MLrosYAakc0DtS3A94kBagjyyPtLXwrGfUhU1 2LFshHX0fBq80oT3gq5SJzID4RoWTuBecvh4CBXgmhEcrao7b7gDeK3NTUptaNzUNpt1E7QSpEJ TMVouKJtKnDHFPLDlsawXT+jApvBJ2hqEaXKGF5hUyxER7+d0ftcMQL3Pm3Kpn2s= X-Received: by 2002:a63:511b:: with SMTP id f27mr13939592pgb.135.1560419076793; Thu, 13 Jun 2019 02:44:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8M4iDY5OrEQQ/BfQmHJgcItcCfq66V5MfvlozA5elWk7LCUxwpYBbivauDkOWO0wyw+Jv X-Received: by 2002:a63:511b:: with SMTP id f27mr13939505pgb.135.1560419075904; Thu, 13 Jun 2019 02:44:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560419075; cv=none; d=google.com; s=arc-20160816; b=uD5PKV9egpRsx4ZBvTQavKXTBZOJpwPEV4YehHYqXAFUMkj17j7ELSef1pkFkowdKv uQaFiiwIREFxYsiZTXj47ElzWa9LZrnytp+fGcGjyic1C4eWe0Af1LhcXCRzyS+igTVG cxMZId3fjviiRcVL5OgfgF8cCoRXi46doUn0upHlJfQmCJbaP7GFqwTeFNWCbANYpeTP /Vv85zRMyKlVqVonht9tIE2Jv4Bk5sqpkz3yD6W/YprVMoqB8oSKEv1YoBbqQnQk5wlD cw8y6IMSTpXUQdfHXYwvdpVUbCt4kMpoqgcxT1pO8OzQ+GwVakwPOVDDyEOP3gcAO6fK lRtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=0sAfzDlcAsndHKBt75dqqx/GnOCOQqtRdathOjahJzQ=; b=Z1fLgYKcCcX8vJtzIY6DCn8IEWI8B5esZQP2DIr0d4mLe1ZhrHDArDdC034mbE2asf Zaf8/CXdMXup+icVLbCS5xx3VPZQTGYOE21DYN3x3BW6Gzc1KdbWsDIo98MwUlBjNB8t RczLLKvnJ0Lp4PoGCg6Oo7OyQ6FXjJUKpqKMpr1TzytKWjw4In1CpJMSUn5r/otqD4b+ pSo9oxieaWUDV2V1H0UmchC6GUgVECAKrEN2VfxikRX5HNWwxocBNMmGj9T8awZSS2Xm g0RLv4+sFG0qNUNkdeUaVoDL2gF6jtTAxhSxO2C3xAhELCnaisnTrFOZq44y9SwYPBD0 SBXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=trz7K9US; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id t3si2629246pgq.254.2019.06.13.02.44.35 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 02:44:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=trz7K9US; spf=pass (google.com: best guess record for domain of batv+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+aff2f865c54b6c032bcd+5772+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=0sAfzDlcAsndHKBt75dqqx/GnOCOQqtRdathOjahJzQ=; b=trz7K9USBFzK+xAnepin47AmRr Ru/Ufe0ArOAav00lGoPPzRUVxrswp05DRpD2d5fXaeZItnlHIGrtF1O1z/B5eK/v1ypkuEUV33AoE O6sWXD/9uMVmrJLXNRSSRwxNiWV3okj38PS6HOorCIE1095zMfIxNPliWKgHj+KFNGQYjRJfvAAE9 OZPPi7DMhfjs+Ay9FbxkmMkIi0kMa6qSNkzN8TL3yorsUR6y30VoiV0rQhnhlXUczuR6wnoc3Tr3D 5CrUdFq3rR6UxwQZviB1fSzfyE69t0fvrojVXmSEKwbbynKreccgHDzaxSTGmzkzt23o/mQnE0h+e YEeclslA==; Received: from mpp-cp1-natpool-1-198.ethz.ch ([82.130.71.198] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbMHY-0001yQ-Rm; Thu, 13 Jun 2019 09:44:33 +0000 From: Christoph Hellwig To: Dan Williams , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 22/22] mm: don't select MIGRATE_VMA_HELPER from HMM_MIRROR Date: Thu, 13 Jun 2019 11:43:25 +0200 Message-Id: <20190613094326.24093-23-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613094326.24093-1-hch@lst.de> References: <20190613094326.24093-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP The migrate_vma helper is only used by noveau to migrate device private pages around. Other HMM_MIRROR users like amdgpu or infiniband don't need it. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe --- drivers/gpu/drm/nouveau/Kconfig | 1 + mm/Kconfig | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig index 66c839d8e9d1..96b9814e6d06 100644 --- a/drivers/gpu/drm/nouveau/Kconfig +++ b/drivers/gpu/drm/nouveau/Kconfig @@ -88,6 +88,7 @@ config DRM_NOUVEAU_SVM depends on DRM_NOUVEAU depends on HMM_MIRROR depends on STAGING + select MIGRATE_VMA_HELPER default n help Say Y here if you want to enable experimental support for diff --git a/mm/Kconfig b/mm/Kconfig index 73676cb4693f..eca88679b624 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -679,7 +679,6 @@ config HMM_MIRROR bool "HMM mirror CPU page table into a device page table" depends on MMU select MMU_NOTIFIER - select MIGRATE_VMA_HELPER help Select HMM_MIRROR if you want to mirror range of the CPU page table of a process into a device page table. Here, mirror means "keep synchronized".