From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 463DD3090D2 for ; Mon, 12 Jan 2026 09:05:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768208742; cv=none; b=o68jgYO4EErnOQicwRn/0lB+QLhHiDyeOJEq56jOjSfWXwD7UGeYsy8TuQqIeZbQPvtBegCu9Lw0ALwNECEDXQ8f/JLec6L9euPILMeCX15SAD+0sAzjTPCdBgo1svZIOFiFXAMQi5XEvL8282lgitGFc9DRiMuMj69EwuyEyso= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768208742; c=relaxed/simple; bh=y3ZqgF1sQAVQrh4PpD7bEcindq/cQQy+iaqc0sgx8c8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=qVCufNlmJ6qFLZgtr9UTJdrzMuDW8UXrpMHVeXI6YiuAgo91Fh1wcYzY6SFW4il3W7BDNivRWOO4q3z95gqUHpAAU0vR4bsGwvdhIVy/TLEg+0aXKuT8Iz6H5m00HonH6nAxEjfS64E6L846U2pMzk0IAiKeH+zNJIYVn7sQ/BE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lhaVxCtv; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lhaVxCtv" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-47d5c7a2f5dso54265995e9.2 for ; Mon, 12 Jan 2026 01:05:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768208740; x=1768813540; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=SzORT/k3ipGubgBn9Q9n+ixZdkO5pikUavXtfHFdUSg=; b=lhaVxCtvSofnl0ENiE/zr8LAGhj25eKaDAl5CbsrxQPYuVZHGbi2bUEMTVXjRorSlT uF1ZfZ6gtxzoQiyTgJUkjnndQQG6dC/R9d8pE+hg5LDISTBmaxZb9agE9Z5m6AEgEpn4 kNPp5G/Ked7TLAShf1eUsi0/wnk0/qsvIXcVdwmfeoy0AbuEb3UkWBnl4SOrNFpgbHq6 7O6adE7gnArofzBjfHXGiaQdxvdcZWDBoiSf0S617bsY8kCUl2IudETg/rkCzSlKwlLP kPlzzc7IShCIwylKcYhekVdqspY1hmB3r0R4eVJmFBmasQT/MGsNQi6l2Yre0mbbY41d 9abw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768208740; x=1768813540; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=SzORT/k3ipGubgBn9Q9n+ixZdkO5pikUavXtfHFdUSg=; b=LwBYJudKMJChl+Hqdk9+bAtHpD1PnyfQldJL/MAXdjhKHUipvS0+l080bAloNMLGA8 Tw96Q3NvQqWgvJoj/Ok6SFgZYet9ozRMu9Boxdlgs1AEFW5jPzYgYHV4/IsSnAx8w3XC uPLwLG7pPmSkyXd0pqftPDFtWMtCwb3eO9Yv5CkdQNuE+LK87zd43Y8coz+PQVj8VYPD 12mreK6nNGaIE+CXGPQcTEs9vJ/EyVZmhpHBDxdGhe7XZd9vva52yob16DBDJOlr7/a2 ZKsF1VIOFX6999Q1zKYC6eri+ZY4ctVM+2s+CIsOVPSpGCxnPwybo5jjQ+Lg6z35kzqp AV+w== X-Forwarded-Encrypted: i=1; AJvYcCWhUqOsPBREYel1RyvgOlVJ9l7y8qVwJerRCMrDIsWtKB6DTLoTOCl3JzzkQrmf909mdQEfguBqS/eXvjc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy71b9Blh9wRTFC1QbUEiluGnEdQTgVuIAAf84+0+8b8piMqyQ/ C7GFiiOtlPDhSGjHQB7Z6fvNhAeVOPONJYKRhxtIU84jl/bwcmZOfwNjRHmez9FZor2eBJqwyJ+ oNn/1pKi+/fvIr7UpQA== X-Google-Smtp-Source: AGHT+IGOJRXfdn4em6HL0Onpde9GGteqaO9fJCUa27BqZN+63xCLbGxcAW9PUxWk98ipz5bhZqrhfl2AZc+TZmA= X-Received: from wmcn3-n1.prod.google.com ([2002:a05:600c:c0c3:10b0:477:aa9e:db24]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:190e:b0:475:dd7f:f6cd with SMTP id 5b1f17b1804b1-47d84b3f21fmr206172495e9.35.1768208739714; Mon, 12 Jan 2026 01:05:39 -0800 (PST) Date: Mon, 12 Jan 2026 09:05:38 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251008151554.340806-1-marco.crivellari@suse.com> <20251008151554.340806-3-marco.crivellari@suse.com> Message-ID: Subject: Re: [PATCH v3 2/2] rust: add system_percpu() around the new system_percpu_wq From: Alice Ryhl To: Marco Crivellari Cc: Boqun Feng , Tejun Heo , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Michal Hocko , Miguel Ojeda , Alex Gaynor Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Fri, Jan 09, 2026 at 05:32:23PM +0100, Marco Crivellari wrote: > On Thu, Oct 9, 2025 at 1:17=E2=80=AFPM Alice Ryhl = wrote: > > [...] > > > If we were to expose the system_percpu_wq to Rust, then we should als= o > > > add queue_work_on() API to Rust, otherwise it's kinda pointless IMO. > > > > > > PS. We can use the CpuId abstraction: > > > > > > http://rust.docs.kernel.org/kernel/cpu/struct.CpuId.html > > > > > > and have an API like: > > > > > > ipml Queue { > > > pub fn queue_on(&self, cpu: CpuId, w: W) -> W::EqueueOutput > > > } > > > > > > or maybe a different new type `PerCpuQueue`? > > > > > > Regards, > > > Boqun > > > > How is it ... can we cleanly separate queues into those where you must > > specify the cpuid, and those where you shouldn't? >=20 > Hi, >=20 > Sorry to come back to you so late. I still had many other subsystems patc= hes, > now there are way less, many of them are accepted. >=20 > Can I have some guidance about this? I am new to Rust. > What's the best way in order to expose the workqueues? >=20 > If I understand correctly, the Idea is extends the functionalities of: >=20 > https://rust.docs.kernel.org/kernel/workqueue/struct.Queue.html >=20 > adding the "queue_on" function. >=20 > Creating a new type like "PerCpuQueue" I guess it means... wraps always > the workqueue_struct structure and defines what's appropriate, like the > new per-cpu workqueue. >=20 > Many thanks in advance! Yes, we can provide a new `struct PerCpuQueue` with same contents as `Queue`, where the `enqueue` and `enqueue_delayed` methods take a cpu id parameter. Then, all of the functions for obtaining queues at the bottom of the file are updated to return &PerCpuQueue instead of &Queue when a cpu id sone option here is tohould be provided to spawn on that queue. This way, you write: workqueue::system().enqueue(my_work_item) or you write: workqueue::system_percpu().enqueue(my_work_item, cpu_id) This way you must supply cpu id with system_percpu_wq() but not with system(). -- Another approach is to add a new `enqueue_cpu` to the existing `Queue` struct. In that case, all of these four combinations become legal: workqueue::system().enqueue(my_work_item) workqueue::system().enqueue_cpu(my_work_item, cpu_id) workqueue::system_percpu().enqueue(my_work_item) workqueue::system_percpu().enqueue_cpu(my_work_item, cpu_id) which approach is best depends on whether you want all four combinations to be legal or not. Alice