linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jie Deng <jie.deng@intel.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
	"Enrico Weigelt, metux IT consult" <lkml@metux.net>,
	"Linux I2C" <linux-i2c@vger.kernel.org>,
	virtualization@lists.linux-foundation.org,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Wolfram Sang" <wsa@kernel.org>,
	"Jason Wang" <jasowang@redhat.com>,
	"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	conghui.chen@intel.com, kblaiech@mellanox.com,
	jarkko.nikula@linux.intel.com,
	"Sergey Semin" <Sergey.Semin@baikalelectronics.ru>,
	"Mike Rapoport" <rppt@kernel.org>,
	loic.poulain@linaro.org, "Tali Perry" <tali.perry1@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Bjorn Andersson" <bjorn.andersson@linaro.org>,
	yu1.wang@intel.com, shuo.a.liu@intel.com,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH v8] i2c: virtio: add a virtio i2c frontend driver
Date: Fri, 19 Mar 2021 14:56:37 +0800	[thread overview]
Message-ID: <6df192ef-abc1-35a6-298d-e3e67655ac1f@intel.com> (raw)
In-Reply-To: <20210319063553.eq5aorcyiame6u2e@vireshk-i7>


On 2021/3/19 14:35, Viresh Kumar wrote:
> On 19-03-21, 14:29, Jie Deng wrote:
>> I also see example drivers/i2c/busses/i2c-xiic.c. Some people might think
>> this way is more clearer than
>>
>> updating each member in probe. Basically, I think it's just a matter of
>> personal preference which doesn't
> Memory used by one instance of struct i2c_adapter (on arm64):
>
> struct i2c_adapter {
>          struct module *            owner;                /*     0     8 */
>          unsigned int               class;                /*     8     4 */
>
>          /* XXX 4 bytes hole, try to pack */
>
>          const struct i2c_algorithm  * algo;              /*    16     8 */
>          void *                     algo_data;            /*    24     8 */
>          const struct i2c_lock_operations  * lock_ops;    /*    32     8 */
>          struct rt_mutex            bus_lock;             /*    40    32 */
>          /* --- cacheline 1 boundary (64 bytes) was 8 bytes ago --- */
>          struct rt_mutex            mux_lock;             /*    72    32 */
>          int                        timeout;              /*   104     4 */
>          int                        retries;              /*   108     4 */
>          struct device              dev;                  /*   112   744 */
>
>          /* XXX last struct has 7 bytes of padding */
>
>          /* --- cacheline 13 boundary (832 bytes) was 24 bytes ago --- */
>          long unsigned int          locked_flags;         /*   856     8 */
>          int                        nr;                   /*   864     4 */
>          char                       name[48];             /*   868    48 */
>
>          /* XXX 4 bytes hole, try to pack */
>
>          /* --- cacheline 14 boundary (896 bytes) was 24 bytes ago --- */
>          struct completion          dev_released;         /*   920    32 */
>          struct mutex               userspace_clients_lock; /*   952    32 */
>          /* --- cacheline 15 boundary (960 bytes) was 24 bytes ago --- */
>          struct list_head           userspace_clients;    /*   984    16 */
>          struct i2c_bus_recovery_info * bus_recovery_info; /*  1000     8 */
>          const struct i2c_adapter_quirks  * quirks;       /*  1008     8 */
>          struct irq_domain *        host_notify_domain;   /*  1016     8 */
>          /* --- cacheline 16 boundary (1024 bytes) --- */
>
>          /* size: 1024, cachelines: 16, members: 19 */
>          /* sum members: 1016, holes: 2, sum holes: 8 */
>          /* paddings: 1, sum paddings: 7 */
> };
>
> So, this extra instance that i2c-xiic.c is creating (and that you want to
> create) is going to waste 1KB of memory and it will never be used.
>
> This is bad coding practice IMHO and it is not really about personal preference.


I will remove that structure and update the members in probe.



  reply	other threads:[~2021-03-19  6:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-16 10:35 [PATCH v8] i2c: virtio: add a virtio i2c frontend driver Jie Deng
2021-03-16  7:44 ` Viresh Kumar
2021-03-18 14:40   ` Enrico Weigelt, metux IT consult
2021-03-18 14:52     ` Arnd Bergmann
2021-03-19  3:54       ` Viresh Kumar
2021-03-19  5:31         ` Jie Deng
2021-03-19  5:40           ` Viresh Kumar
2021-03-19  6:29             ` Jie Deng
2021-03-19  6:35               ` Viresh Kumar
2021-03-19  6:56                 ` Jie Deng [this message]
2021-03-19  8:27                 ` Arnd Bergmann
2021-03-16  7:53 ` Viresh Kumar
2021-03-19  5:53 ` Viresh Kumar
2021-03-19  7:52   ` Jie Deng

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=6df192ef-abc1-35a6-298d-e3e67655ac1f@intel.com \
    --to=jie.deng@intel.com \
    --cc=Sergey.Semin@baikalelectronics.ru \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=bjorn.andersson@linaro.org \
    --cc=conghui.chen@intel.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=jasowang@redhat.com \
    --cc=kblaiech@mellanox.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkml@metux.net \
    --cc=loic.poulain@linaro.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rppt@kernel.org \
    --cc=shuo.a.liu@intel.com \
    --cc=stefanha@redhat.com \
    --cc=tali.perry1@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=viresh.kumar@linaro.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=wsa@kernel.org \
    --cc=yu1.wang@intel.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;
as well as URLs for NNTP newsgroup(s).