Skip to content

power: supply: macsmc: add "auto-discharge" charge behaviour for CHLS - #521

Open
BoiledElectricity wants to merge 3569 commits into
AsahiLinux:asahi-wipfrom
BoiledElectricity:macsmc-force-discharge-configurable
Open

BoiledElectricity wants to merge 3569 commits into
AsahiLinux:asahi-wipfrom
BoiledElectricity:macsmc-force-discharge-configurable

Conversation

@BoiledElectricity

@BoiledElectricity BoiledElectricity commented Jun 24, 2026 •

Copy link
Copy Markdown

Lowering the charge limit on CHLS machines always sets CHLS_FORCE_DISCHARGE, so the battery actively drains down to the limit even on AC. Per review feedback, this is now implemented as a new charge_behaviour value instead of a module parameter:

  • New auto-discharge value (enum + sysfs string + ABI doc): like auto, but actively discharge down to the charge control end threshold.
  • End-threshold writes preserve the current CHLS_FORCE_DISCHARGE bit instead of forcing it on; auto keeps its documented cap-only meaning.
  • The selection lives in the CHLS key itself: no driver state, persists across reboots, and systems upgrading from the old behaviour keep force-discharge until they explicitly write auto.

Resolves the in-code TODO. Tested on M1 MacBook Pro (j293), see comments.

@BoiledElectricity

Copy link
Copy Markdown
Author

Tested on Apple MacBook Pro 13" M1 (j293), kernel 6.19.14, on AC at 100% (this firmware uses the CHLS path, has_chls=1):

  • force_discharge=N + set 90% limit → battery just caps charging, no discharge (Full, current_now=0)
  • force_discharge=Y (default) + set 90% limit → actively discharges (Discharging, ~-360 mA)
force_discharge=N, end_threshold=90:
  status=Full  current_now=0 uA        x4 samples over 8s

force_discharge=Y, end_threshold=90:
  status=Full         current_now=0 uA
  status=Discharging  current_now=-347000 uA
  status=Discharging  current_now=-376000 uA
  status=Discharging  current_now=-361000 uA

Battery restored to 100% / default afterwards.

mjbommar and others added 27 commits July 24, 2026 16:21
…ng it

commit ca978f8 upstream.

scsiback_get_pend_req() obtains a command tag and returns a vscsibk_pend
whose embedded se_cmd has only been memset to 0, so its cmd_kref is 0;
the se_cmd is initialised (kref_init() via target_init_cmd()) only
later, in scsiback_cmd_exec(), on the successful VSCSIIF_ACT_SCSI_CDB
path. The two error paths in scsiback_do_cmd_fn() taken before the
command is submitted -- a failed scsiback_gnttab_data_map() and an
unknown ring_req.act -- call
transport_generic_free_cmd(&pending_req->se_cmd, 0), which kref_put()s a
refcount of 0. That underflows it ("refcount_t: underflow;
use-after-free") and, as the release function is not run, leaks the
command tag.

Impact: a pvSCSI guest can leak every command tag of a LUN's session,
stopping the LUN, by submitting requests with a bad grant reference or
an unknown request type; under panic_on_warn the refcount underflow
panics the host.

Add a helper that just returns the tag with target_free_tag() and sends
the error response. It frees the tag while the v2p reference still pins
the session, and snapshots the response fields beforehand because
freeing the tag can let another ring reuse the pending_req slot.

Fixes: 2dbcdf3 ("xen-scsiback: Convert to percpu_ida tag allocation")
Cc: [email protected]
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Michael Bommarito <[email protected]>
Reviewed-by: Juergen Gross <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Martin K. Petersen <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit d04a179 upstream.

core_scsi3_decode_spec_i_port() and core_scsi3_emulate_register_and_move()
hand the raw PERSISTENT RESERVE OUT parameter buffer to
target_parse_pr_out_transport_id() without telling it how many bytes are
valid.  For an iSCSI TransportID (FORMAT CODE 01b),
iscsi_parse_pr_out_transport_id() locates the ",i,0x" ISID separator with
an unbounded strstr() (and on the error path prints the name with a further
unbounded "%s").  An initiator can submit a TransportID whose iSCSI name
contains neither a ",i,0x" substring nor a NUL terminator, filling the
parameter list to its end, so the scan runs off the end of the buffer.

When the parameter list spans more than one page the buffer is a multi-page
vmap (transport_kmap_data_sg()), so the over-read walks into the trailing
vmalloc guard page and oopses (KASAN: vmalloc-out-of-bounds in strstr).  It
is reachable by any fabric that delivers a PR OUT to a device exported
through an iSCSI TPG, including a guest via vhost-scsi.

Pass the number of received bytes down to the parser and validate the iSCSI
TransportID's own self-described length (ADDITIONAL LENGTH + 4) once, up
front: reject it if it is below the spc4r17 minimum or larger than the
received buffer, then bound the separator search, the ISID walk and the
name copy by that length.  This is the length check the callers already
perform after the parse (core_scsi3_decode_spec_i_port() compares tid_len
against tpdl, core_scsi3_emulate_register_and_move() validates it against
data_length), moved ahead of the scan.  Also drop the unbounded "%s" of the
unterminated name.

Add per-format explicit name-length checks before copying into i_str,
rather than silently truncating with min_t: for FORMAT CODE 00b reject if
the descriptor body (tid_len - 4 bytes) cannot fit in
i_str[TRANSPORT_IQN_LEN]; for FORMAT CODE 01b reject if the name portion
(from &buf[4] up to the separator) cannot fit.  Both checks make the bounds
intent explicit at each format branch.

While here, also reject a FORMAT CODE 01b TransportID whose ",i,0x"
separator sits at the very end of the descriptor: that leaves an empty ISID
and points the returned port nexus pointer at buf + tid_len, one past the
descriptor, which the registration code (__core_scsi3_locate_pr_reg(),
__core_scsi3_alloc_registration()) then dereferences as the ISID string --
the same over-read of the parameter buffer for a malformed descriptor.

Fixes: c66ac9d ("[SCSI] target: Add LIO target core v4.0.0-rc6")
Cc: [email protected]
Signed-off-by: Bryam Vargas <[email protected]>
Reviewed-by: John Garry <[email protected]>
Reviewed-by: David Disseldorp <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Martin K. Petersen <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit fda6a1f upstream.

core_scsi3_emulate_pro_register_and_move() maps the PERSISTENT RESERVE OUT
parameter list with transport_kmap_data_sg() and parses the destination
TransportID with target_parse_pr_out_transport_id(). For an iSCSI
TransportID (FORMAT CODE 01b), iscsi_parse_pr_out_transport_id() returns
the ISID in iport_ptr as a raw pointer into that mapped buffer.

The function then unmaps the buffer with transport_kunmap_data_sg() before
dereferencing iport_ptr in strcmp(), __core_scsi3_locate_pr_reg() and
core_scsi3_alloc_registration(). When the parameter list spans more than
one page (PARAMETER LIST LENGTH > 4096), transport_kmap_data_sg() uses
vmap() and transport_kunmap_data_sg() does vunmap(), so the kernel virtual
address backing iport_ptr is torn down and every subsequent dereference is
a use-after-free read of the unmapped region.

Keep the parameter list mapped until iport_ptr is no longer needed: drop
the early transport_kunmap_data_sg() and unmap once on the success path,
right before returning. The error paths already unmap through the existing
"if (buf) transport_kunmap_data_sg(cmd)" at the out: label, which now runs
on every post-map error exit because buf is no longer cleared early. Only
reads of the mapping happen while spinlocks are held; the map and unmap
calls remain outside any lock. The sibling caller
core_scsi3_decode_spec_i_port() already uses the buffer before unmapping it
and is left unchanged.

Fixes: 4949314 ("target: Allow control CDBs with data > 1 page")
Cc: [email protected]
Signed-off-by: Bryam Vargas <[email protected]>
Reviewed-by: John Garry <[email protected]>
Reviewed-by: David Disseldorp <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Martin K. Petersen <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 2c007ac upstream.

When efct_hw_reqtag_alloc() fails in efct_hw_io_abort(), the error path
returns -ENOSPC without releasing the reference obtained via
kref_get_unless_zero() earlier in the function. All other error paths
correctly drop the reference. This causes a permanent reference leak on the
io_to_abort object.

Additionally, the abort_in_progress flag is left set to true on this path,
which means future abort attempts for the same I/O will immediately return
-EINPROGRESS even though the abort was never submitted, effectively
blocking recovery.

Fix this by adding the missing kref_put() call and reset abort_in_progress
to false, matching the cleanup done in the efct_hw_wq_write() failure path
below.

Cc: [email protected]
Fixes: 63de513 ("scsi: elx: efct: Hardware I/O and SGL initialization")
Signed-off-by: WenTao Liang <[email protected]>
Reviewed-by: Daniel Wagner <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Martin K. Petersen <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 9cb2d52 upstream.

efct_dispatch_fcp_cmd() allocates an efct_io before dispatching an
unsolicited FCP command. If the command has an unsupported additional
CDB, the function returns -EIO before handing the IO to the SCSI layer.

Free the allocated IO before returning from this error path.

Fixes: f45ae6a ("scsi: elx: efct: Unsolicited FC frame processing routines")
Cc: [email protected]
Signed-off-by: Haoxiang Li <[email protected]>
Reviewed-by: Daniel Wagner <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Martin K. Petersen <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 52fce64 upstream.

During unmount or failure teardown all mon_data structures that contain
monitoring event file private data are freed after which kernfs nodes are
removed. However, the RDT_DELETED flag is never set for the statically
allocated default resource group.

A concurrent reader of an event file associated with the default resource
group may, after dropping kernfs active protection, block on rdtgroup_mutex
while unmount proceeds to free the file private data and destroy the kernfs
node without waiting for the reader.

When the mutex is released, the reader wakes up, observes that RDT_DELETED
is not set for the default group, and dereferences the already-freed
file private data.

The scenario can be depicted as follows:
  CPU0                                      CPU1
   /*
    * Default resource group's
    * monitoring data accessible via
    * kernfs file with kernfs_node::priv
    * pointing to a struct mon_data.
    * User opens the file for reading.
    */
   rdtgroup_mondata_show()                 /* arch encounters fatal error */
    rdtgroup_kn_lock_live()                 resctrl_exit()
     atomic_inc(&rdtgroup_default.waitcount) cpus_read_lock()
     kernfs_break_active_protection(kn)      mutex_lock(&rdtgroup_mutex)
     cpus_read_lock()                        resctrl_fs_teardown()
     mutex_lock(&rdtgroup_mutex)              rmdir_all_sub()
                                              mon_put_kn_priv()
                                               /* Delete all mon_data structures */
                                              rdtgroup_destroy_root()
                                               kernfs_destroy_root()
                                               rdtgroup_default.kn = NULL
                                             mutex_unlock(&rdtgroup_mutex)
     /*
      * rdtgroup_default.flags is empty so
      * rdtgroup_kn_lock_live() returns
      * &rdtgroup_default
      */
     md = of->kn->priv;

     /* md points to freed mon_data */

Set RDT_DELETED for the default group unconditionally since the flag does
not lead to the freeing of this statically allocated group.

Do not allow a new resctrl mount if there are any waiters on default group
of previous mount. A new mount will re-initialize the default group that
would appear to waiters from previous mount as though the default group is
accessible causing them to access the mon_data structures from the previous
mount that have been removed.

Fixes: 2a65660 ("x86/resctrl: Expand the width of domid by replacing mon_data_bits")
Closes: https://sashiko.dev/#/patchset/20260508182143.14592-1-tony.luck%40intel.com?part=2 [1]
Reported-by: Sashiko <[email protected]>
Signed-off-by: Tony Luck <[email protected]>
Signed-off-by: Reinette Chatre <[email protected]>
Signed-off-by: Borislav Petkov (AMD) <[email protected]>
Reviewed-by: Chen Yu <[email protected]>
Cc: <[email protected]>
Link: https://patch.msgid.link/49a2ca3ca688f27e1a646cf90e1dc69287021127.1783377598.git.reinette.chatre@intel.com
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 462a999 upstream.

ims_pcu_disconnect() only intended to perform cleanup when the primary
(control) interface is unbound. However, it currently relies on the
interface class to distinguish between control and data interfaces.
A malicious device could present a data interface with the same class
as the control interface, leading to premature cleanup and potential
use-after-free or double-free.

Switch to verifying that the interface being disconnected is indeed
the control interface.

Fixes: 628329d ("Input: add IMS Passenger Control Unit driver")
Cc: [email protected]
Reported-by: Sashiko bot <[email protected]>
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 001428e upstream.

When the driver was converted to use the driver core to instantiate device
attributes (via .dev_groups in the usb_driver structure), the attributes
started appearing on all interfaces bound to the driver. Since the ims-pcu
driver manually claims the secondary data interface during probe, the
driver core automatically creates the sysfs attributes for that interface
as well.

However, the driver only supports these attributes on the primary control
interface. Data interfaces lack the necessary descriptors and internal
state to handle these requests, and accessing them can lead to unexpected
behavior or crashes.

Fix this by updating the is_visible() callbacks for both the main and OFN
attribute groups to verify that the interface being accessed is indeed the
control interface.

Fixes: 204d18a ("Input: ims-pcu - use driver core to instantiate device attributes")
Reported-by: Sashiko bot <[email protected]>
Assisted-by: Gemini:gemini-3.1-pro
Cc: [email protected]
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 441c510 upstream.

During probe the driver claims the data interface, but it never releases
it. Release it in disconnect to avoid leaving it permanently claimed.

Fixes: 628329d ("Input: add IMS Passenger Control Unit driver")
Cc: [email protected]
Reported-by: Sashiko bot <[email protected]>
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit baf5697 upstream.

The driver currently assumes that the first endpoint of the control
interface is an interrupt IN endpoint without verifying it. A malicious
device could provide a different endpoint type, which would then be
passed to usb_fill_int_urb(), potentially leading to kernel warnings
or undefined behavior.

Verify that the control endpoint is an interrupt IN endpoint.

Fixes: 628329d ("Input: add IMS Passenger Control Unit driver")
Cc: [email protected]
Reported-by: Sashiko bot <[email protected]>
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 48c9d92 upstream.

The driver processes response data from device buffers without verifying
that the device actually sent enough data. This can lead to
out-of-bounds reads or processing stale data.

Add checks for the expected response length before accessing the
buffers.

Fixes: 628329d ("Input: add IMS Passenger Control Unit driver")
Cc: [email protected]
Reported-by: Sashiko bot <[email protected]>
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 8adf428 upstream.

In ims_pcu_line_setup(), the driver uses pcu->cmd_buf as a transfer
buffer for usb_control_msg(). However, pcu->cmd_buf is embedded in the
struct ims_pcu allocation, which violates DMA mapping rules regarding
cacheline alignment.

Use a heap-allocated buffer for the line coding data instead.

Fixes: 628329d ("Input: add IMS Passenger Control Unit driver")
Cc: [email protected]
Reported-by: Sashiko bot <[email protected]>
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit d48795b upstream.

The firmware object was not being released if validation failed.
Use __free(firmware) to ensure the firmware is always released.

Fixes: 628329d ("Input: add IMS Passenger Control Unit driver")
Cc: [email protected]
Reported-by: Sashiko bot <[email protected]>
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 2c9b85a upstream.

ims_pcu_reset_packet() incorrectly sets have_stx to true, which implies
that the start-of-packet delimiter has already been received. This
causes the protocol parser to skip waiting for the next STX byte and
potentially process garbage data.

Correctly set have_stx to false when resetting the packet state.

Fixes: 875115b ("Input: ims-pcu - fix heap-buffer-overflow in ims_pcu_process_data()")
Cc: [email protected]
Reported-by: Sashiko bot <[email protected]>
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 403b0a6 upstream.

The debug logging in ims_pcu_irq() unconditionally prints data from
pcu->urb_in_buf. However, if the interrupt fired for pcu->urb_ctrl, the
actual data resides in pcu->urb_ctrl_buf. If urb->actual_length for the
control URB exceeds pcu->max_in_size, this leads to an out-of-bounds
read.

Fix this by printing from the correct buffer associated with the URB.

Fixes: 628329d ("Input: add IMS Passenger Control Unit driver")
Cc: [email protected]
Reported-by: Sashiko bot <[email protected]>
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
…parsing

commit d4579af upstream.

The driver parses CDC union descriptors in ims_pcu_get_cdc_union_desc()
by iterating through the extra descriptor data. However, it does not
verify that the bLength of each descriptor is at least 2. A malicious
device could provide a descriptor with bLength = 0, leading to an
infinite loop in the driver.

Add a check to ensure bLength is at least 2 before proceeding with
parsing.

Fixes: 628329d (Input: add IMS Passenger Control Unit driver)
Cc: [email protected]
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 411b8c4 upstream.

The ims_pcu_reset_device() sysfs callback calls ims_pcu_execute_command()
without acquiring pcu->cmd_mutex. This can lead to data races and
corruption of the shared command buffer if triggered concurrently with
other commands.

Acquire pcu->cmd_mutex before calling ims_pcu_execute_command().

Fixes: 628329d ("Input: add IMS Passenger Control Unit driver")
Cc: [email protected]
Reported-by: Sashiko bot <[email protected]>
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit ca459e2 upstream.

The driver currently trusts the bMasterInterface0 from the CDC union
descriptor without verifying that it matches the interface being
probed. This could lead to the driver overwriting the private data of
another interface.

Validate that the control interface found in the descriptor is indeed
the one we are probing.

Fixes: 628329d ("Input: add IMS Passenger Control Unit driver")
Cc: [email protected]
Reported-by: Sashiko bot <[email protected]>
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit a3b5f24 upstream.

The vub300 driver lifetime-manages its controller state using
vub300->kref, with vub300_delete() freeing the mmc host when the last
reference is dropped. The probe error path after the inactivity timer has
been armed still bypasses that lifetime rule, however, and falls through
to mmc_free_host() directly if mmc_add_host() fails.

The race window is between arming the inactivity timer and reaching the
probe error unwind after mmc_add_host() fails:

        probe thread                     timer/workqueue
        ------------                     ---------------
        kref_init(&vub300->kref)         ref = 1
        kref_get(&vub300->kref)          ref = 2, timer ref
        add_timer(inactivity_timer)      fires after one second
        |
        |   race window
        |<---------------------------------------------------->
        |
        mmc_add_host(mmc)
                                         inactivity timer fires
                                         vub300_queue_dead_work()
                                           kref_get()          ref = 3
                                           queue_work(deadwork)
        mmc_add_host() fails
        timer_delete_sync()
        mmc_free_host(mmc)
          frees vub300
                                         deadwork runs
                                           use-after-free

The inactivity timeout is one second, so this would require
mmc_add_host() to both fail and take more than one second to do so. This
is unlikely to happen in practice, but the error path is still wrong.

timer_delete_sync() only waits for the timer callback itself. It does
not flush deadwork that the callback may already have queued. As a
result, queued deadwork can still hold a kref while the probe error path
directly frees the backing mmc host, including the vub300 storage.

Fix this by using the same lifetime mechanism as disconnect. Clear
vub300->interface so that the timer callback and any queued deadwork
return early and drop their references, then drop the initial probe
reference and return without falling through to err_free_host.

Fixes: 0613ad2 ("mmc: vub300: fix return value check of mmc_add_host()")
Signed-off-by: Guangshuo Li <[email protected]>
Reviewed-by: Johan Hovold <[email protected]>
Cc: [email protected]
Signed-off-by: Ulf Hansson <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit de74d8f upstream.

When an offloaded MACsec RX SC is deleted, macsec_del_rxsc_ctx() freed
the per-SC metadata_dst with metadata_dst_free(), which kfree()s the
object unconditionally and ignores the dst reference count. The RX
datapath in mlx5e_macsec_offload_handle_rx_skb() looks up the SC under
rcu_read_lock() via xa_load(), takes a reference with dst_hold() and
attaches the dst to the skb with skb_dst_set(). A reader that already
obtained the rx_sc pointer can race with the delete path and operate on
freed memory.

Fix the owner side by dropping the reference with dst_release() instead
of freeing unconditionally, and convert the RX datapath to
dst_hold_safe() so a reader racing the SC delete cannot attach a dst
whose last reference was just dropped; only attach it when a reference
was actually taken.

mlx5e_macsec_add_rxsc() also published sc_xarray_element via xa_alloc()
before rx_sc->md_dst was allocated and initialised, so a datapath reader
that looked the SC up by fs_id could observe rx_sc with md_dst still
NULL or, on weakly-ordered architectures, a non-NULL md_dst pointer
whose contents were not yet visible. NULL-check the xa_load() result and
md_dst on the datapath, and reorder add_rxsc() so the xa_alloc() publish
happens only after md_dst is fully initialised; the xarray RCU publish
then pairs with the rcu_read_lock()/xa_load() in the datapath.

Note: macsec_del_rxsc_ctx() also kfree()s rx_sc->sc_xarray_element
without an RCU grace period while the same datapath reads it under
rcu_read_lock(); that is a separate pre-existing issue left to a
follow-up patch.

Found by 0sec automated security-research tooling (https://0sec.ai).

Fixes: b7c9400 ("net/mlx5e: Implement MACsec Rx data path using MACsec skb_metadata_dst")
Cc: [email protected]
Signed-off-by: Doruk Tan Ozturk <[email protected]>
Reviewed-by: Tariq Toukan <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 50fd6dd upstream.

user_event_mm_dup() walks the parent mm's enabler list locklessly under
rcu_read_lock() during fork() (from copy_process()); it does not take
event_mutex:

	rcu_read_lock();
	list_for_each_entry_rcu(enabler, &old_mm->enablers, mm_enablers_link)
		enabler->event = user_event_get(orig->event);

user_event_enabler_destroy() removes an enabler from that list with
list_del_rcu() and then, without waiting for a grace period, drops the
enabler's user_event reference with user_event_put() and frees the enabler
with kfree(). A reader that loaded the enabler before the list_del_rcu()
can still be walking it, which leads to two use-after-frees:

 - kfree(enabler) frees the enabler while that reader dereferences
   enabler->event.

 - user_event_put() may drop the last reference to the user_event, which
   is then freed (via delayed_destroy_user_event() on a work queue), while
   the same reader does user_event_get(orig->event) on it.

Both are reachable by an unprivileged task that can open user_events_data:
one multithreaded process that registers an enabler and then concurrently
unregisters it and calls fork() triggers the race. KASAN reports a
slab-use-after-free in user_event_mm_dup() during clone(), with a
"refcount_t: addition on 0" warning when the user_event is freed.

The enabler use-after-free was found first; the user_event one was reported
by XIAO WU, and the earlier enabler-only fix did not address it.

Defer both the user_event_put() and the kfree(enabler) to a work item
queued with queue_rcu_work(), so they run only after an RCU grace period,
once all readers walking the enabler list have finished. The put must run
in process context because user_event_put() takes event_mutex on the last
reference, so a work queue is used rather than call_rcu(). The now-unlocked
put lets the locked argument of user_event_enabler_destroy() be removed;
all callers are updated.

Fixes: 7235759 ("tracing/user_events: Use remote writes for event enablement")
Cc: [email protected]
Link: https://patch.msgid.link/[email protected]
Reported-by: XIAO WU <[email protected]>
Closes: https://lore.kernel.org/all/[email protected]/
Suggested-by: Beau Belgrave <[email protected]>
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Michael Bommarito <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit aa6dcd5 upstream.

lbtf_free_adapter() calls timer_delete(&priv->command_timer), which does
not wait for a running command_timer_fn() callback. lbtf_free_adapter()
runs on the teardown path right before ieee80211_free_hw() frees priv,
both in lbtf_remove_card() and in the probe error path. command_timer is
armed by mod_timer() in lbtf_cmd() whenever a firmware command is sent.
command_timer_fn() dereferences priv. If a command times out as the
device is removed, command_timer_fn() runs concurrently with teardown and
dereferences priv after it has been freed.

This is the same use-after-free that commit 03cc8f9 ("wifi: libertas:
fix use-after-free in lbs_free_adapter()") fixed in the sibling libertas
driver. The libertas_tf variant has the identical pattern and was left
unchanged. Use timer_delete_sync() so any in-flight callback completes
before priv is freed.

Fixes: 06b16ae ("libertas_tf: main.c, data paths and mac80211 handlers")
Cc: [email protected]
Signed-off-by: Maoyi Xie <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 89038cc upstream.

rt_spin_unlock() releases the RCU protection before unlocking the
lock. That opens the door for the following UAF scenario:

 T1					T2
 spin_lock(&p->lock);		rcu_read_lock();
 invalidate(p);			p = rcu_dereference(ptr);
 rcu_assign_pointer(ptr, NULL);	if (!p) return;
 spin_unlock(&p->lock);		spin_lock(&p->lock)
 				   lock(&lock->lock);
				   rcu_read_lock();
 kfree_rcu(p);			rcu_read_unlock();
				....
				spin_unlock(&p->lock)
				  rcu_read_unlock(); // Ends grace period
 rcu_do_batch()
   kfree(p);
			    UAF ->	  rt_mutex_cmpxchg_release(&lock->lock...)

Regular spinlocks keep preemption disabled accross the unlock operation,
which provides full RCU protection, but the RT substitution fails to
resemble that. Same applies for the rwlock substitution.

Move the rcu_read_unlock() invocation past the unlock operations to match
the non-RT semantics. This makes it asymmetric vs. rt_xxx_lock(), but
that's harmless as the caller needs to hold RCU read lock across the lock
operation. The migrate_enable() call stays before the unlock operation
because there is no per CPU operation in the unlock path which would
require migration to be kept disabled.

Fixes: 0f383b6 ("locking/spinlock: Provide RT variant")
Reported-by: [email protected]
Decoded-by: Jann Horn <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Sebastian Andrzej Siewior <[email protected]>
Acked-by: Al Viro <[email protected]>
Cc: [email protected]
Link: https://patch.msgid.link/87jyrud75z.ffs@fw13
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 26aff38 upstream.

update_rlimit_cpu() converts the RLIMIT_CPU value to nanoseconds with

        u64 nsecs = rlim_new * NSEC_PER_SEC;

On 32-bit kernels both rlim_new (unsigned long) and NSEC_PER_SEC
(1000000000L) are 32-bit, so the multiplication is performed in unsigned
long and truncated for rlim_new > 4 seconds before being widened to u64.

The same file already casts to u64 for the matching computation in
check_process_timers():

        u64 softns = (u64)soft * NSEC_PER_SEC;

As a result, the truncated value is installed into the CPUCLOCK_PROF
expiry cache (nextevt), causing the process CPU timer to be programmed
to fire prematurely for any RLIMIT_CPU soft limit >= 5 seconds. The
actual SIGXCPU/SIGKILL decision in check_process_timers() already casts
to u64 and is therefore correct, so limit enforcement is not broken;
only the expiry-cache programming is wrong. Apply the same cast here so
both paths convert rlim_cur identically.

64-bit kernels are unaffected.

Fixes: 858cf3a ("timers/itimer: Convert internal cputime_t units to nsec")
Signed-off-by: Zhan Xusheng <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 808c447 upstream.

test_ownership.tc is sourced by ftracetest under /bin/sh.

The script currently declares mount_point with local at file scope,
which makes /bin/sh abort with "local: not in a function" before the
test can reach the eventfs ownership checks.

Replace the top-level local declaration with a normal shell variable so
kernels that support the gid= tracefs mount option can run the test at
all.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 8b55572 ("tracing/selftests: Add tracefs mount options test")
Signed-off-by: Cao Ruichuang <[email protected]>
Reviewed-by: Steven Rostedt (Google) <[email protected]>
Acked-by: Masami Hiramatsu (Google) <[email protected]>
Cc: [email protected]
Signed-off-by: Shuah Khan <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 673db10 upstream.

cpuhp_invoke_callback() unwinds earlier callbacks for the same
hotplug state when one instance fails. The rollback path currently
reuses ret, so a successful rollback can hide the original error and
make the failed transition look successful.

Keep the rollback result separate from the original error.

Fixes: 724a868 ("smp/hotplug: Callback vs state-machine consistency")
Signed-off-by: Bradley Morgan <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 86f4365 upstream.

states_show() adds CPU hotplug state names into a single sysfs buffer
using sprintf(). With enough registered states, this can write past the
end of the PAGE_SIZE buffer.

Use sysfs_emit_at() so output is bounded.

Fixes: 98f8cdc ("cpu/hotplug: Add sysfs state interface")
Signed-off-by: Bradley Morgan <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
@jannau
jannau force-pushed the asahi-wip branch 2 times, most recently from c1cb252 to 96fa2b9 Compare August 11, 2026 13:25
@jannau
jannau force-pushed the asahi-wip branch 2 times, most recently from 77cb8f2 to b02aba8 Compare August 26, 2026 09:11
@jannau
jannau force-pushed the asahi-wip branch 2 times, most recently from 710a1d4 to 94fb233 Compare September 12, 2026 09:59
@jannau
jannau force-pushed the asahi-wip branch 2 times, most recently from 0f086c1 to 11ee430 Compare October 15, 2026 17:39
@jannau
jannau force-pushed the asahi-wip branch 2 times, most recently from 7434c5d to 414e55d Compare October 30, 2026 18:19
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 6, 2026
…run onto it

While the floor is down the policy runs on a deferrable timer, queued on
the CPU that ran it last; while that CPU sleeps the run waits, and the
first one after measures each core's busy share over the whole wait, so a
core that has just started a load reads as idle. cpyvar's copies of about
10 ms kept no floor's speed under the ladder (52.5-55.6 GB/s against
100.6 sustained, r187, 2026-11-06; the deferral inferred, not traced).

Each CPU now has a deferrable timer pinned to it, which fires only while
the CPU is awake and moves an overdue run there, so the busy core runs
the policy within a period or two and an idle system still gets no
wakeups for it. A run queued for the time of one already done does
nothing.

floor-ab.sh on AsahiLinux#521 (m3/pairs with the watches off by a [tr] knob,
2026-11-06, three alternated cycles; cpyvar's 1 GiB on cpu10, best
round, GB/s; xz -6 -T1 on cpu10 with PSTR - PDBR):

  ladder, watches:     memcpy 109.8-117.7  ldnp/stnp 127.5-129.5
                       xz 8.20-8.86 s  11.9-12.2 W  98-108 J
  ladder, no watches:  memcpy 52.8-111.0   ldnp/stnp 53.3-129.1
                       xz 8.22-8.54 s  11.5-12.1 W  98-100 J

Without the watches one copy of three stayed at the no-floor speed;
with them every copy rose.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 6, 2026
…run onto it

While the floor is down the policy runs on a deferrable timer, queued on
the CPU that ran it last; while that CPU sleeps the run waits, and the
first one after measures each core's busy share over the whole wait, so a
core that has just started a load reads as idle. cpyvar's copies of about
10 ms kept no floor's speed under the ladder (52.5-55.6 GB/s against
100.6 sustained, r187, 2026-11-06; the deferral inferred, not traced).

Each CPU now has a deferrable timer pinned to it, which fires only while
the CPU is awake and moves an overdue run there, so the busy core runs
the policy within a period or two and an idle system still gets no
wakeups for it. A run queued for the time of one already done does
nothing.

floor-ab.sh on AsahiLinux#521 (m3/pairs with the watches off by a [tr] knob,
2026-11-06, three alternated cycles; cpyvar's 1 GiB on cpu10, best
round, GB/s; xz -6 -T1 on cpu10 with PSTR - PDBR):

  ladder, watches:     memcpy 109.8-117.7  ldnp/stnp 127.5-129.5
                       xz 8.20-8.86 s  11.9-12.2 W  98-108 J
  ladder, no watches:  memcpy 52.8-111.0   ldnp/stnp 53.3-129.1
                       xz 8.22-8.54 s  11.5-12.1 W  98-100 J

Without the watches one copy of three stayed at the no-floor speed;
with them every copy rose.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 7, 2026
…run onto it

While the floor is down the policy runs on a deferrable timer, queued on
the CPU that ran it last; while that CPU sleeps the run waits, and the
first one after measures each core's busy share over the whole wait, so a
core that has just started a load reads as idle. cpyvar's copies of about
10 ms kept no floor's speed under the ladder (52.5-55.6 GB/s against
100.6 sustained, r187, 2026-11-06; the deferral inferred, not traced).

Each CPU now has a deferrable timer pinned to it, which fires only while
the CPU is awake and moves an overdue run there, so the busy core runs
the policy within a period or two and an idle system still gets no
wakeups for it. A run queued for the time of one already done does
nothing.

floor-ab.sh on AsahiLinux#521 (m3/pairs with the watches off by a [tr] knob,
2026-11-06, three alternated cycles; cpyvar's 1 GiB on cpu10, best
round, GB/s; xz -6 -T1 on cpu10 with PSTR - PDBR):

  ladder, watches:     memcpy 109.8-117.7  ldnp/stnp 127.5-129.5
                       xz 8.20-8.86 s  11.9-12.2 W  98-108 J
  ladder, no watches:  memcpy 52.8-111.0   ldnp/stnp 53.3-129.1
                       xz 8.22-8.54 s  11.5-12.1 W  98-100 J

Without the watches one copy of three stayed at the no-floor speed;
with them every copy rose.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 7, 2026
…run onto it

While the floor is down the policy runs on a deferrable timer, queued on
the CPU that ran it last; while that CPU sleeps the run waits, and the
first one after measures each core's busy share over the whole wait, so a
core that has just started a load reads as idle. cpyvar's copies of about
10 ms kept no floor's speed under the ladder (52.5-55.6 GB/s against
100.6 sustained, r187, 2026-11-06; the deferral inferred, not traced).

Each CPU now has a deferrable timer pinned to it, which fires only while
the CPU is awake and moves an overdue run there, so the busy core runs
the policy within a period or two and an idle system still gets no
wakeups for it. A run queued for the time of one already done does
nothing.

floor-ab.sh on AsahiLinux#521 (m3/pairs with the watches off by a [tr] knob,
2026-11-06, three alternated cycles; cpyvar's 1 GiB on cpu10, best
round, GB/s; xz -6 -T1 on cpu10 with PSTR - PDBR):

  ladder, watches:     memcpy 109.8-117.7  ldnp/stnp 127.5-129.5
                       xz 8.20-8.86 s  11.9-12.2 W  98-108 J
  ladder, no watches:  memcpy 52.8-111.0   ldnp/stnp 53.3-129.1
                       xz 8.22-8.54 s  11.5-12.1 W  98-100 J

Without the watches one copy of three stayed at the no-floor speed;
with them every copy rose.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 8, 2026
…run onto it

While the floor is down the policy runs on a deferrable timer, queued on
the CPU that ran it last; while that CPU sleeps the run waits, and the
first one after measures each core's busy share over the whole wait, so a
core that has just started a load reads as idle. cpyvar's copies of about
10 ms kept no floor's speed under the ladder (52.5-55.6 GB/s against
100.6 sustained, r187, 2026-11-06; the deferral inferred, not traced).

Each CPU now has a deferrable timer pinned to it, which fires only while
the CPU is awake and moves an overdue run there, so the busy core runs
the policy within a period or two and an idle system still gets no
wakeups for it. A run queued for the time of one already done does
nothing.

floor-ab.sh on AsahiLinux#521 (m3/pairs with the watches off by a [tr] knob,
2026-11-06, three alternated cycles; cpyvar's 1 GiB on cpu10, best
round, GB/s; xz -6 -T1 on cpu10 with PSTR - PDBR):

  ladder, watches:     memcpy 109.8-117.7  ldnp/stnp 127.5-129.5
                       xz 8.20-8.86 s  11.9-12.2 W  98-108 J
  ladder, no watches:  memcpy 52.8-111.0   ldnp/stnp 53.3-129.1
                       xz 8.22-8.54 s  11.5-12.1 W  98-100 J

Without the watches one copy of three stayed at the no-floor speed;
with them every copy rose.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 8, 2026
…run onto it

While the floor is down the policy runs on a deferrable timer, queued on
the CPU that ran it last; while that CPU sleeps the run waits, and the
first one after measures each core's busy share over the whole wait, so a
core that has just started a load reads as idle. cpyvar's copies of about
10 ms kept no floor's speed under the ladder (52.5-55.6 GB/s against
100.6 sustained, r187, 2026-11-06; the deferral inferred, not traced).

Each CPU now has a deferrable timer pinned to it, which fires only while
the CPU is awake and moves an overdue run there, so the busy core runs
the policy within a period or two and an idle system still gets no
wakeups for it. A run queued for the time of one already done does
nothing.

floor-ab.sh on AsahiLinux#521 (m3/pairs with the watches off by a [tr] knob,
2026-11-06, three alternated cycles; cpyvar's 1 GiB on cpu10, best
round, GB/s; xz -6 -T1 on cpu10 with PSTR - PDBR):

  ladder, watches:     memcpy 109.8-117.7  ldnp/stnp 127.5-129.5
                       xz 8.20-8.86 s  11.9-12.2 W  98-108 J
  ladder, no watches:  memcpy 52.8-111.0   ldnp/stnp 53.3-129.1
                       xz 8.22-8.54 s  11.5-12.1 W  98-100 J

Without the watches one copy of three stayed at the no-floor speed;
with them every copy rose.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 11, 2026
…run onto it

While the floor is down the policy runs on a deferrable timer, queued on
the CPU that ran it last; while that CPU sleeps the run waits, and the
first one after measures each core's busy share over the whole wait, so a
core that has just started a load reads as idle. cpyvar's copies of about
10 ms kept no floor's speed under the ladder (52.5-55.6 GB/s against
100.6 sustained, r187, 2026-11-06; the deferral inferred, not traced).

Each CPU now has a deferrable timer pinned to it, which fires only while
the CPU is awake and moves an overdue run there, so the busy core runs
the policy within a period or two and an idle system still gets no
wakeups for it. A run queued for the time of one already done does
nothing.

floor-ab.sh on AsahiLinux#521 (m3/pairs with the watches off by a [tr] knob,
2026-11-06, three alternated cycles; cpyvar's 1 GiB on cpu10, best
round, GB/s; xz -6 -T1 on cpu10 with PSTR - PDBR):

  ladder, watches:     memcpy 109.8-117.7  ldnp/stnp 127.5-129.5
                       xz 8.20-8.86 s  11.9-12.2 W  98-108 J
  ladder, no watches:  memcpy 52.8-111.0   ldnp/stnp 53.3-129.1
                       xz 8.22-8.54 s  11.5-12.1 W  98-100 J

Without the watches one copy of three stayed at the no-floor speed;
with them every copy rose.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 14, 2026
…run onto it

While the floor is down the policy runs on a deferrable timer, queued on
the CPU that ran it last; while that CPU sleeps the run waits, and the
first one after measures each core's busy share over the whole wait, so a
core that has just started a load reads as idle. cpyvar's copies of about
10 ms kept no floor's speed under the ladder (52.5-55.6 GB/s against
100.6 sustained, r187, 2026-11-06; the deferral inferred, not traced).

Each CPU now has a deferrable timer pinned to it, which fires only while
the CPU is awake and moves an overdue run there, so the busy core runs
the policy within a period or two and an idle system still gets no
wakeups for it. A run queued for the time of one already done does
nothing.

floor-ab.sh on AsahiLinux#521 (m3/pairs with the watches off by a [tr] knob,
2026-11-06, three alternated cycles; cpyvar's 1 GiB on cpu10, best
round, GB/s; xz -6 -T1 on cpu10 with PSTR - PDBR):

  ladder, watches:     memcpy 109.8-117.7  ldnp/stnp 127.5-129.5
                       xz 8.20-8.86 s  11.9-12.2 W  98-108 J
  ladder, no watches:  memcpy 52.8-111.0   ldnp/stnp 53.3-129.1
                       xz 8.22-8.54 s  11.5-12.1 W  98-100 J

Without the watches one copy of three stayed at the no-floor speed;
with them every copy rose.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 19, 2026
…run onto it

While the floor is down the policy runs on a deferrable timer, queued on
the CPU that ran it last; while that CPU sleeps the run waits, and the
first one after measures each core's busy share over the whole wait, so a
core that has just started a load reads as idle. cpyvar's copies of about
10 ms kept no floor's speed under the ladder (52.5-55.6 GB/s against
100.6 sustained, r187, 2026-11-06; the deferral inferred, not traced).

Each CPU now has a deferrable timer pinned to it, which fires only while
the CPU is awake and moves an overdue run there, so the busy core runs
the policy within a period or two and an idle system still gets no
wakeups for it. A run queued for the time of one already done does
nothing.

floor-ab.sh on AsahiLinux#521 (m3/pairs with the watches off by a [tr] knob,
2026-11-06, three alternated cycles; cpyvar's 1 GiB on cpu10, best
round, GB/s; xz -6 -T1 on cpu10 with PSTR - PDBR):

  ladder, watches:     memcpy 109.8-117.7  ldnp/stnp 127.5-129.5
                       xz 8.20-8.86 s  11.9-12.2 W  98-108 J
  ladder, no watches:  memcpy 52.8-111.0   ldnp/stnp 53.3-129.1
                       xz 8.22-8.54 s  11.5-12.1 W  98-100 J

Without the watches one copy of three stayed at the no-floor speed;
with them every copy rose.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 20, 2026
…run onto it

While the floor is down the policy runs on a deferrable timer, queued on
the CPU that ran it last; while that CPU sleeps the run waits, and the
first one after measures each core's busy share over the whole wait, so a
core that has just started a load reads as idle. cpyvar's copies of about
10 ms kept no floor's speed under the ladder (52.5-55.6 GB/s against
100.6 sustained, r187, 2026-11-06; the deferral inferred, not traced).

Each CPU now has a deferrable timer pinned to it, which fires only while
the CPU is awake and moves an overdue run there, so the busy core runs
the policy within a period or two and an idle system still gets no
wakeups for it. A run queued for the time of one already done does
nothing.

floor-ab.sh on AsahiLinux#521 (m3/pairs with the watches off by a [tr] knob,
2026-11-06, three alternated cycles; cpyvar's 1 GiB on cpu10, best
round, GB/s; xz -6 -T1 on cpu10 with PSTR - PDBR):

  ladder, watches:     memcpy 109.8-117.7  ldnp/stnp 127.5-129.5
                       xz 8.20-8.86 s  11.9-12.2 W  98-108 J
  ladder, no watches:  memcpy 52.8-111.0   ldnp/stnp 53.3-129.1
                       xz 8.22-8.54 s  11.5-12.1 W  98-100 J

Without the watches one copy of three stayed at the no-floor speed;
with them every copy rose.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 20, 2026
…run onto it

While the floor is down the policy runs on a deferrable timer, queued on
the CPU that ran it last; while that CPU sleeps the run waits, and the
first one after measures each core's busy share over the whole wait, so a
core that has just started a load reads as idle. cpyvar's copies of about
10 ms kept no floor's speed under the ladder (52.5-55.6 GB/s against
100.6 sustained, r187, 2026-11-06; the deferral inferred, not traced).

Each CPU now has a deferrable timer pinned to it, which fires only while
the CPU is awake and moves an overdue run there, so the busy core runs
the policy within a period or two and an idle system still gets no
wakeups for it. A run queued for the time of one already done does
nothing.

floor-ab.sh on AsahiLinux#521 (m3/pairs with the watches off by a [tr] knob,
2026-11-06, three alternated cycles; cpyvar's 1 GiB on cpu10, best
round, GB/s; xz -6 -T1 on cpu10 with PSTR - PDBR):

  ladder, watches:     memcpy 109.8-117.7  ldnp/stnp 127.5-129.5
                       xz 8.20-8.86 s  11.9-12.2 W  98-108 J
  ladder, no watches:  memcpy 52.8-111.0   ldnp/stnp 53.3-129.1
                       xz 8.22-8.54 s  11.5-12.1 W  98-100 J

Without the watches one copy of three stayed at the no-floor speed;
with them every copy rose.
@jannau
jannau force-pushed the asahi-wip branch 2 times, most recently from ec9d245 to 4cc8b87 Compare November 29, 2026 18:55
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 30, 2026
…run onto it

While the floor is down the policy runs on a deferrable timer, queued on
the CPU that ran it last; while that CPU sleeps the run waits, and the
first one after measures each core's busy share over the whole wait, so a
core that has just started a load reads as idle. cpyvar's copies of about
10 ms kept no floor's speed under the ladder (52.5-55.6 GB/s against
100.6 sustained, r187, 2026-11-06; the deferral inferred, not traced).

Each CPU now has a deferrable timer pinned to it, which fires only while
the CPU is awake and moves an overdue run there, so the busy core runs
the policy within a period or two and an idle system still gets no
wakeups for it. A run queued for the time of one already done does
nothing.

floor-ab.sh on AsahiLinux#521 (m3/pairs with the watches off by a [tr] knob,
2026-11-06, three alternated cycles; cpyvar's 1 GiB on cpu10, best
round, GB/s; xz -6 -T1 on cpu10 with PSTR - PDBR):

  ladder, watches:     memcpy 109.8-117.7  ldnp/stnp 127.5-129.5
                       xz 8.20-8.86 s  11.9-12.2 W  98-108 J
  ladder, no watches:  memcpy 52.8-111.0   ldnp/stnp 53.3-129.1
                       xz 8.22-8.54 s  11.5-12.1 W  98-100 J

Without the watches one copy of three stayed at the no-floor speed;
with them every copy rose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.