From patchwork Thu May 27 20:23:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12285287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75FB0C4708B for ; Thu, 27 May 2021 20:23:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 22250613CC for ; Thu, 27 May 2021 20:23:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22250613CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5AE496B007D; Thu, 27 May 2021 16:23:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52E036B007E; Thu, 27 May 2021 16:23:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFE7C6B0080; Thu, 27 May 2021 16:23:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0001.hostedemail.com [216.40.44.1]) by kanga.kvack.org (Postfix) with ESMTP id 842E86B007D for ; Thu, 27 May 2021 16:23:14 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 2B63B1801C1A2 for ; Thu, 27 May 2021 20:23:14 +0000 (UTC) X-FDA: 78188135508.18.4486878 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id C5B03A0003AC for ; Thu, 27 May 2021 20:23:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622146993; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SAmjiglASlkj6C13Cutnvz5k0d0w8IXdZ7Qyh6+DwYY=; b=DcmN0TE1J7W3flR/ry4yJlzUasUgyMIkZM+kRyPNI3BWwEtlimeTOx+bsu2cdAlbmkghDu VVS3AlU3sraiyFYy9U2fMzjnFt8RJa8cUScXMiRCXSNNcCoO9SCmGJgDpqqb3TewnpvPb2 90K0DECXalgV6eYMocCuirsXWT4Vt/A= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-502-wmSOMiChNYCadnaFle_C4A-1; Thu, 27 May 2021 16:23:11 -0400 X-MC-Unique: wmSOMiChNYCadnaFle_C4A-1 Received: by mail-qt1-f199.google.com with SMTP id g21-20020ac870d50000b0290230013e97e6so841284qtp.21 for ; Thu, 27 May 2021 13:23:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SAmjiglASlkj6C13Cutnvz5k0d0w8IXdZ7Qyh6+DwYY=; b=kSmFc/2OthMNFYunVCq2GtaFfF9mZ0ixT55/dnSfONoFZoDQAzdwOsmpB8dhqT28GI ggL4eWWo/RuM1d0RtQIQpApGL483w7U2QxcO5qiJ9wrNjl4jtX07VumMcDYYxZe64G7r LuHA0CljggrwJ/yBN3QTBwYDYQ+yN8ytAul+vEGUM9HQKiR4wVgEpmRaTcNvPVMIftEn fNW1FNlbFoKlEPxmBJz3hg+ImC/Gbv2eHwW9YjQYWsZh25iPTu1HzInIxXOcrjmFgf5U EpLxnAw9DbqLyUsB+MN5fdYE7DFyHvCh0bpBQAbOMprM5u92ae6T+cTpYUzsVyocPH3U 6+Qw== X-Gm-Message-State: AOAM532GLSEGa1i8/CNnegjc57DJJjC7l4faZwm/uTYa+FAQyr6yqF7A Nib+locIgF0KJUeYhtcYhzp6yQ6r51bbUG3/WsxVWiXCSphpwe061D9ybrqkaZExTOC6GyXl9+E /yXgzeizlERk= X-Received: by 2002:ad4:5227:: with SMTP id r7mr340808qvq.41.1622146991377; Thu, 27 May 2021 13:23:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtCJbSTqUjM7suwiR8IhoI+l1zb1zSSJrik2m04Tqem1imNMBVQvJJonjARh3dJDvw2YkfBA== X-Received: by 2002:ad4:5227:: with SMTP id r7mr340783qvq.41.1622146991171; Thu, 27 May 2021 13:23:11 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-72-184-145-4-219.dsl.bell.ca. [184.145.4.219]) by smtp.gmail.com with ESMTPSA id c7sm2044392qkc.114.2021.05.27.13.23.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 13:23:10 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Mike Rapoport , peterx@redhat.com, Andrew Morton , Mike Kravetz , Jerome Glisse , Miaohe Lin , Nadav Amit , Hugh Dickins , Matthew Wilcox , Jason Gunthorpe , "Kirill A . Shutemov" , Andrea Arcangeli , Axel Rasmussen Subject: [PATCH v3 17/27] mm/hugetlb: Introduce huge pte version of uffd-wp helpers Date: Thu, 27 May 2021 16:23:07 -0400 Message-Id: <20210527202307.31882-1-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210527201927.29586-1-peterx@redhat.com> References: <20210527201927.29586-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DcmN0TE1; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf23.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-Stat-Signature: 9pwm8y6p7fc8zs8icsutd8pwnfs7mmzc X-Rspamd-Queue-Id: C5B03A0003AC X-Rspamd-Server: rspam02 X-HE-Tag: 1622146986-744250 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: They will be used in the follow up patches to either check/set/clear uffd-wp bit of a huge pte. So far it reuses all the small pte helpers. Archs can overwrite these versions when necessary (with __HAVE_ARCH_HUGE_PTE_UFFD_WP* macros) in the future. Signed-off-by: Peter Xu --- include/asm-generic/hugetlb.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/asm-generic/hugetlb.h b/include/asm-generic/hugetlb.h index 8e1e6244a89d..c45b9deb41ff 100644 --- a/include/asm-generic/hugetlb.h +++ b/include/asm-generic/hugetlb.h @@ -32,6 +32,21 @@ static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot) return pte_modify(pte, newprot); } +static inline pte_t huge_pte_mkuffd_wp(pte_t pte) +{ + return pte_mkuffd_wp(pte); +} + +static inline pte_t huge_pte_clear_uffd_wp(pte_t pte) +{ + return pte_clear_uffd_wp(pte); +} + +static inline int huge_pte_uffd_wp(pte_t pte) +{ + return pte_uffd_wp(pte); +} + #ifndef __HAVE_ARCH_HUGE_PTE_CLEAR static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep, unsigned long sz)