From patchwork Wed Jan 20 17:36:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 12033037 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.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 16F78C433E0 for ; Wed, 20 Jan 2021 17:36:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BBBA423122 for ; Wed, 20 Jan 2021 17:36:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BBBA423122 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 523656B000A; Wed, 20 Jan 2021 12:36:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D3CD6B000C; Wed, 20 Jan 2021 12:36:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C6C06B000D; Wed, 20 Jan 2021 12:36:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0067.hostedemail.com [216.40.44.67]) by kanga.kvack.org (Postfix) with ESMTP id 25ED96B000A for ; Wed, 20 Jan 2021 12:36:35 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DAF4E1EE6 for ; Wed, 20 Jan 2021 17:36:34 +0000 (UTC) X-FDA: 77726857908.08.rock95_05075932755c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id B398D1819E772 for ; Wed, 20 Jan 2021 17:36:34 +0000 (UTC) X-HE-Tag: rock95_05075932755c X-Filterd-Recvd-Size: 4137 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 Jan 2021 17:36:33 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id F3DAF20705; Wed, 20 Jan 2021 17:36:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611164193; bh=1NPKVlBGRw3SuPWaJXbQxTnIY7pCrHJ3wlOHyCK9jeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U9ca2SegTpBhZEzpssFClY/cObJnvft5eu8HXnPUhuqoE0GL6ZLTTHCMt+pwygMGS GwJ97sj9K5mpO0BafY2aTyqIHxzV97j9D4ltNM6cyfE+4dftlwGNdjAknrY08pTxKV xhKfsblHNbZBiPjDdzW/d9doz9vT4Q9iKoAZkuqns71CBcrqzdVvpL4A78yc/jzEsb Xgva3GgS62+EQ1vdc7cNnVG7BhcWZP4XTo9pnPGYWqWH+n8/CZP1P0mPvFNlpjhKjX bZ36Xx+btBsNJHmOg7dDapu5k0tI7CvIvpQspgEeYEIjLkAbJTUnIEK6HP956Htv9n ldHKDhkeCS1YQ== From: Will Deacon To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Will Deacon , Catalin Marinas , Jan Kara , Minchan Kim , Andrew Morton , "Kirill A . Shutemov" , Linus Torvalds , Vinayak Menon , Hugh Dickins , Nick Desaulniers , kernel-team@android.com Subject: [PATCH v4 4/8] mm: Move immutable fields of 'struct vm_fault' into anonymous struct Date: Wed, 20 Jan 2021 17:36:08 +0000 Message-Id: <20210120173612.20913-5-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210120173612.20913-1-will@kernel.org> References: <20210120173612.20913-1-will@kernel.org> MIME-Version: 1.0 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: 'struct vm_fault' contains both information about the fault being serviced alongside mutable fields contributing to the state of the fault-handling logic. Unfortunately, the distinction between the two is not clear-cut, and a number of callers end up manipulating the structure temporarily before restoring it when returning. Try to clean this up by moving the immutable fault information into an anonymous struct, which will later be marked as 'const'. GCC will then complain (with an error) about modification of these fields after they have been initialised, although LLVM currently allows them without even a warning: https://bugs.llvm.org/show_bug.cgi?id=48755 Ideally, the 'flags' field would be part of the new structure too, but it seems as though the ->page_mkwrite() path is not ready for this yet. Cc: Kirill A. Shutemov Suggested-by: Linus Torvalds Link: https://lore.kernel.org/r/CAHk-=whYs9XsO88iqJzN6NC=D-dp2m0oYXuOoZ=eWnvv=5OA+w@mail.gmail.com Signed-off-by: Will Deacon --- include/linux/mm.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 251a2339befb..b4a5cb9bff7d 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -517,11 +517,14 @@ static inline bool fault_flag_allow_retry_first(unsigned int flags) * pgoff should be used in favour of virtual_address, if possible. */ struct vm_fault { - struct vm_area_struct *vma; /* Target VMA */ - unsigned int flags; /* FAULT_FLAG_xxx flags */ - gfp_t gfp_mask; /* gfp mask to be used for allocations */ - pgoff_t pgoff; /* Logical page offset based on vma */ - unsigned long address; /* Faulting virtual address */ + struct { + struct vm_area_struct *vma; /* Target VMA */ + gfp_t gfp_mask; /* gfp mask to be used for allocations */ + pgoff_t pgoff; /* Logical page offset based on vma */ + unsigned long address; /* Faulting virtual address */ + }; + unsigned int flags; /* FAULT_FLAG_xxx flags + * XXX: should really be 'const' */ pmd_t *pmd; /* Pointer to pmd entry matching * the 'address' */ pud_t *pud; /* Pointer to pud entry matching