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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 CBC8AC433DB for ; Wed, 20 Jan 2021 18:13:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 63E4C233FA for ; Wed, 20 Jan 2021 18:13:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63E4C233FA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E3CFB6B0007; Wed, 20 Jan 2021 13:13:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DE9116B0008; Wed, 20 Jan 2021 13:13:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6DFE6B000A; Wed, 20 Jan 2021 13:13:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0167.hostedemail.com [216.40.44.167]) by kanga.kvack.org (Postfix) with ESMTP id B10BE6B0007 for ; Wed, 20 Jan 2021 13:13:50 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7DE3D181AEF31 for ; Wed, 20 Jan 2021 18:13:50 +0000 (UTC) X-FDA: 77726951820.14.steam43_2700b392755c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 6804218229835 for ; Wed, 20 Jan 2021 18:13:50 +0000 (UTC) X-HE-Tag: steam43_2700b392755c X-Filterd-Recvd-Size: 6034 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 Jan 2021 18:13:49 +0000 (UTC) Received: by mail-pg1-f181.google.com with SMTP id 30so15727701pgr.6 for ; Wed, 20 Jan 2021 10:13:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vqS6EOPx1v3lWV34LsE0XHCb+L3kcvteEkC/GfC64BE=; b=b7UUDohhc2AV/P0BT5XU6kMSxgSGbx9gumh1WGnEmTDRseGY7iJA+G6oMj8f74T9IP g7a7ce/MHu3y6yyAsCnkxfz+Sij+ZD9X53N4EGLxVW+NhVxW+PPlfDegkd2p/b5Sl4NF /T0Ghpwz5b3UQGdqc+aqnf8kvfVQhb4Dlm8c1q0rpeW7q7/AKR8/JjIcYqXvUo5zXR9X Cp9U8UPguu/Y+CbVFSmiq5i2BAv7P9gMdYGQftTwxXU19cGKiRRWhyYWV8+NGNks0/is H5PkLSsnH7KRZWM3XEO9AYVK4icTY92ntUCzRoE9EA25RmD+U4wHNbUD2SV4sxDner+r VoRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vqS6EOPx1v3lWV34LsE0XHCb+L3kcvteEkC/GfC64BE=; b=hqyHNsj1nlP5TMdQ0ieODDmkDk003DVdLTtuBwHEQjSb283F27ra1LaK9kyxiSFnhX LSu8O2cmHva25NJBRW9SFZImIKGFmljIMsll/1OLsaimV+3TOjRvjISU/Z5SRIHgksUM 7rmQ5CEYzUwZGdvJR0MtALhJSigcQYSbF4bYymXLY42R1pMQ+JGPrSUG3KWUUd8jM7oO FVX5ssQJxDKCkL5VrAXE3wTf1mYo/gXQSX9KYhVbnPiKbF/bRoefmjtXUol3Z+mrXAxA kwyY/2ebk8dYzrrlXOifwn6RBlx4KlhqCsK3uW6rrG/I8hq/1pUtAQ+S2XByADQTEWyH J6Jw== X-Gm-Message-State: AOAM532WPpPky7LOqmBcNAJjsICENDJD+cfCGtpa7OZaZMbsm11/f2DC J5JTNBPw7TOxpzx4uepON/NEhKEUArAvut6RyjCS5w== X-Google-Smtp-Source: ABdhPJzxKvvh4dLbPl6a/sMb5hnfqVGEKnrS2VQPwNZAtsZj2lhEVlzA2jjsOwNk5IvxDMpihfHJvdns9QRf9aoD2V8= X-Received: by 2002:a62:838d:0:b029:1ba:9b85:2eac with SMTP id h135-20020a62838d0000b02901ba9b852eacmr5037355pfe.36.1611166428292; Wed, 20 Jan 2021 10:13:48 -0800 (PST) MIME-Version: 1.0 References: <20210120173612.20913-1-will@kernel.org> <20210120173612.20913-5-will@kernel.org> In-Reply-To: <20210120173612.20913-5-will@kernel.org> From: Nick Desaulniers Date: Wed, 20 Jan 2021 10:13:37 -0800 Message-ID: Subject: Re: [PATCH v4 4/8] mm: Move immutable fields of 'struct vm_fault' into anonymous struct To: Will Deacon Cc: LKML , Linux Memory Management List , Linux ARM , Catalin Marinas , Jan Kara , Minchan Kim , Andrew Morton , "Kirill A . Shutemov" , Linus Torvalds , Vinayak Menon , Hugh Dickins , kernel-team Content-Type: text/plain; charset="UTF-8" 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: On Wed, Jan 20, 2021 at 9:36 AM Will Deacon wrote: > > '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 I think this paragraph+link would be better on patch 8/8. > > 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 > -- Thanks, ~Nick Desaulniers