Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2362297rdb; Mon, 5 Feb 2024 04:28:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgXNsBqR5pvwFdes+PzoBhwdOASUhgSlQjLINNdJgvGI1N4mRNJ64FjUEDJBztC+Rn91MF X-Received: by 2002:a05:620a:122f:b0:783:bfb7:77d5 with SMTP id v15-20020a05620a122f00b00783bfb777d5mr14025161qkj.78.1707136114747; Mon, 05 Feb 2024 04:28:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707136114; cv=pass; d=google.com; s=arc-20160816; b=qatRdIvCCEXwVCpPelN94CQfyurjCuy4tCyruV0tKgdSPzPOd3Ea7P835vUhKxyHLn qhnm5iOTyjWJnjRV16CwiMg7/ie0qHM3fYg0tmsIF2nmT1POK3xtqclvyk3U31mnPsXI HM9beMbqk8JhtoMBCSM+E76wt6gqHRpwj+e04uJtt69RhAWWZozie+BRzyHK38A19HcA BKPZagHeTVDmQB0DUiGkWvviXuh0JLXAN2LZ5jtQ+yhRXYAu8ttjSDnu5hxAqKM8i93y wcU1KnEEX4bHjf9GHBkrALrqnKkQs2AjmLhcLTpg6MAxui6sD/htHFCvgKXHjkUuIhvJ t4eA== 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=daleUQrt9HsLvgJZG6U/EET+1E8JHEi5VCW3vb8WDEM=; fh=V6Z/9Pa0hwGX0fcG2JEtNHrrkvaRy/Cp21JPlJbvv4k=; b=kn6CWIIZcb/g0/Wv77Pnw+CAy0qSMRhjkKRwoJChQELyoasmlfT8V3+jSg1ef+E6JZ L/XYXfpfE7lak1hTxPpq68Kp4zAfb/ru0FVgSD2lC3/5wMAyWiQDdqvCNQI6oXPze+oH o7DQ9eCWwU5FIxH/aZtfONtgJVdj20KMgR7FWhwPlD7n3CBZ4unrDzwh+JN1jaMik0Yz 1gVvhMRRe+0gDgGEA/2UG7Ce2Rh0E/EteBMJo2R85fSpr3nLkx1KXRaeslBtq10v/v17 IN7yiXbGoFPB4QuF2dCL0wjJ0m6j6m/k9nnJ8knyCQh5xWYQTmXrzQyL2oE5yAg3iFKN S0cA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@proton.me header.s=nwtgodaxtrgdtpoqw2aktnr3gy.protonmail header.b=MXwZl4Xc; 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-52595-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52595-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me X-Forwarded-Encrypted: i=1; AJvYcCWwQrZkFXJuQBsakMJDKotKBsCNMzQCzlz9ZBLVT7kUUtK/xHdxnO+IYpbTqfwiFI76wSka/RWXBOCI89YxFIBeml69aRQ6MMf/NNvGEA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h9-20020a05620a13e900b0078401376700si7956273qkl.764.2024.02.05.04.28.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 04:28:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52595-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=nwtgodaxtrgdtpoqw2aktnr3gy.protonmail header.b=MXwZl4Xc; 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-52595-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52595-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7070C1C22D9B for ; Mon, 5 Feb 2024 12:28:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D7B81BF3B; Mon, 5 Feb 2024 12:28:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="MXwZl4Xc" 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 902EC1BDDF; Mon, 5 Feb 2024 12:28:12 +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=1707136094; cv=none; b=Y3oCV62PkMy9vEx2ixeNLs9vg97f6g6aZKuazXlN5WWVYg59nd/FmE4IaEgDNfw4MRMGY+TsOBgJnNATj4wCaYlQwtkejVUIOLegvQgmLY/orKBYiz1plMifBhL47iSV7BmZq382wPv3qkIPloA0sJSJTgrpE0D0i0kJU8AucoQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707136094; c=relaxed/simple; bh=/FmTOpD7EsdsRiWnp+n9V95+jzTNKJcM3d3V70ANPwo=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tLQGwUdL4wM5t5wqBg3gWbw2b+N++8qXSyV1A5cKwPz5BKv18s50Y4CUkwwHMMnFmaKINlXoI/+hygaszCoEjQH7pn6cfg51WxRZ1bVdh0DpR46P+BjssFx7/5t1/VkM2eRwS3MsPsLjRvkW+SfvJdkJPZLR8V+Nph0WcYbTaZw= 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=MXwZl4Xc; 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=nwtgodaxtrgdtpoqw2aktnr3gy.protonmail; t=1707136084; x=1707395284; bh=daleUQrt9HsLvgJZG6U/EET+1E8JHEi5VCW3vb8WDEM=; 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=MXwZl4Xcq0NAM/InqXeNXPf9wRgAGPfjoSJbQTWGPg+AW9+mu6jo7lHfwz2uwHm6y SW/keWP+h1kYMGk24bKAqlJYG84jVzG89V2jpOysGWNhvVmRN8G25TIhJgP3HeYa+x ba8QeUFKlIDnEG26vJOylLSvn+CmS5kN+4RKFH74DQauATw2BuH/oQh+wiRqdL5krb fddRCExmt3IBc9CQU0nI5FRshVR5VpRWw48nMvCd/d1U9UmidRYA0g0+S1YnucCdn1 AtW8fD5a+iW4VqXeo2xzbYlF2fplS2JrI+c1JJtW5tp+oS6c/5ThaXe4AmabVdTqRA 3bxadL17F0S8w== Date: Mon, 05 Feb 2024 12:27:46 +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 , Dan Williams , Kees Cook , Matthew Wilcox , Thomas Gleixner From: Benno Lossin Cc: Daniel Xu , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v4 9/9] rust: file: add abstraction for `poll_table` Message-ID: <9a35d753-793e-4953-9095-742953c06154@proton.me> In-Reply-To: <20240202-alice-file-v4-9-fc9c2080663b@google.com> References: <20240202-alice-file-v4-0-fc9c2080663b@google.com> <20240202-alice-file-v4-9-fc9c2080663b@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 2/2/24 11:55, Alice Ryhl wrote: > The existing `CondVar` abstraction is a wrapper around > `wait_queue_head`, but it does not support all use-cases of the C > `wait_queue_head` type. To be specific, a `CondVar` cannot be registered > with a `struct poll_table`. This limitation has the advantage that you > do not need to call `synchronize_rcu` when destroying a `CondVar`. >=20 > However, we need the ability to register a `poll_table` with a > `wait_queue_head` in Rust Binder. To enable this, introduce a type > called `PollCondVar`, which is like `CondVar` except that you can > register a `poll_table`. We also introduce `PollTable`, which is a safe > wrapper around `poll_table` that is intended to be used with > `PollCondVar`. >=20 > The destructor of `PollCondVar` unconditionally calls `synchronize_rcu` > to ensure that the removal of epoll waiters has fully completed before > the `wait_queue_head` is destroyed. >=20 > That said, `synchronize_rcu` is rather expensive and is not needed in > all cases: If we have never registered a `poll_table` with the > `wait_queue_head`, then we don't need to call `synchronize_rcu`. (And > this is a common case in Binder - not all processes use Binder with > epoll.) The current implementation does not account for this, but if we > find that it is necessary to improve this, a future patch could store a > boolean next to the `wait_queue_head` to keep track of whether a > `poll_table` has ever been registered. >=20 > Signed-off-by: Alice Ryhl > --- > rust/bindings/bindings_helper.h | 1 + > rust/kernel/sync.rs | 1 + > rust/kernel/sync/poll.rs | 117 ++++++++++++++++++++++++++++++++ > 3 files changed, 119 insertions(+) > create mode 100644 rust/kernel/sync/poll.rs Reviewed-by: Benno Lossin --=20 Cheers, Benno