Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5171852iob; Mon, 9 May 2022 10:06:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/oYArK1Ti7KNHovfTl7rpo88UnxQn1gwCpoPSv+sbXfGzUho5GRGgT0UhC9JVg8mE17Jl X-Received: by 2002:ac8:5c56:0:b0:2f3:bdd1:4f1e with SMTP id j22-20020ac85c56000000b002f3bdd14f1emr16058954qtj.545.1652116016353; Mon, 09 May 2022 10:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652116016; cv=none; d=google.com; s=arc-20160816; b=a5KwjNC5eHuhEQo9LEHxiCEjAooCOqgLbNDDGj7hyPjzyOURxfTiE3Ht1V1BTfdVZR WnRzFeWz5GoI2AmzHJynS0J9drcdmtN7DKcn3XXJkcv5E5D3D8IgQxe+2Rx5pqyou/xe tA3beJV7lOBTMSBmnZRVy0N/l+pBusqPV6gtua2NvvG14GVDByaKy2GwmRkcoGykMYbB XZk//JxyB/UEKfo1+ycm8gr32TbiO+NEsgz5ggmUwGTUDhwQ+iN1qwXdyrqlh8054Big esUw/wX7Fqme+I6hbd1sOzQnLSvjBjmEj2plUXQUG58qopza04mBXj9iWzdMHI7i8Hnh Aexw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ePsRSV+PGaQ6y9X7SSsE+rj5HXzVb5XjXkReNS9kvOM=; b=yIeAkKLOgMClM1DyUCXhIPaRK5Ty9aZ1DtfdpMWYUC0RusYlJWzM2uO32EiB7IH1hm Q3f7Q4alQti7GuHWrCIXfFR+qtevJrZ3wxA/Pz2UUkhYbEPn9WkR1K0HvYgiRGyHYxGy WSWmNWVx3bO01Dd3Ulltlx1Gz21JlDSouhaDlVmQ8vZeV1zyKwjx+L7dbSL6gPAkx4l+ wziGj5c10alLdlM2cMeXLqa4oTQpKYAbGPwDs4bPgJN1IsHgYuc7iihvJbEO86A+BAlR DLmb0qKbMCvSgPwNEELcSRJXt5K/aatoH2dIuBKHXLpdQ7bjZP59tnobKMVPXMN5P4ft NUfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EtvoF8Ip; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q5-20020a056214194500b00440e46a7c71si10642383qvk.271.2022.05.09.10.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 10:06:56 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EtvoF8Ip; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 86B5A1E0582; Mon, 9 May 2022 09:56:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239335AbiEIRAe (ORCPT + 99 others); Mon, 9 May 2022 13:00:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239330AbiEIRA2 (ORCPT ); Mon, 9 May 2022 13:00:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2876654000; Mon, 9 May 2022 09:56:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B888E614F5; Mon, 9 May 2022 16:56:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFCA4C385B1; Mon, 9 May 2022 16:56:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652115387; bh=NT/NSm+ixv4NTnm+bzYUbh8NWftsy0GkupiwFftUrCw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=EtvoF8IpfrUKSdvwW8V1qeHxhWfkW598IrjNsAqteSHaADCcEdw4x8KXDr3TbpGco +yggH/xodb4xZyPEnEeIc8mWLqDjS4iXNJXSCuBQpOQ/fSanq8ns6RptBh90cQlffa ZydWP2ygHERY2FiBF7EYP2PUX0oJed77PI+PtGtAug8JPiOmVIAJvSdJSVF0l2WgT3 wW5f+Mu+92KTr/DOaR7Nqi5mZ7fd/NZ7bLFFprVwVSRAaFOoxIjPeDgJTM5EOXSyV1 crJcVua2rcdRuwnbPejGtAvrTv7VAS/uq+3pJDH8Q5DUtKss9HWmbgKe7fxadeJAws EJ34J+Ehy52jg== Date: Mon, 9 May 2022 18:56:20 +0200 From: Mauro Carvalho Chehab To: Andi Shyti Cc: Luis Chamberlain , alsa-devel@alsa-project.org, mauro.chehab@linux.intel.com, David Airlie , Greg KH , intel-gfx@lists.freedesktop.org, Lucas De Marchi , Takashi Iwai , dri-devel@lists.freedesktop.org, Jaroslav Kysela , Kai Vehmanen , linux-modules@vger.kernel.org, Dan Williams , linux-kernel@vger.kernel.org, Pierre-Louis Bossart Subject: Re: [Intel-gfx] [PATCH v5 1/2] module: update dependencies at try_module_get() Message-ID: <20220509185620.05567716@coco.lan> In-Reply-To: References: X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, 5 May 2022 23:35:29 +0200 Andi Shyti escreveu: > Hi Mauro, > > [...] > > > +static int ref_module_dependency(struct module *mod, struct module *this) > > +{ > > + int ret; > > + > > + if (!this || !this->name) > > + return -EINVAL; > > + > > + if (mod == this) > > + return 0; > > + > > + mutex_lock(&module_mutex); > > + > > + ret = ref_module(this, mod); > > + > > +#ifdef CONFIG_MODULE_UNLOAD > > + if (ret) > > + goto ret; > > + > > + ret = sysfs_create_link(mod->holders_dir, > > + &this->mkobj.kobj, this->name); > > +#endif > > + > > +ret: > > + mutex_unlock(&module_mutex); > > + return ret; > > +} > > + > > /* Clear the unload stuff of the module. */ > > static void module_unload_free(struct module *mod) > > { > > @@ -841,24 +886,16 @@ void __module_get(struct module *module) > > } > > EXPORT_SYMBOL(__module_get); > > > > -bool try_module_get(struct module *module) > > +bool try_module_get_owner(struct module *module, struct module *this) > > { > > - bool ret = true; > > + int ret = __try_module_get(module); > > > > - if (module) { > > - preempt_disable(); > > - /* Note: here, we can fail to get a reference */ > > - if (likely(module_is_live(module) && > > - atomic_inc_not_zero(&module->refcnt) != 0)) > > - trace_module_get(module, _RET_IP_); > > - else > > - ret = false; > > + if (ret) > > + ref_module_dependency(module, this); > > do we care about the return value here? I don't think it should care about the return value, as a failure to create a sysfs node for the holder or to add it to the holders list is not fatal: modules can still continue working without that. Also, I opted to be conservative here: currently, not creating these doesn't cause try_module_get() to fail. I'm not sure what would be the impact if this starts to fail. So, right now, I'm opting to just ignore the return value. Perhaps in the future this could a warning (similarly to what sysfs create link does). Regards, Mauro > > Andi > > > > > - preempt_enable(); > > - } > > return ret; > > } > > -EXPORT_SYMBOL(try_module_get); > > +EXPORT_SYMBOL(try_module_get_owner); > > > > void module_put(struct module *module) > > { > > -- > > 2.35.1 Thanks, Mauro