From mboxrd@z Thu Jan 1 00:00:00 1970 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=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 95750C433DB for ; Wed, 20 Jan 2021 17:38:57 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F265D20705 for ; Wed, 20 Jan 2021 17:38:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F265D20705 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=61jiW755ffp391vKUpgC2ME8w8TodPbdQJkS3SxyT/8=; b=gMVqva8U/oLJy51p+54YgBl0E YHhMJ32a11GYLK8VqaaqgGAsFOp62i9V/tiIFEHLsJOWItEVVoep+KMa9szE0Ouu1uzrBqRl2Ichq 7UaSUebenH25BICg8mbCpZ1xFqQyaOUiAtUqAHGclooaunmho8njjFk7taTWRfUOdL6Azk1CJD1vk ItPLL08R1ZK2PvZhmp4FvjbbthBbiPuY6LHcDy8OuleLSz7/7odGPOn+YXVbdRowIR2/o5K66D2xW OXmya9cs/cc38SbbnfDxWXeD+g2eDcNr0ip0UhuzYXH8vDaooz3xxespFp8aNefyM/F5R5oa9GmlI jiBkIFaLA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2HPh-0002CP-7A; Wed, 20 Jan 2021 17:37:01 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2HPG-00024y-1R for linux-arm-kernel@lists.infradead.org; Wed, 20 Jan 2021 17:36:46 +0000 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210120_123634_225689_4DFAFE12 X-CRM114-Status: GOOD ( 14.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nick Desaulniers , kernel-team@android.com, Jan Kara , Minchan Kim , Catalin Marinas , Linus Torvalds , Hugh Dickins , linux-mm@kvack.org, Vinayak Menon , "Kirill A . Shutemov" , Andrew Morton , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org '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 -- 2.30.0.284.gd98b1dd5eaa7-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel