Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp706767pxu; Thu, 7 Jan 2021 16:32:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9OGITFrsuzL+MqSkg6nDmY62ymZeF9ceDGM28jx3m95C0l1PsecpDo/8SgyKZo+c3eA15 X-Received: by 2002:a17:906:aec6:: with SMTP id me6mr969094ejb.542.1610065950992; Thu, 07 Jan 2021 16:32:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610065950; cv=none; d=google.com; s=arc-20160816; b=D/YE/tTNSuUpb6lfM6E1vbEMRWyp+AykLk86DUrwShS/eXCPdc9AkV0wPFM3OHlgx5 oQgZmo7KKJIKSYKZAkj3lIHIaJgqkIhmObUAEbyVSsDiTChiR/S/pWbeeSQzn68pDt4F gXeudcdcaAAhRb4fHLVrtw197JS4zT7ovqGHiyuxB6qITFoGxPrEIk32i0hWZyU6Epaq fCuKrseq6VdRP+jgfdugEkGfD2uQd7abikGpcGIyhmdgRC3WDbl8BHAo0/T74MqdgTXM keGUZwR9riG57iiTiVmktv8/SRdGJG4Io/4YSwtoTN15iAMmStJQAOfIfQVXqmGgSQRI 1H/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=v3fiFgkxHB4dBg8a/pmTLn8VoKflEyyrskKHexKjc5k=; b=NW6KkbjtCd+M7W22ICLgqanOx4IACVKNwFHTZZ/kzyseRIxDVmzjFAnl9TrWXM4rUS rbsMLmMk0tgjOsevC+gWYkt9Qp7meva51cMuQ3XIgRNbv6DHphJC8KO7XG8R2rsQ4giO NzplemxKfHh4eztqNyHIfMK4MwTcqsA78DcE5Exf5ZICuIfnNG3AMi6bQJd6rBGX0u5+ GfIHZCEOM61k+YTHNmCo3Vd8jLX1Mxp4ZAund7Olcn0Mwp7XgbLQpUVNeKJM3gEZZZEl XMzEUSCoMSQ0wU4s5WbLHtGU/gB4WTOXkV9NpiDvuAc3l/dP4ZbFjKjH1uj4S+8z3Pnw 8FWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=eK4zjuxy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e7si3392590ejm.291.2021.01.07.16.32.07; Thu, 07 Jan 2021 16:32:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=eK4zjuxy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729507AbhAHAbZ (ORCPT + 99 others); Thu, 7 Jan 2021 19:31:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729377AbhAHAbY (ORCPT ); Thu, 7 Jan 2021 19:31:24 -0500 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29032C0612F6 for ; Thu, 7 Jan 2021 16:30:44 -0800 (PST) Received: by mail-lf1-x131.google.com with SMTP id h22so19017959lfu.2 for ; Thu, 07 Jan 2021 16:30:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=v3fiFgkxHB4dBg8a/pmTLn8VoKflEyyrskKHexKjc5k=; b=eK4zjuxyXFJ2gaG0Wd4Ql9BVBbzLZSVW7Sw7Jh5FoHSpPl1vDZ5D1DNDbBtczEmxKJ V3ScVZRCqrjYfEBAQ+Z0oItJOvxSkoVEMDhcbXcNTxlhFFFF0pua6Sxv+589A67dZ1A2 5idHoiVnGNpRfGBDdY0PklWQT5JaSw9ylIp8/8HYNedqRkMUvAuF+u1pVfL8wSoDjHjo jsPSZNdKZtFf6Ud/9buvO3Qdy8qlPi2AYwDOvUR284bTL4quc2/vKN+PNTv7ML5gMc2K JwBwc48MGkdYJZxyMTfh2Xl4bhFqlb7NvvxFHlc7oC14bJAsSQ2a6FR24gkCIqhaQDCQ XMJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=v3fiFgkxHB4dBg8a/pmTLn8VoKflEyyrskKHexKjc5k=; b=T7Bz06BH47LjWECApIF2TU6AXPizKXLkWvIqKMevzczqKpw0sNNKEEiCor7eea8d0z WdEsDfyTrvYTF1DN+lWOwHUBfawvEcqmWC4E/yPEpOQO391exjru/MUSwTxHNrLkZ2pD e36nJohRgxXhnMoLeYyBcUxuI6n1E9pqsPyDb6iPYXjh6hzeUD4/7IYnq7J0stRmwzUE zoCE1/x1gFTvr2/yJZWoqiFURFc7DcqwYswLZeYgAy8BOtdDoGIRnwtDjyNCxK/JenOs 6LTNfBHkgTTQ+12VQU0eEbV0Bz+lWdWrR9IzsGruFoTsS0QrsKjSgfWJWLJP+gfJ+nMA 6zcw== X-Gm-Message-State: AOAM531LfT4RJi76jw/Af++u6UKaE6nX7OLNscpjcJnm7jjIHHI6vOqQ c+SzPMjd+e+0qo8GdaRaYXeE4/2RsYwJW8+rSS7XaA== X-Received: by 2002:a2e:240f:: with SMTP id k15mr401941ljk.506.1610065842399; Thu, 07 Jan 2021 16:30:42 -0800 (PST) MIME-Version: 1.0 References: <20201216220850.659584-1-willmcvicker@google.com> <20201218120138.GA5265@linux-8ccs> <20210107143111.GA30412@linux-8ccs> In-Reply-To: <20210107143111.GA30412@linux-8ccs> From: Will McVicker Date: Thu, 7 Jan 2021 16:30:25 -0800 Message-ID: Subject: Re: [PATCH v4] modules: introduce the MODULE_SCMVERSION config To: Jessica Yu Cc: Masahiro Yamada , Michal Marek , Greg Kroah-Hartman , Christoph Hellwig , Saravana Kannan , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jessica, I looked into the LOCALVERSION= part more and finally figured out how that part of the script works. I wasn't familiar with how the parameter substitution worked -- ${parameter:+alt_value}. I verified that we will only get an SCM version returned when LOCALVERSION_AUTO=y and updated the Documentation in v5. Thanks, Will On Thu, Jan 7, 2021 at 6:31 AM Jessica Yu wrote: > > +++ Will McVicker [06/01/21 10:44 -0800]: > >Thanks for the vacation notice Jessica! I'm just letting you know I'm > >back as well and am happy to respond to any concerns regarding v4 when > >you get all caught up. > > > >I hope you had a relaxing holiday :) > > Hi Will - thanks, same to you! > > >On Fri, Dec 18, 2020 at 4:01 AM Jessica Yu wrote: > >> > >> +++ Will McVicker [16/12/20 22:08 +0000]: > >> >Config MODULE_SCMVERSION introduces a new module attribute -- > >> >`scmversion` -- which can be used to identify a given module's SCM > >> >version. This is very useful for developers that update their kernel > >> >independently from their kernel modules or vice-versa since the SCM > >> >version provided by UTS_RELEASE (`uname -r`) will now differ from the > >> >module's vermagic attribute. > >> > > >> >For example, we have a CI setup that tests new kernel changes on the > >> >hikey960 and db845c devices without updating their kernel modules. When > >> >these tests fail, we need to be able to identify the exact device > >> >configuration the test was using. By including MODULE_SCMVERSION, we can > >> >identify the exact kernel and modules' SCM versions for debugging the > >> >failures. > >> > > >> >Additionally, by exposing the SCM version via the sysfs node > >> >/sys/module/MODULENAME/scmversion, one can also verify the SCM versions > >> >of the modules loaded from the initramfs. Currently, modinfo can only > >> >retrieve module attributes from the module's ko on disk and not from the > >> >actual module that is loaded in RAM. > >> > > >> >You can retrieve the SCM version in two ways, > >> > > >> >1) By using modinfo: > >> > > modinfo -F scmversion MODULENAME > >> >2) By module sysfs node: > >> > > cat /sys/module/MODULENAME/scmversion > >> > > >> >Signed-off-by: Will McVicker > >> >--- > [ added back diff ] > >> >Changelog since v3: > >> >- Dropped [PATCH v2 1/2] scripts/setlocalversion: allow running in a subdir > >> > > >> > Documentation/ABI/stable/sysfs-module | 18 ++++++++++++++++++ > >> > include/linux/module.h | 1 + > >> > init/Kconfig | 12 ++++++++++++ > >> > kernel/module.c | 2 ++ > >> > scripts/Makefile.modpost | 22 ++++++++++++++++++++++ > >> > scripts/mod/modpost.c | 24 +++++++++++++++++++++++- > >> > 6 files changed, 78 insertions(+), 1 deletion(-) > >> > > >> >diff --git a/Documentation/ABI/stable/sysfs-module b/Documentation/ABI/stable/sysfs-module > >> >index 6272ae5fb366..2ba731767737 100644 > >> >--- a/Documentation/ABI/stable/sysfs-module > >> >+++ b/Documentation/ABI/stable/sysfs-module > >> >@@ -32,3 +32,21 @@ Description: > >> > Note: If the module is built into the kernel, or if the > >> > CONFIG_MODULE_UNLOAD kernel configuration value is not enabled, > >> > this file will not be present. > >> >+ > >> >+What: /sys/module/MODULENAME/scmversion > >> >+Date: November 2020 > >> >+KernelVersion: 5.11 > > I guess we'll have to bump KernelVersion now (sorry about the timing!) > > >> >+Contact: Will McVicker > >> >+Description: This read-only file will appear if modpost was supplied with an > >> >+ SCM version for the module. It can be enabled with the config > >> >+ MODULE_SCMVERSION. The SCM version is retrieved by > >> >+ scripts/setlocalversion, which means that the presence of this > >> >+ file depends on CONFIG_LOCALVERSION_AUTO=y or LOCALVERSION=. > > I think the "or LOCALVERSION=" part is inaccurate, right? We need > just LOCALVERSION_AUTO for the full scm string for this to work. > > >> >+ When read, the SCM version that the module was compiled with is > >> >+ returned. The SCM version is returned in the following format:: > >> >+ > >> >+ === > >> >+ Git: g[a-f0-9]\+(-dirty)\? > >> >+ Mercurial: hg[a-f0-9]\+(-dirty)\? > >> >+ Subversion: svn[0-9]\+ > >> >+ === > >> >diff --git a/include/linux/module.h b/include/linux/module.h > >> >index c4e7a887f469..6bd710308863 100644 > >> >--- a/include/linux/module.h > >> >+++ b/include/linux/module.h > >> >@@ -372,6 +372,7 @@ struct module { > >> > struct module_attribute *modinfo_attrs; > >> > const char *version; > >> > const char *srcversion; > >> >+ const char *scmversion; > >> > struct kobject *holders_dir; > >> > > >> > /* Exported symbols */ > >> >diff --git a/init/Kconfig b/init/Kconfig > >> >index b77c60f8b963..d9ae12f16ba2 100644 > >> >--- a/init/Kconfig > >> >+++ b/init/Kconfig > >> >@@ -2131,6 +2131,18 @@ config MODULE_SRCVERSION_ALL > >> > the version). With this option, such a "srcversion" field > >> > will be created for all modules. If unsure, say N. > >> > > >> >+config MODULE_SCMVERSION > >> >+ bool "SCM version for modules" > >> >+ depends on LOCALVERSION_AUTO > >> >+ help > >> >+ This enables the module attribute "scmversion" which can be used > >> >+ by developers to identify the SCM version of a given module, e.g. > >> >+ git sha1 or hg sha1. The SCM version can be queried by modinfo or > >> >+ via the sysfs node: /sys/modules/MODULENAME/scmversion. This is > >> >+ useful when the kernel or kernel modules are updated separately > >> >+ since that causes the vermagic of the kernel and the module to > >> >+ differ. > > Since I consider this a debug/developer option, let's add a "If > unsure, say N." at the end of this, similar to the other > module options. > > Thanks! > > Jessica