Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1689594lqe; Mon, 8 Apr 2024 17:58:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXeURIiMNRf4ewP2Zh/zg53dBPTHHU8z5T5n71GfqJVAPoPlc1k84BQvYTSEqHQUd1os8AW8ReOWq9MTkgykR+hIw1KlXdN6dlJbauuTQ== X-Google-Smtp-Source: AGHT+IGuflD2Y6yqEhlZ8qTaSXxdJiYxCUKKonlxwnQI3Pqf7LA1wxqWGQZUAAp2HF8CFN5r4RIO X-Received: by 2002:a54:4006:0:b0:3c5:f149:772c with SMTP id x6-20020a544006000000b003c5f149772cmr5091423oie.5.1712624329683; Mon, 08 Apr 2024 17:58:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712624329; cv=pass; d=google.com; s=arc-20160816; b=vP9IVnhCCMeYWrXVW+BK1e8H52GXoaontwaY98O/Cp5eMA4kedOYan9U555d//fFMi L1pyxQX0zAx8LBWFgL/S7FQApIYeitlCOuqvYWfOM5/MqcrUh+/NZHtTg2EEV7woW7vE AxfPlSnAU5923wXJmx7uhiwMoWz+y/RFm8YCrOHO7ydWNn2v66+fY50VYTujhp46Gkvi QcabkZqUt+Zar6ocEk/ASbDN8xPydtYYjckVdLaAiAUryJf23vz8rj21nuPPJX+bl04H WtYy+w3Kosmix9GyrX60LBEYPBWWykrQd2fOWcbhKM3iWcpUL6qlizuEKo+FVohAVRZc q18Q== 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:message-id:subject:cc :to:from:dkim-signature:date; bh=3p52dOP2BlWsYrHqgAKRiWPR5jPclXgPdAlCcB00rdo=; fh=1Bh2rqZEKqj/nFo9jBYQBemRg7ucFU3NB4EeN2ksPsQ=; b=QFDv1VE6D2Xku8QqDRKGnL0cN1sSi/kFhzVbzUvHN+h+6uwZ8xaUrfDZNX/32fnbPr NPDmWzWfUfaP7Fhv/RlxNXJ9Kv9czsWzOwenUH/jet6WBGVPoauZKJzwdSwIGCzHjBU1 1vR1p/hN3HXzNVcAoYvueN3y08vcIBDMsJZXR6jrgMue+hUotyUTNCc7HO6ByalY6fR+ xwOxO4NF8YwreX5vu6fs8DluZQ8VFOCMr3q97Puip5e7s1bxHQFFH/U71iB+pJOhGm/H WW4NHErGRTIFq7qZHNqFHfoO5+sxYkDWANRwe0ACbnYaSe9Ct3l7mynJWAyuHpeKrV5B z65A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Yg0oT7qs; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-136059-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136059-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id p3-20020a056a000b4300b006ecceaa3383si7575794pfo.9.2024.04.08.17.58.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 17:58:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136059-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Yg0oT7qs; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-136059-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136059-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D3FAFB22B16 for ; Tue, 9 Apr 2024 00:58:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3DF9F79E1; Tue, 9 Apr 2024 00:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Yg0oT7qs" Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (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 9D99B4A2C; Tue, 9 Apr 2024 00:58:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712624310; cv=none; b=cK24GJDR2LLsbJaCz27eOYGSTtdLz/dKcWr22XnsefxpWm+TwUFQqhl70WYOQ9DnW687l9AFF10dcIVYivUXygHIMI7np6lk0t8yuPNApx2MEmtPyqjQxckl4Z0LB0rLjUdk9ckXZGNpJGCiFH9eqdf1pFp3W+7tNByqtHymUz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712624310; c=relaxed/simple; bh=V3FgUl+FC3/IXTQNHB8mnAyeNIvxhDluphd24WLUhWE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Zip/R8gfDXwyWyadf5PbdfoLzxYH7OK+9GpS0HRXxYsqpI96XcteNiL0onfB4mo7Vo8fiz98Ie5REzrDKk39HSfUhrGHwf3siRef+q/kWjUCWUZgUrFD8Q4PDYlhcKazKqmmwXf04RBotbn0FUI5/GIzS/4DyTePkAV49AmhPyA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Yg0oT7qs; arc=none smtp.client-ip=91.218.175.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Mon, 8 Apr 2024 20:58:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1712624306; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3p52dOP2BlWsYrHqgAKRiWPR5jPclXgPdAlCcB00rdo=; b=Yg0oT7qsnYRV74HSHZV+PlfEXWOlcnFzfPrvXVczJoE3Vngi7zfHZ2/ShgxuejqSLDaMMK U5FGxqvfqWMQDSdwmZz3Le+3pQE/gahuOSVkMc0TjzXwTPfS204xfiJqi1B2ETV4/d0MJb jYvHh/kfoPgNCoQM/NPr2GXhQRCRdz8= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Matthew Wilcox Cc: "Paul E. McKenney" , Linus Torvalds , Philipp Stanner , 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 , =?utf-8?B?QmrDtnJu?= 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> 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: X-Migadu-Flow: FLOW_OUT 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.) > > 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. Same thing comes up with bignum code - you really want to be able to tell the compiler "you can apply x/y/z optimizations for these functions", e.g. replace add(mul(a, b), c) with fma(a, b, c). Compiler optimizations are just algebraic transformations, we just need a way to tell the compiler what the algebraic properties of our functions are.