mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Rosen Penev" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Rosen Penev <rosenp@gmail.com>, Thomas Gleixner <tglx@kernel.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: timers/core] timers/migration: Turn tmigr_hierarchy level_list into a flexible array
Date: Tue, 02 Jun 2026 19:35:51 -0000	[thread overview]
Message-ID: <178042895101.710.12067381384261768859.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260522231618.41622-1-rosenp@gmail.com>

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     45b49d7e3ab6490a9b957a4075344093c43d1f7e
Gitweb:        https://git.kernel.org/tip/45b49d7e3ab6490a9b957a4075344093c43d1f7e
Author:        Rosen Penev <rosenp@gmail.com>
AuthorDate:    Fri, 22 May 2026 16:16:18 -07:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 02 Jun 2026 21:34:03 +02:00

timers/migration: Turn tmigr_hierarchy level_list into a flexible array

The level_list array is allocated separately right after the parent
struct. The size of the array is already known.

Move level_list to the struct tail as a flexible array member and fold the
two allocations into a single kzalloc_flex().

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Assisted-by: Claude:Opus-4.7
Link: https://patch.msgid.link/20260522231618.41622-1-rosenp@gmail.com
---
 kernel/time/timer_migration.c | 16 +++++-----------
 kernel/time/timer_migration.h |  5 ++---
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c
index 8ba53ad..548d849 100644
--- a/kernel/time/timer_migration.c
+++ b/kernel/time/timer_migration.c
@@ -1963,17 +1963,15 @@ static struct tmigr_hierarchy *tmigr_get_hierarchy(int cpu)
 	if (hier)
 		return hier;
 
-	hier = kzalloc(sizeof(*hier), GFP_KERNEL);
+	hier = kzalloc_flex(*hier, level_list, tmigr_hierarchy_levels);
 	if (!hier)
 		return ERR_PTR(-ENOMEM);
 
 	hier->cpumask = kzalloc(cpumask_size(), GFP_KERNEL);
-	if (!hier->cpumask)
-		goto err;
-
-	hier->level_list = kzalloc_objs(struct list_head, tmigr_hierarchy_levels);
-	if (!hier->level_list)
-		goto err;
+	if (!hier->cpumask) {
+		kfree(hier);
+		return ERR_PTR(-ENOMEM);
+	}
 
 	for (int i = 0; i < tmigr_hierarchy_levels; i++)
 		INIT_LIST_HEAD(&hier->level_list[i]);
@@ -1982,10 +1980,6 @@ static struct tmigr_hierarchy *tmigr_get_hierarchy(int cpu)
 	list_add_tail(&hier->node, &tmigr_hierarchy_list);
 
 	return hier;
-err:
-	kfree(hier->cpumask);
-	kfree(hier);
-	return ERR_PTR(-ENOMEM);
 }
 
 static int tmigr_connect_old_root(struct tmigr_hierarchy *hier, int cpu,
diff --git a/kernel/time/timer_migration.h b/kernel/time/timer_migration.h
index ea8db95..31735dd 100644
--- a/kernel/time/timer_migration.h
+++ b/kernel/time/timer_migration.h
@@ -9,19 +9,18 @@
  * struct tmigr_hierarchy - a hierarchy associated to a given CPU capacity.
  *                          Homogeneous systems have only one hierarchy.
  *                          Heterogenous have one hierarchy per CPU capacity.
- * @level_list:	Per level lists of tmigr groups
  * @cpumask:	CPUs belonging to this hierarchy
  * @root:	The current root of the hierarchy
  * @capacity:	CPU capacity associated to this hierarchy
  * @node:	Node in the global hierarchy list
+ * @level_list:	Per level lists of tmigr groups
  */
 struct tmigr_hierarchy {
-	struct list_head	*level_list;
 	struct cpumask		*cpumask;
 	struct tmigr_group	*root;
 	unsigned long		capacity;
 	struct list_head	node;
-
+	struct list_head	level_list[];
 };
 
 /**

      reply	other threads:[~2026-06-02 19:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22 23:16 [PATCH] timers/migration: turn " Rosen Penev
2026-06-02 19:35 ` tip-bot2 for Rosen Penev [this message]

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=178042895101.710.12067381384261768859.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=rosenp@gmail.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®