Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp616684lqh; Sat, 4 May 2024 15:17:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWHV46/ePYnfNY9YCLC9jYkxOa3ExSeZk+WSef99mzin3JJggXFsGdk/Ox9PDEMEffOGdFiZcR90TQ98ggX6UDGjcF1XK4Bc38YJiIfPg== X-Google-Smtp-Source: AGHT+IH95T1qA3yqfLY2KbmoKmSLcL8kRigBz/2nPRzg69RPknXmKyWWJt7hFoiD2xzXl3i2Z7nO X-Received: by 2002:a17:906:5a87:b0:a59:5191:f0bf with SMTP id l7-20020a1709065a8700b00a595191f0bfmr4870808ejq.17.1714861065430; Sat, 04 May 2024 15:17:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714861065; cv=pass; d=google.com; s=arc-20160816; b=vzDmO2l8d70SvV69jFTbbBqP+qPT48hSGjf+y7h+QGq6XsxADYl01TwYi88+Jer5n5 tkztZdb5tvksLohr+yUuidquUocrlMgdeqLFIx8sLhdOssnPUJp312lxzHGrrI5HgvKz VwOD1RJkguM+fllzuQN6jqCToJLtzXH7Wbg8w82XffcPos93AU1h4m1Bpm3Vs/bxiLU8 ckkJs3rWvLk8epny2Y0MChDknW+bRRwpxUMIVeZPThTMfX3QnUmiGqEhmLXJc61Pidly hjk9cuPZmRxGp/izRnUEpSK6NSK4dGJMp+JQ9d9HStQjKybOYsGeldSHsSxHGSzusNP8 glfA== 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=EDsjFhHirydymRzbNjI5ngKL5iIpy+KGr/WJr163XoY=; fh=XIehMoNIABZYw4jPMqUUb62eeH1uYrkMesD703g1lX8=; b=ZK6+Ex+q8qRUiH1YAEc6I/1ezMgavL9PF69QeJnDg2Wu+7+BDsymiR7gMKEj0zIVuh 1EM3BaFnBqXZev+9FuhN9ur2Su2OLqJxNrRzmZ292DoAl9pp40GyRGWe6o5Qx4GFbvQm XPp+r+YW3ffzb0PXIOiKx4PeM3IjSD/wRhgOWEDNUePopCWzALtgCZyKu7+E4zzwu0x4 hPE/sEYtwrl17z3a5zkD7fxgJwOCfkpJGaQrj3A/nOGrj/cO7cmpbItsQfl5+VLC3H7H ApMehW4gsk32STgcg5yRlOJ8o/0IAaGyYUu1MfnhE+VYdhk3BU5krgZfhmxKa/OuEGdJ 3ZBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qiBjUSU7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168842-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qa41-20020a17090786a900b00a5970bb3845si3090412ejc.63.2024.05.04.15.17.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 15:17:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qiBjUSU7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168842-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 272AC1F21925 for ; Sat, 4 May 2024 22:17:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B348A84DF0; Sat, 4 May 2024 22:17:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qiBjUSU7" 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 D6ED684A37 for ; Sat, 4 May 2024 22:17:37 +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=1714861057; cv=none; b=FpMG2rox4m84e+uUA875+LuqUJGjTkcGwqU9UvasyqF8c9tlP1yJ5hXURHV7OtfwyF0BBoZtVrXd3vujDaBC1yU6nm7TE2mWxf3GxH8yf82iUoC7Nw59V1Raz61ybJ82KS6PcjSL0gfjZeBLFWocvEJ+lZC0n/Udfc4O6BU3h6M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714861057; c=relaxed/simple; bh=upHKd08o+Ou1Lblw4gOXnZeF1CD2NWpIaEij3oKJwJg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KjpkSYuX3e3lNFUcn5IkUa6WF33rt2OSkLL41QvvG+MncS/n1/C6bVn+H7jrsy5mXkhak0T+YyJSiEj4YhGCwpN56LFPdf3AEll4cAo4PmxP6kJJ6OrpJbqpUWhzq6EDUUtygZaXhcOhA6sAtdKxoEvYPc8CjaOKSVY9IcYYtZs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qiBjUSU7; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AC5BC072AA; Sat, 4 May 2024 22:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714861057; bh=upHKd08o+Ou1Lblw4gOXnZeF1CD2NWpIaEij3oKJwJg=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=qiBjUSU7xROJZZUBVRh6vnS94/TC+VBTtCwfYQ3pN+BxDJ1dMl6V4SoFJXT5+zyQ0 AkwCJ3lckTVghSn+uCBNbiNh8FMrcUVWJ3gnbAEu19OL1D8sUEMAicd7lMVjLThaCO LRpubCtY0tTMmTKttmzGpnRaAKgu5aBIVMZvK25ccwmW1j0oiKsAfwCE5jUffK29FO PQCPBdmbMWjpreO/6gSQ5JTD1uxf40Xr6nlk+XWvjxsMgG7EQXwdPi4HJDC1Nzdchz TBlcnnAHSriFnVLSXDWxUY26MeZNQSp+wmZVYkz6nt6ZeZkTtZgP7S92igR6pgzNfV IaYAfof7LjrpQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DB35ECE0F69; Sat, 4 May 2024 15:17:36 -0700 (PDT) Date: Sat, 4 May 2024 15:17:36 -0700 From: "Paul E. McKenney" To: Linus Torvalds Cc: Boqun Feng , 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: <3f132208-12a2-4821-bf32-8c8569c632fc@paulmck-laptop> Reply-To: paulmck@kernel.org References: <1c886023-ae61-46ba-bb3c-b460c30de937@paulmck-laptop> <2beaba9f-6f83-4a7c-8835-fe5fe88a006c@paulmck-laptop> <3f2c415d-dc7e-4647-9002-4beb804d885c@paulmck-laptop> <7aab574e-b6ba-4038-802f-2d64af09d802@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 Sat, May 04, 2024 at 12:25:12PM -0700, Linus Torvalds wrote: > On Sat, 4 May 2024 at 12:11, Linus Torvalds > wrote: > > > > Anyway, the above are all normal optimizations that compilers > > *already* do, and the only real issue is that with memory ordering, > > the "dominance" thing will need to take into account the ordering > > requirements of other memory operations with stricter memory ordering > > in between. So, for example, if you have > > > > __atomic_store_n(ptr,1, RELAXED); > > __atomic_load_n(otherptr,2, ACQUIRE); > > __atomic_store_n(ptr,2, RELAXED); I am assuming that I should ignore the "2," in that load. > > then the second store doesn't dominate the first store, because > > there's a stricter memory ordering instruction in between. > > Actually, that was a bad example, because in that pattern, the second > store does actually dominate (the second store can not move up beyond > the ACQUIRE, but the first store can indeed move down after it, so > dominance analysis does actually allow the second store to strictly > dominate the first one). Agreed, and the stores can be combined as a result of the fact that the two stores can be reordered to be adjacent to one another. > So the ACQUIRE would need to be SEQ for my example to be valid. And here the C and C++ memory models get very strange due to mixing memory_order_seq_cst and non-memory_order_seq_cst. But if there was a Linux-kernel smp_mb() immediately after that first store, then the compiler would not be allowed to combine the two stores. Though that is true regardless because of the smp_mb()'s barrier(). > Of course, usually the barrier that stops domination is something > entirely different. Even without an actual conditional (which is > almost certainly the most common reason why dominance goes away), it > might be a function call (which could do any arbitrary memory ordering > operations - there was a clang bug in this very case) or something > like an explicit full memory barrier. If there was something like, then the two stores could not be combined, from what I can see. __atomic_store_n(ptr,1, RELAXED); __atomic_load_n(otherptr, ACQUIRE); __atomic_store_n(otherptr, 4, RELEASE); __atomic_store_n(ptr,2, RELAXED); I freely confess that I don't know how to map that into dominance relations, which means that I have no idea what this example means in terms of your rules. > Anyway, take that email as a "written in the MUA on the fly". There > might be other thinkos in there. But I think the big picture was > right. If things go as they usually do, there will be quite a few litmus tests between here and something credible. ;-) Thank you for the tutorial on dominance in CFGs! Thanx, Paul