Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp750107lqm; Wed, 1 May 2024 14:49:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXi0i/ZSrh4I3YR9UpQ6oZRu3dazmVaAUdy3gX1oWn6TmxHf2BC9qNQPhjoNnofFaolxlD4hSJ2rhO6LjJcv2Sa+18bbZCENoe2iWt7dw== X-Google-Smtp-Source: AGHT+IHDZC8HZAdr0eceyQl/3bJswzf56eox4d3dJzKSkwrg4QLkNCS3GkGolyV66XjB764q1RDQ X-Received: by 2002:a05:620a:4d1:b0:78b:d7a8:84f0 with SMTP id 17-20020a05620a04d100b0078bd7a884f0mr296490qks.46.1714600164545; Wed, 01 May 2024 14:49:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714600164; cv=pass; d=google.com; s=arc-20160816; b=J6kqNkzDU+ZXe1a0s1vYYoiCDWTQZP1h8C0HcnCsVgDxbqP1vIBd/YpTKxmHuamERm KNH60Fwt16FuRYQQSbL1/gkF3KVVMCPDHNp2uE/2qjk87nWKYjvltNtSYUrbohZZdhoJ e7sVGeRnHEc0L88y1emQuM0/puqzqs0McTbdq9wKTbc8x0e0mlZ+qe3nZueAktMlfvk8 5p7lbGOHOzwJU7eIROP5mKG4pRdGaEt5OVO3YjzkFf5bQ+70TgkujPNFFYhJ+eZH2+qd CdiyEeEK7iJvqvoEY0ZZUrDUDb6ydN9XXpOAwmLDiGd//kpaFG+9rRjA6LmA0qWqE0Ph R7Jw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=4s7ltN/YbedOxwSmaBkhf3exR3+erAm7oiIEj0ZiQX8=; fh=5OYaGM6GxhqoyvkOO+cntjLzCWdb6x9s0f2esLy/bDo=; b=aboa97gdXX0ezGBTE1gqMmtG/29JsxLPDg6Jn57AN5W8TUFwsAwBJgVl6rcaSRDhPk sil+Tj1zafb7V9lmtSaYD7oArxi1jUaAZr1hJbLU8UxDihnkr7wKAR3if3Od91ShG6gQ 9/mDW23jBez1BzEU6qEcapf/ZTkgSA32Iud+9mQTwnWF3wj/Ky6glHE3g3adkrmE1QA7 CFBuOIOt/rlyjdsTmxgKin01ab0Gb3QEd1fKrteYgfjmZ9e8hdlxpBUa7DRkoLqWT1DH 5geMfhj5a7LrNmZpeM7Gu7vhVW7uABX5vyryiRuupwqWrcreZesAEd7GC8eMZbJuNT6g IiBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dGVtthAq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id de35-20020a05620a372300b0078d6072f0f3si35875390qkb.487.2024.05.01.14.49.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 14:49:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dGVtthAq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 48BFA1C232F1 for ; Wed, 1 May 2024 21:49:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 752CD165FC4; Wed, 1 May 2024 21:49:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dGVtthAq" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A3D14D5BF for ; Wed, 1 May 2024 21:49:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714600158; cv=none; b=YybcINNrZKcHepGtoFEB2785VAfD5CFpWqyPR35Bkv93HmbNeZ1q8OgYzLkxUIaCcdrE1Lj/KgdD1myE9lcm/dMt/01aN6WyUAh5FyNvNi6qGg+ADsukrV+CKBj7W5CAMuVvTHcoLVcfuCIyqquI0oxtDlQ7/FPsjywOsC2hZuc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714600158; c=relaxed/simple; bh=T0e6v2EEGGmGQq2DG+fHGV5WDwv7F/hfovJ40/z0/Zg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EnamLwdRbsx+W/aoQ8ZkIwZrhv+1bMxYezl7Afunue3/tPi5/tBoIcIohh6NVBqYk6PIhWfVr/5g9n/XL3IH7GNQNhug+Ps/aUHbycbxbCmewjwIFndMxpIj6NIVtpeZafKvOzUFpVT8P4BIPpZVxb2Uz2Br14wH70r0Yu6VXKQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dGVtthAq; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A9A4C072AA; Wed, 1 May 2024 21:49:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714600158; bh=T0e6v2EEGGmGQq2DG+fHGV5WDwv7F/hfovJ40/z0/Zg=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=dGVtthAq1OTTQR3QC38kzQA9ogfbxze0/eX5Qgu7ICvOK3Um1LgWVVzlDv0X9yq0C kqFIjgAAVsZRtReZru9aGxaHjNMaMbNbPsKxd+jDS1A508lLEIdEBizVr7Y9rpGRtm 0jCAeNR0Q+vGYosDS9q4wR8jWiY7LLX7pW1Q+iDakGzFiVuAuG7Tut2DYUZZQ+/om9 CLSu0TP/aKe+EztSB3CAVNiTikzM4nH7kwvt+Wx8idbNkYXRUm+Rjazg04RomKECTR HDOlxfSb8DFKdVSovFdqtngYxbiihbK3cNy7yiiEnFESFiOhlNFN5Ttd7XccZU4vd1 xPeyXh7wZnDow== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 926D2CE1073; Wed, 1 May 2024 14:49:17 -0700 (PDT) Date: Wed, 1 May 2024 14:49:17 -0700 From: "Paul E. McKenney" To: Linus Torvalds Cc: Marco Elver , Tetsuo Handa , Greg Kroah-Hartman , Dmitry Vyukov , syzbot , linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Nathan Chancellor , Arnd Bergmann , Al Viro , Jiri Slaby Subject: Re: [PATCH v3] tty: tty_io: remove hung_up_tty_fops Message-ID: <1c886023-ae61-46ba-bb3c-b460c30de937@paulmck-laptop> Reply-To: paulmck@kernel.org References: <892324fc-9b75-4e8a-b3b6-cf3c5b4c3506@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, May 01, 2024 at 02:20:35PM -0700, Linus Torvalds wrote: > On Wed, 1 May 2024 at 14:06, Linus Torvalds > wrote: > > > > So it would be something like > > > > const struct file_operations * __data_racy f_op; > > > > and only the load of f_op would be volatile - not the pointer itself. > > Noe that in reality, we'd actually prefer the compiler to treat that > "__data_racy" as volatile in the sense of "don't reload this value", > but at the same time be the opposite of volatile in the sense that > using one read multiple times is actually a good idea. > > IOW, the problem is rematerialization ("read the value more than once > when there is just one access in the source"), not strictly a "read > the value separately each time it is accessed". > > We've actually had that before: it's not that we want each access to > force a read from memory, we want to avoid a TOCTOU race. > > Many of our "READ_ONCE()" uses are of that kind, and using "volatile" > sadly generates horrible code, but is the only way to tell the > compiler to not ever rematerialize the value by loading it _twice_. > > I'd love to see an extension where "const volatile" basically means > exactly that: the volatile tells the compiler that it can't > rematerialize by doing the load multiple times, but the "const" would > say that if the compiler sees two or more accesses, it can still CSE > them. No promises, other than that if we don't ask, they won't say "yes". Let me see what can be done. Thanx, Paul > Oh well. Thankfully it's not a hugely common code generation problem. > It comes up every once in a while, and I think the last time this > worry came up, I think we had gcc people tell us that they don't > actually ever rematerialize loads from memory. > > Of course, that was an implementation issue, not a guarantee. > > Linus