Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7550902rdb; Wed, 3 Jan 2024 23:02:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCrOSGsYV2jpSTKsWMEyjZKPPjjL1XqKH66gbvxJdX+AAiyZJ5nueE0OzImlEoXqgXcGgL X-Received: by 2002:a17:90b:4c50:b0:28b:dc13:9752 with SMTP id np16-20020a17090b4c5000b0028bdc139752mr155842pjb.65.1704351772556; Wed, 03 Jan 2024 23:02:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704351772; cv=none; d=google.com; s=arc-20160816; b=Aee8bfDM5xtKUyE6TxFxJymKrGBF7O3ohZ6Z2pJnNGlFEXakx1xqJ354qe1LJnARal iJo5Xi+KL6cNLh8ePE1I9nQEgTBHieHKRpc4yBsp7tHly4nkosKbeQRIdJUeR43PdrT4 atjChMRg6XeB5uCyfZBR/BaiLC+dgM5Mu+nAe87QYi/3X3JFpnpHvbC/pg97mmP0c7c8 a8XSvqYWvtgWEUD8SZ8EiKUT3SAJPt6cowZMm5A6VINhh4Wx5ZT4ki1aqxtmS18ssFRG mY7RBXLpO0jQMeEYx82TMJvVvEh1shP/KQtNFDuogqwsn13agcpHBGUcHl3jE3ppVn8v l2NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=oqbD7XhINklVVrKMgqMWg2mjtHFyl1W58UCPjvOqLZc=; fh=43GGo+JeNTBCjICnp+LDwZpEhE4mhNK/aUgqsZqHNN0=; b=ehxfKZGVa8VCD1Iy+T1LOWZE4dzuogz3NpEac4slkOFTiIjr+Z/F3JjUv4v9Oz5GLN da6DymK093P7bKyj6laQFxywDIPNs3wY/hVaH+yG9Kzqz1IF84LpQTB8Brd9oGf1YcHx G1qG+ZuIlkRIhYkCeM0F/ZTDdbQbtPEB9+Wp69gtxw7F3c+r0q6Hl3ucUSOXIf038sFJ LSu/hhpcEjKpyoj0SZ8pFMev7skFvkUEIWyZK7OtdBqiBu+/BwhwEIKZZXDQhNz3B2LD KSYp+gfPLosjvoFLe7sR6YfLz9FJtF0u3/17b2++0iryF54u44yNPhbhaGQgzB/xz2nV UXZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-16299-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16299-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g12-20020a17090a128c00b0028c04beb53csi2517985pja.124.2024.01.03.23.02.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 23:02:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16299-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-16299-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16299-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E7259B24CB2 for ; Thu, 4 Jan 2024 07:02:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 030431DFE3; Thu, 4 Jan 2024 07:02:40 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from bmailout1.hostsharing.net (bmailout1.hostsharing.net [83.223.95.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61E561D699; Thu, 4 Jan 2024 07:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=h08.hostsharing.net Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS RSA CA G1" (verified OK)) by bmailout1.hostsharing.net (Postfix) with ESMTPS id 8489130000D0B; Thu, 4 Jan 2024 08:02:35 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 67757239FE7; Thu, 4 Jan 2024 08:02:35 +0100 (CET) Date: Thu, 4 Jan 2024 08:02:35 +0100 From: Lukas Wunner To: Dan Williams Cc: Ira Weiny , Jonathan Cameron , Smita Koralahalli , Shiju Jose , Yazen Ghannam , Davidlohr Bueso , Dave Jiang , Alison Schofield , Vishal Verma , Ard Biesheuvel , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, Bjorn Helgaas Subject: Re: [PATCH v5 8/9] PCI: Define scoped based management functions Message-ID: <20240104070235.GA13468@wunner.de> References: <20231220-cxl-cper-v5-0-1bb8a4ca2c7a@intel.com> <20231220-cxl-cper-v5-8-1bb8a4ca2c7a@intel.com> <20240104060528.GA10504@wunner.de> <6596539c9729e_8dc6829476@dwillia2-xfh.jf.intel.com.notmuch> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6596539c9729e_8dc6829476@dwillia2-xfh.jf.intel.com.notmuch> User-Agent: Mutt/1.10.1 (2018-07-13) On Wed, Jan 03, 2024 at 10:43:40PM -0800, Dan Williams wrote: > Lukas Wunner wrote: > > On Wed, Dec 20, 2023 at 04:17:35PM -0800, Ira Weiny wrote: > > > --- a/include/linux/pci.h > > > +++ b/include/linux/pci.h > > > @@ -1170,6 +1170,7 @@ int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); > > > u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp); > > > struct pci_dev *pci_dev_get(struct pci_dev *dev); > > > void pci_dev_put(struct pci_dev *dev); > > > +DEFINE_FREE(pci_dev_put, struct pci_dev *, if (_T) pci_dev_put(_T)) > > > > pci_dev_put() already performs a NULL pointer check internally. > > Why duplicate it here? > > Greg asked the same for the introduction of __free(kvfree), and Peter > clarified: > > http://lore.kernel.org/r/20230814161731.GN776869@hirez.programming.kicks-ass.net > > Essentially, that check is more for build-time than runtime because when > the macro is expanded the compiler can notice scenarios where @pdev is > set to NULL (likely by no_free_ptr()) and skip the call to pci_dev_put() > altogether. pci_dev_put() also happens to be out-of-line, so saving a > call when @pdev is NULL a small win in that respect as well. Doubtful whether that's correct. The kernel is compiled with -fno-delete-null-pointer-checks since commit a3ca86aea507 ("Add '-fno-delete-null-pointer-checks' to gcc CFLAGS"). So these NULL pointer checks are generally not optimized away. I've just responded to the discussion you've linked above: https://lore.kernel.org/all/20240104065744.GA6055@wunner.de/ Thanks, Lukas