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=-10.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 53526C433DB for ; Thu, 14 Jan 2021 19:41:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C9BAA239E4 for ; Thu, 14 Jan 2021 19:41:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9BAA239E4 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 D478C8D0116; Thu, 14 Jan 2021 14:41:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CCFD18D00F0; Thu, 14 Jan 2021 14:41:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B97DB8D0116; Thu, 14 Jan 2021 14:41:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0210.hostedemail.com [216.40.44.210]) by kanga.kvack.org (Postfix) with ESMTP id 9D8B48D00F0 for ; Thu, 14 Jan 2021 14:41:41 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 64BAD2C14 for ; Thu, 14 Jan 2021 19:41:41 +0000 (UTC) X-FDA: 77705400402.02.apple98_1010d4d27529 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 4529610097AA1 for ; Thu, 14 Jan 2021 19:41:40 +0000 (UTC) X-HE-Tag: apple98_1010d4d27529 X-Filterd-Recvd-Size: 5619 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Thu, 14 Jan 2021 19:41:36 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 3987F239EF; Thu, 14 Jan 2021 19:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610653295; bh=j72ES8sG143mJE4qoXOz2HxLviBlz2SE24DDEx8XP0o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GTupvysEJQdFamE1YxFEmpRUIuOtDSMco9l+VnAqtDreicebY/e5TFTBV9T5lPwJ+ 6W98Bz9ewmb/e7mc6z4cmTGMvJcALkWW4pn/lVbGNshU51fDceDJu4+NDs5qAvnbAe 8Q5ISSNEjsp8luCkE7n0yHHwg/NVITpnY62NAYheMibO6W3ZZZpOaJ1q/a2GO5hiMI OtadQ5JviuBgoZEv46qUSwHKJtrMv4lr9Roo1oP/94omk3v5kzX5ks27TPQg3anIkz aflwvl5gc9Ezt6aWY2gqecU5AmLW5R2yS+PCkuE//tZGOHmaq5EKszKubPvzUJcJTj PV2DQLD3R1zxg== Date: Thu, 14 Jan 2021 19:41:29 +0000 From: Will Deacon To: Linus Torvalds , ndesaulniers@google.com Cc: Linux Kernel Mailing List , Linux-MM , Linux ARM , Catalin Marinas , Jan Kara , Minchan Kim , Andrew Morton , "Kirill A . Shutemov" , Vinayak Menon , Hugh Dickins , Android Kernel Team Subject: Re: [RFC PATCH 4/8] mm: Separate fault info out of 'struct vm_fault' Message-ID: <20210114194129.GA13314@willie-the-truck> References: <20210114175934.13070-1-will@kernel.org> <20210114175934.13070-5-will@kernel.org> <20210114190021.GB13135@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Content-Transfer-Encoding: quoted-printable 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 Thu, Jan 14, 2021 at 11:09:01AM -0800, Linus Torvalds wrote: > On Thu, Jan 14, 2021 at 11:00 AM Will Deacon wrote: > > > > I tried that initially, but I found that I had to make all of the > > members const to get it to work, at which point the anonymous struct > > wasn't really adding anything. Did I just botch the syntax? >=20 > I'm not sure what you tried. But this stupid test-case sure works for m= e: >=20 > struct hello { > const struct { > unsigned long address; > }; > unsigned int flags; > }; >=20 > extern int fn(struct hello *); >=20 > int test(void) > { > struct hello a =3D { > .address =3D 1, > }; > a.flags =3D 0; > return fn(&a); > } >=20 > and because "address" is in that unnamed constant struct, you can only > set it within that initializer, and cannot do >=20 > a.address =3D 0; >=20 > without an error (the way you _can_ do "a.flags =3D 0"). >=20 > I don't see naming the struct making a difference - apart from forcing > that big rename patch, of course. >=20 > But maybe we're talking about different issues? Urgh... We _are_ both on the same page, and your reply above had me thinking I've lost the plot, so I went back to the start. Check out v5.11-rc3 and apply this patch: diff --git a/include/linux/mm.h b/include/linux/mm.h index ecdf8a8cd6ae..1eb950865450 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -514,11 +514,14 @@ static inline bool fault_flag_allow_retry_first(uns= igned int flags) * pgoff should be used in favour of virtual_address, if possible. */ struct vm_fault { - struct vm_area_struct *vma; /* Target VMA */ + const struct { + struct vm_area_struct *vma; /* Target VMA */ + gfp_t gfp_mask; /* gfp mask to be used fo= r allocations */ + pgoff_t pgoff; /* Logical page offset ba= sed on vma */ + unsigned long address; /* Faulting virtual addre= ss */ + }; + unsigned int flags; /* FAULT_FLAG_xxx flags */ - gfp_t gfp_mask; /* gfp mask to be used for alloca= tions */ - pgoff_t pgoff; /* Logical page offset based on v= ma */ - unsigned long address; /* Faulting virtual address */ pmd_t *pmd; /* Pointer to pmd entry matching * the 'address' */ pud_t *pud; /* Pointer to pud entry matching Sure enough, an arm64 defconfig builds perfectly alright with that change= , but it really shouldn't. I'm using clang 11.0.5, so I had another go with GCC 9.2.1 and bang: mm/filemap.c: In function =E2=80=98filemap_map_pages=E2=80=99: mm/filemap.c:2963:16: error: assignment of member =E2=80=98address=E2=80=99= in read-only object 2963 | vmf->address +=3D (xas.xa_index - last_pgoff) << PAGE_SHIFT; | ^~ make[1]: *** [scripts/Makefile.build:279: mm/filemap.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1805: mm] Error 2 make: *** Waiting for unfinished jobs.... Nick -- any clue what's happening here? We would like that const anonymou= s struct to behave like a const struct member, as the alternative (naming t= he thing) results in a lot of refactoring churn. Cheers, Will