mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: Brian Gerst <brgerst@gmail.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
	 Ingo Molnar <mingo@kernel.org>,
	"H . Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	 Borislav Petkov <bp@alien8.de>, Ard Biesheuvel <ardb@kernel.org>,
	 Linus Torvalds <torvalds@linuxfoundation.org>,
	Andy Lutomirski <luto@kernel.org>,
	 Peter Zijlstra <peterz@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v2 01/11] percpu: Introduce percpu hot section
Date: Wed, 26 Feb 2025 20:36:00 +0100	[thread overview]
Message-ID: <CAFULd4ZP58hPacGp+n_bBZV0e7nomzLMdX7OOu3DEeGe2OxomA@mail.gmail.com> (raw)
In-Reply-To: <20250226180531.1242429-2-brgerst@gmail.com>

On Wed, Feb 26, 2025 at 7:05 PM Brian Gerst <brgerst@gmail.com> wrote:
>
> Add a subsection to the percpu data for frequently accessed variables
> that should remain cached on each processor.  These varables should not
> be accessed from other processors to avoid cacheline bouncing.
>
> This will replace the pcpu_hot struct on x86, and open up similar
> functionality to other architectures and the kernel core.
>
> Signed-off-by: Brian Gerst <brgerst@gmail.com>
> ---
>  include/asm-generic/vmlinux.lds.h | 10 ++++++++++
>  include/linux/percpu-defs.h       | 12 ++++++++++++
>  2 files changed, 22 insertions(+)
>
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index 92fc06f7da74..92dd6065fd0a 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -385,6 +385,11 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
>         . = ALIGN(PAGE_SIZE);                                           \
>         __nosave_end = .;
>
> +#define CACHE_HOT_DATA(align)                                          \
> +       . = ALIGN(align);                                               \
> +       *(SORT_BY_ALIGNMENT(.data..hot.*))                              \
> +       . = ALIGN(align);
> +
>  #define PAGE_ALIGNED_DATA(page_align)                                  \
>         . = ALIGN(page_align);                                          \
>         *(.data..page_aligned)                                          \
> @@ -1065,6 +1070,10 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
>         . = ALIGN(PAGE_SIZE);                                           \
>         *(.data..percpu..page_aligned)                                  \
>         . = ALIGN(cacheline);                                           \
> +       __per_cpu_hot_start = .;                                        \
> +       *(SORT_BY_ALIGNMENT(.data..percpu..hot.*))                      \
> +       . = ALIGN(cacheline);                                           \
> +       __per_cpu_hot_end = .;                                          \
>         *(.data..percpu..read_mostly)                                   \
>         . = ALIGN(cacheline);                                           \
>         *(.data..percpu)                                                \
> @@ -1112,6 +1121,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
>                 INIT_TASK_DATA(inittask)                                \
>                 NOSAVE_DATA                                             \
>                 PAGE_ALIGNED_DATA(pagealigned)                          \
> +               CACLE_HOT_DATA(cacheline)                               \

There is a typo in the above macro name.

Uros.

>                 CACHELINE_ALIGNED_DATA(cacheline)                       \
>                 READ_MOSTLY_DATA(cacheline)                             \
>                 DATA_DATA                                               \
> diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
> index 40d34e032d5b..eb3393f96e5a 100644
> --- a/include/linux/percpu-defs.h
> +++ b/include/linux/percpu-defs.h
> @@ -112,6 +112,18 @@
>  #define DEFINE_PER_CPU(type, name)                                     \
>         DEFINE_PER_CPU_SECTION(type, name, "")
>
> +/*
> + * Declaration/definition used for per-CPU variables that are frequently
> + * accessed and should be in a single cacheline.
> + *
> + * For use only by architecture and core code.
> + */
> +#define DECLARE_PER_CPU_CACHE_HOT(type, name)                          \
> +       DECLARE_PER_CPU_SECTION(type, name, "..hot.." #name)
> +
> +#define DEFINE_PER_CPU_CACHE_HOT(type, name)                           \
> +       DEFINE_PER_CPU_SECTION(type, name, "..hot.." #name)
> +
>  /*
>   * Declaration/definition used for per-CPU variables that must be cacheline
>   * aligned under SMP conditions so that, whilst a particular instance of the
> --
> 2.48.1
>

  reply	other threads:[~2025-02-26 19:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-26 18:05 [PATCH v2 00/11] Add a percpu subsection for cache hot data Brian Gerst
2025-02-26 18:05 ` [PATCH v2 01/11] percpu: Introduce percpu hot section Brian Gerst
2025-02-26 19:36   ` Uros Bizjak [this message]
2025-02-27  2:09     ` Brian Gerst
2025-02-27 14:16   ` kernel test robot
2025-02-27 19:29   ` kernel test robot
2025-02-26 18:05 ` [PATCH v2 02/11] x86/percpu: Move pcpu_hot to " Brian Gerst
2025-02-26 18:05 ` [PATCH v2 03/11] x86/preempt: Move preempt count " Brian Gerst
2025-02-26 18:05 ` [PATCH v2 04/11] x86/smp: Move cpu number " Brian Gerst
2025-02-26 18:05 ` [PATCH v2 05/11] x86/retbleed: Move call depth " Brian Gerst
2025-02-26 18:05 ` [PATCH v2 06/11] x86/softirq: Move softirq_pending " Brian Gerst
2025-02-26 18:05 ` [PATCH v2 07/11] x86/irq: Move irq stacks " Brian Gerst
2025-02-26 20:25   ` Peter Zijlstra
2025-02-27  0:10     ` Brian Gerst
2025-02-26 18:05 ` [PATCH v2 08/11] x86/percpu: Move top_of_stack " Brian Gerst
2025-02-26 20:08   ` Uros Bizjak
2025-02-27  2:10     ` Brian Gerst
2025-02-26 18:05 ` [PATCH v2 09/11] x86/percpu: Move current_task " Brian Gerst
2025-02-26 18:05 ` [PATCH v2 10/11] x86/stackprotector: Move __stack_chk_guard " Brian Gerst
2025-02-26 18:05 ` [PATCH v2 11/11] x86/smp: Move this_cpu_off " Brian Gerst
2025-02-26 20:23 ` [PATCH v2 00/11] Add a percpu subsection for cache hot data Peter Zijlstra
2025-02-27  1:29   ` Brian Gerst
2025-02-27  1:52     ` Brian Gerst

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=CAFULd4ZP58hPacGp+n_bBZV0e7nomzLMdX7OOu3DEeGe2OxomA@mail.gmail.com \
    --to=ubizjak@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=ardb@kernel.org \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linuxfoundation.org \
    --cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®