From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796157797; b=NBWsZgo/xdno0rO4Joh2olva/enM+Iz6GgA0HniWPt2v1gnokSqpTj4bEvdaYliPXNY7 jT+PcEoXLyNZVpMVR3oJL0FCOHtzMILB7rgRI7Seofdwe+s2PtCvWu9Rvd/k9Oo6qdS5o bpzkjP9lqoJu56uMuclWgnVcvAPAa5qCaA5oOBzWeRHihspiNxo3eF6gyHDf7MgqzV1Qg ZXqa/3V25O19Sw2snwLZtspMIua+BuwC0t7m5N4DLszMXb34qA97HDJ/wpsWyqXVhQ4oZ O6hzxDHyI1UAre1xQaolDrqdsMQuVoHnuh7MTFQ3Wfd5hLCPpl6FVh3aWfsLg3RaAjA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796157797; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=4XY5Uv5HXXkIq50BhOeg2vevdufEVFbIBTiVc+r6FlI=; b=th6szGmd1l5amjzGsH9w/zfmxXu0L+9V/wkkS0gemFEaWBxuEeAmcY6mvda2vJSs6U4s SRtaX511mj+ljmoXCLgB1la7+pJE4j0yjzunCrLik7Ngy8Rly/hi1n/4Wnr+ducwfe4QB CRD5vWi+orHAL8KK8cTpKJ+kzhgf99ck78RqISlCv0CGD1Yc3/Qk0vl1xqwOHs6dRi7SG LYvUGctlGE1enk4eZIEaH57ubMUpqcbwwuIS0ZOciYQ+1614aq3l9HJORKMXCYQ4KvYn4 qwTbIpKxYxZogCBcFcwfXdU4cNtZ+t1CMB+HMyy2BQXg9MPKbJh/0fOU9C55CGh4M6A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=s82T2AQM; arc=none smtp.remote-ip=209.85.128.51 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D32D606A31A for ; Tue, 1 Dec 2026 20:43:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8D32D606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=s82T2AQM Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4bb5e3cbf45so11496465e9.1 for ; Tue, 01 Dec 2026 12:43:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796157796; x=1796762596; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=4XY5Uv5HXXkIq50BhOeg2vevdufEVFbIBTiVc+r6FlI=; b=s82T2AQMlrmrnXqNaX2NaWtm+I0gANoXTB1p8nJmv6UHbSWJOK5L4OKeyriAU+uY8o wp2gZXEG74GlZCvR+rU8zaY0gFRtdnWYme8oYeLcPubfaCv/H+w/khaKyi9bk2BHcDqp MvoGHGBQPIb2C+0dVBAmDjM7Px8oCpPYm+1byDP5Dd+YtgnMO+3YDAawwB8ZaiSRKnHV WLNVJZ0/gQPLjIOSp6olFeVsVaIIY5KAShSxBFC5MdqtL4v6f42YhqmwZfRMWnyNs2gu RrBGmPBwMXNpzklLhzFpqP8pxG5H+GN1HdD2BmQghzNeBH3frk5tHX9pTPvTvwytsxN+ epbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796157796; x=1796762596; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4XY5Uv5HXXkIq50BhOeg2vevdufEVFbIBTiVc+r6FlI=; b=JSDNsfo2YX7GkJl2J8JRbeo3Q5sMLVlmiXofBvyLMgbzh4xDQCFeW7NNN51Wda7zVP UirVbrKeP6J/kDspEJx7ezJih2dOqSbA7/w8fK1MAVJ7mLXcEPLRPaj880WE4PVkPpOc YAfBXULoMjB80e80gZxKL7JkWW8kKxxokMp/qFBAY/SfDkkH+un6f03ZSut1fsmwB1hQ sUGVpt941mcNn4AsyUiv2gvEZzYlJKJ4MHntxDk0aNltrpkrLMCe9bs+1J+H0ow7CBX6 Pe2sHMWx18sTJ8F3C9gj0J3M/GVQfJOPiwqIVGGSWiOKj9DZ8AQu1JyyJgUf1c1tAuYu rjEQ== X-Forwarded-Encrypted: i=1; AL+hErFtbzyF5kzbOwJUXUxIkvFUd2iKki49NRXrnR60yVK4z4iNEWbOsifn3npHoiKpf9exO1dLlNgswPe6cNA=@vger.kernel.org X-Gm-Message-State: APuU4Z8ZDiyLHJAD9LK4EhKlBcNTG5jVqHmi+3zoP93V+8H/nyIfdtFh xAIHFwL0tp/Z5pPI/GyG5ITrRMnVvGp9CYXtx0yU2TkNEpdvBcIHnri3 X-Gm-Gg: AZFdTZdIomsY7yaIp1PR1FGUQz2ehJrBIydM6CKxWcrktDO+cfx501gQiiBV0q7+XLC b1Umrl1IxvFbTs3Vfk217XIZIYMEe0k8exeIM9NQwDz+FnMWf9vCgxPvI0B2VWHmJfTctuRNupT 8JVGse2ascvUp34BF3QVO+ILzpZTlkdKTclLrE1IdHR9QLFHXgtKTTC460L97xKKZI1Fgc6fTVr LK2tiUiv9tOB5fpAH6FNeYO3RSyMCbt37Vnes4+LStpSlUoM6oeMDEKm/CIvhzAfyKTryuT+IuL nFQPQGvQHYUQWcD9mk+57Pe8c5XLmM40j3wpuOYr9MdOztBQXKorZrDsKHbU1IL0484h+QUmVmz NYHBF4IN/WgzYMH6r71O5n6MwP7szqQABwHRfNuOWVi3aBZcpyJhkTI2Q91D/1kC0EgoWiYSd7i RDYoavKIDvArpEqO6oNj4S3aIf1hCd/HH9WKFxvIjQpd1oH4Xei3RxzUbLqdHT0rtkQHZOrAL9I GNsRrFL/kp0uJ90SNhNyx4Pk+UFcj578G4nQDHCTAZtQrwpJtbdYUmq5Flqk8eVnWy8LN5Yhx1c 7RhPpwf1OSlfDjyGi7G0d+uDax02Rnox3k1hHyRCAREKE6CL8S7L7TI= X-Received: by 2002:a7b:c011:0:b0:4bb:b631:92e3 with SMTP id 5b1f17b1804b1-4bbb6319ba0mr209450885e9.2.1796157795784; Tue, 01 Dec 2026 12:43:15 -0800 (PST) Received: from scheduler.schedules ([85.100.65.216]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ad644140b5sm69275393f8f.17.2026.12.01.12.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 12:43:14 -0800 (PST) Date: Tue, 1 Dec 2026 23:43:10 +0300 From: Kayra Cizmeci To: Peng Huang Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Juri Lelli , Vincent Guittot , Waiman Long , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , John Stultz , Suren Baghdasaryan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sebastian Andrzej Siewior , Clark Williams , linux-rt-devel@lists.linux.dev Subject: Re: [RFC PATCH v2 0/6] rwsem: priority boost for holders blocking high-priority waiters Message-ID: References: <20261201062738.1047159-1-penghuang@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20261201062738.1047159-1-penghuang@google.com> Hi Peng, On Mon, Nov 30, 2026 at 10:27:27PM -0800, Peng Huang wrote: > Hi, > > High-priority threads (e.g. UI/render) can stall for tens to hundreds > of milliseconds on shared rw_semaphores like mmap_lock or i_rwsem when > preempted low-priority or SCHED_IDLE readers block a writer. Outside > PREEMPT_RT, rwsems have no PI, Proxy Execution covers only mutexes, > and read-owners are anonymous. This hits both servers (/proc/pid/ > cmdline, background MADV_COLD) and phones (nice -10 UI vs. background > MADV_PAGEOUT on small cores, where we found it). > > This RFC raises the fair load weight of contended rwsem holders: > - Patches 1-2: per-task tracking of up to 4 held rwsems (no atomics); > btrfs untracks i_rwsem before cross-task io_uring completion. > - Patch 3: pack top waiter priority into sem->count bits 3..8 (no > struct rw_semaphore growth). > - Patches 4-5: apply boost in set_load_weight() (p->prio and PI > untouched); re-check queued holders on enqueue, preemption, and > tick; drop on unlock. > - Patch 6: KUnit suite (16 cases, 20 tests). > > Opt-in via CONFIG_RWSEM_SCHED_BOOST; disable at boot with > rwsem_sched_boost=0. > > Questions for this RFC > ---------------------- > - Is per-task tracking + weight boost acceptable for readers, or > should this wait for Proxy Execution to cover rwsems? > - Track readers and writers, or readers only (leaving writers to PE)? > - Raw pointer slots (+56 B/task, explicit untrack) or a hash table? > - Reweight via set_load_weight() (stays in cgroup share, moves PELT) > or a floor on flattened EEVDF weight (crosses cgroups, skips PELT)? > > Known limits > ------------ > - Weight is not PI; only runnable holders benefit (not I/O-blocked). > Queued holders wait up to one tick; at most 4 rwsems/task tracked. > - Waiter priority is sampled on queue (so rwsem-to-rwsem propagates > when a boosted holder queues, but not across mutexes or futexes); > concurrent readers share the boost. > - Under FAIR_GROUP_SCHED, boost stays within the holder's cgroup > share; a boosted SCHED_IDLE holder still yields to non-idle wakeups. > - Under Proxy Execution, a fair task running for a non-fair donor is > linked only on its next enqueue or preemption. > > Results (mean high-priority waiter latency) > ------------------------------------------- > - KUnit (UML, nice +19 reader + 4 nice 0 hogs, nice -10 writer): > 1813 -> 50 ms (-97.2%, median of 3; control 1.77-1.81 s). > - QEMU x86_64 -smp 4 (TCG), mmap_lock, same setup (10 runs): > 445.8 -> 8.7 ms within one image (-98.1%, max 14.9 ms, 0/200 > 16 ms; > BASE 394.4 ms, TCG shifts up to 20% across images). > - ARM64 phone (older 6.18 backport), mmap_lock, nice -10 vs. 7 hogs: > 46.95 -> 8.89 ms (-81.1%) unpinned, 229.5 -> 19.4 ms (-91.5%) mid. > > Costs and non-results > --------------------- > - UML uncontended fastpath (boost=0 -> 1, median of 3): read 16.9 -> > 20.2, write 17.1 -> 19.8, nested read 16.9 -> 21.8 ns/op; boosted > holder cycling an unrelated rwsem: 28.5 ns/op. > - Tick scan: walks up to 16 queued holders per tick under rq->lock > (round-robin, up to 4 sem->count reads each); not measured alone. > - Waiter prio rescan: O(1) when waiters share priority; losing a sole > top waiter rescans remaining waiters under wait_lock (O(waiters)). > - QEMU (boost=0 -> 1, 10 runs): madvise +2.4%, mprotect +1.4% (+0.4% > median); equal-priority contention -4.3% mean, -5.6% median > (196-240 ms on vs. 195-268 ms off). > - ARM64 (same backport): madvise -2.2%, mprotect +0.2%; boot-time > hackbench +6.6% and pipe +0.2% (settled -8.7% and -0.7%); > equal-priority contention -10.6% mid-pinned, -2.8% mean / +12.1% > median unpinned. ... > - Browser warm launch from zRAM (same backport, 22 vs. 23 runs): > +2.4% (p=0.45); holders spent 91-96% of inversion in D state (I/O). > - Reader count loses 1 bit (22 bits on 32-bit, > PID_MAX_LIMIT). > Memory: +56 B/task_struct, +16 B/rq. Well if that is the case I can't see increasing the weight would help atleast on this browser thing. Even Proxy Exec. wouldn't help that much. You can't make a sleeping task run earlier while it is sleeping. But aside from that if we really want this, I think it would be better to try to make this compatible with Proxy Exec. rather than trying to implement a new mechanism, no :-)? Thanks! Kayra