linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] PCI: dwc: put struct dw_pcie::{ep,pp} into a union to reduce its size
@ 2021-03-12 14:01 Alexander Lobakin
  2021-03-24  1:31 ` Krzysztof Wilczyński
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Lobakin @ 2021-03-12 14:01 UTC (permalink / raw)
  To: Lorenzo Pieralisi, Bjorn Helgaas
  Cc: Jingoo Han, Gustavo Pimentel, Rob Herring, Alexander Lobakin,
	linux-pci, linux-kernel

A single dw_pcie entity can't be a root complex and an endpoint at
the same time.
We can use this to reduce the size of dw_pcie by 80, from 280 to 200
bytes (on x32, guess more on x64), by putting the related embedded
structures (struct pcie_port and struct dw_pcie_ep) into a union.

Signed-off-by: Alexander Lobakin <alobakin@pm.me>
---
 drivers/pci/controller/dwc/pcie-designware.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 7247c8b01f04..ca8aeba548ab 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -266,8 +266,10 @@ struct dw_pcie {
 	size_t			atu_size;
 	u32			num_ib_windows;
 	u32			num_ob_windows;
-	struct pcie_port	pp;
-	struct dw_pcie_ep	ep;
+	union {
+		struct pcie_port	pp;
+		struct dw_pcie_ep	ep;
+	};
 	const struct dw_pcie_ops *ops;
 	unsigned int		version;
 	int			num_lanes;
--
2.30.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH RESEND] PCI: dwc: put struct dw_pcie::{ep,pp} into a union to reduce its size
  2021-03-12 14:01 [PATCH RESEND] PCI: dwc: put struct dw_pcie::{ep,pp} into a union to reduce its size Alexander Lobakin
@ 2021-03-24  1:31 ` Krzysztof Wilczyński
  2021-03-24 11:33   ` Alexander Lobakin
  0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Wilczyński @ 2021-03-24  1:31 UTC (permalink / raw)
  To: Alexander Lobakin
  Cc: Lorenzo Pieralisi, Bjorn Helgaas, Jingoo Han, Gustavo Pimentel,
	Rob Herring, linux-pci, linux-kernel

Hi Alexander,

Thank you for sending the patch over!

> A single dw_pcie entity can't be a root complex and an endpoint at
> the same time.

Nice catch!

A small nitpick: this would be Root Complex and Endpoint, as it's
customary to capitalise these.

Also, if you could capitalise the subject line - it could also perhaps
be simplified to something like, for example:

  Optimize struct dw_pcie to reduce its size

Feel free to ignore both suggestions, as these are just nitpicks.

> We can use this to reduce the size of dw_pcie by 80, from 280 to 200
> bytes (on x32, guess more on x64), by putting the related embedded
> structures (struct pcie_port and struct dw_pcie_ep) into a union.

[...]
> -	struct pcie_port	pp;
> -	struct dw_pcie_ep	ep;
> +	union {
> +		struct pcie_port	pp;
> +		struct dw_pcie_ep	ep;
> +	};
[...]

How did you measure the difference?  Often, people include pahole output
for the "before" and "after", so to speak, to showcase the difference
and/or improvement.  Do you have something like that handy?

Krzysztof

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RESEND] PCI: dwc: put struct dw_pcie::{ep,pp} into a union to reduce its size
  2021-03-24  1:31 ` Krzysztof Wilczyński
@ 2021-03-24 11:33   ` Alexander Lobakin
  0 siblings, 0 replies; 3+ messages in thread
From: Alexander Lobakin @ 2021-03-24 11:33 UTC (permalink / raw)
  To: Krzysztof Wilczyński
  Cc: Alexander Lobakin, Lorenzo Pieralisi, Bjorn Helgaas, Jingoo Han,
	Gustavo Pimentel, Rob Herring, linux-pci, linux-kernel

From: Krzysztof Wilczyński <kw@linux.com>
Date: Wed, 24 Mar 2021 02:31:42 +0100

> Hi Alexander,

Hi!

> Thank you for sending the patch over!
>
> > A single dw_pcie entity can't be a root complex and an endpoint at
> > the same time.
>
> Nice catch!
>
> A small nitpick: this would be Root Complex and Endpoint, as it's
> customary to capitalise these.
>
> Also, if you could capitalise the subject line - it could also perhaps
> be simplified to something like, for example:
>
>   Optimize struct dw_pcie to reduce its size
>
> Feel free to ignore both suggestions, as these are just nitpicks.

They are both correct, so I can send a v2 if this one wont't be
picked to the tree, let's say, this week.

> > We can use this to reduce the size of dw_pcie by 80, from 280 to 200
> > bytes (on x32, guess more on x64), by putting the related embedded
> > structures (struct pcie_port and struct dw_pcie_ep) into a union.
>
> [...]
> > -	struct pcie_port	pp;
> > -	struct dw_pcie_ep	ep;
> > +	union {
> > +		struct pcie_port	pp;
> > +		struct dw_pcie_ep	ep;
> > +	};
> [...]
>
> How did you measure the difference?  Often, people include pahole output
> for the "before" and "after", so to speak, to showcase the difference
> and/or improvement.  Do you have something like that handy?

I didn't use pahole to measure the difference, just printed sizeofs
for the structures "before" and "after". But I can get pahole's
output and include it in v2 to make commit message more useful.

> Krzysztof

Thanks!
Al


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-24 11:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-12 14:01 [PATCH RESEND] PCI: dwc: put struct dw_pcie::{ep,pp} into a union to reduce its size Alexander Lobakin
2021-03-24  1:31 ` Krzysztof Wilczyński
2021-03-24 11:33   ` Alexander Lobakin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).