Received: by 2002:a19:651b:0:0:0:0:0 with SMTP id z27csp3657926lfb; Mon, 9 May 2022 01:00:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlkatXpryuj5or5A1o1wtiiRd/Is+NfKtf2DiETwhmV3u6l/bhQVa7BmrMcEdJDHCgF4c1 X-Received: by 2002:a05:6638:25c1:b0:32b:897f:1cfa with SMTP id u1-20020a05663825c100b0032b897f1cfamr6622008jat.70.1652083244946; Mon, 09 May 2022 01:00:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652083244; cv=none; d=google.com; s=arc-20160816; b=yukq7eBMi6F5MH34iDkWDpGIKbsW5OhW7akS8aG2bCUxebhBWQW7wz5EwhDHpNACYD VGVxRs4oARNnTIj67RZynYEl0oGi4tqvyCPipCNzPRaL/lZe8MvjbRa3U84hfqtN6dlP zX3nTwM4IQJbkjFvhEredIqrwr3fWDMYLUfke+0G0+bt2ZJrQ6t9wPV8nJKRNdwga5hi Yc6Ef20cafUAnYV8ADGk2dgj2eijX/rn/zqN7j3N/i0+O+ZePFDyvRNolFlxxbvgO6FJ fGgXT7PQsCUy0r5ytBxjLKzhqOJKw8QTJuibwXuCdxm9PjxkYBR/xO0iWvHWnudax40F T4qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vpwL3DbqT9LMSbmqQ5n20H1viJujP13W+km+KmEhOPY=; b=JGst62eLmgwKfIKQROm2XI3tuQsV4W2u4ODHYcjuzZklDeQ8e9FgVqjehOMpyLWfKE 6ns0ooSKn4iGrIdnBRaf3Q7XhGggzRAZuX4+0K4q6Azq8f1XbLb46Ytci1Hiv//m31fi Ia6FPTykRLb/ebjPsT+5Qbwsc05ZVWXA+JIBAsuWM3NqkOho30HxJIYXJn0ZSzBEB4Cl 5WZzitJDT44EmqzvNeSg9r5UlglmlXTP4CskkDdjYheSdeNeCveHufuo5Gh9LYdn5Q6l TWKC1Uk21EBPXGSBIoY3qI5vZX7+8vjT0pxVsxU8EUFrtgqZ/OyHEg4Hrcd0GmW0uVhh PpuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=m6MhUgL6; 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=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id m33-20020a056638272100b003280320a1ebsi10865094jav.67.2022.05.09.01.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 01:00:44 -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=@intel.com header.s=Intel header.b=m6MhUgL6; 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=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E1FBB19061E; Mon, 9 May 2022 00:51:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386005AbiEEVjx (ORCPT + 99 others); Thu, 5 May 2022 17:39:53 -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: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, 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 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