Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3315107rdh; Mon, 27 Nov 2023 10:59:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IG08ZUC9+9KgE0cp1fKSEdB5ikHUa2CPqEOwZyeqA6K/FEyDQkHI8kCCM6sNlbvw1B26ovt X-Received: by 2002:a05:6a00:a0e:b0:6cb:cd3e:93c3 with SMTP id p14-20020a056a000a0e00b006cbcd3e93c3mr14348054pfh.16.1701111570317; Mon, 27 Nov 2023 10:59:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701111570; cv=none; d=google.com; s=arc-20160816; b=GDH0BnZAxZpmgFF/c5zd+WafakiajxwJp68c704SjxefT9HDKlTy4x/VrAUpjkicm3 aXmJt/JxvX4cVEsx4fKMHCPaqszpy2exzJms4dK9ygtofLg+h9Dy6XgZHCMneOE70/yP hYqUWdXOp0I/Uk5CdIuLQbIOuryEv1Hn2Q6iNr57Cf4dBm4p1qGZpZiNpaZuyti+PUqk GPUZON/brnmlIllmchsghrK+whDw8/W8cj8TkH5qptfRnO9ZHrGdiK8w+KYJilZ35MQo rGHcvxmdANAMP5LjMaVsQ4GAeaixafZvRY36oOrKmgXxW/p4LDMr+byuAmRV5QKAwmi/ AKiA== 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=Xy93X6irj0AIeJluZAkj0kASt6nWEEShZFbNAm7nOgc=; fh=t1/wBvH0J1wYXNrhWqzQpvWtRxLuRJys96wSoU/cY8E=; b=tWm6bxFBTBaQi41D42hIoLqjegg4gokAlMOs8QOK0qcE6hfhKj1qVUk13zTKgusyts NB6vcZ1AIz1iNLyauXXdWgiI15Vd6o1Omb56G/wWJJOxMAFPurwFGYm7aCEj8AaA5Oxd s1PdNt84UEwB25d+bRriBAnn2G8NrHA2ghKXbNMpVyYZJnNsCYVX8DdRs6mdEFRCPZ89 JYoX+RB+8DiHK80WyD9zzlLt84MQw5VV3DP6j3u+iPsqz3gdT100+TZC+LkzwTxIU6jn U23QGRT6VtfbW71rNESLHYmGLHuRe5Nf69nn+D/iLXgR7sk48C92z2GRnLz80wE1NiZj ukBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XANlISV1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id f9-20020a056a0022c900b006c6b9625350si10438697pfj.281.2023.11.27.10.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 10:59:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XANlISV1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 60F2C807931F; Mon, 27 Nov 2023 10:59:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232084AbjK0S7I (ORCPT + 99 others); Mon, 27 Nov 2023 13:59:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbjK0S7I (ORCPT ); Mon, 27 Nov 2023 13:59:08 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E44EED4D for ; Mon, 27 Nov 2023 10:59:14 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46187C433C7; Mon, 27 Nov 2023 18:59:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1701111554; bh=Evnqx1z1/S6wB+DGU8MkMOg+woE8DrTDrItqC+r57lA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XANlISV1xf1fmQVFpXBopOP+AnSU7G7UrOU7S/ZcU9L8stKKyEPie3AtN7u9F8P1t JkBriUUwEUsKz3nIsqd3aHhkCOiKkm70rUqn2aPCdYgxTAjRPLTXEvaXfCveKXwdom rtAdTl31K+KBtQDN5JEiMyHZw3cIlCTbfy7YldQ0= Date: Mon, 27 Nov 2023 18:59:12 +0000 From: Greg Kroah-Hartman To: Saeed Mahameed Cc: Arnd Bergmann , Jason Gunthorpe , Leon Romanovsky , Jiri Pirko , Leonid Bloch , Itay Avraham , Jakub Kicinski , linux-kernel@vger.kernel.org, Saeed Mahameed Subject: Re: [PATCH V3 2/5] misc: mlx5ctl: Add mlx5ctl misc driver Message-ID: <2023112727-caddie-eardrum-efe8@gregkh> References: <20231121070619.9836-1-saeed@kernel.org> <20231121070619.9836-3-saeed@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231121070619.9836-3-saeed@kernel.org> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 27 Nov 2023 10:59:27 -0800 (PST) On Mon, Nov 20, 2023 at 11:06:16PM -0800, Saeed Mahameed wrote: > +struct mlx5ctl_dev { > + struct mlx5_core_dev *mdev; > + struct miscdevice miscdev; > + struct auxiliary_device *adev; > + struct list_head fd_list; > + spinlock_t fd_list_lock; /* protect list add/del */ > + struct rw_semaphore rw_lock; > + struct kref refcount; You now have 2 different things that control the lifespan of this structure. We really need some way to automatically check this so that people don't keep making this same mistake, it happens all the time :( Please pick one structure (miscdevice) or the other (kref) to control the lifespan, having 2 will just not work. Also, why a rw_semaphore? Only use those if you can prove with a benchmark that it is actually faster, otherwise it's simpler to just use a normal mutex (hint, you are changing the fields in the structure with the read lock held, which feels very wrong, and so needs a LOT of documentation, or just use a normal mutex...) thanks, greg k-h