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 812283B5E10 for ; Thu, 11 Jun 2026 09:29:16 +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=1781170159; cv=none; b=N/GVzss4iDW12lgVECIhyACbA6fci/OMMTGxpRBLtKadFVhCivkXTGx0ae8aclg0mJM+aIS7nJikOsugGbElPCMCRMc49wOA3wF+/949Brg/z/8MZMl5sJXdzE94bCawgu5xyQBr3UUgqSXlezwExiN5d2JP3UDNzQyKmnbEMVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781170159; c=relaxed/simple; bh=NPPOkTqT1TpRzJ6qc0T4Kx4BSxKkafhtrpIepKUY9MU=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=Pw999yzRt2lIBoD9kSa5pO5HlWsvtj3QaH3Sgcq4flEGps18wkGOaTvDC7ZiwgZZyOAvpPLp7P+98BTQmjgHvEK7HKpszUb2lra1HlYukd42OQF52ZuxT2EqIAiTjaBcy0GRpDdto8AMSGuLXVNDytI6emtL3Tz5itsDmcMpP6c= 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=mQ5c+8Re; 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="mQ5c+8Re" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-490c56e2576so56829305e9.3 for ; Thu, 11 Jun 2026 02:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781170155; x=1781774955; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=77PJbDzH6s4AcUzRmgwa48EFlfnKEYm+oI0aQbmApw0=; b=mQ5c+8RecZk+r2DmLLO44a0zem5W3ABFMOeDYlxw/DRcpD+7QgDNULvgY4yKkk9MBh 17zliVLMYrr/2XWgO8EenXgsgq7L/0c9woREOAf3kt5t2QaCNKp4gihAQ25CmKg+dFlH H4566xmvi7dXoNKPp/rr4KCo71rHO1RMzqQnOeyx0bl2ZTCyv7amX1lieG4I+zInoOuR bRrBhI4G7EKuEkRxhLlXqx6rxBmMnT1t5XptcGWVZSFrhpvyW827fsNEfnhfpdTyPCJJ M/uvRfdAwa9ucdjcuYLzkT4uGDDmYL3ycsNpmGWvxT2T37LHrETbgVZ0G5LU19H2+tbU +flw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781170155; x=1781774955; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=77PJbDzH6s4AcUzRmgwa48EFlfnKEYm+oI0aQbmApw0=; b=hee1eNl6nc7qvh+TNkasviwFjNBUpNOSFvJbA+7pxm7eh+DZoN+NoLs89NqnJnhh96 AqRGHbt7OekX/N77OlvXbrIrXu/LxDA6JYqQJhTsvDwKnQGWHxEzawoZSr3FYOZKE5as 3+pvjcsyrhN1VVeK9HinvMalbEbLDYOscuBrkg2qj+x5p/hprLFw2wPFuy1ZsXq6HQzg wnpXpKt3fgFqrKiXd3i4CSu4+/C64mdKePbnP5EeZ769TJgVsf5WGfOwDWsDfwMXJEUA IqCYyPhpLYPE+R7Chr5U1Zst2UNqqh3qU/Bu2ge+SOCcT6Xk05bOSQr9S4IX6XA/gb8a e1JQ== X-Forwarded-Encrypted: i=1; AFNElJ/mTDcLxv4p9m72WXCdm+cmJRAKde/3bOhZyz4Cxlz8YJwOrCHePRzD0iruPP9uHBtUICywRVRlfHGXY3s=@vger.kernel.org X-Gm-Message-State: AOJu0Yx16wuAc1dUtvVkbWVN1TQ9mHCh2SrDDlBem71UtfrUhzoGSd2a IZtf8m6Wv4l6HYz3G202Yd0STeRPcbdJ6DBfeynHV583lJbLb/OOhv0ufwiwARTD/xc3q2d1mXg SFeYs53zNBs86+aYoKw== X-Received: from wrpi6.prod.google.com ([2002:adf:efc6:0:b0:44f:ef6a:cd7b]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4f94:b0:490:ba61:7981 with SMTP id 5b1f17b1804b1-490e561d579mr26466145e9.23.1781170154874; Thu, 11 Jun 2026 02:29:14 -0700 (PDT) Date: Thu, 11 Jun 2026 09:28:59 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIANt/KmoC/3WRXW+DIBSG/4rhemx8KerV/sfSC8CjJVGxYE2Xx v++U5usnc1uCC/keQ95uJIE0UMidXYlERaffBgx5G8ZcUczdkB9g5kIJgrGuabnqYumATqFvqd SAwijja6ahiAyRWj9Zav7OmA++jSH+L21L/x2+k/RwimjXFdKaqtto6rPLoSuh3cXBnJrWsSDF lzuaIF0VSrDWstL1doXWj7onJU7WiLNXMGrFkpVQPlCqyda7GcrpNvcKqeVBuPEH3q9S4lwOqP a+W6GWJOA4v3g5zpDzZEOPrmP3x0d4TKT5y+os216gW+3fmwg0jHgCm2iafIjlYaBY3lZMSVrd HVY1x/ltU3S2wEAAA== X-Change-Id: 20260117-upgrade-poll-37ee2a7a79dd X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=2527; i=aliceryhl@google.com; h=from:subject:message-id; bh=NPPOkTqT1TpRzJ6qc0T4Kx4BSxKkafhtrpIepKUY9MU=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBqKn/k0VsDI1YlwVHIuBynoWQyXjQ2MbaxToDHN T0DTTq2l6uJAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCaip/5AAKCRAEWL7uWMY5 RvCSEACTilYFKqu328tHihyQKBYf70OHom7hLXE1ukpjytRpYRKm8Nth0LItBEwfpGGPLtItOoU fFHqZx5tgiLt145rD0jmR4U8f2eZup1K5fcVMvHl4Oz3WB1Oau8U3+SJxza60xra5TM74owauTD Tmj54dTgkLFQIrZUGBAIJKjQ7lKEsCQ5+muCgxFinp8Bs+aLgBtk7v1joWuW81vtxIaGRV7AQTj R9iL4N4E2muAWPcUQaB+V3iQ/omWNZkKVOvVcHil2PgTLS09Y7IEtFCiPsErxjFb1zBRXgBkAJv d/I3FwxVDRdbcOH9ZehR4uJA+KkfxzPap5uxlMeIqCoJk9fMRWIhPVFluL3MLpURqbbw0R/Iaf3 spB22xVG5yuX5WbulVif8nsB+nECZgVxQfYhP3l3x0uf0OzOcybOFEMCJURnFndZtHhlEPNZ8F2 QC8cgKxq1strwoBGDsrjcG41/HpJF2f9psfIhXYNZajuRqVFL/GWI4T6qFm+TpE7Dw+snngQ7jd DAEyHC1Da+y8Gk28nMjg9lSstjblFeeAa4WhKoJeU38TuWzQnPE+oqHzZEv5KKqof2fx7ywwL5y t+up8JYBYkGW0zIRy1AYJOKB7SF06PP1ViQl/Ral8uUJ/uA/TypR4oeWSHa6LAoJXpmezYAUj/1 zrDI2BE33KqTAEQ== X-Mailer: b4 0.14.3 Message-ID: <20260611-upgrade-poll-v5-0-497a11c06828@google.com> Subject: [PATCH v5 0/2] Avoid synchronize_rcu() for every thread drop in Rust Binder From: Alice Ryhl To: Greg Kroah-Hartman , Carlos Llamas , Christian Brauner , Boqun Feng Cc: "Paul E. McKenney" , Alexander Viro , Jan Kara , Miguel Ojeda , Boqun Feng , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Gary Guo , linux-fsdevel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Alice Ryhl Content-Type: text/plain; charset="utf-8" Right now Rust Binder calls synchronize_rcu() more often than is necessary. Most processes do not use epoll at all, so they don't require rcu here. Back in Kangrejos I came up with a way to avoid this. Idea is to move the value that needs rcu to a separate allocation that's easy to kfree_rcu(). We pay the allocation only when the proc uses epoll using an "upgrade" strategy - most processes don't. Signed-off-by: Alice Ryhl --- Changes in v5: - Rebase on top of series converting node_refs to spinlock. - Reword comment claiming node_refs is a mutex. - Link to v4: https://lore.kernel.org/r/20260523-upgrade-poll-v4-0-f5b4c747eac2@google.com Changes in v4: - Use SetOnce for PollCondVar variable instead of storing inside spinlock. This avoids calling poll_wait() under the spinlock. - Link to v3: https://lore.kernel.org/r/20260508-upgrade-poll-v3-0-0c619fe846e8@google.com Changes in v3: - This series was almost entirely rewritten to use a different implementation strategy. By moving the PollCondVar to the process we can avoid the upgrade logic entirely. - Link to v2: https://lore.kernel.org/r/20260213-upgrade-poll-v2-0-984a0fb184fb@google.com Changes in v2: - Change how Rust Binder handles the lock class key. - Rebase. - Link to v1: https://lore.kernel.org/r/20260117-upgrade-poll-v1-0-179437b7bd49@google.com --- Alice Ryhl (2): rust: poll: use kfree_rcu() for PollCondVar rust_binder: move (e)poll wait queue to Process drivers/android/binder/node.rs | 4 +- drivers/android/binder/process.rs | 67 ++++++++++++++++++++++-------- drivers/android/binder/thread.rs | 78 +++++++++++++++++------------------ drivers/android/binder/transaction.rs | 6 ++- rust/kernel/sync/poll.rs | 73 +++++++++++++++++++++++++++++++- 5 files changed, 167 insertions(+), 61 deletions(-) --- base-commit: da61573f783897ae5a96c8f1c71aad6242344feb change-id: 20260117-upgrade-poll-37ee2a7a79dd prerequisite-change-id: 20260608-binder-noderefs-spin-3a0ec0589043:v2 prerequisite-patch-id: 3a1c4f545b2281e2e91ea0af7fe6c71f5ae0c08e prerequisite-patch-id: e1ae5f73b329080c0fcea1d2509c085e105f67c3 prerequisite-patch-id: 63f2092c6fd9dd54b7adf93be8d5670d8490f401 prerequisite-patch-id: 5811aeb4ca435a1d4d0bb347d4de9f3b2d91f814 prerequisite-patch-id: 556e45c697f9888c8446245bbcf478422991fddf prerequisite-patch-id: f567ba2263108b12871013309ae7c482d500eeae Best regards, -- Alice Ryhl