From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rIrWSWa6" Received: from mail-vs1-xe34.google.com (mail-vs1-xe34.google.com [IPv6:2607:f8b0:4864:20::e34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B35E91733 for ; Thu, 7 Dec 2023 23:43:37 -0800 (PST) Received: by mail-vs1-xe34.google.com with SMTP id ada2fe7eead31-46603b0de2fso132373137.3 for ; Thu, 07 Dec 2023 23:43:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702021416; x=1702626216; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+4q2vuoSSJgvH7vZRaxIDen/jyKU6XB1LXeL+/4gRcM=; b=rIrWSWa6FMeZTRA6fOsq7PUz5nO/S7mlA2+xHwzMbfB2voaQlNJrCeXFB0LFJLHnwW lcgHihAnps8KkMjw0WtR8PrJrujwWJStNJyWMLVwE1TF3NnLDTEzx/0d3KI2vB9RpKTP /ZQz9Yp627xKNzP365RyfKbmo+H7Sccqxwp5MZ4SCW2RV8UTFqnQW4pkiKsRa2adIK8k 1iYz5a3AmrGvIDcJXgdRYBCpj2el7zudWoQdyvjdk+DItHaCSDB+RNo/NyFxDUxImE/A jI5kkZhkRSqrEDkRF8g1VRuWv86sgrA0+eEcuQAUGyiqDibJShj6Ram4BWguRtBLrcmx /rRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702021416; x=1702626216; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+4q2vuoSSJgvH7vZRaxIDen/jyKU6XB1LXeL+/4gRcM=; b=qEEkjNW3Lf6yJolgzbP+D5JpSeBiY0oa+p1oc9Rf1eBbkDccdqcniYYXjfgXIpM7vf e1onMs7zOLT9HrQPtQo6f+yyG5wg+Vhpovg0HQXCo1gvWXYJS6koIvZ66qyGlib643po b+DkqoEFT3q0YG2vjBVfBEkprh9/PaCJMIU3/C2JDb0mcdb8x7HbMiIeD4/cgyVieBhN Po4PY8gDxeLgKOgRkijfEJaEf+IIgxdUnsp2mXcV2uDPZRe5RcYusvZZSpT2qwM7hmJ/ TT2nUXIEFUfHMCg909hSXViMqCyMfDl2Kz8lgl43fJP1KxiwfVYWOz8qV/tLrDQsJFMV uhow== X-Gm-Message-State: AOJu0YziBorIrgrPfsNZ7rc3EBddQyHzkvf5v+Tjqa0Yh08LHsKeef5H tNpZ1KmxrScFQJMEkU6I6HcfSk9vEE2IzHuNsLBZMg== X-Google-Smtp-Source: AGHT+IH3GFhE6C5y58gfbtDBuMvPVznxpofnP+2ZfxvpHEccq0MFGv9X86KkaH/iD1Z/02axDn1F0RFCnYFzPu5sjwQ= X-Received: by 2002:a05:6102:548d:b0:464:8660:18b2 with SMTP id bk13-20020a056102548d00b00464866018b2mr4377343vsb.22.1702021416509; Thu, 07 Dec 2023 23:43:36 -0800 (PST) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231206-alice-file-v2-0-af617c0d9d94@google.com> <20231206-alice-file-v2-4-af617c0d9d94@google.com> In-Reply-To: From: Alice Ryhl Date: Fri, 8 Dec 2023 08:43:25 +0100 Message-ID: Subject: Re: [PATCH v2 4/7] rust: file: add `FileDescriptorReservation` To: Benno Lossin Cc: 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?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 8, 2023 at 8:37=E2=80=AFAM Benno Lossin wrote: > > +/// Zero-sized type to mark types not [`Send`]. > > +/// > > +/// Add this type as a field to your struct if your type should not be= sent to a different task. > > +/// Since [`Send`] is an auto trait, adding a single field that is `!S= end` will ensure that the > > +/// whole type is `!Send`. > > +/// > > +/// If a type is `!Send` it is impossible to give control over an inst= ance of the type to another > > +/// task. This is useful when a type stores task-local information for= example file descriptors. > > +pub type NotThreadSafe =3D PhantomData<*mut ()>; > > This should be in its own commit. Will do. > Then you can also change the usages of `PhantomData<*mut ()>` in > `Guard` and `TaskRef`. Will do. > It would be nice to use `NotThreadSafe` as the value instead of > `PhantomData`, since it is a bit confusing... That doesn't compile, unfortunately. > I think we might be able to also have a constant with the same name > that is just `pub const NotThreadSafe: NotThreadSafe =3D PhantomData;`. I can try to get this to work, but I worry that they will shadow each other= . Alice