Skip to contentSkip to conversation

kernel/module/dups.c:108:6: warning: no previous prototype for 'kmod_dup_request_exists_wait'

PATCH kernel test robot 1 participant 1 message Apr 14, 2023

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git 20230413-module-alloc-opts
head:   b40c1a39dfb04b688a41f60434d18da848d02cf3
commit: 1b8e410f70b73e3d7bee508036b1f79410c593f3 [117/118] module: add debugging auto-load duplicate module support
config: sparc-allyesconfig (https://download.01.org/0day-ci/archive/20230414/[email protected]/config)
compiler: sparc64-linux-gcc (GCC) 12.1.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/commit/?id=1b8e410f70b73e3d7bee508036b1f79410c593f3
git remote add mcgrof https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git
git fetch --no-tags mcgrof 20230413-module-alloc-opts
git checkout 1b8e410f70b73e3d7bee508036b1f79410c593f3
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc SHELL=/bin/bash kernel/module/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> kernel/module/dups.c:108:6: warning: no previous prototype for 'kmod_dup_request_exists_wait' [-Wmissing-prototypes]
     108 | bool kmod_dup_request_exists_wait(char *module_name, bool wait, int *dup_ret)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> kernel/module/dups.c:208:6: warning: no previous prototype for 'kmod_dup_request_announce' [-Wmissing-prototypes]

208 | void kmod_dup_request_announce(char *module_name, int ret)
| ^~~~~~~~~~~~~~~~~~~~~~~~~

vim +/kmod_dup_request_exists_wait +108 kernel/module/dups.c

107

 > 108	bool kmod_dup_request_exists_wait(char *module_name, bool wait, int *dup_ret)
   109	{
   110		struct kmod_dup_req *kmod_req, *new_kmod_req;
   111		int ret;
   112	
   113		/*
   114		 * Pre-allocate the entry in case we have to use it later
   115		 * to avoid contention with the mutex.
   116		 */
   117		new_kmod_req = kzalloc(sizeof(*new_kmod_req), GFP_KERNEL);
   118		if (!new_kmod_req)
   119			return false;
   120	
   121		memcpy(new_kmod_req->name, module_name, strlen(module_name));
   122		INIT_WORK(&new_kmod_req->complete_work, kmod_dup_request_complete);
   123		INIT_DELAYED_WORK(&new_kmod_req->delete_work, kmod_dup_request_delete);
   124		init_completion(&new_kmod_req->first_req_done);
   125	
   126		mutex_lock(&kmod_dup_mutex);
   127	
   128		kmod_req = kmod_dup_request_lookup(module_name);
   129		if (!kmod_req) {
   130			/*
   131			 * If the first request that came through for a module
   132			 * was with request_module_nowait() we cannot wait for it
   133			 * and share its return value with other users which may
   134			 * have used request_module() and need a proper return value
   135			 * so just skip using them as an anchor.
   136			 *
   137			 * If a prior request to this one came through with
   138			 * request_module() though, then a request_module_nowait()
   139			 * would benefit from duplicate detection.
   140			 */
   141			if (!wait) {
   142				kfree(new_kmod_req);
   143				pr_warn("New request_module_nowait() for %s -- cannot track duplicates for this request\n", module_name);
   144				mutex_unlock(&kmod_dup_mutex);
   145				return false;
   146			}
   147	
   148			/*
   149			 * There was no duplicate, just add the request so we can
   150			 * keep tab on duplicates later.
   151			 */
   152			pr_info("New request_module() for %s\n", module_name);
   153			list_add_rcu(&new_kmod_req->list, &dup_kmod_reqs);
   154			mutex_unlock(&kmod_dup_mutex);
   155			return false;
   156		}
   157		mutex_unlock(&kmod_dup_mutex);
   158	
   159		/* We are dealing with a duplicate request now */
   160	
   161		kfree(new_kmod_req);
   162	
   163		/*
   164		 * To fix these try to use try_then_request_module() instead as that
   165		 * will check if the component you are looking for is present or not.
   166		 * You could also just queue a single request to load the module once,
   167		 * instead of having each and everything you need try to request for
   168		 * the module.
   169		 *
   170		 * Duplicate request_module() calls  can cause quite a bit of wasted
   171		 * vmalloc() space when racing with userspace.
   172		 */
   173		WARN(1, "module-autoload: duplicate request for module %s\n", module_name);
   174	
   175		if (!wait) {
   176			/*
   177			 * If request_module_nowait() was used then the user just
   178			 * wanted to issue the request and if another module request
   179			 * was already its way with the same name we don't care for
   180			 * the return value either. Let duplicate request_module_nowait()
   181			 * calls bail out right away.
   182			 */
   183			*dup_ret = 0;
   184			return true;
   185		}
   186	
   187		/*
   188		 * If a duplicate request_module() was used they *may* care for
   189		 * the return value, so we have no other option but to wait for
   190		 * the first caller to complete. If the first caller used
   191		 * the request_module_nowait() call, subsquent callers will
   192		 * deal with the comprmise of getting a successful call with this
   193		 * optimization enabled ...
   194		 */
   195		ret = wait_for_completion_state(&kmod_req->first_req_done,
   196						TASK_UNINTERRUPTIBLE | TASK_KILLABLE);
   197		if (ret) {
   198			*dup_ret = ret;
   199			return true;
   200		}
   201	
   202		/* Now the duplicate request has the same exact return value as the first request */
   203		*dup_ret = kmod_req->dup_ret;
   204	
   205		return true;
   206	}
   207	
 > 208	void kmod_dup_request_announce(char *module_name, int ret)
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests