Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7895190rdb; Thu, 4 Jan 2024 10:58:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IELYkwPaInmBr5d1DfXhr72yZ4x1nLz7EHimMfu02dTMsasSUty5GdrV/+mGGZ8TyKT5Xne X-Received: by 2002:a05:6a20:7410:b0:196:88b8:cc5a with SMTP id n16-20020a056a20741000b0019688b8cc5amr681564pzd.66.1704394696501; Thu, 04 Jan 2024 10:58:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704394696; cv=none; d=google.com; s=arc-20160816; b=XFaATTfZ+DPFzDMwF9YxCEWJKJJXEB9kbvlC5cM/+8OAqaRJxYbOwJ3aQgmVwt5t9J QsOKH7TmWNsFLz0LQqe0SlGbJAuC80+7QO/4sr8DYHbGD3FVJPC6pbjm598dM2Ai+GXh jPN5v8T0bAyovHAEw6TskIaEa15yvCxtWZNE13U4p2G7tOtYakqu2JsKZ03SBpM9RIKn 77wQ6IQ1wSXokfhLZSM/d1Y1WshpbB93eICDuFsqMkJ1Sbs5YB5B2u5N+HZwCEPRCPHE LwCTvhCbxBSE+VElJE5PWtpZ3PlJWOo0KgtBFHDTR5Re9nWrQvt4ZsEbQbFvRmFUfOse epEw== ARC-Message-Signature: i=1; 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:date:feedback-id:dkim-signature; bh=Os0Q/0d6OHlr8j+k0IDP+XVC9EPOxnxh9xNoVL0KlNA=; fh=baON6TEuz/Uu+wFn69hOCT7hCu9WIFiIXOHPEdnlk6E=; b=MzQzkLhRCBUAjrstPY0kI4UqgE0JkVqIaP+hsq+cZEfcRBRcpm2dE8tcL9BV2gBJqW BGjcGJ+WJWXiuDsZDzl58D/NQ1Lq7FWCs/cUVz9dLVeA5hVJQwwW2qRnPwNvddVdcY9A XLnFVZXU7gstm6SbJ8uhGz6PQQvKA6BPLqsLw2vGg0ZxlFVelzX5qzd/PdzdYfd7bPKv jY58jh2Bm3ySge9I6y7jI1S7qHw3y+HOCgE13CYQqUnbVvD97QUsEDUkPbPAwYT2NsA2 4LDmqUpjjR2aXoNYa9QvIqQT4fD03D0z8F2reootIa+2CcwogSkdMJn5GBvhCahpEmu2 sM3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nERtoKPv; spf=pass (google.com: domain of linux-kernel+bounces-17114-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17114-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e20-20020a63d954000000b005c66d14abd3si12158pgj.672.2024.01.04.10.58.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 10:58:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17114-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=@gmail.com header.s=20230601 header.b=nERtoKPv; spf=pass (google.com: domain of linux-kernel+bounces-17114-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17114-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 1CB28B2105B for ; Thu, 4 Jan 2024 18:58:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0522928E1F; Thu, 4 Jan 2024 18:58:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nERtoKPv" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (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 E0ED728E1C; Thu, 4 Jan 2024 18:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-781bbb1f61fso50840485a.3; Thu, 04 Jan 2024 10:57:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704394678; x=1704999478; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=Os0Q/0d6OHlr8j+k0IDP+XVC9EPOxnxh9xNoVL0KlNA=; b=nERtoKPvOQ61y3PFH/xXlQoDdelJZLdG9/d+rCfidZBdInDIQyIJN9WHt5k4fPXKug 239z/TVCTHx6U1ngHXEB5+NUbQTjWn5LWEn9fCzdmZvJ+gRss9AGjdD0bBKET9043Qs8 GwCc7Hdwd3kQrCgSx8phBoBmpazXCwcX/iYbYSnWD3AYb2AszOairnBBu+CuFGcdyege 8VK367ohP8TE9Trxc5pFN5UAGqeFdKFGXJDflWvymW+5QSfe8IjmijeSYHVA7u8o+fYs +8nGdzfXbTnLw1otEEkCdZPMojPa5hGmQlQs8DDHvoWNpfJshUHGdfnX7VnCvYcO5cl7 zssQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704394678; x=1704999478; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Os0Q/0d6OHlr8j+k0IDP+XVC9EPOxnxh9xNoVL0KlNA=; b=sWJh7L23uQtLGfxjwE2bmxI4PgwQaXzOZYmtGFHJ+Nw5tb5fmdmoD6QbjET2OY9oqj 5odA7acmuU3VMWwpMA12PnNMJ+VNL0FRyEVG1rNuxQodBe8FocOIrpiAytMMDdAx+TiE T+/tRI6UC52/asrPJIfxzAy1oWwcbDdYz3fFpfW8EbMT76aS0C+37YbEQfuiL25KRsN6 rwkwiMCAUIdOKGbhfkSRutrVfoX0oFAycvxiFuSLmckOyeeGMsLx3UzhFcvD80nS2ETg 0DlXs7NGLWk+InM3HLRSseeYwyw/pKj3X5kzVuy5Mdua/Koyp039TT7TyW6Pa3hLUbA/ MPTQ== X-Gm-Message-State: AOJu0YxG9p+EBS+I3HHaXuGZo62xxtZjONBBfUKOyIPtimRT9YSXi7TU OmfbnQ0yqToQ88NNtMMKh9E= X-Received: by 2002:a05:620a:f0f:b0:781:5e6a:355a with SMTP id v15-20020a05620a0f0f00b007815e6a355amr1082524qkl.155.1704394677738; Thu, 04 Jan 2024 10:57:57 -0800 (PST) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id vq10-20020a05620a558a00b00781df19c062sm15990qkn.59.2024.01.04.10.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 10:57:57 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailauth.nyi.internal (Postfix) with ESMTP id BA7FB27C005A; Thu, 4 Jan 2024 13:57:56 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 04 Jan 2024 13:57:56 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdegjedguddukecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeeuohhq uhhnucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrf grthhtvghrnhephedugfduffffteeutddvheeuveelvdfhleelieevtdeguefhgeeuveei udffiedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epsghoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedt ieegqddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfh higihmvgdrnhgrmhgv X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Jan 2024 13:57:55 -0500 (EST) Date: Thu, 4 Jan 2024 10:56:47 -0800 From: Boqun Feng To: Alice Ryhl Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Tiago Lam , Thomas Gleixner , Martin Rodriguez Reboredo , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/4] rust: sync: add `CondVar::notify_sync` Message-ID: References: <20240104-rb-new-condvar-methods-v3-0-70b514fcbe52@google.com> <20240104-rb-new-condvar-methods-v3-1-70b514fcbe52@google.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: <20240104-rb-new-condvar-methods-v3-1-70b514fcbe52@google.com> On Thu, Jan 04, 2024 at 02:02:41PM +0000, Alice Ryhl wrote: > Wake up another thread synchronously. > > This method behaves like `notify_one`, except that it hints to the > scheduler that the current thread is about to go to sleep, so it should > schedule the target thread on the same CPU. > > This is used by Rust Binder as a performance optimization. When sending > a transaction to a different process, we usually know which thread will > handle it, so we can schedule that thread for execution next on this > CPU for better cache locality. > > Reviewed-by: Benno Lossin > Reviewed-by: Martin Rodriguez Reboredo > Reviewed-by: Tiago Lam > Signed-off-by: Alice Ryhl > --- > rust/kernel/sync/condvar.rs | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/rust/kernel/sync/condvar.rs b/rust/kernel/sync/condvar.rs > index f65e19d5a37c..1a3f7b8e03dc 100644 > --- a/rust/kernel/sync/condvar.rs > +++ b/rust/kernel/sync/condvar.rs > @@ -155,6 +155,12 @@ fn notify(&self, count: i32, flags: u32) { > }; > } > > + /// Calls the kernel function to notify one thread synchronously. I feel like "synchronously" needs some explanation here (e.g. using the same description in the commit log), but let's see if other future users really need this ;-) Reviewed-by: Boqun Feng Regards, Boqun > + pub fn notify_sync(&self) { > + // SAFETY: `wait_list` points to valid memory. > + unsafe { bindings::__wake_up_sync(self.wait_list.get(), bindings::TASK_NORMAL) }; > + } > + > /// Wakes a single waiter up, if any. > /// > /// This is not 'sticky' in the sense that if no thread is waiting, the notification is lost > > -- > 2.43.0.472.g3155946c3a-goog >