From patchwork Thu Nov 1 09:58:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 10663723 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 0C7FC13B5 for ; Thu, 1 Nov 2018 09:59:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E61372B663 for ; Thu, 1 Nov 2018 09:59:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D84462B68E; Thu, 1 Nov 2018 09:59:36 +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 BF6912B663 for ; Thu, 1 Nov 2018 09:59:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2FB96B0269; Thu, 1 Nov 2018 05:59:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BE00B6B026A; Thu, 1 Nov 2018 05:59:34 -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 ACDB36B026B; Thu, 1 Nov 2018 05:59:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 831266B0269 for ; Thu, 1 Nov 2018 05:59:34 -0400 (EDT) Received: by mail-qk1-f198.google.com with SMTP id v184-v6so20333644qkh.23 for ; Thu, 01 Nov 2018 02:59:34 -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=HQiW5MjcvqRGkMYnPx9o33Go4qF4+2APaf1UPSFxBiHYJgYnH5nWofDINMsm5oge8B 4pK/nF7yQuaDVxGVubD1XYR6p9PjAfhZ7I4/H3L7YJ3p4A+L+5PZy0M6owOvBxgf7MxL OW/fXlStFAZbbf3GJDfgjlI7KFex1iQEeo1MTEZKIwrmNkUS4LG506DVWAOlAcD2aJYM bLvfeMhrpC6TXXjgmWEZoSZW8uLqYgf1DWXjJbXW4a5/KkIIbYyMrXBCPU11a+vBCOEC SPIPn9CP6NPlm/RNqVSMgnY+s/bkGlGH4DD0noXvVa3ttJNlra5dhaEP7/kCnz2H2NbM +67Q== X-Gm-Message-State: AGRZ1gK2Wd20DxWU993+oHuyrJ4n3c9W9ZyEJMflb1T9pZ3fw6cirBx7 7cRoQ4KgxkByF3OEUYUJvnArbOmLkWkNAl+sJd92P07DmFiZSefdrIPfJED6lbJPtSY2xgoaUd7 4h4okVouuuLnoqX9jZ/8f0KdvCjQD+cqcDeDrcL5KGUyEzcYy3qKcH8WZBOf4EZBDMA== X-Received: by 2002:a37:6c01:: with SMTP id h1-v6mr5891504qkc.67.1541066374232; Thu, 01 Nov 2018 02:59:34 -0700 (PDT) X-Google-Smtp-Source: AJdET5du+CdamIJtvrHD0g2tDQa8XzFp7vzpic40SKW3KJdCz5wOacBBJFOXIWCc/7xYDULMrvlH X-Received: by 2002:a37:6c01:: with SMTP id h1-v6mr5891476qkc.67.1541066373646; Thu, 01 Nov 2018 02:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541066373; cv=none; d=google.com; s=arc-20160816; b=JfZnfrK3zYFO2leRG1tlWvzRE3NM36XloPtJgtTxH16xpxfkj8Um8Jt+RmlBHrRs6C LZRcV/T29O95BEgLsQUTFWBm6GiU/Xj+MTT8OK21xHOZN8Ubw/Yizfbn4+LavOtt0GlI zBkqblKvNmQnJx7AGEMcdvz2R0wUTWbonFTroGnie971cXC9SxaU5/DogbqJrN3EDnue tnCT+hV3zYY+bxQoiV/dea32xjyWiRghSyiJ+rW2YDyEPWqfGWwgJB8LTIoJjPE/i9Az ZTclU3j/iLjyPtmwtxSlrlVvuH9YAhamiKOT0fjxi+5vXm+/Dfutn0p99KTkNENdKuhQ x9ug== 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=qA6lEEqyuBXrnxW6li7IfuMvtHU/2mtGb+FPrChQVNSZ6tN4fl5ALTNyddUS6HuhGg FNSVm9CzcdCs5E2DrnwLE8sRgwUe+tYQvsjIahR2xR9kv6o9JXLOtdWenczGZ9PRzkNv kyV5BWtNKqpuQfOZlrJXhKQu4cuuxl3MT2nmWPCw5n/6UkhgJd/xEz2FY5OGkognG+Xx vcT3bdlviKqptOg3fd1+fVcgzrX9RrAYbjcrcH1/oAJlkX/qn0UUocw5qGeDSQB670rM UInUNoCzzoTlGMr9NiWrpPHXDuXCd//hF14YySYcs3glDV8y7UOi5uept7Lcxj9eHJ6P Fkbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=TbhuP1e0; 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 k18-v6si311183qtj.22.2018.11.01.02.59.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 02:59:33 -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=TbhuP1e0; 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 53EC6227675; Thu, 1 Nov 2018 05:59:32 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id X6zKOFr8iNaF; Thu, 1 Nov 2018 05:59:31 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id BBC3A22766F; Thu, 1 Nov 2018 05:59:31 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com BBC3A22766F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1541066371; bh=N3v2LzU7/zfxpIewN1Lf4Ei0VdWx18Nl2AhIPWVI0IE=; h=From:To:Date:Message-Id; b=TbhuP1e0bdHIwDB0cwHVKv+Z+psJKG9+mIKl7f157uPcoc7c7NurDCULzSizcRQQQ VDewX/KkZihjislKs/3eIcE98ePjZlsghsFBjUQziVMaQ7/KmQkfEwSQSpTJZQmPfE gVCwWZym9W0sFLcxRvkcvkhQVb9Nx5OEgpog9jnE7RoFDQnwrKktqS1e7aKK3t9VfG icm75LePQvAZlL/xNspY08nop3jLusGzT+CWJqUK7dFxsNItdfq5J9YcH4OEmDjPJr 0WAcCvAYZn58El4hgfq4F/P3JB3IUOsC37ah/nOHTJLTLw2M6JGpWy2hNLOcwNz1Em 8wt27ni6gZH6Q== 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 N5HyUErGjTqi; Thu, 1 Nov 2018 05:59:31 -0400 (EDT) Received: from thinkos.etherlink (sessfw99-sesbfw99-92.ericsson.net [192.176.1.92]) by mail.efficios.com (Postfix) with ESMTPSA id CF580227653; Thu, 1 Nov 2018 05:59:25 -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: Thu, 1 Nov 2018 10:58:33 +0100 Message-Id: <20181101095844.24462-6-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181101095844.24462-1-mathieu.desnoyers@efficios.com> References: <20181101095844.24462-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 */