Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3253366ybd; Fri, 28 Jun 2019 05:34:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3gvz474VvznoyM7+xQkmiUG9qZ46Pz4YXpTAe5Zjr36hZJbXKA9dglOf6akj3PwjtIE6D X-Received: by 2002:a17:902:704a:: with SMTP id h10mr11077058plt.337.1561725288507; Fri, 28 Jun 2019 05:34:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561725288; cv=none; d=google.com; s=arc-20160816; b=N8c8oTZKNlT918Lrg3m1914pUOu4Z5K0u/ouqRk72lsss4o+dIv1FS0neW8/S85vxf Smyjx60Pi+OWezpIg9TwrdJBIKyEyXenqnXiIzcyVhZ09t+RMAP28rSJ4g+n15fRzWE5 pwEyAIlw7uISUYdzGBtgl7HUBIFoL3cT2CAXLjL4XV8klHBGNoNFEjCzIV1SutIwBqUZ 5wxgi/oA0hkKnwsZrtBAbERz3cU9ElyzpXyry8PTpLJQZCYj3+ppBXPPa7BPTGUtrbzC aQLODGFtrjD0lKLN0mcxvUpclbSkHVFxMEFJs8Cz+aD11ZdkBFAhCZaYoVHJMnKUXXWp 3sHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:date:message-id:subject:from:cc:to; bh=WZk1wmTPTuwqsNjj39r83H6pOxlAJAg2gOvjsHwx9F4=; b=hQncTrjayUIGQDP3bkck9jfAo/qQWiQ5sQ2uAXTulqsT32lfQoCBk9kyRfRCbMOEnU kMqWZ8Ww+xnQbnKxz4HV0ZS24nrK7fluWoG3UYp3K0lc5/osWzdwDvZMhAfo8Ci5zxCw pG0py8Z3hm6jbNRPpWRwzWVim+y7+tiS5NQjV9fCb/VjJh82ZSBP/pdLK7u2aTY2Wzfp S/r1hEchZ1LJA3R+gZNjbHuw/qVOF5To+zKV/f4NhK7HxxQZSK/2ISpnyGk6TTd3HjQX SFsiff1hQ5lx7lE3qLn1IIu04co8UmCMxO6R6yugKjlkLK9V9KwRrvUf/7CFb6L474pD CgdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q25si2537959pfn.280.2019.06.28.05.34.32; Fri, 28 Jun 2019 05:34:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727561AbfF1Mcq (ORCPT + 99 others); Fri, 28 Jun 2019 08:32:46 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:50524 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727547AbfF1Mcn (ORCPT ); Fri, 28 Jun 2019 08:32:43 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B7F03154982ED060E283; Fri, 28 Jun 2019 20:32:40 +0800 (CST) Received: from [127.0.0.1] (10.184.225.177) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Fri, 28 Jun 2019 20:32:33 +0800 To: , , , CC: , "wangxiaogang (F)" , "Zhoukang (A)" , Mingfangsen From: Zhiqiang Liu Subject: [PATCH] module: add usage links when calling ref_module func Message-ID: <8d7aa8b1-73a2-db7a-82c8-06917eddf235@huawei.com> Date: Fri, 28 Jun 2019 20:32:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset="gb18030" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.184.225.177] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhiqiang Liu Problem: Users can call ref_module func in their modules to construct relationships with other modules. However, the holders '/sys/module//holders' of the target module donot include the users` module. So lsmod command misses detailed info of 'Used by'. When load module, the process is given as follows, load_module() -> mod_sysfs_setup() -> add_usage_links -> do_init_module -> mod->init() add_usage_links func creates holders of target modules linking to this module. If ref_module is called in mod->init() func, the usage links cannot be added. Here, we will add usage link of a to b's holder_dir. Fixes: 9bea7f239 ("module: fix bne2 "gave up waiting for init of module libcrc32c") Signed-off-by: Zhiqiang Liu --- kernel/module.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/module.c b/kernel/module.c index 80c7c09584cf..11c6aff37b1f 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -871,6 +871,11 @@ int ref_module(struct module *a, struct module *b) module_put(b); return err; } + + err = sysfs_create_link(b->holders_dir, &a->mkobj.kobj, a->name); + if (err) + return err; + return 0; } EXPORT_SYMBOL_GPL(ref_module); -- 2.19.1