mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Zhen Lei <thunder.leizhen@huawei.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci <linux-pci@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] PCI: Optimize pci_resource_len() to reduce the binary size of kernel
Date: Fri, 20 Aug 2021 17:11:57 -0500	[thread overview]
Message-ID: <20210820221157.GA3365579@bjorn-Precision-5520> (raw)
In-Reply-To: <20210713072236.3043-1-thunder.leizhen@huawei.com>

On Tue, Jul 13, 2021 at 03:22:36PM +0800, Zhen Lei wrote:
> pci_resource_end() can be 0 only when pci_resource_start() is 0.
> Otherwise, it is definitely an error. In this case, pci_resource_len()
> should be regarded as 0. Therefore, determining whether
> pci_resource_start() and pci_resource_end() are both 0 can be reduced to
> determining only whether pci_resource_end() is 0.
> 
> Although only one condition judgment is reduced, the macro function
> pci_resource_len() is widely referenced in the kernel. I used defconfig to
> compile the latest kernel on X86, and its binary code size was reduced by
> about 3KB.
> 
> Before:
>  [ 2] .rela.text        RELA             0000000000000000  093bfcb0
>       0000000001a67168  0000000000000018   I      68     1     8
> 
> After:
>  [ 2] .rela.text        RELA             0000000000000000  093bfcb0
>       0000000001a66598  0000000000000018   I      68     1     8
> 
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

Applied to pci/resource for v5.15, thanks!

> ---
>  include/linux/pci.h | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 540b377ca8f6..23ef1a15eb5d 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1881,9 +1881,7 @@ int pci_iobar_pfn(struct pci_dev *pdev, int bar, struct vm_area_struct *vma);
>  #define pci_resource_end(dev, bar)	((dev)->resource[(bar)].end)
>  #define pci_resource_flags(dev, bar)	((dev)->resource[(bar)].flags)
>  #define pci_resource_len(dev,bar) \
> -	((pci_resource_start((dev), (bar)) == 0 &&	\
> -	  pci_resource_end((dev), (bar)) ==		\
> -	  pci_resource_start((dev), (bar))) ? 0 :	\
> +	((pci_resource_end((dev), (bar)) == 0) ? 0 :	\
>  							\
>  	 (pci_resource_end((dev), (bar)) -		\
>  	  pci_resource_start((dev), (bar)) + 1))
> -- 
> 2.25.1
> 

      reply	other threads:[~2021-08-20 22:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13  7:22 Zhen Lei
2021-08-20 22:11 ` Bjorn Helgaas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210820221157.GA3365579@bjorn-Precision-5520 \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=thunder.leizhen@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®