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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EBB51CD1292 for ; Mon, 8 Apr 2024 18:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nu+cFd8sG+BS+hazUCjMUPpLYhLhqkaa0QKcbXkPgkI=; b=eT5dQbQfMlNUWs g4+kIsjR5YvrUZw+B4NGeWiv4KFRumLsHB8HLBsJ83YjzXy3flR6GdEDHDGv0LtKnyB7ogWh6swv2 qwLMs1GKDAFXr383U6XFccF5oFjzAx3eCYP/GDFK8KWmfpq2KL0J9ozESbT7SWXdvTtGkTDRGhrgD JwE4kLWbgrroFl4XWSm0i4X6IWWJ4PfilxNdJ6ky3K2V2WQP1XMwDM1qxbyUJ3lwIkcwLCG5AJ5TM hAXwyi0HNoNzVywttWdC7WuoOox75tg7wfewODKMGfuSOsIlUFfG1SFvSyh7RVIyif5nFCA7KjkCL V4LV9qJOHmdaRWCc1IKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtu1v-0000000GXgy-0T00; Mon, 08 Apr 2024 18:47:43 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtu1s-0000000GXfv-2EIb for linux-arm-kernel@lists.infradead.org; Mon, 08 Apr 2024 18:47:42 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DD5756137C; Mon, 8 Apr 2024 18:47:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7457AC433C7; Mon, 8 Apr 2024 18:47:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712602059; bh=SYyVUdi9VjoNm97IS/XTV920oO6eW28EJnO10HujZm8=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=QH3VMMm5SOy+a5/Le74mjOj7Gdef3Nx9WwKw4QdG6/4a+h1jicQcuUxj5+AbinxgI 5O0WFSLX1tLKfiZqZk9z4W57aYMdLzXxokbye8N4IAJTRT10k5C02VRxNvZLANEXPH 96FljbScvGcjKUjEf5DwEKEM5c1SQmnDIiMku/rAZriOl1SsozESEUU/P8SlrWCidN AipWE/sidcx/TcflQso3P15T0WQ+VhU8rBrSGPPBvGDzMSc4OkBRiugBoJDyCVH95M 4e8DhZGuKYDGFqEyanXAB5XTPjkKaLhR1rfGz4FVPrUCAKzWUpjPKSi5TP6PlVxXdc VWuo/YoxOqJ0w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 17CC2CE126C; Mon, 8 Apr 2024 11:47:39 -0700 (PDT) Date: Mon, 8 Apr 2024 11:47:39 -0700 From: "Paul E. McKenney" To: Matthew Wilcox Cc: Linus Torvalds , Philipp Stanner , Kent Overstreet , Boqun Feng , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, llvm@lists.linux.dev, Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Alan Stern , Andrea Parri , Will Deacon , Peter Zijlstra , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , Akira Yokosawa , Daniel Lustig , Joel Fernandes , Nathan Chancellor , Nick Desaulniers , kent.overstreet@gmail.com, Greg Kroah-Hartman , elver@google.com, Mark Rutland , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org Subject: Re: [WIP 0/3] Memory model and atomic API in Rust Message-ID: References: <20240322233838.868874-1-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240408_114740_895301_F9BDA9EC X-CRM114-Status: GOOD ( 27.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: paulmck@kernel.org 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 Mon, Apr 08, 2024 at 06:03:11PM +0100, Matthew Wilcox wrote: > On Mon, Apr 08, 2024 at 09:55:23AM -0700, Paul E. McKenney wrote: > > On Mon, Apr 08, 2024 at 05:02:37PM +0100, Matthew Wilcox wrote: > > > In my ideal world, the compiler would turn this into: > > > > > > newfolio->flags |= folio->flags & MIGRATE_MASK; > > > > Why not accumulate the changes in a mask, and then apply the mask the > > one time? (In situations where __folio_set_foo() need not apply.) > > Yes, absolutely, we can, should and probably eventually will do this > when it gets to the top of somebody's todo list. But it irks me that > we can't tell the compiler this is a safe transformation for it to make. > There are a number of places where similar things happen. > > $ git grep folio_test.*folio_test > > will find you 82 of them (where they happen to be on the same line) > > if (folio_test_dirty(folio) || folio_test_locked(folio) || > folio_test_writeback(folio)) > break; > > turns into: > > 1f41: 48 8b 29 mov (%rcx),%rbp > 1f44: 48 c1 ed 04 shr $0x4,%rbp > 1f48: 83 e5 01 and $0x1,%ebp > 1f4b: 0f 85 d5 00 00 00 jne 2026 > 1f51: 48 8b 29 mov (%rcx),%rbp > 1f54: 83 e5 01 and $0x1,%ebp > 1f57: 0f 85 c9 00 00 00 jne 2026 > 1f5d: 48 8b 29 mov (%rcx),%rbp > 1f60: 48 d1 ed shr $1,%rbp > 1f63: 83 e5 01 and $0x1,%ebp > 1f66: 0f 85 ba 00 00 00 jne 2026 > > rather than _one_ load from rcx and a test against a mask. Agreed, it would be nice if we could convince the compiler to do this for us, preferably without breaking anything. > > If it turns out that we really do need a not-quite-volatile, what exactly > > does it do? You clearly want it to be able to be optimized so as to merge > > similar accesses. Is there a limit to the number of accesses that can > > be merged or to the region of code over which such merging is permitted? > > Either way, how is the compiler informed of these limits? > > Right, like I said, it's not going to be easy to define exactly what we > want. Or to convince the usual suspects that any definition we might come up with is useful/implementable/teacheable/... :-/ Thanx, Paul _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel