Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1399411rdb; Fri, 9 Feb 2024 23:52:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVF4a8lTu3Q+EebSmBA1WHGokIAfhteE/7iE4o35mMaKgi38UtWNkJK4BF/BQhzvE7DFtthxYoFaDPYRsn3flJToWH72S/8onh/6VD3oA== X-Google-Smtp-Source: AGHT+IHEVpwbduS37mMKTshImcAmw6oIqSHrBGkKulL9/Dz7GOHreqxmeb1FKEAZ+GbIqYxWLnkS X-Received: by 2002:a17:906:7d5:b0:a37:a66b:b361 with SMTP id m21-20020a17090607d500b00a37a66bb361mr919378ejc.21.1707551561503; Fri, 09 Feb 2024 23:52:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707551561; cv=pass; d=google.com; s=arc-20160816; b=x/BBjPpTDHtDREzL7OLRdVwOikHNzuIkcFplX66nzOvLK86OZZoOLte8APJH1t1doz hRZxVAeh+kz3JkC9g0YwpD3gH9IYwf6QgB5sFBw/zqyoDX3TX27RUOGxYSsBywBkcvLJ /vTQt1e8TlWkt9Qv8JQroO+4nGyPmr2YtX60JUe6nZ6TsgwnglYMQQqBE+Iofkp5IT9O HutRnVqXjVIpNCxLO072AZV7X/upOVwbLRLrxuA3Ie4Leph6ses2KiF21WuPiHL9vZeZ p2QmqOA792zT5CU5OWEwgsmDQbH+a6+ZCnoGnPxpEYD38mguqCflDf4TpOXYjiGTNgGr feGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=0g4QBN1/rGV7VTiFr0/5TgIubmQLI1xDKrfOY+r3ugk=; fh=N3zarSPLPIFPRR/Od0iqAIGw5a+L7jY9yvQugtMQeK4=; b=1I0189sZ7yk6HC688ybqKSIUXVbt2nOSFiyecRufnwxnkoJkmY8mTYGiFt1erDraUt zGFLScuRGPwZHr0hE5brMHcn1kcUSkFcg/oNZFtNgCkTNh8zjDH5opb066O2ZTatuRy1 hfgdsJTg1fYyQ4k4tYQ8gbQt2x6syuvtecV0bH2CrEt39mCqqGQVJaM7hf7Twn1oJ4S+ s7PACKvVGFj/9SlaB1DHeSabAO6YKPXngpceZ+AyvSXNP0dy0NMDym0LxVCjOJDLDHtN KmSa870JR0gDP8nc4luGTj35mceoSrbRU++p2rp3MDKmkWeU1zBy4HDhVPhX9yn+cIEl beCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@umich.edu header.s=google-2016-06-03 header.b=p4Hz46jY; arc=pass (i=1 spf=pass spfdomain=umich.edu dkim=pass dkdomain=umich.edu dmarc=pass fromdomain=umich.edu); spf=pass (google.com: domain of linux-kernel+bounces-60342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60342-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umich.edu X-Forwarded-Encrypted: i=2; AJvYcCVEQ3Nu+zaXG0ROEndOR2E0xqKl779AimxjgbiG44reiJbRY7+yM9chfAeLvVm+gasuArUoy0WsxGSmVMELpCugx1li5TX0o0H97OfT6A== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dc22-20020a170906c7d600b00a384f95cb21si1601355ejb.1028.2024.02.09.23.52.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 23:52:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@umich.edu header.s=google-2016-06-03 header.b=p4Hz46jY; arc=pass (i=1 spf=pass spfdomain=umich.edu dkim=pass dkdomain=umich.edu dmarc=pass fromdomain=umich.edu); spf=pass (google.com: domain of linux-kernel+bounces-60342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60342-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umich.edu 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 1FF721F23D60 for ; Sat, 10 Feb 2024 07:52:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D0752328B6; Sat, 10 Feb 2024 07:52:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=umich.edu header.i=@umich.edu header.b="p4Hz46jY" Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8C6D525B for ; Sat, 10 Feb 2024 07:52:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707551549; cv=none; b=d/v6dfjFBx8BDhW61djW+C0tnjxTHKIShvHmq1g9v534+Ye8mXVelvXsMKxQgTGHe7snHKwzNye0KK7RV2TMYQx/cm6JsTolKdue5NWDxXjFlVi5IfgColg1n16QTihvuv9xDWg78EFl8/hjRv8yh18LXw1PlEvYVufR8ukJIxE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707551549; c=relaxed/simple; bh=gZo8nudx91n7QmkKsXW07rSEvmw1YmQIFCRQ9PVoTH4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=OCd1bLA9obcfzlCdvRGXz5vfXImD3HqNQx96hcMVjofSvD0SgL21GcD3KaHjLTMgtLLlqEr7PG9F1XMFcfyvi37bCKwL8BAwhzkuBscqeVafiSqy4fb0hhmP68LZUO33u0S0xr8CWZlzRiWX5dBmb+D38+n5/VIHRDxzreXXg6s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=umich.edu; spf=pass smtp.mailfrom=umich.edu; dkim=pass (2048-bit key) header.d=umich.edu header.i=@umich.edu header.b=p4Hz46jY; arc=none smtp.client-ip=209.85.219.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=umich.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=umich.edu Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-dc755832968so1061160276.0 for ; Fri, 09 Feb 2024 23:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=google-2016-06-03; t=1707551546; x=1708156346; 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=0g4QBN1/rGV7VTiFr0/5TgIubmQLI1xDKrfOY+r3ugk=; b=p4Hz46jYpc+qRjV8GuJEwQaP4mM/nrHF0nqpHQAa4LELGQa9otfR+sukLDTAkeU0n5 aDHF4dZxbCh1GcYaW76hyT+S2OLWO2bYkKrFL6QKQMg8z16uBbmxlcStO/25b8sAn3sI 8DGybrgoPJslvavZbaNOJ3UnxDb5GO3XfurPTZBbHRjH0UDjfs/Zeub34NyX09bYHfx3 EJLVH2Po0vOBxf7771d71MLR97JST5rhWB7M6gE7CgTpr/N5UiZOu3Xr517spBbyIZcL aZ27AfmdPhudqB0glav8lp5pjiMgKR34ZnRK3VvGhtQUxSNagjJVzpyBD7AZvsE8IhgE L3gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707551546; x=1708156346; 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=0g4QBN1/rGV7VTiFr0/5TgIubmQLI1xDKrfOY+r3ugk=; b=LyHJN7IkxD2NM+tcHpCp6eOXZUf9jD3YIGpUzvGyqS4TFLCnhcpbtRDllcyZXRLLYF JhYT6Nn0GXCz+cn7hoQ2l+VgS56prNbr4dzwLoXOWKolhsJgLilqYRqjfoE7hv0eSnWr K3gJAOl1segNsJoQRTXcRNoLSTzpvywRw3jM56NkcQ0erHH/1kqJxVhH2/8hhfQJFyzD wh9Nae2XGNnlZHpKCQblv/ZhcubtBq5wU7G6Ia9rOYccjQjxpsO80D6slSdSefQP06VW ACm0WQ+MEW9ijLLJXwQqMQ8cSO7dGy2ZsP6lfAq5B1TKwdOJHNlzBwk1lwzG+Xno/XVG AmPg== X-Forwarded-Encrypted: i=1; AJvYcCX+v+P0WphbawRHZ4U8vrk8amlSy3mHM49KXxG2LM7nPkmyICC9R4SLd/pttIbq6OG/yUlcqTmAAAp5WMCQKdg0KdZTo3QSuZt+stIs X-Gm-Message-State: AOJu0YymTuMnoi3fhwI0gsG3CC44nkvcHsAUHxukyArIero2ZOv8UJA6 OExECKUzWHgadO6ECqfYvNXEFP5zY1JchUUqMUwC0RDo9DQwbEQyUC5zCbe9TxQ83y0X45PmF+D 0AkTf4GuHYMBe1KQ9Jsblt/0Zc170ieugStBA5A== X-Received: by 2002:a25:28d:0:b0:dc6:d87e:77d1 with SMTP id 135-20020a25028d000000b00dc6d87e77d1mr1096217ybc.43.1707551545768; Fri, 09 Feb 2024 23:52:25 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240209-alice-file-v5-0-a37886783025@google.com> <20240209-alice-file-v5-9-a37886783025@google.com> In-Reply-To: <20240209-alice-file-v5-9-a37886783025@google.com> From: Trevor Gross Date: Sat, 10 Feb 2024 01:52:14 -0600 Message-ID: Subject: Re: [PATCH v5 9/9] rust: file: add abstraction for `poll_table` To: Alice Ryhl Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , 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, Martin Rodriguez Reboredo Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 9, 2024 at 5:22=E2=80=AFAM Alice Ryhl wr= ote: > > 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`. > > 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`. > > 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. > > 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. > > Reviewed-by: Benno Lossin > Reviewed-by: Martin Rodriguez Reboredo > Signed-off-by: Alice Ryhl One nit below Reviewed-by: Trevor Gross > +/// Creates a [`PollCondVar`] initialiser with the given name and a newl= y-created lock class. > +#[macro_export] > +macro_rules! new_poll_condvar { > + ($($name:literal)?) =3D> { > + $crate::sync::poll::PollCondVar::new($crate::optional_name!($($n= ame)?), $crate::static_lock_class!()) > + }; > +} Length > 100, this could wrap: macro_rules! new_poll_condvar { ($($name:literal)?) =3D> { $crate::sync::poll::PollCondVar::new( $crate::optional_name!($($name)?), $crate::static_lock_clas= s!() ) }; }