Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp887652rdb; Fri, 19 Jan 2024 01:44:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4x7Bj+GbtrmZLnGwzfIInVpRDfjzvnXqwGPSk1KpF5rZt2RnKtB+X+AynAkW11PNVUDWR X-Received: by 2002:a17:906:3548:b0:a2d:54ca:1ff9 with SMTP id s8-20020a170906354800b00a2d54ca1ff9mr979455eja.150.1705657454501; Fri, 19 Jan 2024 01:44:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705657454; cv=pass; d=google.com; s=arc-20160816; b=vCfI5/2YX4hIrbJSqmLObIVxi8nnekFPS6076mWHNWZk8rBg1ex7g68lIcIMklBqHn 5aC47gdwzWQZd0OaF0nQFP9oinZ3J9NPnwy4NwZyklnZaZUODBWs37Uh9ixMxVxT7jx1 Z+L5HjCuAhsL+ARzrO8nQbCdIyhMBF+203ba/DZ9eIHkEDJNFw648PD9GyAHAd5/Qtyf tiXaJP5cskJUYynMQHSegpJ3XWt1UKaO37GsQd592n53pJzXozci3mEjxYNmMHQIxLZ9 oI2s2Iw+oP81wTaGOqZVfyEkRIxTORjDeshktWXkz2+rKQs5+eRFB/M1PAu1q1BOkPdW 3U9Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:feedback-id:references :in-reply-to:message-id:subject:cc:from:to:date:dkim-signature; bh=+LdiskQeHEZLdxUpn/S/pubmhIJOcYkLCINwk9ZEXhs=; fh=vUWE8ToOtC64Gu3xFme/xSdtZBLqP3rROTf0yx2qvYE=; b=Eqe95NEAFL/PejsNeq7p/PjdhcMcaSxmPK/sOB0Le91HFAD8mD36tMl/4CLugobgIy tIhj1xluopt4n1MTsOB9qGOtOP/DrE0XJZEb+9M/VlzKDJ12oJ1l5fWUjNDyEWM0QiAf lOzQbuj4lq0jSkuS7/zi8PGT/hCmhPwM9bTaV+Lox1ETXP0tUf1r132wWODRFCdxWEfJ MGK8zeVrbggPkWtJjktpU31kuSCF/mBjc0dc+akKwbkvJd5SYeUYfkH5mTD3PkUVwbTF 1mhaTJpjSkKXHimMDuLnPTHk/jYZkZRIjnFsX/v99mPLOPKkjjmJD5oryNJA0i0cgQfi moUw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@proton.me header.s=plqhpujkl5dg7mbbrfxmygange.protonmail header.b=TYzO3Kv3; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-30966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u2-20020a17090657c200b00a2f164f2511si1625460ejr.692.2024.01.19.01.44.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 01:44:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=plqhpujkl5dg7mbbrfxmygange.protonmail header.b=TYzO3Kv3; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-30966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me 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 387881F21DAD for ; Fri, 19 Jan 2024 09:44:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C7873C68E; Fri, 19 Jan 2024 09:43:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="TYzO3Kv3" Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) (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 884F83C463; Fri, 19 Jan 2024 09:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.22 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705657429; cv=none; b=SDG+Rinvsvm2zJSBFtMqs6BRH/uu+ZmKvXuOn2IKapCPzxJdSfhWDRBvyZ8q0jeYuAFJYmntF9WaJbPDRAVsX9wLsLUlE/syOnwKerBsSQUiOGWqlLLkeYjAbCyiNfM9RJYJ8vXFe2VSyxxVgvB8nwY8fEJmycqKElR8FeFfxX4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705657429; c=relaxed/simple; bh=tG2zsCK8yQbCDBC3gzpjutSRIN2h2t3FmjArqi3HUsA=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qqf120H/RJtfrUaJ6l9NDkmdb04jPXb8mY8bdkpgIN+sgKuz0TjR8mR8OIAZOFra4Nhp8Ap90CYPL7n0DxIvbNK1S8XyqQrEZzH7COQGnrY82wyzNTjtAX63DWDlTNfMOa8Z2G7YJCsaIxgmbiVIEQ9dRBoJn99dM1Ez/EdZM10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=TYzO3Kv3; arc=none smtp.client-ip=185.70.43.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=plqhpujkl5dg7mbbrfxmygange.protonmail; t=1705657418; x=1705916618; bh=+LdiskQeHEZLdxUpn/S/pubmhIJOcYkLCINwk9ZEXhs=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=TYzO3Kv3NP/nXCpS9KlHhzYw6dzOjNA9WCqWMCaf5s5TZI4X9gF8CoshCPEzWGb2V Jw5CAxiB2CH0mQcsY6b6qehsWqgG/nc2AiC1LtSYGgstutdQpD5vPVE2i66PNAVCcT mGlQ0CwXXmzR1kUCg4CCaRL5LANeLg7TNEPsUt97XUIwr3fAASwnHkC78D2v8BbTwY 22TBc1ACbb33Z6tDY59Y4hJlkaNQi9f+GZ2r2cTZVDmbhZlswHOvDsTbgjyhw8cEdk 0V3v6zPEix1/sDRey8BIe+KlDmpFJeupanjDH4vpl6DKxg/LS0LQwLvXm7HM5SUwfx eJ3thEiUyWzfA== Date: Fri, 19 Jan 2024 09:43:23 +0000 To: Alice Ryhl , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Peter Zijlstra , Alexander Viro , Christian Brauner , Greg Kroah-Hartman , =?utf-8?Q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan From: Benno Lossin Cc: Dan Williams , Kees Cook , Matthew Wilcox , Thomas Gleixner , Daniel Xu , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v3 4/9] rust: types: add `NotThreadSafe` Message-ID: In-Reply-To: <20240118-alice-file-v3-4-9694b6f9580c@google.com> References: <20240118-alice-file-v3-0-9694b6f9580c@google.com> <20240118-alice-file-v3-4-9694b6f9580c@google.com> Feedback-ID: 71780778:user:proton 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=utf-8 Content-Transfer-Encoding: quoted-printable On 1/18/24 15:36, Alice Ryhl wrote: > This introduces a new marker type for types that shouldn't be thread > safe. By adding a field of this type to a struct, it becomes non-Send > and non-Sync, which means that it cannot be accessed in any way from > threads other than the one it was created on. >=20 > This is useful for APIs that require globals such as `current` to remain > constant while the value exists. >=20 > We update two existing users in the Kernel to use this helper: >=20 > * `Task::current()` - moving the return type of this value to a > different thread would not be safe as you can no longer be guaranteed > that the `current` pointer remains valid. > * Lock guards. Mutexes and spinlocks should be unlocked on the same > thread as where they were locked, so we enforce this using the Send > trait. >=20 > There are also additional users in later patches of this patchset. See > [1] and [2] for the discussion that led to the introducion of this > patch. >=20 > Link: https://lore.kernel.org/all/nFDPJFnzE9Q5cqY7FwSMByRH2OAn_BpI4H53NQf= WIlN6I2qfmAqnkp2wRqn0XjMO65OyZY4h6P4K2nAGKJpAOSzksYXaiAK_FoH_8QbgBI4=3D@pro= ton.me/ [1] > Link: https://lore.kernel.org/all/nFDPJFnzE9Q5cqY7FwSMByRH2OAn_BpI4H53NQf= WIlN6I2qfmAqnkp2wRqn0XjMO65OyZY4h6P4K2nAGKJpAOSzksYXaiAK_FoH_8QbgBI4=3D@pro= ton.me/ [2] > Suggested-by: Benno Lossin > Signed-off-by: Alice Ryhl Reviewed-by: Benno Lossin --=20 Cheers, Benno