From owner-svn-src-head@freebsd.org Thu Mar 12 23:04:41 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B528426E1F7; Thu, 12 Mar 2020 23:04:41 +0000 (UTC) (envelope-from freqlabs@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48dktK420Zz4LvH; Thu, 12 Mar 2020 23:04:41 +0000 (UTC) (envelope-from freqlabs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6CB722C9ED; Thu, 12 Mar 2020 23:04:41 +0000 (UTC) (envelope-from freqlabs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02CN4fE8062078; Thu, 12 Mar 2020 23:04:41 GMT (envelope-from freqlabs@FreeBSD.org) Received: (from freqlabs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02CN4fXO062077; Thu, 12 Mar 2020 23:04:41 GMT (envelope-from freqlabs@FreeBSD.org) Message-Id: <202003122304.02CN4fXO062077@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: freqlabs set sender to freqlabs@FreeBSD.org using -f From: Ryan Moeller Date: Thu, 12 Mar 2020 23:04:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r358923 - in head: lib/libpmcstat usr.sbin/pmcstat X-SVN-Group: head X-SVN-Commit-Author: freqlabs X-SVN-Commit-Paths: in head: lib/libpmcstat usr.sbin/pmcstat X-SVN-Commit-Revision: 358923 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Mar 2020 23:04:41 -0000 Author: freqlabs Date: Thu Mar 12 23:04:40 2020 New Revision: 358923 URL: https://svnweb.freebsd.org/changeset/base/358923 Log: libpmcstat: Try /boot/modules if module not found Modules from ports/pkg are commonly installed to /boot/modules rather than to the same directory the kernel resides in. Look there if a module is not found next to the kernel. Submitted by: mmacy Reported by: Nick Principe Approved by: mmacy (mentor) MFC after: 2 weeks Sponsored by: iXsystems, Inc. Modified: head/lib/libpmcstat/libpmcstat_image.c head/usr.sbin/pmcstat/pmcstat.8 Modified: head/lib/libpmcstat/libpmcstat_image.c ============================================================================== --- head/lib/libpmcstat/libpmcstat_image.c Thu Mar 12 21:26:36 2020 (r358922) +++ head/lib/libpmcstat/libpmcstat_image.c Thu Mar 12 23:04:40 2020 (r358923) @@ -278,6 +278,7 @@ pmcstat_image_get_elf_params(struct pmcstat_image *ima GElf_Shdr sh; enum pmcstat_image_type image_type; char buffer[PATH_MAX]; + char buffer_modules[PATH_MAX]; assert(image->pi_type == PMCSTAT_IMAGE_UNKNOWN); @@ -292,23 +293,32 @@ pmcstat_image_get_elf_params(struct pmcstat_image *ima assert(path != NULL); /* - * Look for kernel modules under FSROOT/KERNELPATH/NAME, - * and user mode executable objects under FSROOT/PATHNAME. + * Look for kernel modules under FSROOT/KERNELPATH/NAME and + * FSROOT/boot/modules/NAME, and user mode executable objects + * under FSROOT/PATHNAME. */ - if (image->pi_iskernelmodule) + if (image->pi_iskernelmodule) { (void) snprintf(buffer, sizeof(buffer), "%s%s/%s", args->pa_fsroot, args->pa_kernel, path); - else + (void) snprintf(buffer_modules, sizeof(buffer_modules), + "%s/boot/modules/%s", args->pa_fsroot, path); + } else { (void) snprintf(buffer, sizeof(buffer), "%s%s", args->pa_fsroot, path); + } e = NULL; - if ((fd = open(buffer, O_RDONLY, 0)) < 0) { + fd = open(buffer, O_RDONLY, 0); + if (fd < 0 && !image->pi_iskernelmodule) { warnx("WARNING: Cannot open \"%s\".", buffer); goto done; } - + if (fd < 0 && (fd = open(buffer_modules, O_RDONLY, 0)) < 0) { + warnx("WARNING: Cannot open \"%s\" or \"%s\".", + buffer, buffer_modules); + goto done; + } if (elf_version(EV_CURRENT) == EV_NONE) { warnx("WARNING: failed to init elf\n"); goto done; Modified: head/usr.sbin/pmcstat/pmcstat.8 ============================================================================== --- head/usr.sbin/pmcstat/pmcstat.8 Thu Mar 12 21:26:36 2020 (r358922) +++ head/usr.sbin/pmcstat/pmcstat.8 Thu Mar 12 23:04:40 2020 (r358923) @@ -309,6 +309,8 @@ should look for the kernel and its modules. The default is to use the path of the running kernel obtained from the .Va kern.bootfile sysctl. +Modules will also be searched for in /boot/modules if not found in +.Ar kerneldir . .It Fl l Ar secs Set system-wide performance measurement duration for .Ar secs