lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <87qzxf6zde.ffs@tglx>
Date: Wed, 13 Aug 2025 16:59:57 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To:linux-block@...r.kernel.org
Cc: cgroups@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>, Peter
 Zijlstra <peterz@...radead.org>, Jens Axboe <axboe@...nel.dk>, Josef Bacik
 <josef@...icpanda.com>, Tejun Heo <tj@...nel.org>
Subject: [PATCH] blkcg: Optimize exit to user space

blkcg uses TIF_NOTIFY_RESUME to handle throttling on exit to user
space. TIF_NOTIFY_RESUME is a multiplexing TIF bit, which is utilized by
other entities as well.

This results in a unconditional blkcg_maybe_throttle_current() call for
every invocation of resume_user_mode_work(), which is a pointless exercise
as most of the time there is no throttling work to do.

Optimize this by doing a quick check of the throttling condition before
invoking it.

Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Cc: Tejun Heo <tj@...nel.org>
Cc: Josef Bacik <josef@...icpanda.com>
Cc: Jens Axboe <axboe@...nel.dk>
---
 block/blk-cgroup.c         |    4 ++--
 include/linux/blk-cgroup.h |   10 +++++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -2001,7 +2001,7 @@ static void blkcg_maybe_throttle_blkg(st
 }
 
 /**
- * blkcg_maybe_throttle_current - throttle the current task if it has been marked
+ * __blkcg_maybe_throttle_current - throttle the current task if it has been marked
  *
  * This is only called if we've been marked with set_notify_resume().  Obviously
  * we can be set_notify_resume() for reasons other than blkcg throttling, so we
@@ -2010,7 +2010,7 @@ static void blkcg_maybe_throttle_blkg(st
  * to be called by people willy-nilly as it will actually do the work to
  * throttle the task if it is setup for throttling.
  */
-void blkcg_maybe_throttle_current(void)
+void __blkcg_maybe_throttle_current(void)
 {
 	struct gendisk *disk = current->throttle_disk;
 	struct blkcg *blkcg;
--- a/include/linux/blk-cgroup.h
+++ b/include/linux/blk-cgroup.h
@@ -14,6 +14,7 @@
  * 	              Nauman Rafique <nauman@...gle.com>
  */
 
+#include <linux/sched.h>
 #include <linux/types.h>
 
 struct bio;
@@ -26,7 +27,14 @@ struct gendisk;
 extern struct cgroup_subsys_state * const blkcg_root_css;
 
 void blkcg_schedule_throttle(struct gendisk *disk, bool use_memdelay);
-void blkcg_maybe_throttle_current(void);
+void __blkcg_maybe_throttle_current(void);
+
+static inline void blkcg_maybe_throttle_current(void)
+{
+	if (unlikely(current->throttle_disk))
+		__blkcg_maybe_throttle_current();
+}
+
 bool blk_cgroup_congested(void);
 void blkcg_pin_online(struct cgroup_subsys_state *blkcg_css);
 void blkcg_unpin_online(struct cgroup_subsys_state *blkcg_css);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ