From nobody Wed Apr 8 07:42:47 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 B919C238C15 for ; Wed, 29 Oct 2025 11:12:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761736365; cv=none; b=kO+6BGUgAoxInrxsEUz3E2mY+nX9Rg+q668anTQyBfyAndoIA4OEFAeCh16bL2jf6Vnc8Ko88ZVX4hi++1jT6PbQ7Zhu23b2ODmXSfTWPTERhIMVvmBno+683pjKXScO5K5XETvNawHd46JAshF88oVViJ+CVylJTfM8OjeqTu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761736365; c=relaxed/simple; bh=79EZrYHav2KM8e+2sNwtRiJvFGLeza7Clf+zUyt951g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j9xMiR3fnsexlFm6lMYuncnlwwRC9DOgbnv03XTV/8QhhWNq8XrOAYbVPJzZwNBJGhbg7boWYA3s9PpWAjSshuKLZX1d2YnftUfVN6NOcUoYUHWuoRMmycF2dNLJJwIKKtbXDbkfUQzEbc5cU6Sk8smJAGCHSA/pXDGCxFQ1TK0= 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=EpML6vyC; arc=none smtp.client-ip=198.175.65.21 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="EpML6vyC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761736363; x=1793272363; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=79EZrYHav2KM8e+2sNwtRiJvFGLeza7Clf+zUyt951g=; b=EpML6vyC6KcoO8JHMxoULMVd8MRIDMtz4IXg/yoJH40K8uyrpcgg//u0 ubiiO00SmbAkI3ksWwNti9VqX5mVKs4he/Ag+E4cRlcN4EuRdzX08+3w5 YyBvpif4Rk1YolTGOcoZ9ewjF3ChsnPptduZnBs7wuKpiA+xRE7oG0bj8 QUWvVtM0+igjhWPwneanpfYfCqjNnQvq4PweQVJT1043wwS2RX895lOdF h4nGZNP1fjCGpcmqHWduwgFKZH9XfdwrCqCi857nrLf45F09AljgVegmW MY7dmd7cqZUTrNFyhY2lg5J9K60k5qhcmDOZWFusQvIKSrFxnwPs4f8dH g==; X-CSE-ConnectionGUID: EIEVNfOvQ7+AEYhhMVM+pA== X-CSE-MsgGUID: uA4xQzBERtq3GWfZGiY72g== X-IronPort-AV: E=McAfee;i="6800,10657,11531"; a="63757584" X-IronPort-AV: E=Sophos;i="6.17,312,1747724400"; d="scan'208";a="63757584" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2025 04:12:42 -0700 X-CSE-ConnectionGUID: tKzygAexS5yWP12M9x6CUw== X-CSE-MsgGUID: Xh2d5YL5RCq+SUSCx9ZB+g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,263,1754982000"; d="scan'208";a="184816534" Received: from black.igk.intel.com ([10.91.253.5]) by orviesa006.jf.intel.com with ESMTP; 29 Oct 2025 04:12:40 -0700 Received: by black.igk.intel.com (Postfix, from userid 1003) id E522D98; Wed, 29 Oct 2025 12:12:39 +0100 (CET) From: Andy Shevchenko To: Feng Tang , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Andrew Morton , Petr Mladek Subject: [PATCH v2 3/6] panic: sys_info: Replace struct sys_info_name with plain array of strings Date: Wed, 29 Oct 2025 12:07:38 +0100 Message-ID: <20251029111202.3217870-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029111202.3217870-2-andriy.shevchenko@linux.intel.com> References: <20251029111202.3217870-2-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 | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/lib/sys_info.c b/lib/sys_info.c index 6b0188b30227..5aecf4b6025f 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,12 +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) { - len +=3D scnprintf(names + len, sizeof(names) - len, - "%s%s", delim, si_names[i].name); - delim =3D ","; - } + for_each_set_bit(i, &si_bits, ARRAY_SIZE(si_names)) { + len +=3D scnprintf(names + len, sizeof(names) - len, + "%s%s", delim, si_names[i]); + delim =3D ","; } =20 table =3D *ro_table; --=20 2.50.1