Received: by 10.192.165.156 with SMTP id m28csp2338474imm; Thu, 12 Apr 2018 12:34:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx48DE6X3mkQ/OmTVigkeczMtFq0FEnJ0pHy3BOgy7AZtt9Pqa6JiGiJANrEO53hOyHByQp9+ X-Received: by 10.98.149.78 with SMTP id p75mr8853213pfd.188.1523561676268; Thu, 12 Apr 2018 12:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523561676; cv=none; d=google.com; s=arc-20160816; b=Qav6Qi1VV+4AG12l2pmPBSzdLRMm1EuVv71BxreUQEPcrGsbiHJS7CaWa3lvyJakNo QByIzxa9G2bWY/oI1OIUltLmNbEDMgjsl8Eu4tHVS7YRP13i0aRfDjVcNet1Gqy5tbL9 4fFsTIWWhoeMJixlfsK/BqxO2YBy30BApRu/ybEYutqTPK2VhcnruuCoLtjFSK0Qx0Y+ etLK7d/nZqmJi3b+Ei/Me3PEngW58f4lZCDWmZPnwLXQLfGwsi6A8RozhJM2wrQfw8Wa a7AetBmUhZ+QstwxN5dXoEghKR0JsCCn714jw7f58O1weTUHT7xw40q1te25CF797qFg eBZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=kPasYKXuLJRrZhnlJXgullBv/OdMbbm+GUlTZHSAl1E=; b=junkaKlAr5GkkVaCJT2DzchOd3fszxtCqzeff/kUQsPJlLksz+ynS/WvEdwZZ4Z/rR 2qFb1oHY3Ekgrq1xRvCSTPxKNmYphSDggoNbSXdmreDkVqhLr/+tUjLv17W9hEWWLzFk gc+h30q28zDoxEKEVfjtMEjvhXy4xW3yVGla5fgtYqu4mNN6WsqreSEZxL6LRmqwvvma azhIE7Xk1nGsD4BlPsQ6dxhsME3HUaIqx85gb13yx34e9Kn37a6LcptKBorC7+VKuTa4 4W2pjZUZrCaefS9RWwcfnvcMFAMNryacBUaJYvtMZKfrGEF1rSgoApuOuGI1MYHFK0mv IaFQ== ARC-Authentication-Results: i=1; mx.google.com; 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 k3-v6si2472956plt.233.2018.04.12.12.34.22; Thu, 12 Apr 2018 12:34:36 -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; 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 S1753990AbeDLTbm (ORCPT + 99 others); Thu, 12 Apr 2018 15:31:42 -0400 Received: from mail.efficios.com ([167.114.142.138]:45804 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753352AbeDLT2Y (ORCPT ); Thu, 12 Apr 2018 15:28:24 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 0ED7C1B0719; Thu, 12 Apr 2018 15:28:24 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail02.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 8v8mq5RqICbg; Thu, 12 Apr 2018 15:28:23 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 82EBD1B0706; Thu, 12 Apr 2018 15:28:23 -0400 (EDT) X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail02.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id cUaDUmlcmqhW; Thu, 12 Apr 2018 15:28:23 -0400 (EDT) Received: from thinkos.internal.efficios.com (192-222-157-41.qc.cable.ebox.net [192.222.157.41]) by mail.efficios.com (Postfix) with ESMTPSA id 291E81B06F4; Thu, 12 Apr 2018 15:28:23 -0400 (EDT) From: Mathieu Desnoyers To: Peter Zijlstra , "Paul E . McKenney" , Boqun Feng , Andy Lutomirski , Dave Watson Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Paul Turner , Andrew Morton , Russell King , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andrew Hunter , Andi Kleen , Chris Lameter , Ben Maurer , Steven Rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Mathieu Desnoyers , linux-mm@kvack.org Subject: [RFC PATCH for 4.18 11/23] mm: Provide is_vma_noncached Date: Thu, 12 Apr 2018 15:27:48 -0400 Message-Id: <20180412192800.15708-12-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180412192800.15708-1-mathieu.desnoyers@efficios.com> References: <20180412192800.15708-1-mathieu.desnoyers@efficios.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide is_vma_noncached() static inline to allow generic code to check whether the given vma consists of noncached memory. Signed-off-by: Mathieu Desnoyers CC: "Paul E. McKenney" CC: Peter Zijlstra CC: Paul Turner CC: Thomas Gleixner CC: Andrew Hunter CC: Andy Lutomirski CC: Andi Kleen CC: Dave Watson CC: Chris Lameter CC: Ingo Molnar CC: "H. Peter Anvin" CC: Ben Maurer CC: Steven Rostedt CC: Josh Triplett CC: Linus Torvalds CC: Andrew Morton CC: Russell King CC: Catalin Marinas CC: Will Deacon CC: Michael Kerrisk CC: Boqun Feng CC: linux-mm@kvack.org --- include/linux/mm.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index ad06d42adb1a..1f93a061a43b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2425,6 +2425,30 @@ static inline struct page *follow_page(struct vm_area_struct *vma, return follow_page_mask(vma, address, foll_flags, &unused_page_mask); } +static inline bool pgprot_same(pgprot_t a, pgprot_t b) +{ + return pgprot_val(a) == pgprot_val(b); +} + +#ifdef pgprot_noncached +static inline bool is_vma_noncached(struct vm_area_struct *vma) +{ + pgprot_t pgprot = vma->vm_page_prot; + + /* Check whether architecture implements noncached pages. */ + if (pgprot_same(pgprot_noncached(PAGE_KERNEL), PAGE_KERNEL)) + return false; + if (!pgprot_same(pgprot, pgprot_noncached(pgprot))) + return false; + return true; +} +#else +static inline bool is_vma_noncached(struct vm_area_struct *vma) +{ + return false; +} +#endif + #define FOLL_WRITE 0x01 /* check pte is writable */ #define FOLL_TOUCH 0x02 /* mark page accessed */ #define FOLL_GET 0x04 /* do get_page on page */ -- 2.11.0