From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47B00C433FE for ; Thu, 5 May 2022 21:35:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2CC3810F9BF; Thu, 5 May 2022 21:35:39 +0000 (UTC) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id C484B10F9BF; Thu, 5 May 2022 21:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651786537; x=1683322537; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=bGKPoFs3oKrceGUWOKyLUpHxG8GVrtEbDeiLw6i4OsE=; b=Ogx1RR/KSM4Sx7QKQbIjMF55RcazwZ9gfe4YwtB6yW/UkAOSmWCfG0/X 7OhWp5Kj1IZBOGNAdWvrye9IZuB3YPGeygCMKrI6s072gkzQjIDeyhNBV bCurPXekYJ36EjjWRcRLrliiBM4JujAPSRbiiCaVlGT5MPecRxETCYI8V j8sqJyl3D3JdJ8kW79OhEZ0UlkHV6hito/40dWRH8oemCRbYkI12UrDcp nku8q3XKvr3XhStGDA5rEz+TrUgXUKR4We2Mf6cXrC28kfzx7WZHUajJQ Gj4gwGJexSEetHKe8qd6DGB6EzyGiqhiHdqLdWcv+wlSQXzq67AnqJlYC w==; X-IronPort-AV: E=McAfee;i="6400,9594,10338"; a="255736560" X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="255736560" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 14:35:36 -0700 X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="735163599" Received: from blaesing-mobl.ger.corp.intel.com (HELO intel.com) ([10.251.218.207]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 14:35:32 -0700 Date: Thu, 5 May 2022 23:35:29 +0200 From: Andi Shyti To: Mauro Carvalho Chehab Subject: Re: [Intel-gfx] [PATCH v5 1/2] module: update dependencies at try_module_get() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mauro.chehab@linux.intel.com, linux-kernel@vger.kernel.org, David Airlie , Greg KH , intel-gfx@lists.freedesktop.org, Lucas De Marchi , alsa-devel@alsa-project.org, dri-devel@lists.freedesktop.org, Takashi Iwai , Kai Vehmanen , Luis Chamberlain , Dan Williams , Jaroslav Kysela , linux-modules@vger.kernel.org, Pierre-Louis Bossart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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? 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6174BC433F5 for ; Thu, 5 May 2022 21:36:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386002AbiEEVju (ORCPT ); Thu, 5 May 2022 17:39:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385999AbiEEVjb (ORCPT ); Thu, 5 May 2022 17:39:31 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2792813E15; Thu, 5 May 2022 14:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651786538; x=1683322538; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=bGKPoFs3oKrceGUWOKyLUpHxG8GVrtEbDeiLw6i4OsE=; b=m6MhUgL6fX5ZMeg27UV7l4WMkpICqIU4xfE7syo2mpW9sEVddVg4GIyr IcZ144Ud+mhHYZJ2PagG29hR5EWKRv3/5DTtI1N4qkmkfk6Z29bGH8rEX 7EVlWhrIyoCLZ7d3jSB6cYA/xAmf+wVQEKAgfacQv5CoNISKHKkFyUmiA fxVASzSALgeQz0pnHEsA2HEW+xDqpxJKM7QgYQ8GQ/dXpAZdCa8YTynWb dKxtXLZk3H9qKccPdVLlxTU7iOzzOeNzx0ztqRI8GdvAZpVEtKxAZUX6K XQyMegif2vC32XN0k2s8UmrfT/dckVZVmSgq3kzhujxiOkUNsOluNYHww w==; X-IronPort-AV: E=McAfee;i="6400,9594,10338"; a="268152596" X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="268152596" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 14:35:36 -0700 X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="735163599" Received: from blaesing-mobl.ger.corp.intel.com (HELO intel.com) ([10.251.218.207]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 14:35:32 -0700 Date: Thu, 5 May 2022 23:35:29 +0200 From: Andi Shyti To: Mauro Carvalho Chehab 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: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: 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? 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