From nobody Sun May 24 20:33:24 2026 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F696349CE0 for ; Fri, 22 May 2026 23:16:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779491798; cv=none; b=srwIqUd8ihZ4iHrdNv8EF8oWSA6aV0MAKo3KuHHYZTgT/JzZ26kg1NB0H9A4GLXhr2aUdLPOsi6eslNvsBw7oOsofCkZFGkVAmoC+iBBnzOTpt/aB5Pzeo0ZYbY5tQXlTGiP9AyDlh6Olfyqygdpj+xLzVX3CALDn/YyXOW3ZDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779491798; c=relaxed/simple; bh=NhVNsexTtXSmJdkbtAwXat6Q+QzHW/mW7kvFfbQ/s5s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=q+0qcKzj5lnz9dBqG7Se2i/f1stOYajC44Fo0iW7n01tyJgWJOXX0nk/GVeC7WJ0rCQwU7UyBGue4+y7VGuHZhvVpXjP4Pj9tSQbzqgiETvffb03OEVpXxl0gO2G/8Dl3rPnEGZthd7mMPyNxqTv+PwSL/wabIRAVp9lWGG5aQM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ph8lj+Q/; arc=none smtp.client-ip=209.85.216.51 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.b="Ph8lj+Q/" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-367cbac9cb1so7457592a91.3 for ; Fri, 22 May 2026 16:16:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779491796; x=1780096596; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vbf0Jy6OWfOYA4l4FjxjDsogIDRcJSnbx8IRAFz5ZK0=; b=Ph8lj+Q/70LfVkHGq0LO6MqQyDkmd8nUippP5DeI9hineL4Z27H4gG6eFlSK8uSewZ NFZqQBBp78ev4UJNKhP3WyryapZRoXYpaFb02aJZYtgIzpdRkHTY0ah44qsGJuQa0HO6 cCD42Ey6IG/lrSwFyfbk0inVvc+FY8fVkjtSrCiDDYcn7oD6/6izc5YhLPrXrislOUG0 8bbbcLn1U4YxnBCWACHQgkKFLUvWhdeBgTS3VIR0/Oj2m8/pmi0f4uQ7MOGDzgeLzLZF Obe/44SJHMJZM2pmxuQaSYBr0CzClb54lk1GAKRmEx/PyBSibwnoErpHVMjunw+z8Qw3 X+uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779491796; x=1780096596; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vbf0Jy6OWfOYA4l4FjxjDsogIDRcJSnbx8IRAFz5ZK0=; b=nSQHhnAAsP9zyacYbFnK8qugo3NlZPDzoSGTp2vc1E0MwcoHT1QTgiH8ySESB6W9Qf vcd6L1Lc6xoJKvXxyOvcf834/cWZaSi0LoaUBv2Ic8rpRRfEo+HjVsePxr32LNzyBgnK rvIjGljSWAN+Xvt06TJUtFiJ8EQ40dDJLxpJCG0tk6s1qHqWHvUjleFDP07rCKIlo+/K vsaS71I5GLKnx+Qme9XZcRCt3vKot9+vIIojODqKLinFEBw6/hhK0IUEvFaQqec+4QT1 RzE7edaD17PbvszMhRYZ8J4XLzvn/Tj2Es6HgAk6Fu94daKtd02o6nb818f9gmRPa48f FQTg== X-Gm-Message-State: AOJu0YwxPA7cgzMCfSjLgKgT/tRXyDPobkHjAJzJVYnDrjSpQzTJCo98 xexV+Llp0CduNwE+JUU/rhGsXSb8qoA5Nkj8WG6BAU6gDHt7Z+4FXGqRyEYYXg== X-Gm-Gg: Acq92OGnjwbABw/bIRS6sjk4377FhFE6bmDLrNVx9T8w0DrjWknJefInlML5gWq0C8M Yc8apKSrx0fSnK0tODtFfEkE7FQX75NiiNW+0IUW4GsaJ4t0UtMdGnouVEbVmpWYuLLdwxUTsHE mfueZWX7hYqaBnyH6Yhze/43SgKevfG1taM+1Hzl6dNeB7E4eBukXI6UQxZbJGBvrhHCNU+Siis 6tu9bTfR29V3PiiwRrDT2z2nQzhiy8FXYaEfbciEeD2ufZ55BgD8V9IvnYnSBTKtfK5XX+OCQZ6 gburrdXjZIYV5CmrQPyGN4pKenJGwlw3UU2o4BwL3f/v4OFoPIt26+5pnFuorNEYYXZ4mN7sihM z0eg15G37kLD9MGpaRK3eLVMfnt82MQYbTUFPe4Mc0r86fS0O0NnRzCoh0w0gdDxAccmntalNlK I4FzwaUqLovxE50g927teD56Lp2KB3ygPyCQvHpmPv0ltI5mdp0jSA4SnyozDA63gZa78buNCaH WvsAryJZHmyonbNT7rjJxN/bjTQDtJy/hw= X-Received: by 2002:a17:90b:2e04:b0:359:1130:1047 with SMTP id 98e67ed59e1d1-36a677c7a77mr5115828a91.17.1779491796036; Fri, 22 May 2026 16:16:36 -0700 (PDT) Received: from ryzen ([2601:644:8000:5b5d:7285:c2ff:fe45:8a32]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a6ec5a287sm1779650a91.0.2026.05.22.16.16.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 16:16:35 -0700 (PDT) From: Rosen Penev To: linux-kernel@vger.kernel.org Cc: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner Subject: [PATCH] timers/migration: turn tmigr_hierarchy level_list into a flexible array Date: Fri, 22 May 2026 16:16:18 -0700 Message-ID: <20260522231618.41622-1-rosenp@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" level_list was kzalloc_objs()'d separately right after the parent struct, with the count (tmigr_hierarchy_levels, a module-static set during init) trivially available before the parent allocation. Move level_list to the struct tail as a flexible array member and fold the two allocations into a single kzalloc_flex(). The cpumask sub-allocation has variable size from cpumask_size() and stays separate; with level_list gone the err label collapses into a short inline cleanup. Assisted-by: Claude:Opus-4.7 Signed-off-by: Rosen Penev --- 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 25e3c563eb74..daaf6c91eead 100644 --- a/kernel/time/timer_migration.c +++ b/kernel/time/timer_migration.c @@ -1925,17 +1925,15 @@ static struct tmigr_hierarchy *tmigr_get_hierarchy(= unsigned int capacity) if (hier) return hier; =20 - hier =3D kzalloc(sizeof(*hier), GFP_KERNEL); + hier =3D kzalloc_flex(*hier, level_list, tmigr_hierarchy_levels); if (!hier) return ERR_PTR(-ENOMEM); =20 hier->cpumask =3D kzalloc(cpumask_size(), GFP_KERNEL); - if (!hier->cpumask) - goto err; - - hier->level_list =3D kzalloc_objs(struct list_head, tmigr_hierarchy_level= s); - if (!hier->level_list) - goto err; + if (!hier->cpumask) { + kfree(hier); + return ERR_PTR(-ENOMEM); + } =20 for (int i =3D 0; i < tmigr_hierarchy_levels; i++) INIT_LIST_HEAD(&hier->level_list[i]); @@ -1944,10 +1942,6 @@ static struct tmigr_hierarchy *tmigr_get_hierarchy(u= nsigned int capacity) list_add_tail(&hier->node, &tmigr_hierarchy_list); =20 return hier; -err: - kfree(hier->cpumask); - kfree(hier); - return ERR_PTR(-ENOMEM); } =20 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 291bfb6adfc3..c75e31a644e1 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 capaci= ty. - * @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[]; }; =20 /** --=20 2.54.0