Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4151698ybl; Mon, 3 Feb 2020 13:35:58 -0800 (PST) X-Google-Smtp-Source: APXvYqynf/8SU6DFZ9eEDfjQIWTOd8b6+lpQSqkO5QDkZyx9ZL1YnFJ1q/U/LncivcNISnO3amXU X-Received: by 2002:aca:7244:: with SMTP id p65mr793198oic.50.1580765758571; Mon, 03 Feb 2020 13:35:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580765758; cv=none; d=google.com; s=arc-20160816; b=E/t6ldAHUFFAsp/O0bUOsn0XrItgMZdcLIou0YoDEdmbMVDtAKaNf264EN2rpAp40f u+mLXqLrNXvsKb2B8AtiiOnYn9G7hYnfk8r6CopehlXrT6bQoDNf608uioMkMzYw8NFI SxTMneHITtsa7e5niHitudV7d/6ulsIUv51bbNrdp+V3KgisASoYCtZvopBWrKL9hRV8 R7IB7K+FrxxJWU0wM0P4tS05Y/01iAuc1pNhkY+zO/O4weYxXRepSki5ko5Lzmt7hOyT jp6+Vysi3nzRKFTyw4hBxmxfIptncYxuuBBh1N8n7mGSjOkzZ8zSojAs5HoY4ssNEcDh E3Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=RopiKUB7iog3vHCG/dVyQVRi17HY++IdZnq14RjmMqo=; b=CJWz3+cAIJs1uo6LUiJQnzotXwlbKLL8872gDrlRtwowWY8xN4FO8KVxSLazck5hoH l0Z+5EmCkRVErnjQOtxnDFKXGLHvv7odShcsZw+RYuVWHWxgGh3C1KhnWxnOZNgD5wxc IPsQ3odWH63cZ3N2CpKAZ0yKfLEJK4eqY85pFpSx+8KAhkSmNHwSmFuh2XI3cH+65pnd PIMi7m/zv9ZCrtJziJU2zFiFbrd3hzUdY+lfOCEC5dAgUCnfjS0NWsPxuLP42ZTYiEux 4db6qz4KeDMAEZ4QSq5syILM+L0Do7fFkUlIR+WAy3nJtXIGL9tiBSwNbrcZ1Ne0Mp+I WB/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=qCNcTepK; 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 x19si9323099otk.89.2020.02.03.13.35.45; Mon, 03 Feb 2020 13:35:58 -0800 (PST) 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=qCNcTepK; 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 S1726924AbgBCVex (ORCPT + 99 others); Mon, 3 Feb 2020 16:34:53 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:58158 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgBCVex (ORCPT ); Mon, 3 Feb 2020 16:34:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=RopiKUB7iog3vHCG/dVyQVRi17HY++IdZnq14RjmMqo=; b=qCNcTepKO/3xSSn/r68TuzJnKt b2OiqCyvcFUUCCCK6Cv9cMtmbBCWvbSY9HbCzoQ+nTTK6Pxo9KdDl8xjsD8mavlTxr7ffgM4bY5jI AODGNG2a/KJ1GGnInvzU2bGXJQvPtn8Zr75YRh7YBiM2wN1RwLhSBO+Dpq/R4gXUvmr2f4yVsBA2O +HQNwoIKHINdjxW34l2NoVYFStBBu88xEuAh/WLw1BQ9ds7XH6Lcjx9XTY2FLc8xLwLXQAOjFquka NX3t2BWf08QbBO6vk11n1FqvqNxg6EvK59GsxvC8Ev6WMc16PJw/v/43KKDud2wKo2JGkG+ghrgsv 0jE6UybQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iyjMg-0004O9-7p; Mon, 03 Feb 2020 21:34:42 +0000 Date: Mon, 3 Feb 2020 13:34:42 -0800 From: Matthew Wilcox To: Joao Martins Cc: linux-nvdimm@lists.01.org, Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny , Alex Williamson , Cornelia Huck , kvm@vger.kernel.org, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, Liran Alon , Nikita Leshenko , Barret Rhoden , Boris Ostrovsky , Konrad Rzeszutek Wilk Subject: Re: [PATCH RFC 01/10] mm: Add pmd support for _PAGE_SPECIAL Message-ID: <20200203213442.GK8731@bombadil.infradead.org> References: <20200110190313.17144-1-joao.m.martins@oracle.com> <20200110190313.17144-2-joao.m.martins@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200110190313.17144-2-joao.m.martins@oracle.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 10, 2020 at 07:03:04PM +0000, Joao Martins wrote: > +++ b/arch/x86/include/asm/pgtable.h > @@ -293,6 +293,15 @@ static inline int pgd_devmap(pgd_t pgd) > { > return 0; > } > +#endif > + > +#ifdef CONFIG_ARCH_HAS_PTE_SPECIAL > +static inline int pmd_special(pmd_t pmd) > +{ > + return !!(pmd_flags(pmd) & _PAGE_SPECIAL); > +} > +#endif The ifdef/endif don't make much sense here; x86 does have PTE_SPECIAL, and this is an x86 header file, so that can be assumed. > +++ b/mm/gup.c > @@ -2079,6 +2079,9 @@ static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr, > return __gup_device_huge_pmd(orig, pmdp, addr, end, pages, nr); > } > > + if (pmd_special(orig)) > + return 0; Here, you're calling it unconditionally. I think you need a pmd_special() conditionally defined in include/asm-generic/pgtable.h +#ifndef CONFIG_ARCH_HAS_PTE_SPECIAL +static inline bool pmd_special(pmd_t pmd) +{ + return false; +} +#endif (oh, and plese use bool instead of int; I know that's different from pte_special(), but pte_special() predates bool and nobody's done the work to convert it yet) > +++ b/mm/huge_memory.c > @@ -791,6 +791,8 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, > entry = pmd_mkhuge(pfn_t_pmd(pfn, prot)); > if (pfn_t_devmap(pfn)) > entry = pmd_mkdevmap(entry); > + else if (pfn_t_special(pfn)) > + entry = pmd_mkspecial(entry); Again, we'll need a generic one. > @@ -823,8 +825,7 @@ vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write) > * but we need to be consistent with PTEs and architectures that > * can't support a 'special' bit. > */ > - BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) && > - !pfn_t_devmap(pfn)); > + BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))); Should that rather be ... + BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) && + !pfn_t_devmap(pfn) && !pfn_t_special(pfn)); I also think this comment needs adjusting: /* * There is no pmd_special() but there may be special pmds, e.g. * in a direct-access (dax) mapping, so let's just replicate the * !CONFIG_ARCH_HAS_PTE_SPECIAL case from vm_normal_page() here. */