linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: "Jérôme Pouiller" <jerome.pouiller@silabs.com>
Cc: Jaehee Park <jhpark1013@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	outreachy@lists.linux.dev, Stefano Brivio <sbrivio@redhat.com>
Subject: Re: [PATCH] staging: wfx: use container_of() to get vif
Date: Sat, 9 Apr 2022 17:37:32 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2204091737130.2655@hadrien> (raw)
In-Reply-To: <1911301.taCxCBeP46@pc-42>

[-- Attachment #1: Type: text/plain, Size: 2589 bytes --]



On Sat, 9 Apr 2022, Jérôme Pouiller wrote:

> On Saturday 9 April 2022 00:21:02 CEST Jaehee Park wrote:
> > On Fri, Apr 08, 2022 at 11:49:49AM +0200, Julia Lawall wrote:
> > > On Thu, 7 Apr 2022, Jaehee Park wrote:
> > >
> > > > Use container_of() to get vif. This improves the code in two ways:
> > > > [1] it speeds up the compilation because container_of() saves steps to
> > > > retrieve vif (the representation of ieee80211_vif), and
> > >
> > > I don't understand this part.
> > >
> > > julia
> > >
> >
> > Thank you for your message. I revised the commit message (below)--
> > I hope it makes it clearer. I'm open to suggestions as well!
> >
> > Currently, upon virtual interface creation, wfx_add_interface() stores
> > a reference to the corresponding struct ieee80211_vif in private data,
> > for later usage. This is not needed when using the container_of
> > construct. This construct already has all the info it needs to retrieve
> > the reference to the corresponding struct from the offset that is
> > already available, inherent in container_of(), between its type and
> > member inputs (struct ieee80211_vif and drv_priv, respectively).
> > Remove vif (which was previously storing the reference to the struct
> > ieee80211_vif) from the struct wfx_vif, define a macro
> > wvif_to_vif(wvif) for container_of(), and replace all wvif->vif with
> > the newly defined container_of construct.
> >
> > Sorry if I'm putting out more information than was asked for:
> > Diagram is worth a thousand words; this one is made by Stefano when
> > he was explaining the container_of() construct:
> >
> > .-----------------------------------.
> > |  .------------------------------. |
> > '->| struct ieee80211_vif         | |
> >    |------------------------------| |
> >    | 1                            | |
> >    | 2                            | |
> >    |  .--------------------------.| |
> >    | 3| struct wfx_vif drv_priv   | |
> >    |  |---------------------------| |
> >    |  | ...                       | |
> >    |  |                           | |
> >    |  | struct ieee80211_vif *vif---'
> >    '------------------------------'
> > In this example, the offset is 3.
> > What I want to convey here is the compiler already knows the offset
> > of drv_priv within struct ieee80211_vif by using the container_of()
> > construct. So, it doesn't need to do extra work.
>
> Wow, nice ascii art :)
>
> I think that Julia has not understand why you said it "speeds up the
> compilation". I think you meant "speeds up the execution", don't you?

Yes, that was my concern.

julia

  reply	other threads:[~2022-04-09 15:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-07 20:41 [PATCH] staging: wfx: use container_of() to get vif Jaehee Park
2022-04-07 21:17 ` Jaehee Park
2022-04-08  1:09 ` Alison Schofield
2022-04-08  1:50   ` Jaehee Park
2022-04-08  9:49 ` Julia Lawall
2022-04-08 22:21   ` Jaehee Park
2022-04-09 13:54     ` Jérôme Pouiller
2022-04-09 15:37       ` Julia Lawall [this message]
2022-04-12  4:01         ` Jaehee Park

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=alpine.DEB.2.22.394.2204091737130.2655@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=jerome.pouiller@silabs.com \
    --cc=jhpark1013@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=outreachy@lists.linux.dev \
    --cc=sbrivio@redhat.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).