Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752395AbbBSFtZ (ORCPT ); Thu, 19 Feb 2015 00:49:25 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:64973 "EHLO relay1.mentorg.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750793AbbBSFtY (ORCPT ); Thu, 19 Feb 2015 00:49:24 -0500 Message-ID: <54E5795C.5050804@mentor.com> Date: Thu, 19 Feb 2015 11:19:16 +0530 From: Harish Jenny Kandiga Nagaraj User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Lucas De Marchi , Rusty Russell CC: linux-modules , lkml , greg KH Subject: Re: [PATCH] libkmod-module: Remove directory existence check for KMOD_MODULE_BUILTIN References: <1424177796-17923-1-git-send-email-harish_kandiga@mentor.com> <874mqjuaky.fsf@rustcorp.com.au> <87vbiysv1v.fsf@rustcorp.com.au> In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [137.202.0.76] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2735 Lines: 56 On Thursday 19 February 2015 06:49 AM, Lucas De Marchi wrote: > On Wed, Feb 18, 2015 at 8:40 PM, Rusty Russell wrote: >> Lucas De Marchi writes: >>> On Wed, Feb 18, 2015 at 2:07 AM, Rusty Russell wrote: >>> Yeah, I just thought (an wanted that) the attributes were being >>> created first and then hooked up in the sysfs tree under >>> /sys/module/. I.e. if the directory exists and there's no >>> initstate this is because it's a builtin module. I don't want to >>> wait/sleep on the file to appear because users of >>> kmod_module_get_initstate() may not tolerate this behavior. >>> >>> Looking up at the old module-init-tools, it used an ugly loop with >>> usleep() before trying to read the file again :-/ >>> >>> Can we change kernel side guaranteeing the initstate file appears >>> together with the directory? >> Greg? The core problem is that kmod looks for >> /sys/module//initstate; if it's not there, it assumes a builtin >> module. > Just to make it clear: > > We try to open /sys/module//initstate. If it fails we stat > /sys/module/ checking if it exists and is a directory. If it > does then we assume the module is builtin. > >> However, this is racy when a module is being inserted. Is there a way >> to create this sysfs file and dir atomically? > Greg, the question is still valid since it'd be nice to have this > guarantee and be able to correctly reply the state with whatever is in > initstate file, but... > > Rusty, thinking again if we fallback to "coming" instead of "builtin" > everything should be fine, no? Because the decision about builtin has > already been taken by looking at the modules.builtin index. If we > return "coming" here the second call to modprobe would call > init_module() again which would wait for the first one to complete (or > return EEXIST if it's already live) since we only shortcut the > init_module() call if the module is live or builtin > > what do you think? > > > Harrish, in your patch if you just change the "return > KMOD_MODULE_BUILTIN;" to "return KMOD_MODULE_COMING;" does it work? > Yes. Returning KMOD_MODULE_COMING instead of KMOD_MODULE_BUILTIN works. The built-in modules are handled by looking at the modules.builtin index file. Is there any chance of returning KMOD_MODULE_COMING for builti-in modules? If it does not have any impact, then the fix should be fine. Do I need to send a separate patch ? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/