From patchwork Wed Oct 10 19:19:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 10635121 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 0C16816B1 for ; Wed, 10 Oct 2018 19:20:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B00422A9F9 for ; Wed, 10 Oct 2018 19:20:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9ED312AA34; Wed, 10 Oct 2018 19:20: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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 551A02A9F9 for ; Wed, 10 Oct 2018 19:20:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C8FC6B0007; Wed, 10 Oct 2018 15:20:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 49ECB6B0008; Wed, 10 Oct 2018 15:20:12 -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 38CF76B000A; Wed, 10 Oct 2018 15:20:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 0EB2B6B0007 for ; Wed, 10 Oct 2018 15:20:12 -0400 (EDT) Received: by mail-qt1-f197.google.com with SMTP id n1-v6so6119430qtb.17 for ; Wed, 10 Oct 2018 12:20:12 -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-filter:dkim-signature:from:to:cc:subject :date:message-id:in-reply-to:references; bh=N3v2LzU7/zfxpIewN1Lf4Ei0VdWx18Nl2AhIPWVI0IE=; b=TgkUhr7oS8n8lmSuCsR0TqGEwpAI1fobe/UngU3153T3Z46jXqz7XkcJtVI090T7Ki N8JU1keek3rO4/AjmV5cbp0vruzN3AYBZv90mqoYN9f8CSHtwFScZLNRXT5X+85TOvZa UD8zCe85iwfPEFiQYGt8yG5lHHdmu5XfJ57ef9cjiNZv2S8TPV1ZUELiUp9sWQyGKfJj uBJ9KVXC9wzqVKlFQyKQUY5lILAdB1vOgi4eBGavlTjCBueYp8cL8gOQp3wSyLWibV9v v5OTNZLs2k8MZrCos5N8lUfEhGmJ3bZf3XxOvPe5dpbwdDrWg5jbbk9wYBUK/hUnKQ+g Hx6w== X-Gm-Message-State: ABuFfoiAKw8hyx+KZKaKhz5SUUlIhPIoqKnspYyUof9um6iv7eQ523WV 0BvK1H3FoQQuPjmOn4EHRmR/Wj5LVhQjbYPDDjbx4LdlFMuzxT18VyibKb4rkZ5G2SqLZDneEJ8 +nrJW7r6os1mwfbYMbstT+9kVfFTylOlfpPpSe4LwxlVcMMZ9ZMQibZUYwq7EyGeRNg== X-Received: by 2002:ac8:35ef:: with SMTP id l44-v6mr29182440qtb.165.1539199211727; Wed, 10 Oct 2018 12:20:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV60TE8C7Z6LkjWGY0KoX5ops0tePKKhe6HlDa6c6VgucOPnLMLB13vc7Qm349UjvF6RwzL80 X-Received: by 2002:ac8:35ef:: with SMTP id l44-v6mr29182383qtb.165.1539199210757; Wed, 10 Oct 2018 12:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539199210; cv=none; d=google.com; s=arc-20160816; b=TMsLVu77WAsrNMImF+b/NxlHrQ1T0yn0aDVqlmMG7ekDLilDv+EGVE6qt2w71l+Dbz StSDQqHLnqX3+t+E0KVL7JReHekcyaqOS3XbBTn5SP6r/TRU8QJq9+EbGueDF0ULk830 834qzARhetsVAqSP6eQcmpwkLgw9BRBrNMPdgeMQeSJkZhJ8pJGODES5dG4NBnjcXjq4 a3Iy190j4UY2ohLVyZvd2YGVfUnrlWSX3NlxSYmuMNKU9jlfzIBSkrdLokR0IKQAVbgx OExyNV8YF5bMFsdgSq1Zuoa7DN5TBqFMzrXfUZuaX/xBw3v2/Vo9/3yhrJ+CriMma003 2wBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=N3v2LzU7/zfxpIewN1Lf4Ei0VdWx18Nl2AhIPWVI0IE=; b=urJFr4wGN736QkPm8eIoC64xF91JxkDvdd2q2c9R6Z8JR0McYlZSheVovCKjQyDZpx zwv74ee73e2cD7dUOrUjc9faSMthTYJjgi0thdJZQuHVchD8T7LZsvKWz2/iAtcup9Cy beHvNv8ZomgXmxgP5ikLexY296jmVVrhYRnLJtY49g89aAkShbkjvo3nbGHE+/wR0XdT M8O1yJPjZUvDW5V6c+76CDz9Vg86BztFOf2bFILOhxrf+Ct71SWzH4mSxD4tqhGkfnUf umDBJCByYxw4ziOn8am7+aI5AaYKT6u9j2UAKjA//7j8FNSu1uYkbLx9D7mwOV1L44lF 2NFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=pojuf1kk; spf=pass (google.com: domain of mathieu.desnoyers@efficios.com designates 2607:5300:60:7898::beef as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from mail.efficios.com (mail.efficios.com. [2607:5300:60:7898::beef]) by mx.google.com with ESMTPS id h23-v6si1144456qve.115.2018.10.10.12.20.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 12:20:10 -0700 (PDT) Received-SPF: pass (google.com: domain of mathieu.desnoyers@efficios.com designates 2607:5300:60:7898::beef as permitted sender) client-ip=2607:5300:60:7898::beef; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=pojuf1kk; spf=pass (google.com: domain of mathieu.desnoyers@efficios.com designates 2607:5300:60:7898::beef as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 68508183B8F; Wed, 10 Oct 2018 15:20:09 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id Cc-RHBPAIvn7; Wed, 10 Oct 2018 15:20:08 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id D9714183B8C; Wed, 10 Oct 2018 15:20:08 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com D9714183B8C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1539199208; bh=N3v2LzU7/zfxpIewN1Lf4Ei0VdWx18Nl2AhIPWVI0IE=; h=From:To:Date:Message-Id; b=pojuf1kk6MRO/Lc3GGHNBSlUm1oXl0KHEDFzI70c+3NmZTyRvFmBSWtRkJyDPkerP 3RS7Kw6yS/PRMkyWpvXNRGCYiHv0glP/ms4u/yjTYdsbXHU9WL2ycoA8ac8cGbmoK/ g8GwLiZ0cKNOJHXjH0WXQdQ7VwZvjF9LbqsO0dselL4l3lZnC8h3nY3e3wY1QjKBq0 WvLJK2sDLpZM3tjBa+STMCbBi1lXAt3WnHunTvQvBu8xfG/8ZhaW5SjXKZ5hkSL71G NUbqWFAMSLHdlgTBT8595h6zRLFX/fFzo9LFTZuOV3xmZ6EwL7WsLmyZWoIWC2FDZX Xqz/RePjhyXeQ== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id ZosSI9PQcR26; Wed, 10 Oct 2018 15:20:08 -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 59062183B7F; Wed, 10 Oct 2018 15:20:07 -0400 (EDT) From: Mathieu Desnoyers To: Peter Zijlstra , "Paul E . McKenney" , Boqun Feng Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Thomas Gleixner , Andy Lutomirski , Dave Watson , Paul Turner , Andrew Morton , Russell King , Ingo Molnar , "H . Peter Anvin" , Andi Kleen , Chris Lameter , Ben Maurer , Steven Rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes , Mathieu Desnoyers , linux-mm@kvack.org Subject: [RFC PATCH for 4.21 05/16] mm: Provide is_vma_noncached Date: Wed, 10 Oct 2018 15:19:25 -0400 Message-Id: <20181010191936.7495-6-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181010191936.7495-1-mathieu.desnoyers@efficios.com> References: <20181010191936.7495-1-mathieu.desnoyers@efficios.com> 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 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: 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 0416a7204be3..18acf4f339f8 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2551,6 +2551,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 */