Received: by 2002:a05:7412:a9a3:b0:f9:327e:43ab with SMTP id o35csp120668rdh; Mon, 18 Dec 2023 06:10:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAczvtO0zLbJ9rYc7Mgk0AFuVF5NEmprfIsHDUzXPaw47M+x6tux9a0B1crGSySUtRcaSt X-Received: by 2002:a50:ab1a:0:b0:553:721b:81c7 with SMTP id s26-20020a50ab1a000000b00553721b81c7mr507228edc.45.1702908651394; Mon, 18 Dec 2023 06:10:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702908651; cv=none; d=google.com; s=arc-20160816; b=KIA7DdVwtbZVLFSwst2EwoWHLgkks9mL/Zd3boR3CLBGKFQ5Nb9HfR+Tug6iFifFrT pFexnSjvP/FpAztg/WcimFoSZBoAuoYmY4q8J3aVOLE9YMNFHNuyIGM7bdJ7DNIGn8ua hzbTCYZLG9l+s7o5BN7tuI95ze373Zgo1pLDvsX5QYTN0ZJ9qYSwx9SzYhVenxhfveRI 88SYQjVKByIGqnhgJbh8bv9hnmIapXpgyJF3l9+KyQGBurve0mS6/Z9hu/A+v1sEoz+E a5tQHRnj0al72CXh4khsFk0i+IDGwQZlOca8W89BAJqe6tgynPfardJKEXCDdJrul3nD Nltw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=uEWiEw11l9W9VDZwJ54qEagNKb2hiHwOOqjnhdmXxQY=; fh=PigGyr0k2UHxlHDObR4tN2IY8Z8lWBCCEIGD12vhblo=; b=v/X1v0xBqam1HSn6WFkqINtTmCGR7Z5HBAuYqJIbxu8lDbHPGCfp4mfGVx2UuwwGoX 6+XI1s2uFi9jUP1FcOByRsM7dGoWAmBYf9RTjx+fMZa51BTuMqjZV43xkOQhjwlng+zO KFVHH9RUvj6hNodoWm2Z920kAlERhS+Cg+I6fCxIqWkM03cwmEnyT2NfS3SYpmTUsNGw YCAFfPNhaz31ivYvD+BbfM6SxElFI7NyOjDqr9DkWohgpixocq1owN1EauHlL4mxyqAX 3mnuOqCeuEQ0DkWsdNyPSnoP0b7xi5tWU6lV6MZEsgTIJlC+7eU/JwkTzp8epiXXwBk5 Ko0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gnDmNFj2; spf=pass (google.com: domain of linux-kernel+bounces-3808-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3808-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id e10-20020a056402190a00b00550dcbb7dcesi8779320edz.362.2023.12.18.06.10.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 06:10:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3808-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gnDmNFj2; spf=pass (google.com: domain of linux-kernel+bounces-3808-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3808-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 73DB81F24578 for ; Mon, 18 Dec 2023 14:09:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5B7C498B9; Mon, 18 Dec 2023 14:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gnDmNFj2" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0C312498A1; Mon, 18 Dec 2023 14:06:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2874C433CD; Mon, 18 Dec 2023 14:06:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702908373; bh=Z96PU5W2ggJEyQ3xd3FBWcAN+FmQAsXzZYJ/t2N1glI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=gnDmNFj2cEVVi/t2swX4NmCVibFEic32MKl+v3vqDnPza2McdbbYvmTNjKPlq/tE8 BRWhX0XU47n+oikJ4Z9JBfurdpkZUbVrq2xMo3GgZzAJEdV2MJ6I0IrYsfCbEZnBrt y7gTYSZc+4mW3IMN/TGvNfhlI1pW6sJ1KzPQ5K/H8BabE57HKIM6SWkiCpgXAS9+ok 9Kzbq5PCE7LJJbt40U+TtHfxD/bDGUK/IpMM4j1ZfZ4KQ5EtguYwkvMJzYB8nGf0OI 8VK2uA6VyLaqRGsHk9LzyVqmhTpUCWA0yeiDFF+tlFqLzEWt8JDA3YgoRI90BqZVbo XvA1hlBbMeN7Q== Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-1ef36a04931so2154500fac.2; Mon, 18 Dec 2023 06:06:13 -0800 (PST) X-Gm-Message-State: AOJu0YybYixrtnI72j1CXhCvvC19iR7kLz8WKmEYHQUfKa27MFW/lCf7 zs2TYfni8UVE7MoCz/IFl/7wVs8XLUmRvZIrgBw= X-Received: by 2002:a05:6870:4597:b0:1fb:75a:c42e with SMTP id y23-20020a056870459700b001fb075ac42emr15603576oao.87.1702908373023; Mon, 18 Dec 2023 06:06:13 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <32b332af189bfca8acdb231cee294355aa4af290.1701892062.git.msuchanek@suse.de> <20231210210748.GM9696@kitsune.suse.cz> <20231212130324.GP9696@kitsune.suse.cz> In-Reply-To: <20231212130324.GP9696@kitsune.suse.cz> From: Masahiro Yamada Date: Mon, 18 Dec 2023 23:05:36 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6 1/2] depmod: Handle installing modules under a different directory To: =?UTF-8?Q?Michal_Such=C3=A1nek?= Cc: linux-modules@vger.kernel.org, Takashi Iwai , Lucas De Marchi , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Jiri Slaby , Jan Engelhardt , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Dec 12, 2023 at 10:03=E2=80=AFPM Michal Such=C3=A1nek wrote: > > On Mon, Dec 11, 2023 at 01:29:15PM +0900, Masahiro Yamada wrote: > > On Mon, Dec 11, 2023 at 6:07=E2=80=AFAM Michal Such=C3=A1nek wrote: > > > > > > Hello! > > > > > > On Mon, Dec 11, 2023 at 03:43:44AM +0900, Masahiro Yamada wrote: > > > > On Thu, Dec 7, 2023 at 4:48=E2=80=AFAM Michal Suchanek wrote: > > > > > > > > > > Some distributions aim at shipping all files in /usr. > > > > > > > > > > The path under which kernel modules are installed is hardcoded to= /lib > > > > > which conflicts with this goal. > > > > > > > > > > When kmod provides kmod.pc, use it to determine the correct modul= e > > > > > installation path. > > > > > > > > > > With kmod that does not provide the config /lib/modules is used a= s > > > > > before. > > > > > > > > > > While pkg-config does not return an error when a variable does no= t exist > > > > > the kmod configure script puts some effort into ensuring that > > > > > module_directory is non-empty. With that empty module_directory f= rom > > > > > pkg-config can be used to detect absence of the variable. > > > > > > > > > > Signed-off-by: Michal Suchanek > > > > > --- > > > > > v6: > > > > > - use ?=3D instead of :=3D to make it easier to override the val= ue > > > > > > > > > > > > "KERNEL_MODULE_DIRECTORY=3D/local/usr/lib/modules make modules_inst= all" > > > > will override the install destination, but > > > > depmod will not be not aware of it. > > > > > > At the same time if you know what you are doing you can build a src r= pm > > > for another system that uses a different location. > > > > > > > How to avoid the depmod error? > > > > > > Not override the variable? > > > > You are not answering my question. > > You intentionally changed :=3D to ?=3D. > > > > This implies that KERNEL_MODULE_DIRECTORY is an interface to users, > > and should be documented in Documentation/kbuild/kbuild.rst > > That's reasonable > > > However, it never works if it is overridden from the env variable > > or make command line because there is no way to let depmod know > > the fact that KERNEL_MODULE_DIRECTORY has been overridden. > > And there should not. kmod is not aware, kbuild is. That's the > direction of information flow. kmod defines where it looks for the > modules, and kbuild shoukld install the modules there. Then, you cannot explain why KERNEL_MODULE_DIRECTORY should be exposed as a user interface. The MODULE_DIRECTORY in depmod is determined when kmod is compiled. Kbuild takes KERNEL_MODULE_DIRECTORY from pkg-config. If these two do not agree, it never works. > If the user knows better (eg. possibility of building src-rpm for a > different you brought up) they can override the autodetection. No, it does not work. The user has no way to override the MODULE_DIRECTORY in depmod. > > In my understanding, depmod does not provide an option to > > specify the module directory from a command line option, does it? > > No it does not. > > > If not, is it reasonable to add a new option to depmod? > > I don't think so. The module directory is intentionally in a fixed > location. It can be set at compile time, and that's it. > > Then when running depmod on the target distribution either kbuild and > kmod agree on the location or the build fails. That's the intended > outcome. > > kmod recently grew the ability to use modules outside of module > directory. For that to work internally the path to these out-of-kernel > modules is stored as absolute path, and the path of modules that are in > the module directory is stored relative to the module directory. > > Setting the module directory location dynamically still should not break > this but I am not sure it's a great idea. In the end modprobe needs to > find those modules, and if depmod puts the modules.dep in arbitrary > location it will not. That is true when modules are compiled and installed on the local machine. If you create an SRPM with KERNEL_MODULE_DIRECTORY, builders must follow it. > > > depmod provides the "-b basedir" option, but it only allows > > adding a prefix to the default "/lib/modules/". > > Yes, that's for installation into a staging directory, and there again > the modules that are inside the module directory are considedred > 'in-kernel'. Not sure how well this even works with 'out-of-kernel' > modules. > > > (My original idea to provide the prefix_part, it would have worked > > like -b "${INSTALL_MOD_PATH}${MOD_PREFIX}", which you refused) > > It's not clear that adding a prefix covers all use cases. It is an > arbitrary limitation that the module path must end with '/lib/modules'. > > It may allow taking some shortcuts in some places but is unnecessarily > limiting. > > Thanks > > Michal --=20 Best Regards Masahiro Yamada