From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Thomas Monjalon" <thomas@monjalon.net>
Cc: <david.marchand@redhat.com>, <honnappa.nagarahalli@arm.com>,
<konstantin.v.ananyev@yandex.ru>, <bruce.richardson@intel.com>,
<mattias.ronnblom@ericsson.com>, <dev@dpdk.org>,
<olivier.matz@6wind.com>, <andrew.rybchenko@oktetlabs.ru>,
<dev@dpdk.org>
Subject: RE: [PATCH] clarify purpose of empty cache lines
Date: Thu, 12 Oct 2023 08:07:37 +0200 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9EF3D@smartserver.smartshare.dk> (raw)
In-Reply-To: <6554142.G0QQBjFxQf@thomas>
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Thursday, 12 October 2023 01.44
>
> 04/09/2023 10:43, Morten Brørup:
> > /** Force minimum cache line alignment. */
> > #define __rte_cache_min_aligned __rte_aligned(RTE_CACHE_LINE_MIN_SIZE)
> >
> > +#define _RTE_CACHE_GUARD_HELPER2(unique) \
> > + char cache_guard_ ## unique[RTE_CACHE_LINE_SIZE *
> RTE_CACHE_GUARD_LINES] \
> > + __rte_cache_aligned
> > +#define _RTE_CACHE_GUARD_HELPER1(unique) _RTE_CACHE_GUARD_HELPER2(unique)
>
> What is the reason for this intermediate helper macro?
>
> > +/**
> > + * Empty cache lines, to guard against false sharing-like effects
> > + * on systems with a next-N-lines hardware prefetcher.
> > + *
> > + * Use as spacing between data accessed by different lcores,
> > + * to prevent cache thrashing on hardware with speculative prefetching.
> > + */
> > +#define RTE_CACHE_GUARD _RTE_CACHE_GUARD_HELPER1(__COUNTER__)
HELPER1 is required to convert __COUNTER__ to a number before HELPER2 concatenates it to cache_guard_.
If using HELPER2 directly,
#define RTE_CACHE_GUARD _RTE_CACHE_GUARD_HELPER2(__COUNTER__)
would expand to:
char cache_guard___COUNTER__[RTE_CACHE_LINE_SIZE * RTE_CACHE_GUARD_LINES]
__rte_cache_aligned
Which is not unique, and would prevent using RTE_CACHE_GUARD multiple times in the same structure.
prev parent reply other threads:[~2023-10-12 6:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-04 8:43 Morten Brørup
2023-09-04 9:12 ` Bruce Richardson
2023-10-11 15:59 ` Thomas Monjalon
2023-09-05 6:41 ` Morten Brørup
2023-10-11 23:43 ` Thomas Monjalon
2023-10-12 6:00 ` Morten Brørup
2023-10-12 6:07 ` Morten Brørup [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=98CBD80474FA8B44BF855DF32C47DC35E9EF3D@smartserver.smartshare.dk \
--to=mb@smartsharesystems.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=bruce.richardson@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=honnappa.nagarahalli@arm.com \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=mattias.ronnblom@ericsson.com \
--cc=olivier.matz@6wind.com \
--cc=thomas@monjalon.net \
/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).