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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F89FC433E0 for ; Thu, 21 Jan 2021 17:50:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E694C21973 for ; Thu, 21 Jan 2021 17:50:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389205AbhAURsP convert rfc822-to-8bit (ORCPT ); Thu, 21 Jan 2021 12:48:15 -0500 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:43424 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389074AbhAURqz (ORCPT ); Thu, 21 Jan 2021 12:46:55 -0500 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-7-70jJZbebO02FvmwaO8iuwQ-1; Thu, 21 Jan 2021 17:44:57 +0000 X-MC-Unique: 70jJZbebO02FvmwaO8iuwQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 21 Jan 2021 17:44:55 +0000 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 21 Jan 2021 17:44:55 +0000 From: David Laight To: 'Christoph Hellwig' , Christophe Leroy CC: Petr Mladek , Jiri Kosina , "Andrew Donnellan" , "linux-kbuild@vger.kernel.org" , David Airlie , "Masahiro Yamada" , Josh Poimboeuf , Maarten Lankhorst , "linux-kernel@vger.kernel.org" , Maxime Ripard , "live-patching@vger.kernel.org" , Michal Marek , "Joe Lawrence" , "dri-devel@lists.freedesktop.org" , Thomas Zimmermann , Jessica Yu , Frederic Barrat , Daniel Vetter , Miroslav Benes , "linuxppc-dev@lists.ozlabs.org" Subject: RE: [PATCH 02/13] module: add a module_loaded helper Thread-Topic: [PATCH 02/13] module: add a module_loaded helper Thread-Index: AQHW8BhvE0+Qt/OaHkK/jwqI2nu4BKoyViXg Date: Thu, 21 Jan 2021 17:44:55 +0000 Message-ID: <8d59f11971764db2a104c87937e1d3ab@AcuMS.aculab.com> References: <20210121074959.313333-1-hch@lst.de> <20210121074959.313333-3-hch@lst.de> <844a7fc3-2cba-46d2-fd4e-e5fe16b08573@csgroup.eu> <20210121171119.GA29916@lst.de> In-Reply-To: <20210121171119.GA29916@lst.de> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > On Thu, Jan 21, 2021 at 11:00:20AM +0100, Christophe Leroy wrote: > > > +bool module_loaded(const char *name); > > > > Maybe module_is_loaded() would be a better name. > > Fine with me. It does look like both callers aren't 'unsafe'. But it is a bit strange returning a stale value. It did make be look a bit more deeply at try_module_get(). For THIS_MODULE (eg to get an extra reference for a kthread) I doubt it can ever fail. But the other cases require a 'module' structure be passed in. ISTM that unloading the module could invalidate the pointer that has just been read from some other structure. I'm guessing that some other lock must always be held. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) 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 X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,PDS_BAD_THREAD_QP_64, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3F6BC433DB for ; Thu, 21 Jan 2021 17:47:29 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F1DB122B2B for ; Thu, 21 Jan 2021 17:47:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1DB122B2B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=ACULAB.COM Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DM8wt60sjzDrV2 for ; Fri, 22 Jan 2021 04:47:26 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aculab.com (client-ip=185.58.86.151; helo=eu-smtp-delivery-151.mimecast.com; envelope-from=david.laight@aculab.com; receiver=) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4DM8tD3rbmzDqQ3 for ; Fri, 22 Jan 2021 04:45:06 +1100 (AEDT) Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-7-70jJZbebO02FvmwaO8iuwQ-1; Thu, 21 Jan 2021 17:44:57 +0000 X-MC-Unique: 70jJZbebO02FvmwaO8iuwQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 21 Jan 2021 17:44:55 +0000 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 21 Jan 2021 17:44:55 +0000 From: David Laight To: 'Christoph Hellwig' , Christophe Leroy Subject: RE: [PATCH 02/13] module: add a module_loaded helper Thread-Topic: [PATCH 02/13] module: add a module_loaded helper Thread-Index: AQHW8BhvE0+Qt/OaHkK/jwqI2nu4BKoyViXg Date: Thu, 21 Jan 2021 17:44:55 +0000 Message-ID: <8d59f11971764db2a104c87937e1d3ab@AcuMS.aculab.com> References: <20210121074959.313333-1-hch@lst.de> <20210121074959.313333-3-hch@lst.de> <844a7fc3-2cba-46d2-fd4e-e5fe16b08573@csgroup.eu> <20210121171119.GA29916@lst.de> In-Reply-To: <20210121171119.GA29916@lst.de> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , Michal Marek , Andrew Donnellan , Jessica Yu , "linux-kbuild@vger.kernel.org" , David Airlie , Masahiro Yamada , Jiri Kosina , Maarten Lankhorst , "linux-kernel@vger.kernel.org" , Maxime Ripard , Joe Lawrence , "dri-devel@lists.freedesktop.org" , Thomas Zimmermann , Josh Poimboeuf , Frederic Barrat , "live-patching@vger.kernel.org" , Daniel Vetter , Miroslav Benes , "linuxppc-dev@lists.ozlabs.org" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" >=20 > On Thu, Jan 21, 2021 at 11:00:20AM +0100, Christophe Leroy wrote: > > > +bool module_loaded(const char *name); > > > > Maybe module_is_loaded() would be a better name. >=20 > Fine with me. It does look like both callers aren't 'unsafe'. But it is a bit strange returning a stale value. It did make be look a bit more deeply at try_module_get(). For THIS_MODULE (eg to get an extra reference for a kthread) I doubt it can ever fail. But the other cases require a 'module' structure be passed in. ISTM that unloading the module could invalidate the pointer that has just been read from some other structure. I'm guessing that some other lock must always be held. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales) 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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D418C433E9 for ; Fri, 22 Jan 2021 08:46:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CA655236F9 for ; Fri, 22 Jan 2021 08:46:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA655236F9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=ACULAB.COM Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AA4496E9D0; Fri, 22 Jan 2021 08:46:00 +0000 (UTC) X-Greylist: delayed 900 seconds by postgrey-1.36 at gabe; Thu, 21 Jan 2021 18:01:08 UTC Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 234366E8D9 for ; Thu, 21 Jan 2021 18:01:08 +0000 (UTC) Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-7-70jJZbebO02FvmwaO8iuwQ-1; Thu, 21 Jan 2021 17:44:57 +0000 X-MC-Unique: 70jJZbebO02FvmwaO8iuwQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 21 Jan 2021 17:44:55 +0000 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 21 Jan 2021 17:44:55 +0000 From: David Laight To: 'Christoph Hellwig' , Christophe Leroy Subject: RE: [PATCH 02/13] module: add a module_loaded helper Thread-Topic: [PATCH 02/13] module: add a module_loaded helper Thread-Index: AQHW8BhvE0+Qt/OaHkK/jwqI2nu4BKoyViXg Date: Thu, 21 Jan 2021 17:44:55 +0000 Message-ID: <8d59f11971764db2a104c87937e1d3ab@AcuMS.aculab.com> References: <20210121074959.313333-1-hch@lst.de> <20210121074959.313333-3-hch@lst.de> <844a7fc3-2cba-46d2-fd4e-e5fe16b08573@csgroup.eu> <20210121171119.GA29916@lst.de> In-Reply-To: <20210121171119.GA29916@lst.de> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US X-Mailman-Approved-At: Fri, 22 Jan 2021 08:45:43 +0000 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: Petr Mladek , Michal Marek , Andrew Donnellan , Jessica Yu , "linux-kbuild@vger.kernel.org" , David Airlie , Masahiro Yamada , Jiri Kosina , "linux-kernel@vger.kernel.org" , Joe Lawrence , "dri-devel@lists.freedesktop.org" , Thomas Zimmermann , Josh Poimboeuf , Frederic Barrat , "live-patching@vger.kernel.org" , Miroslav Benes , "linuxppc-dev@lists.ozlabs.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" > > On Thu, Jan 21, 2021 at 11:00:20AM +0100, Christophe Leroy wrote: > > > +bool module_loaded(const char *name); > > > > Maybe module_is_loaded() would be a better name. > > Fine with me. It does look like both callers aren't 'unsafe'. But it is a bit strange returning a stale value. It did make be look a bit more deeply at try_module_get(). For THIS_MODULE (eg to get an extra reference for a kthread) I doubt it can ever fail. But the other cases require a 'module' structure be passed in. ISTM that unloading the module could invalidate the pointer that has just been read from some other structure. I'm guessing that some other lock must always be held. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel