linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Daniel Borkmann' <daniel@iogearbox.net>,
	liqiong <liqiong@nfschina.com>, Yonghong Song <yhs@fb.com>,
	Andrii Nakryiko <andrii@kernel.org>,
	"Martin KaFai Lau" <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"hukun@nfschina.com" <hukun@nfschina.com>,
	"qixu@nfschina.com" <qixu@nfschina.com>,
	"yuzhe@nfschina.com" <yuzhe@nfschina.com>,
	"renyu@nfschina.com" <renyu@nfschina.com>
Subject: RE: [PATCH 1/2] kernel/bpf: change "char *" string form to "char []"
Date: Fri, 13 May 2022 11:14:34 +0000	[thread overview]
Message-ID: <017900c07229451085f82ae1e71cd825@AcuMS.aculab.com> (raw)
In-Reply-To: <92cc4844-5815-c3b0-63be-2e54dc36e1d9@iogearbox.net>

From: Daniel Borkmann
> Sent: 12 May 2022 22:00
> 
> On 5/12/22 7:08 PM, liqiong wrote:
> > 在 2022年05月12日 23:16, Yonghong Song 写道:
> >>
> >> On 5/12/22 7:28 AM, liqiong wrote:
> >>> The string form of "char []" declares a single variable. It is better
> >>> than "char *" which creates two variables.
> >>
> >> Could you explain in details about why it is better in generated codes?
> >> It is not clear to me why your patch is better than the original code.
> >
> > The  string form of "char *" creates two variables in the final assembly output,
> > a static string, and a char pointer to the static string.  Use  "objdump -S -D  *.o",
> > can find out the static string  occurring  at "Contents of section .rodata".
> 
> There are ~360 instances of this type in the tree from a quick grep, do you
> plan to convert all them ?

There are also all the places with const char *names[] = ...;
where the actual names are all similar length so replacing with
const char names[][n] saves space.

Although that transformation has a bigger effect on shared libs.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

      parent reply	other threads:[~2022-05-13 11:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-12 14:28 [PATCH 1/2] kernel/bpf: change "char *" string form to "char []" liqiong
2022-05-12 15:16 ` Yonghong Song
2022-05-12 17:08   ` liqiong
2022-05-12 20:59     ` Daniel Borkmann
2022-05-13  2:04       ` liqiong
2022-05-13 11:14       ` David Laight [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=017900c07229451085f82ae1e71cd825@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=hukun@nfschina.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liqiong@nfschina.com \
    --cc=netdev@vger.kernel.org \
    --cc=qixu@nfschina.com \
    --cc=renyu@nfschina.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    --cc=yuzhe@nfschina.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).