public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Meyer <thomas@m3y3r.de>
To: David Rheinsberg <david@readahead.eu>
Cc: rust-for-linux@vger.kernel.org, teg@jklm.no,
	Miguel Ojeda <ojeda@kernel.org>
Subject: Re: [RFC 07/16] bus1: add man-page
Date: Sat, 11 Apr 2026 14:46:37 +0200	[thread overview]
Message-ID: <adpCrdG4gZbMAL2v@localhost.localdomain> (raw)
In-Reply-To: <adEurRZBWe9poAI4@jupiter>

Hi,

I did write a small test program, that creates handles in a loop till it gets
an error from the OS, and run it against the code from your wip/bus1 branch on
github/bus1/linux. The creation of handles itself doesn't seems to get
accounted. If you like I can upload this little test program somewhere.

I'm a rust beginner, so be gentle :-)
Here is my try of fixing it:

commit aa0b3987801e8ea773254badcd17b73ae140dbf2
Author: Thomas Meyer <thomas@m3y3r.de>
Date:   Sat Apr 11 14:06:47 2026 +0200

    bus1: charge handles and fix unlink

diff --git a/ipc/bus1/bus.rs b/ipc/bus1/bus.rs
index 70a6a4f35d96e..e5222fdb931a7 100644
--- a/ipc/bus1/bus.rs
+++ b/ipc/bus1/bus.rs
@@ -20,6 +20,7 @@ enum MessageError {
 #[pin_data]
 struct Peer {
     actor: Arc<acct::Actor>,
+    charge: acct::Charge,
     waitq: *mut kernel::bindings::wait_queue_head,
     queue: lll::List<TxNodeRef>,
     queue_committed: atomic::Atomic<usize>,
@@ -36,6 +37,7 @@ struct PeerLocked {
 #[pin_data]
 struct Node {
     owner: Arc<Peer>,
+    charge: acct::Charge,
     userdata: atomic::Atomic<usize>,
     op_rb: rb::Node,
     #[pin]
@@ -124,10 +126,15 @@ fn new(
         actor: Arc<acct::Actor>,
         waitq: *mut kernel::bindings::wait_queue_head,
     ) -> Result<Arc<Self>, AllocError> {
+        let charge = actor.as_arc_borrow().charge(
+            actor.as_arc_borrow(),
+            &[1, core::mem::size_of::<Self>() as u64],
+        ).map_err(|_| AllocError)?;
         let tx = Tx::new()?;
         match Arc::pin_init(
             pin_init!(Self {
                 actor,
+                charge,
                 waitq,
                 queue: lll::List::new(),
                 queue_committed: atomic::Atomic::new(0),
@@ -381,9 +388,14 @@ impl Node {
     fn new(
         owner: Arc<Peer>,
     ) -> Result<Arc<Self>, AllocError> {
+        let charge = owner.actor.as_arc_borrow().charge(
+            owner.actor.as_arc_borrow(),
+            &[1, core::mem::size_of::<Self>() as u64],
+        ).map_err(|_| AllocError)?;
         match Arc::pin_init(
             pin_init!(Self {
                 owner,
+                charge,
                 userdata: atomic::Atomic::new(0),
                 op_rb: rb::Node::new(),
                 inner <- kernel::sync::new_mutex!(
@@ -470,6 +482,10 @@ fn new(
         node: Arc<Node>,
         owner: Arc<Peer>,
     ) -> Result<Arc<Handle>, AllocError> {
+        let _charge = owner.actor.as_arc_borrow().charge(
+            owner.actor.as_arc_borrow(),
+            &[1, core::mem::size_of::<Self>() as u64],
+        ).map_err(|_| AllocError)?;
         Arc::new(
             Self {
                 node,
@@ -803,12 +819,10 @@ fn commit(self: Pin<&mut Self>) {
             let txnode = TxNodeRef::new_release_handle(h.clone());
             if let Err(_) = to.queue.try_link_front(txnode) {
                 kernel::warn_on!(true);
-                c.try_unlink_and_move_next();
-                continue;
             }
 
             h.as_arc_borrow().unlink();
-            c.move_next();
+            c.try_unlink_and_move_next();
         }
 
         // Step #2

  parent reply	other threads:[~2026-04-11 12:46 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 19:02 [RFC 00/16] bus1: Capability-based IPC for Linux David Rheinsberg
2026-03-31 19:02 ` [RFC 01/16] rust/sync: add LockedBy::access_mut_unchecked() David Rheinsberg
2026-03-31 19:29   ` Miguel Ojeda
2026-03-31 19:02 ` [RFC 02/16] rust/sync: add Arc::drop_unless_unique() David Rheinsberg
2026-03-31 19:02 ` [RFC 03/16] rust/alloc: add Vec::into_boxed_slice() David Rheinsberg
2026-03-31 19:28   ` Miguel Ojeda
2026-03-31 21:10   ` Gary Guo
2026-03-31 22:07   ` Danilo Krummrich
2026-04-01  9:28     ` David Rheinsberg
2026-03-31 19:02 ` [RFC 04/16] rust/error: add EXFULL, EBADRQC, EDQUOT, ENOTRECOVERABLE David Rheinsberg
2026-03-31 19:02 ` [RFC 05/16] bus1: add module scaffolding David Rheinsberg
2026-03-31 19:02 ` [RFC 06/16] bus1: add the user-space API David Rheinsberg
2026-03-31 19:02 ` [RFC 07/16] bus1: add man-page David Rheinsberg
2026-04-01 16:30   ` Jonathan Corbet
2026-04-01 18:01     ` David Rheinsberg
2026-04-01 18:06       ` David Rheinsberg
2026-04-04 15:30   ` Thomas Meyer
2026-04-09 13:14     ` David Rheinsberg
2026-04-11 12:46     ` Thomas Meyer [this message]
2026-03-31 19:03 ` [RFC 08/16] bus1/util: add basic utilities David Rheinsberg
2026-03-31 19:35   ` Miguel Ojeda
2026-04-01 11:05     ` David Rheinsberg
2026-04-01 11:25       ` Miguel Ojeda
2026-03-31 19:03 ` [RFC 09/16] bus1/util: add field projections David Rheinsberg
2026-03-31 19:38   ` Miguel Ojeda
2026-03-31 19:03 ` [RFC 10/16] bus1/util: add IntoDeref/FromDeref David Rheinsberg
2026-03-31 19:44   ` Miguel Ojeda
2026-03-31 19:03 ` [RFC 11/16] bus1/util: add intrusive data-type helpers David Rheinsberg
2026-03-31 19:03 ` [RFC 12/16] bus1/util: add intrusive single linked lists David Rheinsberg
2026-03-31 19:03 ` [RFC 13/16] bus1/util: add intrusive rb-tree David Rheinsberg
2026-03-31 19:43   ` Miguel Ojeda
2026-03-31 19:03 ` [RFC 14/16] bus1/acct: add resouce accounting David Rheinsberg
2026-03-31 19:03 ` [RFC 15/16] bus1: introduce peers, handles, and nodes David Rheinsberg
2026-03-31 19:03 ` [RFC 16/16] bus1: implement the uapi David Rheinsberg
2026-03-31 19:46 ` [RFC 00/16] bus1: Capability-based IPC for Linux Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=adpCrdG4gZbMAL2v@localhost.localdomain \
    --to=thomas@m3y3r.de \
    --cc=david@readahead.eu \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=teg@jklm.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox