Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1917857rdb; Thu, 7 Dec 2023 12:22:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGrCpvIUIJ/UneqaL9ttI3vbhIDX19Afba/1i72+R2OjdJ+YxpzOUfbMO+m+sasidGrObfw X-Received: by 2002:a05:6a20:8fa5:b0:18b:d2d6:2f73 with SMTP id k37-20020a056a208fa500b0018bd2d62f73mr2905105pzj.7.1701980545200; Thu, 07 Dec 2023 12:22:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701980545; cv=none; d=google.com; s=arc-20160816; b=cOWYyZIG/lm1WNEnIPMjFe9y4Cd/s+VU951VopSgLF3JegZkURXfnG9MpANQywM4kD dicjnbUyxlP36BcdBPy8jAophAFPBhq9ycQfvN3UlZi5tprIzlFim2eG+5lcXEBKr2/V 4hiP6j5LCuVbt8pnIBdMux+DI59e55vCI9oflNtpxqG20VByrAGc+J7A+HFMZFuZdODz Wl/Vo8yil4qPexLzwmFNhh0JgyD029ajzGKUshQtWF3sstjlYiw4cN3ptm0SzR+QfLsv NmMQ6hgmhFuso4m0HI5Bmh8BiLl+162VW6Oq8XQauojSvW/U+9Wx1SCLoQF3XkI0LJWk 4V/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :date:dkim-signature; bh=uJSND0rxUIaQSNMIcl3FEGD0TOMeemf0Jpuoq4FqA1o=; fh=A2E0LtHfen5vzl6zi7oB6cYaIuZGWaj7krUTbI9Debk=; b=hTqe+nqEWTgNT8xqjeqwKxmLF37NWp7mLRdT07DBEkI1bL8F3+O1ciG7Vz6DBDHd4D Nj9Gc6ujA9uYWUp20nDI3Js/1xf6rDc3VJKwrH1OS8VL4d11tMWmekwGdd7SnG4Dr3ss +7Fw18snDAqeTAdM1KptXp2b7HuJ4KJhIXazITIApQxJrUXyfwvmBmuD+3WpuQ5y6LSR vYoa6rHCa9MWRp+UcOO931vJY+MO4CdCeknB4zWMUtMgYrut90b8fGrvycTr24YJtMv8 x96duro/kFTNGFAi3veqIG08qj266xWqJrQ0vefT4I46eD6DbZX7Beih9l4WVVYFHg96 550g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=FaDt5exg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id b5-20020a63eb45000000b005bd85b32495si236826pgk.685.2023.12.07.12.22.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 12:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=FaDt5exg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 0C16E84AA9E1; Thu, 7 Dec 2023 12:22:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbjLGUWG (ORCPT + 99 others); Thu, 7 Dec 2023 15:22:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjLGUWE (ORCPT ); Thu, 7 Dec 2023 15:22:04 -0500 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5F191719 for ; Thu, 7 Dec 2023 12:22:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1701980528; x=1702239728; bh=uJSND0rxUIaQSNMIcl3FEGD0TOMeemf0Jpuoq4FqA1o=; 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=FaDt5exgc4gRIStEIuctEsxtbjMiHrEXxCl6hXCl4U76PpBJUnY5/dflD4X4A9uQJ cokabxPmFDSJM7ulWQdXwSOTj0ntKhg3hd55W4CCySVv9ongeuq4V/NUjcbMpAcxSC K9QuoG0U5H9+7uSJKKti4dFeDk01MWvonuGJDiV87A45dO6OK/KA7OKXl4IxABwdwy 9//peOXdMCIv45qae3HwYNyjrR3lPZ+LWhfzfyJcvF7mbS0fUe6Ngr4lgI+2I87UB/ CuH7jmVLXuxhGamsEXK8DWQt3bbGhjO7X/ku43Gljln8yCNn9OPHBepfcxB7cq1IET ppsSxMVsWhwqw== Date: Thu, 07 Dec 2023 20:21:48 +0000 To: Alice Ryhl From: 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 , Ingo Molnar , Will Deacon , Waiman Long , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] rust: sync: add `CondVar::notify_sync` Message-ID: In-Reply-To: <20231206-rb-new-condvar-methods-v1-1-33a4cab7fdaa@google.com> References: <20231206-rb-new-condvar-methods-v1-0-33a4cab7fdaa@google.com> <20231206-rb-new-condvar-methods-v1-1-33a4cab7fdaa@google.com> Feedback-ID: 71780778:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 07 Dec 2023 12:22:22 -0800 (PST) On 12/6/23 11:09, Alice Ryhl wrote: > Wake up another thread synchronously. >=20 > 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. >=20 > 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. >=20 > Signed-off-by: Alice Ryhl > --- > rust/kernel/sync/condvar.rs | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > diff --git a/rust/kernel/sync/condvar.rs b/rust/kernel/sync/condvar.rs > index b679b6f6dbeb..9861c6749ad0 100644 > --- a/rust/kernel/sync/condvar.rs > +++ b/rust/kernel/sync/condvar.rs > @@ -155,6 +155,12 @@ fn notify(&self, count: i32, flags: u32) { > }; > } >=20 > + /// Calls the kernel function to notify one thread synchronously. > + pub fn notify_sync(&self) { > + // SAFETY: `wait_list` points to valid memory. > + unsafe { bindings::__wake_up_sync(self.wait_list.get(), bindings= ::TASK_NORMAL) }; I took a look at the C function (i.e. __wake_up_common) and there I found this: lockdep_assert_held(&wq_head->lock); So I think this function requires that the lock is held, how are you ensuring this? --=20 Cheers, Benno