lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 27 Dec 2017 20:32:55 +0800
From:   Chao Fan <fanc.fnst@...fujitsu.com>
To:     <linux-kernel@...r.kernel.org>, <gregkh@...uxfoundation.org>
CC:     <bhe@...hat.com>, <tokunaga.keiich@...fujitsu.com>,
        <douly.fnst@...fujitsu.com>
Subject: Re: [RFC PATCH] memory-hotplug: add sysfs immovable_mem attribute

The result in my virtual machine looks like this:
[root@...alhost ~]# cat /sys/devices/system/memory/immovable_mem 
a0000@0,1f300000@...000,1f400000@...00000,1f400000@...00000,1f400000@...00000,1f400000@...00000,1f400000@...00000,4800000@...00000,1ac00000@...000000,1f400000@...c00000,1f400000@...000000,1f400000@...400000

Any comments will be welcome.

Thanks,
Chao Fan

On Wed, Dec 27, 2017 at 08:30:12PM +0800, Chao Fan wrote:
>In sometimes users specify the memory region in immovable node in
>some kernel commandline, such as "kernel_core" or the "immovable_mem="
>in the patchset that I have send. But users don't know the memory
>region. So add this interface to print it.
>
>It will show like this: "nn@ss,nn@ss,...". "nn" means the size of memory
>region, "ss" means the start position of this region.
>
>Signed-off-by: Chao Fan <fanc.fnst@...fujitsu.com>
>---
> drivers/base/memory.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
>
>diff --git a/drivers/base/memory.c b/drivers/base/memory.c
>index 1d60b58a8c19..9cadf1a9dccb 100644
>--- a/drivers/base/memory.c
>+++ b/drivers/base/memory.c
>@@ -25,6 +25,7 @@
> 
> #include <linux/atomic.h>
> #include <linux/uaccess.h>
>+#include <linux/acpi.h>
> 
> static DEFINE_MUTEX(mem_sysfs_mutex);
> 
>@@ -389,6 +390,52 @@ static ssize_t show_phys_device(struct device *dev,
> }
> 
> #ifdef CONFIG_MEMORY_HOTREMOVE
>+/*
>+ * Immovable memory region
>+ */
>+
>+static ssize_t
>+show_immovable_mem(struct device *dev, struct device_attribute *attr,
>+		   char *buf)
>+{
>+	struct acpi_table_header *table_header = NULL;
>+	struct acpi_srat_mem_affinity *ma;
>+	struct acpi_subtable_header *th;
>+	unsigned long long table_size;
>+	unsigned long long table_end;
>+	char pbuf[35], *p = buf;
>+	int len;
>+
>+	acpi_get_table(ACPI_SIG_SRAT, 0, &table_header);
>+
>+	table_size = sizeof(struct acpi_table_srat);
>+	table_end = (unsigned long)table_header + table_header->length;
>+	th = (struct acpi_subtable_header *)((unsigned long)
>+	      table_header + table_size);
>+
>+	while (((unsigned long)th) +
>+	       sizeof(struct acpi_subtable_header) < table_end) {
>+		if (th->type == 1) {
>+			ma = (struct acpi_srat_mem_affinity *)th;
>+			if (ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE)
>+				continue;
>+			len = sprintf(pbuf, "%llx@...x",
>+			       ma->length, ma->base_address);
>+			if (p != buf) {
>+				*p = ',';
>+				p++;
>+			}
>+			memcpy(p, pbuf, len);
>+			p = p + len;
>+		}
>+		th = (struct acpi_subtable_header *)((unsigned long)
>+		      th + th->length);
>+	}
>+	return sprintf(buf, "%s\n", buf);
>+}
>+
>+static DEVICE_ATTR(immovable_mem, 0444, show_immovable_mem, NULL);
>+
> static void print_allowed_zone(char *buf, int nid, unsigned long start_pfn,
> 		unsigned long nr_pages, int online_type,
> 		struct zone *default_zone)
>@@ -798,6 +845,9 @@ static struct attribute *memory_root_attrs[] = {
> #endif
> 
> 	&dev_attr_block_size_bytes.attr,
>+#ifdef CONFIG_MEMORY_HOTREMOVE
>+	&dev_attr_immovable_mem.attr,
>+#endif
> 	&dev_attr_auto_online_blocks.attr,
> 	NULL
> };
>-- 
>2.14.3
>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ