The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2 0/4] arm64: refactor the rodata=xxx
@ 2024-11-26  8:56 Huang Shijie
  2024-11-26  8:56 ` [PATCH v2 1/4] arm64: make rodata=on behaviour be the original rodata=full Huang Shijie
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Huang Shijie @ 2024-11-26  8:56 UTC (permalink / raw)
  To: catalin.marinas, will
  Cc: patches, paulmck, akpm, thuth, rostedt, xiongwei.song, ardb,
	steven.price, suzuki.poulose, mark.rutland, linux-doc,
	linux-kernel, linux-arm-kernel, cl, Huang Shijie

From Documentation/admin-guide/kernel-parameters.txt, we know that:
 rodata=	[KNL,EARLY]
	on	Mark read-only kernel memory as read-only (default).
	off	Leave read-only kernel memory writable for debugging.
	full	Mark read-only kernel memory and aliases as read-only
		[arm64]

So the "rodata=on" is the default.

But the current code does not follow the document, it makes "rodata=full"
as the default.

This patch set follows Will's suggetions:
  - Make our "on" behaviour be what is currently done by "full"
  - Remove RODATA_FULL_DEFAULT_ENABLED
  - Introduce a new option (e.g. "rodata=noalias") which would match the
    current "on" behaviour
  - Update (simplify) the documentation

  https://lists.infradead.org/pipermail/linux-arm-kernel/2024-October/972613.html

v2:
  Follows Will's suggetions.
  Add a new file fine-tuning-tips.rst for the expert users.

v1:
   https://lists.infradead.org/pipermail/linux-arm-kernel/2024-October/971415.html

Huang Shijie (4):
  arm64: make rodata=on behaviour be the original rodata=full
  arm64: remove CONFIG_RODATA_FULL_DEFAULT_ENABLED
  arm64: introduce rodata=noalias
  arm64: add a new document for the fine-tuning tips

 .../admin-guide/kernel-parameters.txt         |  2 +-
 Documentation/arch/arm64/fine-tuning-tips.rst | 23 +++++++++++++++++++
 Documentation/arch/arm64/index.rst            |  1 +
 arch/arm64/Kconfig                            | 14 -----------
 arch/arm64/include/asm/setup.h                |  4 ++--
 arch/arm64/mm/pageattr.c                      |  2 +-
 6 files changed, 28 insertions(+), 18 deletions(-)
 create mode 100644 Documentation/arch/arm64/fine-tuning-tips.rst

-- 
2.40.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 1/4] arm64: make rodata=on behaviour be the original rodata=full
  2024-11-26  8:56 [PATCH v2 0/4] arm64: refactor the rodata=xxx Huang Shijie
@ 2024-11-26  8:56 ` Huang Shijie
  2024-12-06  4:21   ` Anshuman Khandual
  2024-11-26  8:56 ` [PATCH v2 2/4] arm64: remove CONFIG_RODATA_FULL_DEFAULT_ENABLED Huang Shijie
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Huang Shijie @ 2024-11-26  8:56 UTC (permalink / raw)
  To: catalin.marinas, will
  Cc: patches, paulmck, akpm, thuth, rostedt, xiongwei.song, ardb,
	steven.price, suzuki.poulose, mark.rutland, linux-doc,
	linux-kernel, linux-arm-kernel, cl, Huang Shijie

Make rodata=on behaviour be the original rodata=full.
After this patch, the rodata=on will be the default,
and the arm64 kernel behaviour will follow the
Documentation/admin-guide/kernel-parameters.txt:
	rodata=		[KNL,EARLY]
		on	Mark read-only kernel memory as read-only (default).

Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
---
 arch/arm64/include/asm/setup.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/setup.h b/arch/arm64/include/asm/setup.h
index ba269a7a3201..5ded3bd11476 100644
--- a/arch/arm64/include/asm/setup.h
+++ b/arch/arm64/include/asm/setup.h
@@ -21,7 +21,7 @@ static inline bool arch_parse_debug_rodata(char *arg)
 	if (!arg)
 		return false;
 
-	if (!strcmp(arg, "full")) {
+	if (!strcmp(arg, "on")) {
 		rodata_enabled = rodata_full = true;
 		return true;
 	}
@@ -31,7 +31,7 @@ static inline bool arch_parse_debug_rodata(char *arg)
 		return true;
 	}
 
-	if (!strcmp(arg, "on")) {
+	if (!strcmp(arg, "full")) {
 		rodata_enabled = true;
 		rodata_full = false;
 		return true;
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 2/4] arm64: remove CONFIG_RODATA_FULL_DEFAULT_ENABLED
  2024-11-26  8:56 [PATCH v2 0/4] arm64: refactor the rodata=xxx Huang Shijie
  2024-11-26  8:56 ` [PATCH v2 1/4] arm64: make rodata=on behaviour be the original rodata=full Huang Shijie
@ 2024-11-26  8:56 ` Huang Shijie
  2024-12-06  4:40   ` Anshuman Khandual
  2024-11-26  8:56 ` [PATCH v2 3/4] arm64: introduce rodata=noalias Huang Shijie
  2024-11-26  8:56 ` [PATCH v2 4/4] arm64: add a new document for the fine-tuning tips Huang Shijie
  3 siblings, 1 reply; 13+ messages in thread
From: Huang Shijie @ 2024-11-26  8:56 UTC (permalink / raw)
  To: catalin.marinas, will
  Cc: patches, paulmck, akpm, thuth, rostedt, xiongwei.song, ardb,
	steven.price, suzuki.poulose, mark.rutland, linux-doc,
	linux-kernel, linux-arm-kernel, cl, Huang Shijie

The default kernel is rodata=on which means
CONFIG_RODATA_FULL_DEFAULT_ENABLED is always enabled by default.
So we can remove CONFIG_RODATA_FULL_DEFAULT_ENABLED now.

Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
---
 arch/arm64/Kconfig       | 14 --------------
 arch/arm64/mm/pageattr.c |  2 +-
 2 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 4316b1fe8bf8..a9ca305a31d8 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1653,20 +1653,6 @@ config MITIGATE_SPECTRE_BRANCH_HISTORY
 	  When taking an exception from user-space, a sequence of branches
 	  or a firmware call overwrites the branch history.
 
-config RODATA_FULL_DEFAULT_ENABLED
-	bool "Apply r/o permissions of VM areas also to their linear aliases"
-	default y
-	help
-	  Apply read-only attributes of VM areas to the linear alias of
-	  the backing pages as well. This prevents code or read-only data
-	  from being modified (inadvertently or intentionally) via another
-	  mapping of the same memory page. This additional enhancement can
-	  be turned off at runtime by passing rodata=[off|on] (and turned on
-	  with rodata=full if this option is set to 'n')
-
-	  This requires the linear region to be mapped down to pages,
-	  which may adversely affect performance in some cases.
-
 config ARM64_SW_TTBR0_PAN
 	bool "Emulate Privileged Access Never using TTBR0_EL1 switching"
 	depends on !KCSAN
diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c
index 39fd1f7ff02a..6eef08d8451e 100644
--- a/arch/arm64/mm/pageattr.c
+++ b/arch/arm64/mm/pageattr.c
@@ -20,7 +20,7 @@ struct page_change_data {
 	pgprot_t clear_mask;
 };
 
-bool rodata_full __ro_after_init = IS_ENABLED(CONFIG_RODATA_FULL_DEFAULT_ENABLED);
+bool rodata_full __ro_after_init = true;
 
 bool can_set_direct_map(void)
 {
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 3/4] arm64: introduce rodata=noalias
  2024-11-26  8:56 [PATCH v2 0/4] arm64: refactor the rodata=xxx Huang Shijie
  2024-11-26  8:56 ` [PATCH v2 1/4] arm64: make rodata=on behaviour be the original rodata=full Huang Shijie
  2024-11-26  8:56 ` [PATCH v2 2/4] arm64: remove CONFIG_RODATA_FULL_DEFAULT_ENABLED Huang Shijie
@ 2024-11-26  8:56 ` Huang Shijie
  2024-12-06  4:29   ` Anshuman Khandual
  2024-11-26  8:56 ` [PATCH v2 4/4] arm64: add a new document for the fine-tuning tips Huang Shijie
  3 siblings, 1 reply; 13+ messages in thread
From: Huang Shijie @ 2024-11-26  8:56 UTC (permalink / raw)
  To: catalin.marinas, will
  Cc: patches, paulmck, akpm, thuth, rostedt, xiongwei.song, ardb,
	steven.price, suzuki.poulose, mark.rutland, linux-doc,
	linux-kernel, linux-arm-kernel, cl, Huang Shijie

The rodata=noalias is the original rodata=on.

The rodata=noalias can provide us more block mappings and contiguous hits
to map the linear region which minimize the TLB footprint. And the
linear aliases of pages belonging to read-only mappings in vmalloc
region are also marked as read-only.

Also update kernel-parameters.txt for it:
   change "full" to "noalias"

Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
---
 Documentation/admin-guide/kernel-parameters.txt | 2 +-
 arch/arm64/include/asm/setup.h                  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index dc663c0ca670..54b4df42e631 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5894,7 +5894,7 @@
 	rodata=		[KNL,EARLY]
 		on	Mark read-only kernel memory as read-only (default).
 		off	Leave read-only kernel memory writable for debugging.
-		full	Mark read-only kernel memory and aliases as read-only
+		noalias	Use more block mappings,may have better performance.
 		        [arm64]
 
 	rockchip.usb_uart
diff --git a/arch/arm64/include/asm/setup.h b/arch/arm64/include/asm/setup.h
index 5ded3bd11476..3d96dde4d214 100644
--- a/arch/arm64/include/asm/setup.h
+++ b/arch/arm64/include/asm/setup.h
@@ -31,7 +31,7 @@ static inline bool arch_parse_debug_rodata(char *arg)
 		return true;
 	}
 
-	if (!strcmp(arg, "full")) {
+	if (!strcmp(arg, "noalias")) {
 		rodata_enabled = true;
 		rodata_full = false;
 		return true;
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 4/4] arm64: add a new document for the fine-tuning tips
  2024-11-26  8:56 [PATCH v2 0/4] arm64: refactor the rodata=xxx Huang Shijie
                   ` (2 preceding siblings ...)
  2024-11-26  8:56 ` [PATCH v2 3/4] arm64: introduce rodata=noalias Huang Shijie
@ 2024-11-26  8:56 ` Huang Shijie
  2024-12-02 19:19   ` Christoph Lameter
                     ` (2 more replies)
  3 siblings, 3 replies; 13+ messages in thread
From: Huang Shijie @ 2024-11-26  8:56 UTC (permalink / raw)
  To: catalin.marinas, will
  Cc: patches, paulmck, akpm, thuth, rostedt, xiongwei.song, ardb,
	steven.price, suzuki.poulose, mark.rutland, linux-doc,
	linux-kernel, linux-arm-kernel, cl, Huang Shijie

Put some fine-tuning tips in this file:
	1.) rodata=noalias
	2.) slab_strict_numa
	3.) CONFIG_SCHED_CLUSTER

We can add more tips in future.

Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
---
 Documentation/arch/arm64/fine-tuning-tips.rst | 23 +++++++++++++++++++
 Documentation/arch/arm64/index.rst            |  1 +
 2 files changed, 24 insertions(+)
 create mode 100644 Documentation/arch/arm64/fine-tuning-tips.rst

diff --git a/Documentation/arch/arm64/fine-tuning-tips.rst b/Documentation/arch/arm64/fine-tuning-tips.rst
new file mode 100644
index 000000000000..70ef1cef92fb
--- /dev/null
+++ b/Documentation/arch/arm64/fine-tuning-tips.rst
@@ -0,0 +1,23 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+================
+fine-tuning tips
+================
+
+This file contains some fine-tuning tips for arm64 machines.
+These tips do not gurantee that you can get better performance,
+but you can try them with your workload.
+
+rodata=noalias
+----------------
+It can provide us more block mappings and contiguous hits
+to map the linear region which minimizes the TLB footprint.
+
+slab_strict_numa
+----------------
+In NUMA, it will provide the local memory allocation by SLUB.
+
+CONFIG_SCHED_CLUSTER
+----------------
+Some arm64 machines have cpu core cluster, enable it may
+helps you get better performance.
diff --git a/Documentation/arch/arm64/index.rst b/Documentation/arch/arm64/index.rst
index 6a012c98bdcd..36d1ef09bd71 100644
--- a/Documentation/arch/arm64/index.rst
+++ b/Documentation/arch/arm64/index.rst
@@ -16,6 +16,7 @@ ARM64 Architecture
     cpu-feature-registers
     cpu-hotplug
     elf_hwcaps
+    fine-tuning-tips
     gcs
     hugetlbpage
     kdump
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 4/4] arm64: add a new document for the fine-tuning tips
  2024-11-26  8:56 ` [PATCH v2 4/4] arm64: add a new document for the fine-tuning tips Huang Shijie
@ 2024-12-02 19:19   ` Christoph Lameter
  2024-12-06  3:23   ` [PATCH v2 4/4 fix] " Huang Shijie
  2024-12-06  3:56   ` [PATCH v2 4/4] " Anshuman Khandual
  2 siblings, 0 replies; 13+ messages in thread
From: Christoph Lameter @ 2024-12-02 19:19 UTC (permalink / raw)
  To: Huang Shijie
  Cc: catalin.marinas, will, patches, paulmck, akpm, thuth, rostedt,
	xiongwei.song, ardb, steven.price, suzuki.poulose, mark.rutland,
	linux-doc, linux-kernel, linux-arm-kernel

On Tue, 26 Nov 2024, Huang Shijie wrote:

> +slab_strict_numa
> +----------------
> +In NUMA, it will provide the local memory allocation by SLUB.

"Slab objects will be placed individually according to memory policies. 
Increases object locality which is useful for NUMA systems using SLC 
caches"

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 4/4 fix] arm64: add a new document for the fine-tuning tips
  2024-11-26  8:56 ` [PATCH v2 4/4] arm64: add a new document for the fine-tuning tips Huang Shijie
  2024-12-02 19:19   ` Christoph Lameter
@ 2024-12-06  3:23   ` Huang Shijie
  2024-12-06  3:56   ` [PATCH v2 4/4] " Anshuman Khandual
  2 siblings, 0 replies; 13+ messages in thread
From: Huang Shijie @ 2024-12-06  3:23 UTC (permalink / raw)
  To: catalin.marinas, will
  Cc: patches, cl, paulmck, akpm, thuth, rostedt, xiongwei.song, ardb,
	steven.price, suzuki.poulose, mark.rutland, linux-doc,
	linux-kernel, linux-arm-kernel, Huang Shijie

Put some fine-tuning tips in this file:
	1.) rodata=noalias
	2.) slab_strict_numa
	3.) CONFIG_SCHED_CLUSTER

We can add more tips in future.

Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
---
Add the comment from Christoph.
---
 Documentation/arch/arm64/fine-tuning-tips.rst | 25 +++++++++++++++++++
 Documentation/arch/arm64/index.rst            |  1 +
 2 files changed, 26 insertions(+)
 create mode 100644 Documentation/arch/arm64/fine-tuning-tips.rst

diff --git a/Documentation/arch/arm64/fine-tuning-tips.rst b/Documentation/arch/arm64/fine-tuning-tips.rst
new file mode 100644
index 000000000000..df67a5ac87b9
--- /dev/null
+++ b/Documentation/arch/arm64/fine-tuning-tips.rst
@@ -0,0 +1,25 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+================
+fine-tuning tips
+================
+
+This file contains some fine-tuning tips for arm64 machines.
+These tips do not gurantee that you can get better performance,
+but you can try them with your workload.
+
+rodata=noalias
+----------------
+It can provide us more block mappings and contiguous hits
+to map the linear region which minimizes the TLB footprint.
+
+slab_strict_numa
+----------------
+In NUMA, it will provide the local memory allocation by SLUB.
+Slab objects will be placed individually according to memory policies.
+Increases object locality which is useful for NUMA systems using SLC caches.
+
+CONFIG_SCHED_CLUSTER
+----------------
+Some arm64 machines have cpu core clusters, enable it may
+helps you get better performance.
diff --git a/Documentation/arch/arm64/index.rst b/Documentation/arch/arm64/index.rst
index 6a012c98bdcd..36d1ef09bd71 100644
--- a/Documentation/arch/arm64/index.rst
+++ b/Documentation/arch/arm64/index.rst
@@ -16,6 +16,7 @@ ARM64 Architecture
     cpu-feature-registers
     cpu-hotplug
     elf_hwcaps
+    fine-tuning-tips
     gcs
     hugetlbpage
     kdump
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 4/4] arm64: add a new document for the fine-tuning tips
  2024-11-26  8:56 ` [PATCH v2 4/4] arm64: add a new document for the fine-tuning tips Huang Shijie
  2024-12-02 19:19   ` Christoph Lameter
  2024-12-06  3:23   ` [PATCH v2 4/4 fix] " Huang Shijie
@ 2024-12-06  3:56   ` Anshuman Khandual
  2024-12-06  6:14     ` Shijie Huang
  2 siblings, 1 reply; 13+ messages in thread
From: Anshuman Khandual @ 2024-12-06  3:56 UTC (permalink / raw)
  To: Huang Shijie, catalin.marinas, will
  Cc: patches, paulmck, akpm, thuth, rostedt, xiongwei.song, ardb,
	steven.price, suzuki.poulose, mark.rutland, linux-doc,
	linux-kernel, linux-arm-kernel, cl

On 11/26/24 14:26, Huang Shijie wrote:
> Put some fine-tuning tips in this file:
> 	1.) rodata=noalias
> 	2.) slab_strict_numa
> 	3.) CONFIG_SCHED_CLUSTER
> 
> We can add more tips in future.
> 
> Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
> ---
>  Documentation/arch/arm64/fine-tuning-tips.rst | 23 +++++++++++++++++++
>  Documentation/arch/arm64/index.rst            |  1 +
>  2 files changed, 24 insertions(+)
>  create mode 100644 Documentation/arch/arm64/fine-tuning-tips.rst
> 
> diff --git a/Documentation/arch/arm64/fine-tuning-tips.rst b/Documentation/arch/arm64/fine-tuning-tips.rst
> new file mode 100644
> index 000000000000..70ef1cef92fb
> --- /dev/null
> +++ b/Documentation/arch/arm64/fine-tuning-tips.rst
> @@ -0,0 +1,23 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +================
> +fine-tuning tips
> +================
> +
> +This file contains some fine-tuning tips for arm64 machines.
> +These tips do not gurantee that you can get better performance,
> +but you can try them with your workload.
> +
> +rodata=noalias
> +----------------
> +It can provide us more block mappings and contiguous hits
> +to map the linear region which minimizes the TLB footprint.
> +
> +slab_strict_numa
> +----------------
> +In NUMA, it will provide the local memory allocation by SLUB.
> +
> +CONFIG_SCHED_CLUSTER
> +----------------
> +Some arm64 machines have cpu core cluster, enable it may
> +helps you get better performance.
> diff --git a/Documentation/arch/arm64/index.rst b/Documentation/arch/arm64/index.rst
> index 6a012c98bdcd..36d1ef09bd71 100644
> --- a/Documentation/arch/arm64/index.rst
> +++ b/Documentation/arch/arm64/index.rst
> @@ -16,6 +16,7 @@ ARM64 Architecture
>      cpu-feature-registers
>      cpu-hotplug
>      elf_hwcaps
> +    fine-tuning-tips
>      gcs
>      hugetlbpage
>      kdump
Although the idea for such a file makes sense, to help system admins
tune the kernel command line for required behaviour, I am concerned
about the overall structure and scope for such a document. Should it
contain tips regarding all the subsystems on the platform, till what
extent these details should be described in there and then there are
so many aspects for a required behaviour etc ?

Besides maintaining such a document might also be very difficult as
well given how implementations will change over time thus requiring
different tuning etc. Hence kernel source might not be a place for
such a document.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 1/4] arm64: make rodata=on behaviour be the original rodata=full
  2024-11-26  8:56 ` [PATCH v2 1/4] arm64: make rodata=on behaviour be the original rodata=full Huang Shijie
@ 2024-12-06  4:21   ` Anshuman Khandual
  0 siblings, 0 replies; 13+ messages in thread
From: Anshuman Khandual @ 2024-12-06  4:21 UTC (permalink / raw)
  To: Huang Shijie, catalin.marinas, will
  Cc: patches, paulmck, akpm, thuth, rostedt, xiongwei.song, ardb,
	steven.price, suzuki.poulose, mark.rutland, linux-doc,
	linux-kernel, linux-arm-kernel, cl



On 11/26/24 14:26, Huang Shijie wrote:
> Make rodata=on behaviour be the original rodata=full.
> After this patch, the rodata=on will be the default,
> and the arm64 kernel behaviour will follow the
> Documentation/admin-guide/kernel-parameters.txt:
> 	rodata=		[KNL,EARLY]
> 		on	Mark read-only kernel memory as read-only (default).
> 
> Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
> ---
>  arch/arm64/include/asm/setup.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/setup.h b/arch/arm64/include/asm/setup.h
> index ba269a7a3201..5ded3bd11476 100644
> --- a/arch/arm64/include/asm/setup.h
> +++ b/arch/arm64/include/asm/setup.h
> @@ -21,7 +21,7 @@ static inline bool arch_parse_debug_rodata(char *arg)
>  	if (!arg)
>  		return false;
>  
> -	if (!strcmp(arg, "full")) {
> +	if (!strcmp(arg, "on")) {
>  		rodata_enabled = rodata_full = true;
>  		return true;
>  	}
> @@ -31,7 +31,7 @@ static inline bool arch_parse_debug_rodata(char *arg)
>  		return true;
>  	}
>  
> -	if (!strcmp(arg, "on")) {
> +	if (!strcmp(arg, "full")) {
>  		rodata_enabled = true;
>  		rodata_full = false;
>  		return true;

After this patch we have the following and seems like 'rodata=full'
is temporarily broken until the subsequent patches come in ?

static inline bool arch_parse_debug_rodata(char *arg)
{
        extern bool rodata_enabled;
        extern bool rodata_full;

        if (!arg)
                return false;

        if (!strcmp(arg, "on")) {
                rodata_enabled = rodata_full = true;
                return true;
        }

        if (!strcmp(arg, "off")) {
                rodata_enabled = rodata_full = false;
                return true;
        }

        if (!strcmp(arg, "full")) {
                rodata_enabled = true;
                rodata_full = false;     <---------------- here
                return true;
        }

        return false;
}

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 3/4] arm64: introduce rodata=noalias
  2024-11-26  8:56 ` [PATCH v2 3/4] arm64: introduce rodata=noalias Huang Shijie
@ 2024-12-06  4:29   ` Anshuman Khandual
  2024-12-06  5:50     ` Shijie Huang
  0 siblings, 1 reply; 13+ messages in thread
From: Anshuman Khandual @ 2024-12-06  4:29 UTC (permalink / raw)
  To: Huang Shijie, catalin.marinas, will
  Cc: patches, paulmck, akpm, thuth, rostedt, xiongwei.song, ardb,
	steven.price, suzuki.poulose, mark.rutland, linux-doc,
	linux-kernel, linux-arm-kernel, cl



On 11/26/24 14:26, Huang Shijie wrote:
> The rodata=noalias is the original rodata=on.
> 
> The rodata=noalias can provide us more block mappings and contiguous hits
> to map the linear region which minimize the TLB footprint. And the
> linear aliases of pages belonging to read-only mappings in vmalloc
> region are also marked as read-only.
> 
> Also update kernel-parameters.txt for it:
>    change "full" to "noalias"
> 
> Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
> ---
>  Documentation/admin-guide/kernel-parameters.txt | 2 +-
>  arch/arm64/include/asm/setup.h                  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index dc663c0ca670..54b4df42e631 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -5894,7 +5894,7 @@
>  	rodata=		[KNL,EARLY]
>  		on	Mark read-only kernel memory as read-only (default).
>  		off	Leave read-only kernel memory writable for debugging.
> -		full	Mark read-only kernel memory and aliases as read-only
> +		noalias	Use more block mappings,may have better performance.
>  		        [arm64]
>  
>  	rockchip.usb_uart
> diff --git a/arch/arm64/include/asm/setup.h b/arch/arm64/include/asm/setup.h
> index 5ded3bd11476..3d96dde4d214 100644
> --- a/arch/arm64/include/asm/setup.h
> +++ b/arch/arm64/include/asm/setup.h
> @@ -31,7 +31,7 @@ static inline bool arch_parse_debug_rodata(char *arg)
>  		return true;
>  	}
>  
> -	if (!strcmp(arg, "full")) {
> +	if (!strcmp(arg, "noalias")) {
>  		rodata_enabled = true;
>  		rodata_full = false;
>  		return true;

This patch should be folded back into [PATCH 1/4] ensuring that

- "rodata=" processing gets updated completely i.e dropping 'full',
  adding new 'noalias' and also updating the documentation at once

- Avoids temporary the "full" option breakage as mentioned earlier

Also please do add in code comment above arch_parse_debug_rodata()
function explaining all the options after these update.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 2/4] arm64: remove CONFIG_RODATA_FULL_DEFAULT_ENABLED
  2024-11-26  8:56 ` [PATCH v2 2/4] arm64: remove CONFIG_RODATA_FULL_DEFAULT_ENABLED Huang Shijie
@ 2024-12-06  4:40   ` Anshuman Khandual
  0 siblings, 0 replies; 13+ messages in thread
From: Anshuman Khandual @ 2024-12-06  4:40 UTC (permalink / raw)
  To: Huang Shijie, catalin.marinas, will
  Cc: patches, paulmck, akpm, thuth, rostedt, xiongwei.song, ardb,
	steven.price, suzuki.poulose, mark.rutland, linux-doc,
	linux-kernel, linux-arm-kernel, cl

On 11/26/24 14:26, Huang Shijie wrote:
> The default kernel is rodata=on which means

Right but this is true only after the update in the series.

        if (!strcmp(arg, "on")) {
                rodata_enabled = rodata_full = true;
                return true;
        }

rodata_full is always "true" via 'rodata=on' and does not depend
on the config RODATA_FULL_DEFAULT_ENABLED anymore, so it can be
dropped. Please update this commit message with these context as
well.

> CONFIG_RODATA_FULL_DEFAULT_ENABLED is always enabled by default.
> So we can remove CONFIG_RODATA_FULL_DEFAULT_ENABLED now.
> 
> Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
> ---
>  arch/arm64/Kconfig       | 14 --------------
>  arch/arm64/mm/pageattr.c |  2 +-
>  2 files changed, 1 insertion(+), 15 deletions(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 4316b1fe8bf8..a9ca305a31d8 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -1653,20 +1653,6 @@ config MITIGATE_SPECTRE_BRANCH_HISTORY
>  	  When taking an exception from user-space, a sequence of branches
>  	  or a firmware call overwrites the branch history.
>  
> -config RODATA_FULL_DEFAULT_ENABLED
> -	bool "Apply r/o permissions of VM areas also to their linear aliases"
> -	default y
> -	help
> -	  Apply read-only attributes of VM areas to the linear alias of
> -	  the backing pages as well. This prevents code or read-only data
> -	  from being modified (inadvertently or intentionally) via another
> -	  mapping of the same memory page. This additional enhancement can
> -	  be turned off at runtime by passing rodata=[off|on] (and turned on
> -	  with rodata=full if this option is set to 'n')
> -
> -	  This requires the linear region to be mapped down to pages,
> -	  which may adversely affect performance in some cases.
> -
>  config ARM64_SW_TTBR0_PAN
>  	bool "Emulate Privileged Access Never using TTBR0_EL1 switching"
>  	depends on !KCSAN
> diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c
> index 39fd1f7ff02a..6eef08d8451e 100644
> --- a/arch/arm64/mm/pageattr.c
> +++ b/arch/arm64/mm/pageattr.c
> @@ -20,7 +20,7 @@ struct page_change_data {
>  	pgprot_t clear_mask;
>  };
>  
> -bool rodata_full __ro_after_init = IS_ENABLED(CONFIG_RODATA_FULL_DEFAULT_ENABLED);
> +bool rodata_full __ro_after_init = true;
>  
>  bool can_set_direct_map(void)
>  {

This patch can still follow the first one but after folding in the
third patch.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 3/4] arm64: introduce rodata=noalias
  2024-12-06  4:29   ` Anshuman Khandual
@ 2024-12-06  5:50     ` Shijie Huang
  0 siblings, 0 replies; 13+ messages in thread
From: Shijie Huang @ 2024-12-06  5:50 UTC (permalink / raw)
  To: Anshuman Khandual, Huang Shijie, catalin.marinas, will
  Cc: patches, paulmck, akpm, thuth, rostedt, xiongwei.song, ardb,
	steven.price, suzuki.poulose, mark.rutland, linux-doc,
	linux-kernel, linux-arm-kernel, cl


On 2024/12/6 12:29, Anshuman Khandual wrote:
>
> On 11/26/24 14:26, Huang Shijie wrote:
>> The rodata=noalias is the original rodata=on.
>>
>> The rodata=noalias can provide us more block mappings and contiguous hits
>> to map the linear region which minimize the TLB footprint. And the
>> linear aliases of pages belonging to read-only mappings in vmalloc
>> region are also marked as read-only.
>>
>> Also update kernel-parameters.txt for it:
>>     change "full" to "noalias"
>>
>> Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
>> ---
>>   Documentation/admin-guide/kernel-parameters.txt | 2 +-
>>   arch/arm64/include/asm/setup.h                  | 2 +-
>>   2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
>> index dc663c0ca670..54b4df42e631 100644
>> --- a/Documentation/admin-guide/kernel-parameters.txt
>> +++ b/Documentation/admin-guide/kernel-parameters.txt
>> @@ -5894,7 +5894,7 @@
>>   	rodata=		[KNL,EARLY]
>>   		on	Mark read-only kernel memory as read-only (default).
>>   		off	Leave read-only kernel memory writable for debugging.
>> -		full	Mark read-only kernel memory and aliases as read-only
>> +		noalias	Use more block mappings,may have better performance.
>>   		        [arm64]
>>   
>>   	rockchip.usb_uart
>> diff --git a/arch/arm64/include/asm/setup.h b/arch/arm64/include/asm/setup.h
>> index 5ded3bd11476..3d96dde4d214 100644
>> --- a/arch/arm64/include/asm/setup.h
>> +++ b/arch/arm64/include/asm/setup.h
>> @@ -31,7 +31,7 @@ static inline bool arch_parse_debug_rodata(char *arg)
>>   		return true;
>>   	}
>>   
>> -	if (!strcmp(arg, "full")) {
>> +	if (!strcmp(arg, "noalias")) {
>>   		rodata_enabled = true;
>>   		rodata_full = false;
>>   		return true;
> This patch should be folded back into [PATCH 1/4] ensuring that
Thanks, I will do it in next version.
>
> - "rodata=" processing gets updated completely i.e dropping 'full',
>    adding new 'noalias' and also updating the documentation at once
>
> - Avoids temporary the "full" option breakage as mentioned earlier
>
> Also please do add in code comment above arch_parse_debug_rodata()
> function explaining all the options after these update.

No problem.


Thanks

Huang Shijie


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 4/4] arm64: add a new document for the fine-tuning tips
  2024-12-06  3:56   ` [PATCH v2 4/4] " Anshuman Khandual
@ 2024-12-06  6:14     ` Shijie Huang
  0 siblings, 0 replies; 13+ messages in thread
From: Shijie Huang @ 2024-12-06  6:14 UTC (permalink / raw)
  To: Anshuman Khandual, Huang Shijie, catalin.marinas, will
  Cc: patches, paulmck, akpm, thuth, rostedt, xiongwei.song, ardb,
	steven.price, suzuki.poulose, mark.rutland, linux-doc,
	linux-kernel, linux-arm-kernel, cl


On 2024/12/6 11:56, Anshuman Khandual wrote:
> On 11/26/24 14:26, Huang Shijie wrote:
>> Put some fine-tuning tips in this file:
>> 	1.) rodata=noalias
>> 	2.) slab_strict_numa
>> 	3.) CONFIG_SCHED_CLUSTER
>>
>> We can add more tips in future.
>>
>> Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
>> ---
>>   Documentation/arch/arm64/fine-tuning-tips.rst | 23 +++++++++++++++++++
>>   Documentation/arch/arm64/index.rst            |  1 +
>>   2 files changed, 24 insertions(+)
>>   create mode 100644 Documentation/arch/arm64/fine-tuning-tips.rst
>>
>> diff --git a/Documentation/arch/arm64/fine-tuning-tips.rst b/Documentation/arch/arm64/fine-tuning-tips.rst
>> new file mode 100644
>> index 000000000000..70ef1cef92fb
>> --- /dev/null
>> +++ b/Documentation/arch/arm64/fine-tuning-tips.rst
>> @@ -0,0 +1,23 @@
>> +.. SPDX-License-Identifier: GPL-2.0
>> +
>> +================
>> +fine-tuning tips
>> +================
>> +
>> +This file contains some fine-tuning tips for arm64 machines.
>> +These tips do not gurantee that you can get better performance,
>> +but you can try them with your workload.
>> +
>> +rodata=noalias
>> +----------------
>> +It can provide us more block mappings and contiguous hits
>> +to map the linear region which minimizes the TLB footprint.
>> +
>> +slab_strict_numa
>> +----------------
>> +In NUMA, it will provide the local memory allocation by SLUB.
>> +
>> +CONFIG_SCHED_CLUSTER
>> +----------------
>> +Some arm64 machines have cpu core cluster, enable it may
>> +helps you get better performance.
>> diff --git a/Documentation/arch/arm64/index.rst b/Documentation/arch/arm64/index.rst
>> index 6a012c98bdcd..36d1ef09bd71 100644
>> --- a/Documentation/arch/arm64/index.rst
>> +++ b/Documentation/arch/arm64/index.rst
>> @@ -16,6 +16,7 @@ ARM64 Architecture
>>       cpu-feature-registers
>>       cpu-hotplug
>>       elf_hwcaps
>> +    fine-tuning-tips
>>       gcs
>>       hugetlbpage
>>       kdump
> Although the idea for such a file makes sense, to help system admins
> tune the kernel command line for required behaviour, I am concerned
This file also contains the CONFIG_SCHED_CLUSTER which is not a kernel 
command line.
> about the overall structure and scope for such a document. Should it
> contain tips regarding all the subsystems on the platform, till what
> extent these details should be described in there and then there are
> so many aspects for a required behaviour etc ?

My original thought is to let this file contains the tips only works in 
arm64.

All the tips which _may_ make the arm64 machines get better performance 
can be

recorded here.

Then the arm64 kernel engineers(the newbies) can follow this file, and 
ramp up

quickly.


>
> Besides maintaining such a document might also be very difficult as
> well given how implementations will change over time thus requiring
> different tuning etc. Hence kernel source might not be a place for
> such a document.

okay. If the kernel source is not the right place, I can remove this 
patch in next version.


Thanks

Huang Shijie


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-12-06  6:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-26  8:56 [PATCH v2 0/4] arm64: refactor the rodata=xxx Huang Shijie
2024-11-26  8:56 ` [PATCH v2 1/4] arm64: make rodata=on behaviour be the original rodata=full Huang Shijie
2024-12-06  4:21   ` Anshuman Khandual
2024-11-26  8:56 ` [PATCH v2 2/4] arm64: remove CONFIG_RODATA_FULL_DEFAULT_ENABLED Huang Shijie
2024-12-06  4:40   ` Anshuman Khandual
2024-11-26  8:56 ` [PATCH v2 3/4] arm64: introduce rodata=noalias Huang Shijie
2024-12-06  4:29   ` Anshuman Khandual
2024-12-06  5:50     ` Shijie Huang
2024-11-26  8:56 ` [PATCH v2 4/4] arm64: add a new document for the fine-tuning tips Huang Shijie
2024-12-02 19:19   ` Christoph Lameter
2024-12-06  3:23   ` [PATCH v2 4/4 fix] " Huang Shijie
2024-12-06  3:56   ` [PATCH v2 4/4] " Anshuman Khandual
2024-12-06  6:14     ` Shijie Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox