From 200c5ab01c0ee7afb5c6dedf0181c7789d7e81b2 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Wed, 1 Jul 2026 18:11:49 +0200 Subject: [PATCH 1/6] Makefile: Remove unused substitutions from specfile target @COMPATLIB@, @COMPATMAJOR@, and @LIBPSM2_COMPAT_CONF_DIR@ do not appear in libpsm2.spec.in, so the corresponding sed expressions were no-ops. Co-Authored-By: Claude Sonnet 4.6 Signed-off-by: Michal Schmidt --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index 9faeb73..dad2d41 100644 --- a/Makefile +++ b/Makefile @@ -451,12 +451,9 @@ specfile: specfile_clean | $(OUTDIR) sed -e 's/@TARGLIB@/'${TARGLIB}'/g' \ -e 's/@RPM_NAME@/'${RPM_NAME}'/g' \ -e 's/@RPM_NAME_BASEEXT@/'${RPM_NAME_BASEEXT}'/g' \ - -e 's/@COMPATLIB@/'${COMPATLIB}'/g' \ - -e 's/@COMPATMAJOR@/'${COMPATMAJOR}'/g' \ -e 's;@UDEVDIR@;'${UDEVDIR}';g' \ -e 's/@MAJOR@/'${MAJOR}'/g' \ -e 's/@MINOR@/'${MINOR}'/g' \ - -e 's:@LIBPSM2_COMPAT_CONF_DIR@:'${LIBPSM2_COMPAT_CONF_DIR}':g' \ -e 's:@LIBPSM2_COMPAT_SYM_CONF_DIR@:'${LIBPSM2_COMPAT_SYM_CONF_DIR}':g' \ -e 's;@SPEC_FILE_RELEASE_DIST@;'${SPEC_FILE_RELEASE_DIST}';g' \ -e 's/@DIST_SHA@/'${DIST_SHA}'/g' > \ From c9dece14de9c07e131ae715ad627f72638486e23 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Wed, 1 Jul 2026 12:16:00 +0200 Subject: [PATCH 2/6] Remove obsolete 40-psm.rules and redundant MODE from compat rules 40-psm.rules set MODE="0666" on hfi1 device nodes as a workaround for old kernels that did not set proper permissions. Since kernel commit e116a64fab650 ("IB/hfi: Properly set permissions for user device files"), the driver itself ensures the device node access mode is 0666. The commit is from 2015. It was included in Linux v4.3 and backported to RHEL in version 7.2. The udev rule has been redundant for more than 10 years. Remove 40-psm.rules entirely and drop the redundant MODE="0666" from 40-psm-compat.rules, keeping only its SYMLINK+="ipath" directives. Co-Authored-By: Claude Opus 4.6 Signed-off-by: Michal Schmidt --- 40-psm.rules | 52 -------------------------------------- Makefile | 10 -------- compat/40-psm-compat.rules | 2 +- libpsm2.spec.in | 1 - 4 files changed, 1 insertion(+), 64 deletions(-) delete mode 100644 40-psm.rules diff --git a/40-psm.rules b/40-psm.rules deleted file mode 100644 index ba8d494..0000000 --- a/40-psm.rules +++ /dev/null @@ -1,52 +0,0 @@ -# -# This file is provided under a dual BSD/GPLv2 license. When using or -# redistributing this file, you may do so under either license. -# -# GPL LICENSE SUMMARY -# -# Copyright(c) 2015 Intel Corporation. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of version 2 of the GNU General Public License as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# Contact Information: -# Intel Corporation, www.intel.com -# -# BSD LICENSE -# -# Copyright(c) 2015 Intel Corporation. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Intel Corporation nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -KERNEL=="hfi1", MODE="0666" -KERNEL=="hfi1_[0-9]", MODE="0666" diff --git a/Makefile b/Makefile index dad2d41..8dd62b7 100644 --- a/Makefile +++ b/Makefile @@ -175,14 +175,12 @@ LIBPSM2_COMPAT_SYM_CONF_DIR := /etc # It then messes up sed operations for PSM_CUDA=1. # So leaving the commented out line here as documentation to NOT set it. # SPEC_FILE_RELEASE_DIST := -UDEV_40_PSM_RULES := %{_udevrulesdir}/40-psm.rules ifeq (fedora,$(DISTRO)) # On Fedora, we change these two variables to these values: LIBPSM2_COMPAT_CONF_DIR := /usr/lib LIBPSM2_COMPAT_SYM_CONF_DIR := %{_prefix}/lib SPEC_FILE_RELEASE_DIST := %{?dist} - UDEV_40_PSM_RULES :=# else ifeq (rhel,${DISTRO}) # Insert code specific to RHEL here. else ifeq (sles,${DISTRO}) @@ -416,9 +414,6 @@ install: all install -m 0644 -D psm2.h ${DESTDIR}/usr/include/psm2.h install -m 0644 -D psm2_mq.h ${DESTDIR}/usr/include/psm2_mq.h install -m 0644 -D psm2_am.h ${DESTDIR}/usr/include/psm2_am.h -ifneq (fedora,${DISTRO}) - install -m 0644 -D 40-psm.rules ${DESTDIR}$(UDEVDIR)/rules.d/40-psm.rules -endif # The following files and dirs were part of the noship rpm: mkdir -p ${DESTDIR}/usr/include/hfi1diag mkdir -p ${DESTDIR}/usr/include/hfi1diag/linux-x86_64 @@ -458,11 +453,6 @@ specfile: specfile_clean | $(OUTDIR) -e 's;@SPEC_FILE_RELEASE_DIST@;'${SPEC_FILE_RELEASE_DIST}';g' \ -e 's/@DIST_SHA@/'${DIST_SHA}'/g' > \ ${OUTDIR}/${RPM_NAME}.spec - if [ -f /etc/redhat-release ] && [ `grep -o "[0-9.]*" /etc/redhat-release | cut -d"." -f1` -lt 7 ]; then \ - sed -i 's;@40_PSM_RULES@;'${UDEVDIR}'/rules.d/40-psm.rules;g' ${OUTDIR}/${RPM_NAME}.spec; \ - else \ - sed -i 's;@40_PSM_RULES@;'${UDEV_40_PSM_RULES}';g' ${OUTDIR}/${RPM_NAME}.spec; \ - fi # We can't totally prevent two make dist calls in a row from packaging # the previous make dist, unless we switch to using a dedicated ./src folder diff --git a/compat/40-psm-compat.rules b/compat/40-psm-compat.rules index fc7c4b1..39a2dfd 100644 --- a/compat/40-psm-compat.rules +++ b/compat/40-psm-compat.rules @@ -49,4 +49,4 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # KERNEL=="hfi1", SYMLINK+="ipath" -KERNEL=="hfi1_[0-9]", MODE="0666", SYMLINK+="ipath" +KERNEL=="hfi1_[0-9]", SYMLINK+="ipath" diff --git a/libpsm2.spec.in b/libpsm2.spec.in index 51f683f..7be3ec5 100644 --- a/libpsm2.spec.in +++ b/libpsm2.spec.in @@ -153,7 +153,6 @@ make %{?_smp_mflags} %license COPYING %{_libdir}/@TARGLIB@.so.@MAJOR@.@MINOR@ %{_libdir}/@TARGLIB@.so.@MAJOR@ -@40_PSM_RULES@ %files -n @RPM_NAME@-devel %{_libdir}/@TARGLIB@.so From 770eef6ffca592a8af7285b7c069b814c4849d01 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Wed, 1 Jul 2026 17:39:24 +0200 Subject: [PATCH 3/6] libpsm2.spec.in: drop special RHEL 6 handling Maintenance support phase for RHEL 6 ended in June 2024 ([1]). RHEL 6 is in "Extended life cycle support" phase now. Its users likely prefer to not touch anything, so they have no need to run the latest upstream psm2 code. Drop the special handling of RHEL 6 in the spec file template. @UDEVDIR@ becomes unused. Remove the substitution in the Makefile. [1] https://access.redhat.com/support/policy/updates/errata#Life_Cycle_Dates Signed-off-by: Michal Schmidt --- Makefile | 1 - libpsm2.spec.in | 9 --------- 2 files changed, 10 deletions(-) diff --git a/Makefile b/Makefile index 8dd62b7..b0b7be0 100644 --- a/Makefile +++ b/Makefile @@ -446,7 +446,6 @@ specfile: specfile_clean | $(OUTDIR) sed -e 's/@TARGLIB@/'${TARGLIB}'/g' \ -e 's/@RPM_NAME@/'${RPM_NAME}'/g' \ -e 's/@RPM_NAME_BASEEXT@/'${RPM_NAME_BASEEXT}'/g' \ - -e 's;@UDEVDIR@;'${UDEVDIR}';g' \ -e 's/@MAJOR@/'${MAJOR}'/g' \ -e 's/@MINOR@/'${MINOR}'/g' \ -e 's:@LIBPSM2_COMPAT_SYM_CONF_DIR@:'${LIBPSM2_COMPAT_SYM_CONF_DIR}':g' \ diff --git a/libpsm2.spec.in b/libpsm2.spec.in index 7be3ec5..44d9b91 100644 --- a/libpsm2.spec.in +++ b/libpsm2.spec.in @@ -81,12 +81,10 @@ Provides: @RPM_NAME@%{_isa} = %{version}-%{release} BuildRequires: libnuma-devel Requires: libnuma1 %else -%if 0%{?rhel}==0 || 0%{?rhel} > 6 BuildRequires: systemd BuildRequires: numactl-devel Requires: numactl-libs %endif -%endif %package -n @RPM_NAME@-devel Summary: Development files for Cornelis PSM2 @@ -147,9 +145,6 @@ make %{?_smp_mflags} %postun -p /sbin/ldconfig %files -n @RPM_NAME@@RPM_NAME_BASEEXT@ -%if 0%{?rhel} && 0%{?rhel} < 7 -%{!?_licensedir:%global license %doc} -%endif %license COPYING %{_libdir}/@TARGLIB@.so.@MAJOR@.@MINOR@ %{_libdir}/@TARGLIB@.so.@MAJOR@ @@ -164,11 +159,7 @@ make %{?_smp_mflags} %files -n @RPM_NAME@-compat %{_libdir}/psm2-compat -%if 0%{?rhel} && 0%{?rhel} < 7 -@UDEVDIR@/rules.d/40-psm-compat.rules -%else %{_udevrulesdir}/40-psm-compat.rules -%endif @LIBPSM2_COMPAT_SYM_CONF_DIR@/modprobe.d/libpsm2-compat.conf %{_prefix}/lib/libpsm2 From 0fe6bfb5e86a16f93c86890f35ac8dc0eb376c86 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Thu, 2 Jul 2026 19:51:24 +0200 Subject: [PATCH 4/6] Makefile: detect kmod distconfdir via pkg-config Instead of hardcoding /usr/lib for Fedora and /etc for everything else, query kmod's pkg-config for the distconfdir variable. kmod ships kmod.pc since version 32 (March 2024). Older distros have no kmod.pc, so if the detection fails, fall back to /lib. /lib/modprobe.d has been supported since module-init-tools 3.13 (May 2011), so the fallback works on all relevant distros, with or without /usr-merge. I considered changing the name LIBPSM2_COMPAT_CONF_DIR to KMOD_DISTCONFDIR, but I noticed that SUSE's RPM spec sets the variable, so I chose to keep it. Signed-off-by: Michal Schmidt --- Makefile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index b0b7be0..1a57fe4 100644 --- a/Makefile +++ b/Makefile @@ -168,18 +168,22 @@ nthreads := $(shell echo $$(( `nproc` * 2 )) ) DISTRO := $(shell . /etc/os-release; if [ "$$ID" = "sle_hpc" ]; then ID="sles"; fi; echo $$ID) -# By default the following two variables have the following values: -LIBPSM2_COMPAT_CONF_DIR := /etc -LIBPSM2_COMPAT_SYM_CONF_DIR := /etc +PKG_CONFIG ?= pkg-config + +# Detect where kmod looks for packaged config files. +# If that fails, default to /lib, which should work on all distros since 2011, +# with or without /usr-merge. +LIBPSM2_COMPAT_CONF_DIR := $(or $(shell $(PKG_CONFIG) --variable=distconfdir kmod 2>/dev/null),/lib) +export LIBPSM2_COMPAT_CONF_DIR + +LIBPSM2_COMPAT_SYM_CONF_DIR := $(patsubst /usr%,\%{_prefix}%,$(LIBPSM2_COMPAT_CONF_DIR)) + # We can't set SPEC_FILE_RELEASE_DIST to an empty value, a space will result. # It then messes up sed operations for PSM_CUDA=1. # So leaving the commented out line here as documentation to NOT set it. # SPEC_FILE_RELEASE_DIST := ifeq (fedora,$(DISTRO)) - # On Fedora, we change these two variables to these values: - LIBPSM2_COMPAT_CONF_DIR := /usr/lib - LIBPSM2_COMPAT_SYM_CONF_DIR := %{_prefix}/lib SPEC_FILE_RELEASE_DIST := %{?dist} else ifeq (rhel,${DISTRO}) # Insert code specific to RHEL here. @@ -192,8 +196,6 @@ ifdef PSM_CUDA SPEC_FILE_RELEASE_DIST += cuda endif -export LIBPSM2_COMPAT_CONF_DIR - # The desired version number comes from the most recent tag starting with "v" ifeq (true, $(shell git rev-parse --is-inside-work-tree 2>/dev/null)) ISGIT := 1 # Cache the result for later @@ -248,8 +250,6 @@ endif LDLIBS := -lrt -ldl -lnuma ${EXTRA_LIBS} -pthread -PKG_CONFIG ?= pkg-config - UDEVDIR := $(shell $(PKG_CONFIG) --variable=udevdir udev 2>/dev/null) ifndef UDEVDIR UDEVDIR = /lib/udev From cf95cb72988cc9edcda91b9915d3da6211240752 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Thu, 2 Jul 2026 20:22:14 +0200 Subject: [PATCH 5/6] Makefile: fix "cuda" suffix addition To truly avoid adding a space, do not use the "+=" operator, but variable expansion and concatenation. Signed-off-by: Michal Schmidt --- Makefile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 1a57fe4..d450fb2 100644 --- a/Makefile +++ b/Makefile @@ -178,11 +178,6 @@ export LIBPSM2_COMPAT_CONF_DIR LIBPSM2_COMPAT_SYM_CONF_DIR := $(patsubst /usr%,\%{_prefix}%,$(LIBPSM2_COMPAT_CONF_DIR)) -# We can't set SPEC_FILE_RELEASE_DIST to an empty value, a space will result. -# It then messes up sed operations for PSM_CUDA=1. -# So leaving the commented out line here as documentation to NOT set it. -# SPEC_FILE_RELEASE_DIST := - ifeq (fedora,$(DISTRO)) SPEC_FILE_RELEASE_DIST := %{?dist} else ifeq (rhel,${DISTRO}) @@ -193,7 +188,7 @@ endif ifdef PSM_CUDA #Value needs to be something without spaces or dashes '-' -SPEC_FILE_RELEASE_DIST += cuda +SPEC_FILE_RELEASE_DIST := $(SPEC_FILE_RELEASE_DIST)cuda endif # The desired version number comes from the most recent tag starting with "v" From 801b305231d5512b1d59d4c0551cdb2a9d391266 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Thu, 2 Jul 2026 20:06:35 +0200 Subject: [PATCH 6/6] Makefile: replace DISTRO detection with direct Fedora-family check DISTRO's only remaining purpose was setting SPEC_FILE_RELEASE_DIST to %{?dist} on Fedora. Replace it with a direct shell snippet that checks whether "fedora" appears as a word in ID or ID_LIKE from /etc/os-release, which correctly covers Fedora itself and derivatives like RHEL, CentOS, and AlmaLinux. Drop the now-empty RHEL and SLES ifeq stubs along with the stale comment block. Co-Authored-By: Claude Opus 4.6 Signed-off-by: Michal Schmidt --- Makefile | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index d450fb2..ca98929 100644 --- a/Makefile +++ b/Makefile @@ -157,17 +157,6 @@ MINOR := $(PSM2_LIB_MINOR) nthreads := $(shell echo $$(( `nproc` * 2 )) ) -# The following line sets the DISTRO variable to: -# 'rhel' if the host is running RHEL. -# 'suse' if the host is running SUSE. -# 'fedora' if the host is running Fedora. -# 'ubuntu' if the host is running Ubuntu. -# -# The DISTRO variable is used subsequently for variable -# behaviors of the 3 distros. - -DISTRO := $(shell . /etc/os-release; if [ "$$ID" = "sle_hpc" ]; then ID="sles"; fi; echo $$ID) - PKG_CONFIG ?= pkg-config # Detect where kmod looks for packaged config files. @@ -178,13 +167,8 @@ export LIBPSM2_COMPAT_CONF_DIR LIBPSM2_COMPAT_SYM_CONF_DIR := $(patsubst /usr%,\%{_prefix}%,$(LIBPSM2_COMPAT_CONF_DIR)) -ifeq (fedora,$(DISTRO)) - SPEC_FILE_RELEASE_DIST := %{?dist} -else ifeq (rhel,${DISTRO}) - # Insert code specific to RHEL here. -else ifeq (sles,${DISTRO}) - # Insert code specific to SLES here. -endif +# Set %{?dist} on Fedora and Fedora-like distributions (ID or ID_LIKE contains "fedora"). +SPEC_FILE_RELEASE_DIST := $(shell . /etc/os-release; echo "$$ID $$ID_LIKE" | grep -qw fedora && echo '%{?dist}') ifdef PSM_CUDA #Value needs to be something without spaces or dashes '-'