Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7562596rdb; Wed, 3 Jan 2024 23:37:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAS4fMTkvfSI9ts8Pt4rAXtgc1m1nAkN8t23tVl8/JX2w1KTt+i/FRMGvh2uz5fM6jgceD X-Received: by 2002:a05:6a20:6d12:b0:196:4721:f442 with SMTP id fv18-20020a056a206d1200b001964721f442mr121350pzb.79.1704353864757; Wed, 03 Jan 2024 23:37:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704353864; cv=none; d=google.com; s=arc-20160816; b=AwWFDrFarJSWc4x0XpGkYzk6y1T+YhFmohH5LfYvFptCwomOU6LIlDvNCDZb7E4ib8 a8L7qy+UpzOw8/qbs+ubVNNTYoWG/5ZgOakM3ZltDFV7l52Nl6tQEKMSomaA7qIZ7Z6G G/YveGcl7y/51ZgtEfCgBcCTxkOdI3Fyyuz7aowNlyTPztLd9lHJxdcPz5cYmhC+w6s7 NHt6jwv5iRW4j10xh1wjGlZn7riGVBY3qhTPhYkTP5e13g7u7vvxFWOUHZ+q4VhPZcvw F2e19f+Jdw6oLyqZw5soh5bdew7uAx8atHsB/SEekVUO8RNskIZ+3sGzipvvjH50zMLY 8nqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=DTJlAp/1XxfS8CcWtDoghHulXb9YvnyMXYj1yaibztI=; fh=YNYWracdW+kUoxsEiOkLGpDtYKb4cHF8sEvXd/R3Pww=; b=h6+na+npc21mMbIdeL9WMF73i9PEwjeC/+MUoopO8FTljjVuoem60s99OW5jXkXkpb 8ZLpg8K/tP9KmrAWqFyv7llPyXiawjusqrN3LVKn0g3eduXL9lRv/oDJ1KKolvsjFrFx fhnf1Zm7LJc1G/7sxbeSNSa23ZCnz882RRmLKLHjQW/eFApOIR9J47z8BCrsPDyQbv/y U/7fV9d3PBIBNq09s+GiB9AVe4Le9ckeksMAHp660C4l0vw63Qhki6A90DSk2GNRJMPy 2/kIk1dBtO1Q29YZTowKFlJnS9TUd1yCjFc/K+KwWVwy9HTpf6RMM4Zvax7T1Iiovsf1 uhrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GwubNwgj; spf=pass (google.com: domain of linux-kernel+bounces-16323-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16323-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t11-20020a056a0021cb00b006d97238a396si22592331pfj.85.2024.01.03.23.37.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 23:37:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16323-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GwubNwgj; spf=pass (google.com: domain of linux-kernel+bounces-16323-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16323-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5ED6628731D for ; Thu, 4 Jan 2024 07:37:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2BE31F613; Thu, 4 Jan 2024 07:37:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GwubNwgj" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D98CE15EA6; Thu, 4 Jan 2024 07:37:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51099C433C8; Thu, 4 Jan 2024 07:37:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704353856; bh=atAczvBpbmGSvkt1pg+/6q2+kUOQhOSbBRS7ljsGUqE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GwubNwgjwG0q2RuxyiLvmP9xIKpTZYhvf8OYSsdMEleUGDlxrFnT83li2NF6S3Hz9 JWWXUEv8aqsB3S8ZamxNA9x1Tfuu9RZ8/HDrUgkhYE46hNatUdUXA0el9f5T9LiukR CVfJUyx/QG/OJfZlRdOhomU1q0fQEm9reN7/wTvhGVDaTnQVW7MSx4HGY7Gjthnt3d sNlMMn0Ta7gnjYHV752I4Kty1KIW2utSEg8yIlJS/PYnXGFtYwF7x+7rqj7lrvme/e LbijIPLPnFmYSmGpPoiLDwaxn/j5BRgQuQBZVKEaM8iaGvwzUB4xTR9FP36XI7k4Gl VwNHKgZxPBmaA== Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-50ea8fbf261so210762e87.2; Wed, 03 Jan 2024 23:37:36 -0800 (PST) X-Gm-Message-State: AOJu0YzvMvph01jSVlEzGcKku9osLp+PcILUoc6j/bg292BFOfYI6uW8 wn0xU3MkLymzEaNUrMIb2Xg8ZXzsjtPSQAFO7cQ= X-Received: by 2002:ac2:5504:0:b0:50e:aa46:7576 with SMTP id j4-20020ac25504000000b0050eaa467576mr94689lfk.7.1704353854547; Wed, 03 Jan 2024 23:37:34 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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> <20240104070235.GA13468@wunner.de> In-Reply-To: <20240104070235.GA13468@wunner.de> From: Ard Biesheuvel Date: Thu, 4 Jan 2024 08:37:23 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 8/9] PCI: Define scoped based management functions To: Lukas Wunner Cc: Dan Williams , Ira Weiny , Jonathan Cameron , Smita Koralahalli , Shiju Jose , Yazen Ghannam , Davidlohr Bueso , Dave Jiang , Alison Schofield , Vishal Verma , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, Bjorn Helgaas Content-Type: text/plain; charset="UTF-8" On Thu, 4 Jan 2024 at 08:02, Lukas Wunner wrote: > > 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/ > AIUI, Peter is referring to constant propagation of compile time constant pointers here, not pointer variables where the NULL check is elided if the variable has already been dereferenced.