summaryrefslogtreecommitdiff
path: root/app-admin/rasdaemon
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2023-12-29 01:37:52 +0000
committerV3n3RiX <venerix@koprulu.sector>2023-12-29 01:37:52 +0000
commitdd5af718da993c9a6f040afb037ba1246974c6e5 (patch)
treec8544b7bb70c29e5cb9a3858fd0c16c62c1f6f27 /app-admin/rasdaemon
parent29eb24bde1b57b17d24078f22ee071e27f6b5348 (diff)
gentoo auto-resync : 29:12:2023 - 01:37:52
Diffstat (limited to 'app-admin/rasdaemon')
-rw-r--r--app-admin/rasdaemon/Manifest3
-rw-r--r--app-admin/rasdaemon/files/rasdaemon-0.8.0-check-online-cpus-not-configured.patch40
-rw-r--r--app-admin/rasdaemon/files/rasdaemon-0.8.0-table-create-offline-cpus.patch179
-rw-r--r--app-admin/rasdaemon/rasdaemon-0.8.0-r2.ebuild87
4 files changed, 309 insertions, 0 deletions
diff --git a/app-admin/rasdaemon/Manifest b/app-admin/rasdaemon/Manifest
index cdee195bcef0..4b05210d2a67 100644
--- a/app-admin/rasdaemon/Manifest
+++ b/app-admin/rasdaemon/Manifest
@@ -1,6 +1,8 @@
AUX ras-mc-ctl.openrc-r1 419 BLAKE2B 50239d64b95c1759a2fb88107b78875b9f6227c256c2a59628b33dfaf720c649e714afe24424f34e865d1fc46145daa8deda4e8612ef6c0d11ef1bf67b2c2e88 SHA512 f12c82432086bfdd0ee24a767b2c6dae9a50cb65038189bfdc2aff9447e5e734e1277d809ed3c7a55ac31034773983e1f46f466adabdd4e727b491c260c5c53e
AUX rasdaemon-0.6.8-bashisms-configure.patch 9566 BLAKE2B 8a59f4255ff37bda63047bacbecd6a90856f9fa8acc42f8fffec653e20161d0cd6ebde06c9d54004f9c81e17c3e18b8673345690af75604557a7d97d45b72149 SHA512 f8a98bd9c3cb1050f66207105fac80efd1a4ea7f1dcbe997d0f8f611d345eb1026c9d8a4923eef4240fd072fec99e9f1fcb0e2b46d85c053d3d5fcf7da4469b2
AUX rasdaemon-0.8.0-bashisms-configure.patch 1727 BLAKE2B bb399aabb71d4eea1290db0fc9ea1f30a41374992d367aaf32bbe6f856f556fffbb073fcd0975a018e984ec74252d4db978d239f5e4daad55e75d063b4c04d71 SHA512 63a7611e9a87441dad2dbb550251f287aa531dc524d35f9525e78d81fb6607453634823cd3d133e07c0a23416ba4cc990e4b927dc8a95228bc9be3d2a1ce8909
+AUX rasdaemon-0.8.0-check-online-cpus-not-configured.patch 1497 BLAKE2B ff575397a81432e755543ebb543f8f1ce342b15a8571c6e01fc8908b424091ab0bf9cdaec2ee262ec1f8f3d867fdafbde8777fc130a44a1a0198c75cbb822fa9 SHA512 cbba79181e92ba9eec96ad1ea09f530c294a8a6e8d7d58b8bf3c132775cddc6ac1dc844d56ca1f0ba678274849955aa1292d0fda8503abdabc519639dd70651e
+AUX rasdaemon-0.8.0-table-create-offline-cpus.patch 5693 BLAKE2B 14d1c8d50842a06e3d8f41175ed2ee2e0ee1d0b64949cecfd564c6318f2ff88520509e78034a313cccc0927509916417d685f82d65e9c81c98913ece4a17b0f7 SHA512 7ee19a81f02cfb0d229410b3dbf4004dcbcd6b0805378786a112d197297856be3291f7ad368945ed3045a5e49a223d9aab60908f9fdec7367858549a33ff3dfa
AUX rasdaemon.confd 108 BLAKE2B 0a6f45d7984965411fe31350bc14e263c0994230b0eff4051a7210bb3e8cbdc293d8c0bccb6417802be879326f127b2fb691a8db73c37f433a258b46eb8bd857 SHA512 f22d7273c5ac57fef57dae5c5c6d765c1554a17889b96a9aedfe13e1b31d969298a537042cd70d3d9cec6896e8b5c1e3e20313e5b4feaeca2a206dc51e3f2ee9
AUX rasdaemon.openrc-r2 424 BLAKE2B d3be2b06631ec3dc60e464b5fb38a4778e92a93fc284455f53f6b7c43a05d182b79f478362ed93a706b421ca99f6a21afdd2cbd53d125711bbf1d0f267304ace SHA512 2e30602222443e519cefc1f138dc537f5e22109fde2f8ebb0f8962abd926721389defc46cfa8db667db8618d4dc4257d36e9855367c3c8f2b7d28cb8684a4adf
DIST rasdaemon-0.6.8.tar.gz 161343 BLAKE2B 95dab212e404480d45e5b07fa0f9ec7361036c9295a81dd082657c71cf8ad1114cc28f163b8975733e2042dfeb957f8da71dc52440249c75c24653c1ce235e86 SHA512 634638154c6b0bf7a079d6aba884a55e540c9edc3c25715a792ad7535c68629618e9cef8b6ec7e20845f78bd57f712d437be4d772523020f09d30cce42759a30
@@ -9,5 +11,6 @@ DIST rasdaemon-0.8.0.tar.bz2 394983 BLAKE2B 24209f468fea2bc4e85dcac51e363e44a8a4
EBUILD rasdaemon-0.6.8-r2.ebuild 1472 BLAKE2B dbc2f9640d87137e5a7c714c077415baf2c513c5ce2e10f3ee2cff59f12cc8f096ffc625c02d9556a5c0d5a4f03208def23c386f8824242f0276dae98acc36af SHA512 a3ceade6b072dbc5cab09f7f337a32fc8fb5ce56e19a327df7b503eda22133aeaf98e8f9a9047b7a5655ab997f8ba886f58ed711d10fdc22f73d718cee343038
EBUILD rasdaemon-0.7.0.ebuild 1346 BLAKE2B 0d877f64100ef2c8e321a7dfd8a591e65a6de26a2c7309dfac1b24807ce843adecca82274db350845993a1e924ed418415c23e50b76f1e3e60057d03f1bb1396 SHA512 c45512febbed1a68b1c54639c00e0a6f7380d2371540430ab3376b1908cf98851561d1b96ba96eb67bb34a7bb604409b560f06c451a62fc8a58f417c5deb47e3
EBUILD rasdaemon-0.8.0-r1.ebuild 1810 BLAKE2B 3accbf11b31a1d227829cfd34d51cd64ddff674f9808f754c9d32a8f42450b483c37b50e33a88e498f2743cf79afad5b1993e53f1c51b65ddf82c7b29691174b SHA512 429318a37adf55600281fcc00a3b214d07198c0ac467269006663356c44722919c030e49a371b74544a2d7f51835a900dbbb52acdf78a49407be30f7f9f21d3a
+EBUILD rasdaemon-0.8.0-r2.ebuild 1937 BLAKE2B 6e910fd6513747f598052c5b4ff2f77fb72a8069e699c4ed5cadfd383276f4b107b83b47961d08d6421670b261de6957781473485466b81aff6e6cf04a6df963 SHA512 aec12516120f7c6809b0d2dcc445766784aef7211f10742b4e5f3f0f1a2f28927a88816c55ef7b02943f06225b89fc3cc1337563750aa59bc12ba92d081f201e
EBUILD rasdaemon-0.8.0.ebuild 1752 BLAKE2B 10f96dcd267210df5f9eec96e8200ede9d63d9e5b97c62131fc772204976734a66a9bf6bcde8b09f084e0e39aab7d8b54ee9d5c9fdb907c75a0f59dac160ac66 SHA512 f97f8bc5651cdc83d5e3f29e5197965f157663bc9e86073a58082c0b9a95f79218cd2144b98dba2c8b5036cb79ed88f8a82b4d605c7c864a29cfab49f0b677c6
MISC metadata.xml 1086 BLAKE2B d9017158e600a5aca8b1ca0600a36efec9f12c26493e28b129a0029caa37224b2e5341292ffdebabdc81893aebddba7b893d69f66f87ff4fd927e5310a4482c8 SHA512 3801a8c374a0d38f9efc07a288eb338739e74d1e7e41a182b871f01ce8cfd695621cfb6c883e5ce8da267e1440bf8106db6ad5ac12ef5e156bba958f72ea6297
diff --git a/app-admin/rasdaemon/files/rasdaemon-0.8.0-check-online-cpus-not-configured.patch b/app-admin/rasdaemon/files/rasdaemon-0.8.0-check-online-cpus-not-configured.patch
new file mode 100644
index 000000000000..0d3e60976659
--- /dev/null
+++ b/app-admin/rasdaemon/files/rasdaemon-0.8.0-check-online-cpus-not-configured.patch
@@ -0,0 +1,40 @@
+https://bugs.gentoo.org/890286
+https://github.com/mchehab/rasdaemon/issues/77
+https://github.com/mchehab/rasdaemon/commit/f1ea76375281001cdf4a048c1a4a24d86c6fbe48
+
+From f1ea76375281001cdf4a048c1a4a24d86c6fbe48 Mon Sep 17 00:00:00 2001
+From: Zeph / Liz Loss-Cutler-Hull <warp-spam_git@aehallh.com>
+Date: Sun, 9 Jul 2023 04:57:19 -0700
+Subject: [PATCH] Check CPUs online, not configured.
+
+When the number of CPUs detected is greater than the number of CPUs in
+the system, rasdaemon will crash when it receives some events.
+
+Looking deeper, we also fail to use the poll method for similar reasons
+in this case.
+
+All of this can be prevented by checking to see how many CPUs are
+currently online (sysconf(_SC_NPROCESSORS_ONLN)) instead of how many
+CPUs the current kernel was configured to support
+(sysconf(_SC_NPROCESSORS_CONF)).
+
+For the kernel side of the discussion, see https://lore.kernel.org/lkml/CAM6Wdxft33zLeeXHhmNX5jyJtfGTLiwkQSApc=10fqf+rQh9DA@mail.gmail.com/T/
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+---
+ ras-events.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/ras-events.c b/ras-events.c
+index a82dab2..5935163 100644
+--- a/ras-events.c
++++ b/ras-events.c
+@@ -350,7 +350,7 @@ static void parse_ras_data(struct pthread_data *pdata, struct kbuffer *kbuf,
+
+ static int get_num_cpus(struct ras_events *ras)
+ {
+- return sysconf(_SC_NPROCESSORS_CONF);
++ return sysconf(_SC_NPROCESSORS_ONLN);
+ #if 0
+ char fname[MAX_PATH + 1];
+ int num_cpus = 0;
+
diff --git a/app-admin/rasdaemon/files/rasdaemon-0.8.0-table-create-offline-cpus.patch b/app-admin/rasdaemon/files/rasdaemon-0.8.0-table-create-offline-cpus.patch
new file mode 100644
index 000000000000..4eb3977930c6
--- /dev/null
+++ b/app-admin/rasdaemon/files/rasdaemon-0.8.0-table-create-offline-cpus.patch
@@ -0,0 +1,179 @@
+https://bugs.gentoo.org/890286
+https://github.com/mchehab/rasdaemon/issues/77
+https://github.com/mchehab/rasdaemon/commit/6f7851f72d8464c7a20a248d4abf4362de8f0ba9
+
+From 6f7851f72d8464c7a20a248d4abf4362de8f0ba9 Mon Sep 17 00:00:00 2001
+From: Shiju Jose <shiju.jose@huawei.com>
+Date: Sun, 5 Mar 2023 23:14:42 +0000
+Subject: [PATCH] rasdaemon: fix table create if some cpus are offline
+
+Fix for regression in ras_mc_create_table() if some cpus are offline
+at the system start
+
+Issue:
+
+Regression in the ras_mc_create_table() if some of the cpus are offline
+at the system start when run the rasdaemon.
+
+This issue is reproducible in ras_mc_create_table() with decode and
+record non-standard events and reproducible sometimes with
+ras_mc_create_table() for the standard events.
+
+Also in the multi thread way, there is memory leak in ras_mc_event_opendb()
+as struct sqlite3_priv *priv and sqlite3 *db allocated/initialized per
+thread, but stored in the common struct ras_events ras in pthread data,
+which is shared across the threads.
+
+Reason:
+
+when the system starts with some of the cpus offline and then run
+the rasdaemon, read_ras_event_all_cpus() exit with error and switch to
+the multi thread way. However read() in read_ras_event() return error in
+threads for each of the offline CPUs and does clean up including calling
+ras_mc_event_closedb().
+
+Since the 'struct ras_events ras' passed in the pthread_data to each of the
+threads is common, struct sqlite3_priv *priv and sqlite3 *db allocated/
+initialized per thread and stored in the common 'struct ras_events ras',
+are getting overwritten in each ras_mc_event_opendb()(which called from
+pthread per cpu), result memory leak.
+
+Also when ras_mc_event_closedb() is called in the above error case from
+the threads corresponding to the offline cpus, close the sqlite3 *db and
+free sqlite3_priv *priv stored in the common 'struct ras_events ras',
+result regression when accessing priv->db in the ras_mc_create_table()
+from another context later.
+
+Solution:
+
+In ras_mc_event_opendb(), allocate struct sqlite3_priv *priv,
+init sqlite3 *db and create tables common for the threads with shared
+'struct ras_events ras' based on a reference count and free them in the
+same way.
+
+Also protect critical code ras_mc_event_opendb() and ras_mc_event_closedb()
+using mutex in the multi thread case from any regression caused by the
+thread pre-emption.
+
+Reported-by: Lei Feng <fenglei47@h-partners.com>
+Signed-off-by: Shiju Jose <shiju.jose@huawei.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+---
+ ras-events.c | 16 +++++++++++++++-
+ ras-events.h | 4 +++-
+ ras-record.c | 12 ++++++++++++
+ 3 files changed, 30 insertions(+), 2 deletions(-)
+
+diff --git a/ras-events.c b/ras-events.c
+index 49e4f9a..5fe8e19 100644
+--- a/ras-events.c
++++ b/ras-events.c
+@@ -625,19 +625,25 @@ static void *handle_ras_events_cpu(void *priv)
+
+ log(TERM, LOG_INFO, "Listening to events on cpu %d\n", pdata->cpu);
+ if (pdata->ras->record_events) {
++ pthread_mutex_lock(&pdata->ras->db_lock);
+ if (ras_mc_event_opendb(pdata->cpu, pdata->ras)) {
++ pthread_mutex_unlock(&pdata->ras->db_lock);
+ log(TERM, LOG_ERR, "Can't open database\n");
+ close(fd);
+ kbuffer_free(kbuf);
+ free(page);
+ return 0;
+ }
++ pthread_mutex_unlock(&pdata->ras->db_lock);
+ }
+
+ read_ras_event(fd, pdata, kbuf, page);
+
+- if (pdata->ras->record_events)
++ if (pdata->ras->record_events) {
++ pthread_mutex_lock(&pdata->ras->db_lock);
+ ras_mc_event_closedb(pdata->cpu, pdata->ras);
++ pthread_mutex_unlock(&pdata->ras->db_lock);
++ }
+
+ close(fd);
+ kbuffer_free(kbuf);
+@@ -993,6 +999,11 @@ int handle_ras_events(int record_events)
+
+ /* Poll doesn't work on this kernel. Fallback to pthread way */
+ if (rc == -255) {
++ if (pthread_mutex_init(&ras->db_lock, NULL) != 0) {
++ log(SYSLOG, LOG_INFO, "sqlite db lock init has failed\n");
++ goto err;
++ }
++
+ log(SYSLOG, LOG_INFO,
+ "Opening one thread per cpu (%d threads)\n", cpus);
+ for (i = 0; i < cpus; i++) {
+@@ -1005,6 +1016,8 @@ int handle_ras_events(int record_events)
+ i);
+ while (--i)
+ pthread_cancel(data[i].thread);
++
++ pthread_mutex_destroy(&ras->db_lock);
+ goto err;
+ }
+ }
+@@ -1012,6 +1025,7 @@ int handle_ras_events(int record_events)
+ /* Wait for all threads to complete */
+ for (i = 0; i < cpus; i++)
+ pthread_join(data[i].thread, NULL);
++ pthread_mutex_destroy(&ras->db_lock);
+ }
+
+ log(SYSLOG, LOG_INFO, "Huh! something got wrong. Aborting.\n");
+diff --git a/ras-events.h b/ras-events.h
+index 6c9f507..649b0c0 100644
+--- a/ras-events.h
++++ b/ras-events.h
+@@ -56,7 +56,9 @@ struct ras_events {
+ time_t uptime_diff;
+
+ /* For ras-record */
+- void *db_priv;
++ void *db_priv;
++ int db_ref_count;
++ pthread_mutex_t db_lock;
+
+ /* For the mce handler */
+ struct mce_priv *mce_priv;
+diff --git a/ras-record.c b/ras-record.c
+index a367939..adc97a4 100644
+--- a/ras-record.c
++++ b/ras-record.c
+@@ -763,6 +763,10 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
+
+ printf("Calling %s()\n", __FUNCTION__);
+
++ ras->db_ref_count++;
++ if (ras->db_ref_count > 1)
++ return 0;
++
+ ras->db_priv = NULL;
+
+ priv = calloc(1, sizeof(*priv));
+@@ -912,6 +916,13 @@ int ras_mc_event_closedb(unsigned int cpu, struct ras_events *ras)
+
+ printf("Calling %s()\n", __func__);
+
++ if (ras->db_ref_count > 0)
++ ras->db_ref_count--;
++ else
++ return -1;
++ if (ras->db_ref_count > 0)
++ return 0;
++
+ if (!priv)
+ return -1;
+
+@@ -1018,6 +1029,7 @@ int ras_mc_event_closedb(unsigned int cpu, struct ras_events *ras)
+ log(TERM, LOG_ERR,
+ "cpu %u: Failed to shutdown sqlite: error = %d\n", cpu, rc);
+ free(priv);
++ ras->db_priv = NULL;
+
+ return 0;
+ }
+
diff --git a/app-admin/rasdaemon/rasdaemon-0.8.0-r2.ebuild b/app-admin/rasdaemon/rasdaemon-0.8.0-r2.ebuild
new file mode 100644
index 000000000000..790f5a194f26
--- /dev/null
+++ b/app-admin/rasdaemon/rasdaemon-0.8.0-r2.ebuild
@@ -0,0 +1,87 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools flag-o-matic linux-info systemd
+
+DESCRIPTION="Reliability, Availability and Serviceability logging tool"
+HOMEPAGE="https://github.com/mchehab/rasdaemon"
+# This if can be dropped > 0.8.0, see https://github.com/mchehab/rasdaemon/issues/88
+if [[ ${PV} == 0.8.0 ]] ; then
+ SRC_URI="https://github.com/mchehab/rasdaemon/releases/download/refs%2Fheads%2Fmaster/${P}.tar.bz2"
+else
+ SRC_URI="https://github.com/mchehab/rasdaemon/releases/download/v${PV}/${P}.tar.bz2"
+fi
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86"
+IUSE="selinux"
+
+DEPEND="
+ dev-db/sqlite
+ dev-libs/libtraceevent
+ elibc_musl? ( sys-libs/argp-standalone )
+"
+RDEPEND="
+ ${DEPEND}
+ dev-perl/DBI
+ dev-perl/DBD-SQLite
+ sys-apps/dmidecode
+ selinux? ( sec-policy/selinux-rasdaemon )
+"
+BDEPEND="sys-devel/gettext"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-0.8.0-bashisms-configure.patch
+ "${FILESDIR}"/${PN}-0.8.0-table-create-offline-cpus.patch
+ "${FILESDIR}"/${PN}-0.8.0-check-online-cpus-not-configured.patch
+)
+
+pkg_setup() {
+ linux-info_pkg_setup
+ local CONFIG_CHECK="~ACPI_EXTLOG ~DEBUG_FS"
+ check_extra_config
+}
+
+src_prepare() {
+ default
+
+ # Only here for 0.8.0's bashism patch
+ eautoreconf
+}
+
+src_configure() {
+ local myconfargs=(
+ --enable-sqlite3
+ --enable-abrt-report
+ --enable-aer
+ --enable-arm
+ --enable-extlog
+ --enable-hisi-ns-decode
+ --enable-mce
+ --enable-non-standard
+ --enable-devlink
+ --enable-diskerror
+ --enable-memory-ce-pfa
+ --includedir="/usr/include/${PN}"
+ --localstatedir=/var
+ )
+
+ use elibc_musl && append-libs -largp
+
+ econf "${myconfargs[@]}"
+}
+
+src_install() {
+ default
+
+ keepdir "/var/lib/${PN}"
+
+ systemd_dounit misc/*.service
+
+ newinitd "${FILESDIR}/rasdaemon.openrc-r2" rasdaemon
+ newinitd "${FILESDIR}/ras-mc-ctl.openrc-r1" ras-mc-ctl
+ newconfd "${FILESDIR}"/rasdaemon.confd rasdaemon
+}