Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4272232ybi; Mon, 29 Jul 2019 22:57:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtnsLZVVDb/yWQyk7cgC+5W8uSbXU/2QtMmWGUcaLy/uQ/CUkolWqJoBUsoJOeiS2XMpDD X-Received: by 2002:a17:902:9b94:: with SMTP id y20mr113393193plp.260.1564466271712; Mon, 29 Jul 2019 22:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564466271; cv=none; d=google.com; s=arc-20160816; b=YfKrW91kmwIxpV2DykI8Hp71t7BWRX/bNLzQhKTQmTaBHZTEu/xsrZ+UwVKyxHynMZ D1Ii8h5LzrkplrjPZmMRDOcQ5NsssagTPlmEoL8SPqJkvplvMGwp3Z6CB/6ct0mgcMcr B7xls2HugihXu5fU6/LmJToQhNZRxLo2EiCB5HSmEtHiEtMO2z1H2B1ZySZO1ZmDDP3W CufZJlAOW3NBZjwuXkDcuaUo4ut5sJT/uT76cN+jPD/DLldkKefTE7auMPUFEZhAqI11 xgmrtlxWzq13O+ETcWBYbczjJ3duqqz46M7jGXP5ZoDyJyXHKjkhLBIcRGm15G6UIFOE FUUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/5sNjyutpvGxyHVQu1GnV/XZDve/kWrhGHnNmckcmW4=; b=lvG9yOar1xPLK/RIklh86T3gW8m3COqnXB4IZ0Upk9tnpVKXvhMfQGafwEjLDhGxX1 yh1OKSCc3i1yaaDIM3TXifJQSqkxq5eLwnPG4DkOw7Oq9H8T6BhDVoKoWpdFxKP+Wl8F P27jDqZshPaQQ6g5X+X7HPaYgHi4qz/7ws6WSAUw+Qi8I4SuuPYxBHao20zAvenQUDki y8H1ZB6eZTXKwVODVy6lmzZjkWWDtYnX9IBQuD3Aj1ITGG1v4olI7isHP0fKei5Bm+IF MijvyUbP3T+9DJ7LeQUcSgoV47yudVNgygUvW4lrexuMRjNhJ0l3Kw8GwXEKqEurqtD1 IdCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=qUVDb0Gb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f139si58758852pfa.2.2019.07.29.22.57.37; Mon, 29 Jul 2019 22:57:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=qUVDb0Gb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729684AbfG3Fwv (ORCPT + 99 others); Tue, 30 Jul 2019 01:52:51 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:46806 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729671AbfG3Fws (ORCPT ); Tue, 30 Jul 2019 01:52:48 -0400 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=/5sNjyutpvGxyHVQu1GnV/XZDve/kWrhGHnNmckcmW4=; b=qUVDb0Gb7qkDZ66Y+5kTNUPiZS oPKFdf1FdqOh8A+YmmGZN9LNdSXHfAWdAy/P90p3MOCc2Z96eNVGgpwDoqMg90kChee4ehDTqgr0j Pkj3WfEI90d1K0L5yj8xDhi4zgmFwII7fKqNTkcOh87hmP8aIWYto5bpxj6Uy1e0sMmXDfuZHNiQe ryhsB5F5qd969AsJYWXGSU3b3LjXZyE7SQi6J6IID+hg37hn/a03/WzGB57Vb+NcFVUtwUa5rdmZi cmRAd6TOTOi1MrSWzl3EdA3D5NUMB0guYKclteB1z/GzP1uvBIhvL0Mxg647o4EVb80KI84ij7PDP xbU47HuQ==; Received: from [195.167.85.94] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hsL40-0001NU-9X; Tue, 30 Jul 2019 05:52:44 +0000 From: Christoph Hellwig To: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Jason Gunthorpe , Ben Skeggs , Felix Kuehling Cc: Ralph Campbell , linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/13] mm: only define hmm_vma_walk_pud if needed Date: Tue, 30 Jul 2019 08:52:00 +0300 Message-Id: <20190730055203.28467-11-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190730055203.28467-1-hch@lst.de> References: <20190730055203.28467-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We only need the special pud_entry walker if PUD-sized hugepages and pte mappings are supported, else the common pagewalk code will take care of the iteration. Not implementing this callback reduced the amount of code compiled for non-x86 platforms, and also fixes compile failures with other architectures when helpers like pud_pfn are not implemented. Signed-off-by: Christoph Hellwig --- mm/hmm.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/mm/hmm.c b/mm/hmm.c index e63ab7f11334..4d3bd41b6522 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -455,15 +455,6 @@ static inline uint64_t pmd_to_hmm_pfn_flags(struct hmm_range *range, pmd_t pmd) range->flags[HMM_PFN_VALID]; } -static inline uint64_t pud_to_hmm_pfn_flags(struct hmm_range *range, pud_t pud) -{ - if (!pud_present(pud)) - return 0; - return pud_write(pud) ? range->flags[HMM_PFN_VALID] | - range->flags[HMM_PFN_WRITE] : - range->flags[HMM_PFN_VALID]; -} - static int hmm_vma_handle_pmd(struct mm_walk *walk, unsigned long addr, unsigned long end, @@ -700,10 +691,19 @@ static int hmm_vma_walk_pmd(pmd_t *pmdp, return 0; } -static int hmm_vma_walk_pud(pud_t *pudp, - unsigned long start, - unsigned long end, - struct mm_walk *walk) +#if defined(CONFIG_ARCH_HAS_PTE_DEVMAP) && \ + defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) +static inline uint64_t pud_to_hmm_pfn_flags(struct hmm_range *range, pud_t pud) +{ + if (!pud_present(pud)) + return 0; + return pud_write(pud) ? range->flags[HMM_PFN_VALID] | + range->flags[HMM_PFN_WRITE] : + range->flags[HMM_PFN_VALID]; +} + +static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end, + struct mm_walk *walk) { struct hmm_vma_walk *hmm_vma_walk = walk->private; struct hmm_range *range = hmm_vma_walk->range; @@ -765,6 +765,9 @@ static int hmm_vma_walk_pud(pud_t *pudp, return 0; } +#else +#define hmm_vma_walk_pud NULL +#endif static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask, unsigned long start, unsigned long end, -- 2.20.1