All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ye Liu <ye.liu@linux.dev>
To: bsingharora@gmail.com, yang.yang29@zte.com.cn
Cc: linux-kernel@vger.kernel.org, Ye Liu <liuye@kylinos.cn>
Subject: [PATCH] delayacct: use macro to simplify delayacct_end calls
Date: Mon, 14 Apr 2025 14:32:27 +0800	[thread overview]
Message-ID: <20250414063227.97035-1-ye.liu@linux.dev> (raw)

From: Ye Liu <liuye@kylinos.cn>

Replace repetitive calls to delayacct_end() with a new macro
DELAYACCT_END to reduce code duplication.
No functional changes.

Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
 kernel/delayacct.c | 50 +++++++++++++---------------------------------
 1 file changed, 14 insertions(+), 36 deletions(-)

diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index eb63a021ac04..3d7ca3928be2 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -18,6 +18,14 @@ DEFINE_STATIC_KEY_FALSE(delayacct_key);
 int delayacct_on __read_mostly;	/* Delay accounting turned on/off */
 struct kmem_cache *delayacct_cache;
 
+#define DELAYACCT_END(task, type) \
+	delayacct_end(&(task)->delays->lock, \
+		      &(task)->delays->type##_start, \
+		      &(task)->delays->type##_delay, \
+		      &(task)->delays->type##_count, \
+		      &(task)->delays->type##_delay_max, \
+		      &(task)->delays->type##_delay_min)
+
 static void set_delayacct(bool enabled)
 {
 	if (enabled) {
@@ -123,12 +131,7 @@ void __delayacct_blkio_start(void)
  */
 void __delayacct_blkio_end(struct task_struct *p)
 {
-	delayacct_end(&p->delays->lock,
-		      &p->delays->blkio_start,
-		      &p->delays->blkio_delay,
-		      &p->delays->blkio_count,
-		      &p->delays->blkio_delay_max,
-		      &p->delays->blkio_delay_min);
+	DELAYACCT_END(p, blkio);
 }
 
 int delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
@@ -231,12 +234,7 @@ void __delayacct_freepages_start(void)
 
 void __delayacct_freepages_end(void)
 {
-	delayacct_end(&current->delays->lock,
-		      &current->delays->freepages_start,
-		      &current->delays->freepages_delay,
-		      &current->delays->freepages_count,
-		      &current->delays->freepages_delay_max,
-		      &current->delays->freepages_delay_min);
+	DELAYACCT_END(current, freepages);
 }
 
 void __delayacct_thrashing_start(bool *in_thrashing)
@@ -255,12 +253,7 @@ void __delayacct_thrashing_end(bool *in_thrashing)
 		return;
 
 	current->in_thrashing = 0;
-	delayacct_end(&current->delays->lock,
-		      &current->delays->thrashing_start,
-		      &current->delays->thrashing_delay,
-		      &current->delays->thrashing_count,
-		      &current->delays->thrashing_delay_max,
-		      &current->delays->thrashing_delay_min);
+	DELAYACCT_END(current, thrashing);
 }
 
 void __delayacct_swapin_start(void)
@@ -270,12 +263,7 @@ void __delayacct_swapin_start(void)
 
 void __delayacct_swapin_end(void)
 {
-	delayacct_end(&current->delays->lock,
-		      &current->delays->swapin_start,
-		      &current->delays->swapin_delay,
-		      &current->delays->swapin_count,
-		      &current->delays->swapin_delay_max,
-		      &current->delays->swapin_delay_min);
+	DELAYACCT_END(current, swapin);
 }
 
 void __delayacct_compact_start(void)
@@ -285,12 +273,7 @@ void __delayacct_compact_start(void)
 
 void __delayacct_compact_end(void)
 {
-	delayacct_end(&current->delays->lock,
-		      &current->delays->compact_start,
-		      &current->delays->compact_delay,
-		      &current->delays->compact_count,
-		      &current->delays->compact_delay_max,
-		      &current->delays->compact_delay_min);
+	DELAYACCT_END(current, compact);
 }
 
 void __delayacct_wpcopy_start(void)
@@ -300,12 +283,7 @@ void __delayacct_wpcopy_start(void)
 
 void __delayacct_wpcopy_end(void)
 {
-	delayacct_end(&current->delays->lock,
-		      &current->delays->wpcopy_start,
-		      &current->delays->wpcopy_delay,
-		      &current->delays->wpcopy_count,
-		      &current->delays->wpcopy_delay_max,
-		      &current->delays->wpcopy_delay_min);
+	DELAYACCT_END(current, wpcopy);
 }
 
 void __delayacct_irq(struct task_struct *task, u32 delta)
-- 
2.25.1


             reply	other threads:[~2025-04-14  6:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-14  6:32 Ye Liu [this message]
2025-04-20  3:58 ` [PATCH] delayacct: use macro to simplify delayacct_end calls yang.yang29
2025-04-21  2:44   ` Ye Liu

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=20250414063227.97035-1-ye.liu@linux.dev \
    --to=ye.liu@linux.dev \
    --cc=bsingharora@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuye@kylinos.cn \
    --cc=yang.yang29@zte.com.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.