From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5799DE6918E for ; Fri, 22 Nov 2024 19:55:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BE3B6B0082; Fri, 22 Nov 2024 14:55:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 96D966B0083; Fri, 22 Nov 2024 14:55:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85C1E6B0085; Fri, 22 Nov 2024 14:55:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6788C6B0082 for ; Fri, 22 Nov 2024 14:55:02 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D68F1140FFD for ; Fri, 22 Nov 2024 19:55:01 +0000 (UTC) X-FDA: 82814781924.08.76832BD Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id 18F6B80005 for ; Fri, 22 Nov 2024 19:53:16 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=N6e9o22d; dmarc=none; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732305232; a=rsa-sha256; cv=none; b=hbBpYhzpqnUAxjGhNZfoZbTCQqqzVnofDC48vrVcQWbhb/TVvOlhZcTzL9q3FPdoOtMhuc LugspoGRdpTTUEwbykP8xotWM3KiKKXPdGEBbSaNgA78cjRYB/wb/s5ULgb9eZwTd1YQHx rXPn6BKZZvuduWU5qVMEaD7JtSUogXk= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=N6e9o22d; dmarc=none; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732305232; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=F4IQQGbkbmf3wjPhz8ksZi8Xqv5qdPwCrcqy196y0rY=; b=jBgLMu3rlgM8jqZmvwBJVzqkUNnT79Pz0Zm9b99sqaPDiQAHm1QPibvIHFEPrmLyS4lS0g IsI0EYydvK0chITkDi4HGlRHZkI3zHSzsjU6HyXnt9PZtHpKZN3N71jLX6ITAYD+n7dJAq lqunkQzK7/9cvPFAL+/8D6GyNsaECoc= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=F4IQQGbkbmf3wjPhz8ksZi8Xqv5qdPwCrcqy196y0rY=; b=N6e9o22dJkp5p6biR6EHC/9n/g mnCk6rxI7rFyzdGlvGjqq3alLN3mfMdT/mwTgVDU22PdAC+bp10PqvIdJnSZsb0Ki2022vCpgI1A3 lLWZ8Lxc/00UkjXAWTwD/xnJyBPxAD+pNaUll0m5O7zOQJ51vUWG+8hPnSG1X2TQq6IbThfwyD0Mz D6HOPGAA9na4kOSWc+YjwbzIH70+2fT2Tg/QvZ+vtzGSIlgHGjWQYwciBDMbTG+XV+WCNHGErk8aS uLsC/UMd0ejMEzlpSivrnLIA4OzJLixnoLuamB1ZjX8gpkWDnN+puXSLZE+Gk3n5c3wZA9Q/dKWEm hJY2Idgw==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tEZjv-00000008Dxt-2ZgJ; Fri, 22 Nov 2024 19:54:51 +0000 Date: Fri, 22 Nov 2024 19:54:51 +0000 From: Matthew Wilcox To: Alice Ryhl Cc: Boqun Feng , Miguel Ojeda , Lorenzo Stoakes , Vlastimil Babka , John Hubbard , "Liam R. Howlett" , Andrew Morton , Greg Kroah-Hartman , Arnd Bergmann , Christian Brauner , Jann Horn , Suren Baghdasaryan , Alex Gaynor , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , linux-kernel@vger.kernel.org, linux-mm@kvack.org, rust-for-linux@vger.kernel.org, Andreas Hindborg Subject: Re: [PATCH v9 8/8] task: rust: rework how current is accessed Message-ID: References: <20241122-vma-v9-0-7127bfcdd54e@google.com> <20241122-vma-v9-8-7127bfcdd54e@google.com> <6740c786.050a0220.31315a.5363@mx.google.com> <6740d8be.050a0220.30b282.4f2e@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspam-User: X-Rspamd-Queue-Id: 18F6B80005 X-Rspamd-Server: rspam11 X-Stat-Signature: gg3t5ptx6yi1s9yiijpnaurm7xfjb3oj X-HE-Tag: 1732305196-509149 X-HE-Meta: U2FsdGVkX196zcjJ65NCu0buhIjhfF7YRM6H9w/A2M3c68DDoX5w+A+IB87xGrcGC0OxdcsxeYf7zOyqv7bXo5wG3rbBENCqJu3M6db057DK5x+LbV3on4Br3ATAmyY/T5+9if02yEb5qqXQdiOJEZlfK0JAkpRxd0ThMRWPhBKwwWqvklrLQlW/bBiLhuotHvgghHytYtNUN0AxsBqGZAYaziRw0kGvrD8L+3JzKS22jdG/UXCaorKk/MDXvmlQfZa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NCDPOcR72BnanGPwwTU8QGnKUbmNPOipP8fx4/O5jGY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Nov 22, 2024 at 08:43:33PM +0100, Alice Ryhl wrote: > On Fri, Nov 22, 2024 at 8:30 PM Matthew Wilcox wrote: > > > > On Fri, Nov 22, 2024 at 11:17:15AM -0800, Boqun Feng wrote: > > > > I don't think this is a problem? As long as a thread exists somewhere > > > > with `current` being equal to the task, we should be fine? > > > > > > > > > > I think I had a misunderstanding on what you meant by "operations > > > that are only valid on the current task", you mean these operations can > > > be run by other threads, but it has to be *on* a task_struct that's > > > "currently running", right? BTW, you probably want to reword a bit, > > > because the "current" task may be blocked, so technically it's not > > > "running". > > > > > > Basically, the operations that `CurrentTask` have are the methods that > > > are safe to call (even on a different thread) for the "current" task, as > > > long as it exists (not dead or exited). In that definition, not being > > > `Sync` is fine. > > > > > > But I have to admit I'm a bit worried that people may be confused, and > > > add new methods that can be only run by the current thread in the > > > future. > > > > I agree, I think CurrentTask should refer to "current". Or we'll > > confuse everyone. Would ActiveTask be a good name for this CurrentTask? > > I mean, it does refer to current. Any time you have a `&CurrentTask`, > then you know that you got the pointer by reading the value of > `current`, and that the task you got it from hasn't returned to > userspace (or otherwise exited) yet. > > But the name ActiveTask also makes sense I guess. OK, I'm going to be all rust newbie about this (zoea?) Given that there are operations that we can do on 'current' that aren't safe to do if we pass current to another thread, is the right thing to say that we have Task, and you can get a (Rust) reference to Task either by it being 'current', or by getting a refcount on it using get_task_struct()? And I think that's called a typestate?