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=-5.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 CFD03C433E0 for ; Thu, 21 Jan 2021 21:30:20 +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 7F55123A5B for ; Thu, 21 Jan 2021 21:30:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F55123A5B 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:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MUGwrUJIPS117i0rT1ZZtsl2Rt8UXWtNUs0iFs1nlss=; b=WYrxQwTY6/R6Oylt54+WkiCBl X6r5X+37HnaT5+J7xHCuHPpsifWFgUBSXt+M5cMptMXkCk8N5VqghntGYA0gW5U7ledTkZu/9zNIY oE4CL1bRbnkO0YVJKK6Shmg4FTC3hxH1tz0ieilCrC08XYDnT/P78IytrJQKD4Lw6mHfj+m9QJ0ly ZddZOLdKliqdGgMVYhklYGe2oLu8EBvGkokf3B32CUW0wk1aopaY0gl92rcWT0cG2Acb9NjK9aKFV +J2tHkLglZJR6oInP30A/z2cactYd7ikNs8p5uEAxUGC0kCWM4gLqxltHH4NAD7xTQpO0aH63p63i qzYK9Cwbw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2hVT-0002yU-Lm; Thu, 21 Jan 2021 21:28:43 +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 1l2hVQ-0002wQ-Fw for linux-arm-kernel@lists.infradead.org; Thu, 21 Jan 2021 21:28:41 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0311623A53; Thu, 21 Jan 2021 21:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611264518; bh=Dd1W9bCeOuqQQTWgQKKjURvCvrcjupnyMPuQIYgLAi8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Kwi1tgKNlVNM/FF/m5oTJAgGIXLi5xbGLLa/ACf5QQj8ztMOuzklYEmWRnE/74HJ7 LNn/REQ4/tO1id5izd309fpe+HOqBBdejgqiBZwtnTTUkIOlo/Zx45sGObLk4UjIMA C9Uaehs8Yi5cylTIwnpPo0NAw8mtqKDaCu6XaU1ncdu67byAoMPiirzfYToqSSckSX 8Z9InGZgbG37RHpkegkpqkdJ9KJBmA4F7c/pjSYvwNQGj6hDYRGqkjrOzY1Ecx1TdA uAeDhL6GEtaaoZ1UeHruQQxxMgiQ5lX89wDAwD7OPR8IeM3EmGYB9rEznjWR96T1a/ muxSRNkN6tNRQ== Date: Thu, 21 Jan 2021 21:28:32 +0000 From: Will Deacon To: Nick Desaulniers Subject: Re: [PATCH v4 8/8] mm: Mark anonymous struct field of 'struct vm_fault' as 'const' Message-ID: <20210121212832.GA23234@willie-the-truck> References: <20210120173612.20913-1-will@kernel.org> <20210120173612.20913-9-will@kernel.org> <20210121131101.GD22123@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210121_162840_696035_816D3633 X-CRM114-Status: GOOD ( 21.95 ) 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: kernel-team , Jan Kara , "Kirill A . Shutemov" , Minchan Kim , Catalin Marinas , Hugh Dickins , LKML , Linux Memory Management List , Vinayak Menon , Luc Van Oostenryck , Andrew Morton , Linus Torvalds , Linux ARM 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 On Thu, Jan 21, 2021 at 11:24:36AM -0800, Nick Desaulniers wrote: > On Thu, Jan 21, 2021 at 5:11 AM Will Deacon wrote: > > > > On Wed, Jan 20, 2021 at 11:02:06AM -0800, Linus Torvalds wrote: > > > On Wed, Jan 20, 2021 at 10:27 AM Nick Desaulniers > > > wrote: > > > > > > > > Is there a difference between: [ const unnamed struct and individual const members ] > > > > > > Semantically? No. > > > > > > Syntactically the "group the const members together" is a lot cleaner, > > > imho. Not just from a "just a single const" standpoint, but from a > > > "code as documentation" standpoint. > > > > > > But I guess to avoid the clang issue, we could do the "mark individual > > > fields" thing. > > > > I'd prefer to wait until the bug against LLVM has been resolved before we > > try to work around anything. Although I couldn't find any other examples > > like this in the kernel, requiring all of the member fields to be marked as > > 'const' still feels pretty fragile to me; it's only a matter of time before > > new non-const fields get added, at which point the temptation for developers > > to remove 'const' from other fields when it gets in the way is pretty high. > > What's to stop a new non-const field from getting added outside the > const qualified anonymous struct? > What's to stop someone from removing const from the anonymous struct? > What's to stop a number of callers from manipulating the structure > temporarily before restoring it when returning by casting away the > const? > > Code review. Sure, but here we are cleaning up this stuff, so I think review only gets you so far. To me: const struct { int foo; long bar; }; clearly says "don't modify fields of this struct", whereas: struct { const int foo; const long bar; }; says "don't modify foo or bar, but add whatever you like on the end" and that's the slippery slope. So then we end up with the eye-sore of: const struct { const int foo; const long bar; }; and maybe that's the right answer, but I'm just saying we should wait for clang to make up its mind first. It's not like this is a functional problem, and there are enough GCC users around that we're not exactly in a hurry. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel