mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Howard Yen <howardyen@google.com>
Cc: hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com,
	gregkh@linuxfoundation.org, rafael@kernel.org,
	broonie@kernel.org, james@equiv.tech, james.clark@arm.com,
	masahiroy@kernel.org, linux-kernel@vger.kernel.org,
	iommu@lists.linux.dev
Subject: Re: [PATCH v2] dma-coherent: add support for multi coherent rmems per dev
Date: Thu, 8 Feb 2024 12:56:27 +0200	[thread overview]
Message-ID: <ZcSzW1kFZIZ_f759@smile.fi.intel.com> (raw)
In-Reply-To: <CAJDAHvYYUcn2HL1QTSG-KA0QcuAOotk5hY4cpuasOu_H=X-V0A@mail.gmail.com>

On Thu, Feb 08, 2024 at 03:53:37PM +0800, Howard Yen wrote:
> On Tue, Feb 6, 2024 at 11:43 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Mon, Feb 05, 2024 at 02:08:00PM +0200, Andy Shevchenko wrote:
> > > On Mon, Feb 05, 2024 at 07:23:00AM +0000, Howard Yen wrote:

...

> > > > @@ -18,15 +18,9 @@ struct dma_coherent_mem {
> > > >     unsigned long   *bitmap;
> > > >     spinlock_t      spinlock;
> > > >     bool            use_dev_dma_pfn_offset;
> > > > +   struct list_head        node;
> > >
> > > Have you run `pahole`? Here I see wasted bytes for nothing.
> >
> > On top of that one may make container_of() to be no-op, by placing this member
> > to be the first one. But, double check this with bloat-o-meter (that it indeed
> > does better code generation) and on the other hand check if the current first
> > member is not performance critical and having additional pointer arithmetics is
> > okay.
> >
> > > >  };
> 
> I'm trying to re-org the members as below
> 
> from ===>
> 
> struct dma_coherent_mem {
> void *                     virt_base;            /*     0     8 */
> dma_addr_t                 device_base;          /*     8     8 */
> unsigned long              pfn_base;             /*    16     8 */
> int                        size;                 /*    24     4 */
> 
> /* XXX 4 bytes hole, try to pack */
> 
> unsigned long *            bitmap;               /*    32     8 */
> spinlock_t                 spinlock;             /*    40     4 */
> bool                       use_dev_dma_pfn_offset; /*    44     1 */
> 
> /* XXX 3 bytes hole, try to pack */
> 
> struct list_head           node;                 /*    48    16 */
> 
> /* size: 64, cachelines: 1, members: 8 */
> /* sum members: 57, holes: 2, sum holes: 7 */
> };
> 
> 
> to ===>
> 
> struct dma_coherent_mem {
> struct list_head           node;                 /*     0    16 */
> void *                     virt_base;            /*    16     8 */
> dma_addr_t                 device_base;          /*    24     8 */
> unsigned long              pfn_base;             /*    32     8 */
> int                        size;                 /*    40     4 */
> spinlock_t                 spinlock;             /*    44     4 */
> unsigned long *            bitmap;               /*    48     8 */
> bool                       use_dev_dma_pfn_offset; /*    56     1 */
> 
> /* size: 64, cachelines: 1, members: 8 */
> /* padding: 7 */

Which seems better that above, right?

> };
> 
> Looks like there is about 7 bytes padding at the end of the structure.
> Should I add __attribute__((__packed__)) to not add the padding?

No, __packed is about alignment, may give you much worse code generation.
With list_head member first you might get better code from the original,
check it with bloat-o-meter.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-02-08 10:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-05  7:23 Howard Yen
2024-02-05 12:08 ` Andy Shevchenko
2024-02-06 15:43   ` Andy Shevchenko
2024-02-08  7:53     ` Howard Yen
2024-02-08 10:56       ` Andy Shevchenko [this message]
2024-02-08 14:57         ` Howard Yen

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=ZcSzW1kFZIZ_f759@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=howardyen@google.com \
    --cc=iommu@lists.linux.dev \
    --cc=james.clark@arm.com \
    --cc=james@equiv.tech \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=masahiroy@kernel.org \
    --cc=rafael@kernel.org \
    --cc=robin.murphy@arm.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

Powered by JetHome