From nobody Sat Feb 7 21:08:15 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F11623F26A for ; Thu, 30 Oct 2025 13:20:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761830423; cv=none; b=TCTC56iIaz7PLQ7WW8c5MJjRhdxOSst9uywIhUwOB0KIiCPctIyv6IyHRr+Et6PFs2cd66Lthp7dMsV929VkHsGGLEwHNntgt7t58pykeWiE4aryVeXa95fDMZWB1woYhz5n83ImeKBFGPa9U7zX72GKJWjb4hVBne/RroIt6kU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761830423; c=relaxed/simple; bh=2BVQ+Utgl3MIvxAIbys54i5YDo2PSGETCCd/ZKN+Ves=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mgEQZoy9npoveMBLFLyuA1VhJhXj++JvYzzqhZQ2R+1FhE5yzZYSFtJ0UpuZ8TmGJn1mZaP6f2eZG0dcMsQPivgeYKfZpqrimIviX22WJ/JIaLovXZW2SqkWonLyxnuEYo9yg3gzhMr9nCb0un1CGaNhacT4ezqsNTDrqyTHjnk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=mR4yFvR1; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mR4yFvR1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761830421; x=1793366421; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2BVQ+Utgl3MIvxAIbys54i5YDo2PSGETCCd/ZKN+Ves=; b=mR4yFvR1IGpYyXyd6llF+sHrCKy6F5UovUd25OOe9VuQvg4VOrrIWHz+ hT0xzHVVTWPesxqkTTJb9C7JzFcZjDD9t9HSoKkwg64lRSG+PdJ9FgDN6 TkOXXM5aH0i8s0gqR0cArMD6Oo7goA8wNEJxLuSHkYlg3iBP+A2IyMn5Y ElCXTwsLEuZcYm5XoglX8Tb7AHtgb1j4i0yE4JTa7KAjxPiSJmSGniAq2 VE4MYZhlHsN8s1nhbGTOtZoHm2+lw50zh791r+D6FfmyhNyx9O2nbycHX Q4v0Zi2OlU/G6ZezkvRtmU9wVHU0P7MwS3CH6WgQ3VCjuY9FO8rWmhrMo A==; X-CSE-ConnectionGUID: 0u6jSVWuRdqhLEz8KrQVDA== X-CSE-MsgGUID: ztgD373QQ+erqRh5MTADow== X-IronPort-AV: E=McAfee;i="6800,10657,11598"; a="89437050" X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="89437050" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 06:20:20 -0700 X-CSE-ConnectionGUID: SvBEd8zPTP6E9MLTdnlfCg== X-CSE-MsgGUID: cJHczWWHTAi/S9xSxuu6wA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="190026363" Received: from black.igk.intel.com ([10.91.253.5]) by orviesa003.jf.intel.com with ESMTP; 30 Oct 2025 06:20:19 -0700 Received: by black.igk.intel.com (Postfix, from userid 1003) id 7839499; Thu, 30 Oct 2025 14:20:18 +0100 (CET) From: Andy Shevchenko To: Feng Tang , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Andrew Morton Subject: [PATCH v3 3/6] panic: sys_info: Replace struct sys_info_name with plain array of strings Date: Thu, 30 Oct 2025 12:44:19 +0100 Message-ID: <20251030132007.3742368-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251030132007.3742368-1-andriy.shevchenko@linux.intel.com> References: <20251030132007.3742368-1-andriy.shevchenko@linux.intel.com> 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" There is no need to keep a custom structure just for the need of a plain array of strings. Replace struct sys_info_name with plain array of strings. With that done, simplify the code, in particular, naturally use for_each_set_bit() when iterating over si_bits_global bitmap. Signed-off-by: Andy Shevchenko --- lib/sys_info.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/lib/sys_info.c b/lib/sys_info.c index 6b0188b30227..29a63238b31d 100644 --- a/lib/sys_info.c +++ b/lib/sys_info.c @@ -1,30 +1,29 @@ // SPDX-License-Identifier: GPL-2.0-only -#include +#include #include +#include #include #include -#include #include +#include +#include +#include =20 #include =20 -struct sys_info_name { - unsigned long bit; - const char *name; -}; - /* * When 'si_names' gets updated, please make sure the 'sys_info_avail' * below is updated accordingly. */ -static const struct sys_info_name si_names[] =3D { - { SYS_INFO_TASKS, "tasks" }, - { SYS_INFO_MEM, "mem" }, - { SYS_INFO_TIMERS, "timers" }, - { SYS_INFO_LOCKS, "locks" }, - { SYS_INFO_FTRACE, "ftrace" }, - { SYS_INFO_ALL_BT, "all_bt" }, - { SYS_INFO_BLOCKED_TASKS, "blocked_tasks" }, +static const char * const si_names[] =3D { + [ilog2(SYS_INFO_TASKS)] =3D "tasks", + [ilog2(SYS_INFO_MEM)] =3D "mem", + [ilog2(SYS_INFO_TIMERS)] =3D "timers", + [ilog2(SYS_INFO_LOCKS)] =3D "locks", + [ilog2(SYS_INFO_FTRACE)] =3D "ftrace", + [ilog2(SYS_INFO_PANIC_CONSOLE_REPLAY)] =3D "", + [ilog2(SYS_INFO_ALL_BT)] =3D "all_bt", + [ilog2(SYS_INFO_BLOCKED_TASKS)] =3D "blocked_tasks", }; =20 /* Expecting string like "xxx_sys_info=3Dtasks,mem,timers,locks,ftrace,...= " */ @@ -36,12 +35,9 @@ unsigned long sys_info_parse_param(char *str) =20 s =3D str; while ((name =3D strsep(&s, ",")) && *name) { - for (i =3D 0; i < ARRAY_SIZE(si_names); i++) { - if (!strcmp(name, si_names[i].name)) { - si_bits |=3D si_names[i].bit; - break; - } - } + i =3D match_string(si_names, ARRAY_SIZE(si_names), name); + if (i >=3D 0) + __set_bit(i, &si_bits); } =20 return si_bits; @@ -85,10 +81,10 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_= table, int write, si_bits =3D READ_ONCE(*si_bits_global); =20 names[0] =3D '\0'; - for (i =3D 0; i < ARRAY_SIZE(si_names); i++) { - if (si_bits & si_names[i].bit) { + for_each_set_bit(i, &si_bits, ARRAY_SIZE(si_names)) { + if (*si_names[i]) { len +=3D scnprintf(names + len, sizeof(names) - len, - "%s%s", delim, si_names[i].name); + "%s%s", delim, si_names[i]); delim =3D ","; } } --=20 2.50.1