Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4620612rdb; Tue, 12 Dec 2023 05:03:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHN9Yz2NCfFq2BEwvgwfnw22/o6kxINbAiwt8Qh2D0AGh0y4BZch8DKIBXw912wIorCcaxA X-Received: by 2002:a17:90a:e395:b0:286:bfed:6f55 with SMTP id b21-20020a17090ae39500b00286bfed6f55mr2704047pjz.38.1702386226258; Tue, 12 Dec 2023 05:03:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702386226; cv=none; d=google.com; s=arc-20160816; b=m1zNWwS47YdyQ5ndknPPIPEBlmmIxxnkwz97l1NyXmbgIy2yVaf9K4GCcm51RqfFhd y2wsifeiN2c5jH9eO0trKOIqgqnS3g+7Bi918z2aQ1WF2ICMPQTJMO5ACKZrlh9JFVaX +mDiIrI0vYeYWHg34VJFQkum2yebAzMbYZKmMtdRuVWhjg/0ts0aJ8w4h/r1eVk+TKCT JAqGIuQZESeUYwrg/vLimKZFmsuxNsGP/UcAm18tQftag+T4HVml7/iEUkffKJ7JliEK ET/nrKoivjUMTgbBGOZv5nQ896viLmrgHMsFFFTCumJQQxKp0JqwCNKtL6Cre0/1Vg9S yNuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=xVXdFzvQktyLQVIaWnR4yUGDApS7kfx3XEGvF1V5fLE=; fh=Truqr19bsBHlZipx1NMX4lNb7Kaad+Z0v/m3f4t6n04=; b=p2yp88upyOTIWLox8WYZDImtXZ++N29KsR1SzBmdREfcWssvhhewBpiEjagMNd+jhe UCb8YKlzf3kM8c81GYCuM/IhvEev9B/aoEFYbRa5aKsktyM/swUaxAbOSjhtOCNkxy4m O0ECDGiBr933TUe9ilbiUM8Gm+w3DuUKpgn/PF1TIRAMM9wctscge30IfRi7S4f0YBmg U7LHbVvcUqDVRhyvq/I1VMEqZ8pXxXAbol0MXRpfs+ry+l+1AApAg0OInBtUnt2rAvIB 4r1JHCL5qTwWYQD6OkhNNvGQQYb7jf+H10JKhAg49XSYCxOVfeoiRajPSDZzW57E0x0v 5IrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=TvRCbxCS; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=TvRCbxCS; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=Y4ppXHF3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id u23-20020a17090ae01700b00288795e256fsi7770793pjy.120.2023.12.12.05.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 05:03:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=TvRCbxCS; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=TvRCbxCS; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=Y4ppXHF3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id E206C8056C51; Tue, 12 Dec 2023 05:03:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376364AbjLLNDX (ORCPT + 99 others); Tue, 12 Dec 2023 08:03:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232565AbjLLNDV (ORCPT ); Tue, 12 Dec 2023 08:03:21 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 135C795; Tue, 12 Dec 2023 05:03:27 -0800 (PST) Received: from kitsune.suse.cz (unknown [10.100.12.127]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 872181FD14; Tue, 12 Dec 2023 13:03:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702386205; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xVXdFzvQktyLQVIaWnR4yUGDApS7kfx3XEGvF1V5fLE=; b=TvRCbxCStGI5SbuUc0ZDH03srM9Hbq7fjrvtcMNI2TC9KfAxrGfyK7p00Y/4IZPxXVdgnp NPsfXheED+Ze9n+ErxShl1qRxxfOwtf+3eRUIDbjdbDyP6DNlHD0HIx2whHjY7QqQn4UF3 lIYLSlzvwSPl5fG0N7UgpvWD71+FQv4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702386205; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xVXdFzvQktyLQVIaWnR4yUGDApS7kfx3XEGvF1V5fLE=; b=Y4ppXHF3MfijWBsq8ZAZGig+3uj7vJDPgJwfmzcav60cb1jtGypRuOUR4opT3bSuiIqZ+Y PxnY89hV8RBSH7Cw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702386205; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xVXdFzvQktyLQVIaWnR4yUGDApS7kfx3XEGvF1V5fLE=; b=TvRCbxCStGI5SbuUc0ZDH03srM9Hbq7fjrvtcMNI2TC9KfAxrGfyK7p00Y/4IZPxXVdgnp NPsfXheED+Ze9n+ErxShl1qRxxfOwtf+3eRUIDbjdbDyP6DNlHD0HIx2whHjY7QqQn4UF3 lIYLSlzvwSPl5fG0N7UgpvWD71+FQv4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702386205; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xVXdFzvQktyLQVIaWnR4yUGDApS7kfx3XEGvF1V5fLE=; b=Y4ppXHF3MfijWBsq8ZAZGig+3uj7vJDPgJwfmzcav60cb1jtGypRuOUR4opT3bSuiIqZ+Y PxnY89hV8RBSH7Cw== Date: Tue, 12 Dec 2023 14:03:24 +0100 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Masahiro Yamada Cc: linux-modules@vger.kernel.org, Takashi Iwai , Lucas De Marchi , Michal =?iso-8859-1?Q?Koutn=FD?= , Jiri Slaby , Jan Engelhardt , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 1/2] depmod: Handle installing modules under a different directory Message-ID: <20231212130324.GP9696@kitsune.suse.cz> References: <32b332af189bfca8acdb231cee294355aa4af290.1701892062.git.msuchanek@suse.de> <20231210210748.GM9696@kitsune.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Level: X-Spam-Score: -1.60 X-Spam-Level: Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [-1.60 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_TWELVE(0.00)[12]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[vger.kernel.org,suse.com,gmail.com,inai.de,kernel.org,google.com,fjasle.eu]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Score: -1.60 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 12 Dec 2023 05:03:39 -0800 (PST) On Mon, Dec 11, 2023 at 01:29:15PM +0900, Masahiro Yamada wrote: > On Mon, Dec 11, 2023 at 6:07 AM Michal Suchánek wrote: > > > > Hello! > > > > On Mon, Dec 11, 2023 at 03:43:44AM +0900, Masahiro Yamada wrote: > > > On Thu, Dec 7, 2023 at 4:48 AM 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 module > > > > installation path. > > > > > > > > With kmod that does not provide the config /lib/modules is used as > > > > before. > > > > > > > > While pkg-config does not return an error when a variable does not exist > > > > the kmod configure script puts some effort into ensuring that > > > > module_directory is non-empty. With that empty module_directory from > > > > pkg-config can be used to detect absence of the variable. > > > > > > > > Signed-off-by: Michal Suchanek > > > > --- > > > > v6: > > > > - use ?= instead of := to make it easier to override the value > > > > > > > > > "KERNEL_MODULE_DIRECTORY=/local/usr/lib/modules make modules_install" > > > 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 rpm > > 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 := to ?=. > > 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. If the user knows better (eg. possibility of building src-rpm for a different you brought up) they can override the autodetection. > 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. > 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