All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Douglas RAILLARD <douglas.raillard@arm.com>
Cc: acme@redhat.com, dwarves@vger.kernel.org
Subject: Re: [PATCH v3 6/6] btf_loader.c: Use cacheline size to infer alignment
Date: Thu, 28 Oct 2021 10:24:46 -0300	[thread overview]
Message-ID: <YXqknmflB1WS8rnE@kernel.org> (raw)
In-Reply-To: <20211028122710.881181-7-douglas.raillard@arm.com>

Em Thu, Oct 28, 2021 at 01:27:10PM +0100, Douglas RAILLARD escreveu:
> From: Douglas Raillard <douglas.raillard@arm.com>
> 
> When the alignment is larger than natural, it is very likely that the
> source code was using the cacheline size. Therefore, use the cacheline
> size when it would only result in increasing the alignment.

--- /tmp/btfdiff.dwarf.pXdgRU   2021-10-28 10:22:11.738200232 -0300
+++ /tmp/btfdiff.btf.bkDkdf     2021-10-28 10:22:11.925205061 -0300
@@ -107,7 +107,7 @@ struct Qdisc {
        /* XXX 24 bytes hole, try to pack */

        /* --- cacheline 2 boundary (128 bytes) --- */
-       struct sk_buff_head        gso_skb __attribute__((__aligned__(64))); /*   128    24 */
+       struct sk_buff_head        gso_skb __attribute__((__aligned__(32))); /*   128    24 */
        struct qdisc_skb_head      q;                    /*   152    24 */
        struct gnet_stats_basic_packed bstats;           /*   176    16 */
        /* --- cacheline 3 boundary (192 bytes) --- */

This one is gone with heuristic, thanks for accepting my suggestion and
coding it this fast!

Applied.

I'm pushing it out to the 'next' branch, please work from there, I'll
move it to 'master' when it passes libbpf's CI tests.

- Arnaldo
 
> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
> ---
>  btf_loader.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/btf_loader.c b/btf_loader.c
> index e500eae..7a5b16f 100644
> --- a/btf_loader.c
> +++ b/btf_loader.c
> @@ -476,6 +476,7 @@ static uint32_t class__infer_alignment(const struct conf_load *conf,
>  				       uint32_t natural_alignment,
>  				       uint32_t smallest_offset)
>  {
> +	uint16_t cacheline_size = conf->conf_fprintf->cacheline_size;
>  	uint32_t alignment = 0;
>  	uint32_t offset_delta = byte_offset - smallest_offset;
>  
> @@ -494,6 +495,15 @@ static uint32_t class__infer_alignment(const struct conf_load *conf,
>  	/* Natural alignment, nothing to do */
>  	if (alignment <= natural_alignment || alignment == 1)
>  		alignment = 0;
> +	/* If the offset is compatible with being aligned on the cacheline size
> +	 * and this would only result in increasing the alignment, use the
> +	 * cacheline size as it is safe and quite likely to be what was in the
> +	 * source.
> +	 */
> +	else if (alignment < cacheline_size &&
> +		 cacheline_size % alignment == 0 &&
> +		 byte_offset % cacheline_size == 0)
> +		alignment = cacheline_size;
>  
>  	return alignment;
>  }
> -- 
> 2.25.1

-- 

- Arnaldo

  reply	other threads:[~2021-10-28 13:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28 12:27 [PATCH v3 0/6] Infer BTF alignment Douglas RAILLARD
2021-10-28 12:27 ` [PATCH v3 1/6] fprintf: Fix nested struct printing Douglas RAILLARD
2021-10-28 12:40   ` Arnaldo Carvalho de Melo
2021-10-28 12:27 ` [PATCH v3 2/6] btf_loader.c: Refactor class__fixup_btf_bitfields Douglas RAILLARD
2021-10-28 13:15   ` Arnaldo Carvalho de Melo
2021-10-28 12:27 ` [PATCH v3 3/6] btf_loader.c: Infer alignment info Douglas RAILLARD
2021-10-28 13:15   ` Arnaldo Carvalho de Melo
2021-10-28 12:27 ` [PATCH v3 4/6] dwarves_fprintf: Move cacheline_size into struct conf_fprintf Douglas RAILLARD
2021-10-28 13:18   ` Arnaldo Carvalho de Melo
2021-10-28 12:27 ` [PATCH v3 5/6] btf_loader.c: Propagate struct conf_load Douglas RAILLARD
2021-10-28 13:19   ` Arnaldo Carvalho de Melo
2021-10-28 12:27 ` [PATCH v3 6/6] btf_loader.c: Use cacheline size to infer alignment Douglas RAILLARD
2021-10-28 13:24   ` Arnaldo Carvalho de Melo [this message]
2021-10-28 14:12     ` Douglas Raillard

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=YXqknmflB1WS8rnE@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=douglas.raillard@arm.com \
    --cc=dwarves@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.