* [PATCH 0/3] lsmem/chmem: add memory zone awareness
@ 2017-09-27 17:44 Gerald Schaefer
2017-09-27 17:44 ` [PATCH 1/3] " Gerald Schaefer
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: Gerald Schaefer @ 2017-09-27 17:44 UTC (permalink / raw)
To: util-linux, Karel Zak
Cc: Michal Hocko, linux-mm, Heiko Carstens, Andre Wild, Gerald Schaefer
These patches are against lsmem/chmem in util-linux, they add support
for listing and changing memory zone allocation.
Added Michal Hocko and linux-mm on cc, to raise general awareness for
the lsmem/chmem tools, and the new memory zone functionality in
particular. I think this can be quite useful for memory hotplug kernel
development, and if not, sorry for the noise.
Andre Wild (1):
lsmem/chmem: add memory zone awareness to bash-completion
Gerald Schaefer (2):
lsmem/chmem: add memory zone awareness
tests/lsmem: update lsmem test with ZONES column
bash-completion/chmem | 1 +
bash-completion/lsmem | 2 +-
sys-utils/chmem.8 | 19 +++++
sys-utils/chmem.c | 136 +++++++++++++++++++++++++++++++--
sys-utils/lsmem.1 | 4 +-
sys-utils/lsmem.c | 98 +++++++++++++++++++++++-
tests/expected/lsmem/lsmem-s390-zvm-6g | 21 +++++
tests/expected/lsmem/lsmem-x86_64-16g | 39 ++++++++++
tests/ts/lsmem/lsmem | 1 +
9 files changed, 309 insertions(+), 12 deletions(-)
--
2.13.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/3] lsmem/chmem: add memory zone awareness
2017-09-27 17:44 [PATCH 0/3] lsmem/chmem: add memory zone awareness Gerald Schaefer
@ 2017-09-27 17:44 ` Gerald Schaefer
2017-09-27 17:44 ` [PATCH 2/3] tests/lsmem: update lsmem test with ZONES column Gerald Schaefer
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Gerald Schaefer @ 2017-09-27 17:44 UTC (permalink / raw)
To: util-linux, Karel Zak
Cc: Michal Hocko, linux-mm, Heiko Carstens, Andre Wild, Gerald Schaefer
With this patch, valid memory zones can be shown with lsmem, and chmem can
set memory online/offline in a specific memory zone, if allowed by the
kernel. The valid memory zones are read from the "valid_zones" sysfs
attribute, and setting memory online to a specific zone is done by
echoing "online_kernel" or "online_movable" to the "state" sysfs
attribute, in addition to the previous "online".
This patch also changes the default behavior of chmem, when setting memory
online without specifying a memory zone. If valid, memory will be set
online to the zone Movable. This zone is preferable for memory hotplug, as
it makes memory offline much more likely to succeed.
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
---
sys-utils/chmem.8 | 19 ++++++++
sys-utils/chmem.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++----
sys-utils/lsmem.1 | 4 +-
sys-utils/lsmem.c | 98 ++++++++++++++++++++++++++++++++++++++-
4 files changed, 246 insertions(+), 11 deletions(-)
diff --git a/sys-utils/chmem.8 b/sys-utils/chmem.8
index a116bc9e7a4b..dae7413d4899 100644
--- a/sys-utils/chmem.8
+++ b/sys-utils/chmem.8
@@ -5,6 +5,7 @@ chmem \- configure memory
.B chmem
.RB [ \-h "] [" \-V "] [" \-v "] [" \-e | \-d "]"
[\fISIZE\fP|\fIRANGE\fP|\fB\-b\fP \fIBLOCKRANGE\fP]
+[-z ZONE]
.SH DESCRIPTION
The chmem command sets a particular size or range of memory online or offline.
.
@@ -25,6 +26,19 @@ and <last> is the number of the last memory block in the memory
range. Alternatively a single block can be specified. \fIBLOCKRANGE\fP requires
the \fB--blocks\fP option.
.
+.IP "\(hy" 2
+Specify \fIZONE\fP as the name of a memory zone, as shown in the output of the
+\fBlsmem -o +ZONES\fP command. The output shows one or more valid memory zones
+for each memory range. If multiple zones are shown, then the memory range
+currently belongs to the first zone. By default, chmem will set memory online
+to the zone Movable, if this is among the valid zones. This default can be
+changed by specifying the \fB--zone\fP option with another valid zone.
+For memory ballooning, it is recommended to select the zone Movable for memory
+online and offline, if possible. Memory in this zone is much more likely to be
+able to be offlined again, but it cannot be used for arbitrary kernel
+allocations, only for migratable pages (e.g. anonymous and page cache pages).
+Use the \fB\-\-help\fR option to see all available zones.
+.
.PP
\fISIZE\fP and \fIRANGE\fP must be aligned to the Linux memory block size, as
shown in the output of the \fBlsmem\fP command.
@@ -51,6 +65,11 @@ Set the specified \fIRANGE\fP, \fISIZE\fP, or \fIBLOCKRANGE\fP of memory offline
.BR \-e ", " \-\-enable
Set the specified \fIRANGE\fP, \fISIZE\fP, or \fIBLOCKRANGE\fP of memory online.
.TP
+.BR \-z ", " \-\-zone
+Select the memory \fIZONE\fP where to set the specified \fIRANGE\fP, \fISIZE\fP,
+or \fIBLOCKRANGE\fP of memory online or offline. By default, memory will be set
+online to the zone Movable, if possible.
+.TP
.BR \-h ", " \-\-help
Print a short help text, then exit.
.TP
diff --git a/sys-utils/chmem.c b/sys-utils/chmem.c
index d9bc95cc191a..2f0680de8750 100644
--- a/sys-utils/chmem.c
+++ b/sys-utils/chmem.c
@@ -49,6 +49,7 @@ struct chmem_desc {
unsigned int use_blocks : 1;
unsigned int is_size : 1;
unsigned int verbose : 1;
+ unsigned int have_zones : 1;
};
enum {
@@ -57,6 +58,38 @@ enum {
CMD_NONE
};
+enum zone_id {
+ ZONE_DMA = 0,
+ ZONE_DMA32,
+ ZONE_NORMAL,
+ ZONE_HIGHMEM,
+ ZONE_MOVABLE,
+ ZONE_DEVICE,
+};
+
+static char *zone_names[] = {
+ [ZONE_DMA] = "DMA",
+ [ZONE_DMA32] = "DMA32",
+ [ZONE_NORMAL] = "Normal",
+ [ZONE_HIGHMEM] = "Highmem",
+ [ZONE_MOVABLE] = "Movable",
+ [ZONE_DEVICE] = "Device",
+};
+
+/*
+ * name must be null-terminated
+ */
+static int zone_name_to_id(const char *name)
+{
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(zone_names); i++) {
+ if (!strcasecmp(name, zone_names[i]))
+ return i;
+ }
+ return -1;
+}
+
static void idxtostr(struct chmem_desc *desc, uint64_t idx, char *buf, size_t bufsz)
{
uint64_t start, end;
@@ -68,22 +101,49 @@ static void idxtostr(struct chmem_desc *desc, uint64_t idx, char *buf, size_t bu
idx, start, end);
}
-static int chmem_size(struct chmem_desc *desc, int enable)
+static int chmem_size(struct chmem_desc *desc, int enable, int zone_id)
{
char *name, *onoff, line[BUFSIZ], str[BUFSIZ];
uint64_t size, index;
+ const char *zn;
int i, rc;
size = desc->size;
onoff = enable ? "online" : "offline";
i = enable ? 0 : desc->ndirs - 1;
+ if (enable && zone_id >= 0) {
+ if (zone_id == ZONE_MOVABLE)
+ onoff = "online_movable";
+ else
+ onoff = "online_kernel";
+ }
+
for (; i >= 0 && i < desc->ndirs && size; i += enable ? 1 : -1) {
name = desc->dirs[i]->d_name;
index = strtou64_or_err(name + 6, _("Failed to parse index"));
path_read_str(line, sizeof(line), _PATH_SYS_MEMORY "/%s/state", name);
- if (strcmp(onoff, line) == 0)
+ if (strncmp(onoff, line, 6) == 0)
continue;
+
+ if (desc->have_zones) {
+ path_read_str(line, sizeof(line),
+ _PATH_SYS_MEMORY "/%s/valid_zones", name);
+ if (zone_id >= 0) {
+ zn = zone_names[zone_id];
+ if (enable && !strcasestr(line, zn))
+ continue;
+ if (!enable && strncasecmp(line, zn, strlen(zn)))
+ continue;
+ } else if (enable) {
+ /* By default, use zone Movable for online, if valid */
+ if (strcasestr(line, zone_names[ZONE_MOVABLE]))
+ onoff = "online_movable";
+ else
+ onoff = "online";
+ }
+ }
+
idxtostr(desc, index, str, sizeof(str));
rc = path_write_str(onoff, _PATH_SYS_MEMORY"/%s/state", name);
if (rc == -1 && desc->verbose) {
@@ -115,15 +175,23 @@ static int chmem_size(struct chmem_desc *desc, int enable)
return size == 0 ? 0 : size == desc->size ? -1 : 1;
}
-static int chmem_range(struct chmem_desc *desc, int enable)
+static int chmem_range(struct chmem_desc *desc, int enable, int zone_id)
{
char *name, *onoff, line[BUFSIZ], str[BUFSIZ];
uint64_t index, todo;
+ const char *zn;
int i, rc;
todo = desc->end - desc->start + 1;
onoff = enable ? "online" : "offline";
+ if (enable && zone_id >= 0) {
+ if (zone_id == ZONE_MOVABLE)
+ onoff = "online_movable";
+ else
+ onoff = "online_kernel";
+ }
+
for (i = 0; i < desc->ndirs; i++) {
name = desc->dirs[i]->d_name;
index = strtou64_or_err(name + 6, _("Failed to parse index"));
@@ -133,7 +201,7 @@ static int chmem_range(struct chmem_desc *desc, int enable)
break;
idxtostr(desc, index, str, sizeof(str));
path_read_str(line, sizeof(line), _PATH_SYS_MEMORY "/%s/state", name);
- if (strcmp(onoff, line) == 0) {
+ if (strncmp(onoff, line, 6) == 0) {
if (desc->verbose && enable)
fprintf(stdout, _("%s already enabled\n"), str);
else if (desc->verbose && !enable)
@@ -141,6 +209,29 @@ static int chmem_range(struct chmem_desc *desc, int enable)
todo--;
continue;
}
+
+ if (desc->have_zones) {
+ path_read_str(line, sizeof(line),
+ _PATH_SYS_MEMORY "/%s/valid_zones", name);
+ if (zone_id >= 0) {
+ zn = zone_names[zone_id];
+ if (enable && !strcasestr(line, zn)) {
+ warnx(_("%s enable failed: Zone mismatch"), str);
+ continue;
+ }
+ if (!enable && strncasecmp(line, zn, strlen(zn))) {
+ warnx(_("%s disable failed: Zone mismatch"), str);
+ continue;
+ }
+ } else if (enable) {
+ /* By default, use zone Movable for online, if valid */
+ if (strcasestr(line, zone_names[ZONE_MOVABLE]))
+ onoff = "online_movable";
+ else
+ onoff = "online";
+ }
+ }
+
rc = path_write_str(onoff, _PATH_SYS_MEMORY"/%s/state", name);
if (rc == -1) {
if (enable)
@@ -237,6 +328,8 @@ static void parse_parameter(struct chmem_desc *desc, char *param)
static void __attribute__((__noreturn__)) usage(void)
{
FILE *out = stdout;
+ unsigned int i;
+
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] [SIZE|RANGE|BLOCKRANGE]\n"), program_invocation_short_name);
@@ -247,6 +340,14 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -e, --enable enable memory\n"), out);
fputs(_(" -d, --disable disable memory\n"), out);
fputs(_(" -b, --blocks use memory blocks\n"), out);
+ fputs(_(" -z, --zone select memory zone ("), out);
+ for (i = 0; i < ARRAY_SIZE(zone_names); i++) {
+ fputs(zone_names[i], out);
+ if (i < ARRAY_SIZE(zone_names) - 1)
+ fputc('|', out);
+ }
+ fputs(")\n", out);
+
fputs(_(" -v, --verbose verbose output\n"), out);
fputs(USAGE_SEPARATOR, out);
printf(USAGE_HELP_OPTIONS(16));
@@ -259,7 +360,8 @@ static void __attribute__((__noreturn__)) usage(void)
int main(int argc, char **argv)
{
struct chmem_desc _desc = { }, *desc = &_desc;
- int cmd = CMD_NONE;
+ int cmd = CMD_NONE, zone_id = -1;
+ char *zone = NULL;
int c, rc;
static const struct option longopts[] = {
@@ -269,6 +371,7 @@ int main(int argc, char **argv)
{"help", no_argument, NULL, 'h'},
{"verbose", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
+ {"zone", required_argument, NULL, 'z'},
{NULL, 0, NULL, 0}
};
@@ -285,7 +388,7 @@ int main(int argc, char **argv)
read_info(desc);
- while ((c = getopt_long(argc, argv, "bdehvV", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "bdehvVz:", longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
@@ -308,6 +411,9 @@ int main(int argc, char **argv)
case 'V':
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
+ case 'z':
+ zone = xstrdup(optarg);
+ break;
default:
errtryhelp(EXIT_FAILURE);
}
@@ -320,10 +426,24 @@ int main(int argc, char **argv)
parse_parameter(desc, argv[optind]);
+ /* The valid_zones sysfs attribute was introduced with kernel 3.18 */
+ if (path_exist(_PATH_SYS_MEMORY "/memory0/valid_zones"))
+ desc->have_zones = 1;
+ else if (zone)
+ warnx(_("zone ignored, no valid_zones sysfs attribute present"));
+
+ if (zone && desc->have_zones) {
+ zone_id = zone_name_to_id(zone);
+ if (zone_id == -1) {
+ warnx(_("unknown memory zone: %s"), zone);
+ errtryhelp(EXIT_FAILURE);
+ }
+ }
+
if (desc->is_size)
- rc = chmem_size(desc, cmd == CMD_MEMORY_ENABLE ? 1 : 0);
+ rc = chmem_size(desc, cmd == CMD_MEMORY_ENABLE ? 1 : 0, zone_id);
else
- rc = chmem_range(desc, cmd == CMD_MEMORY_ENABLE ? 1 : 0);
+ rc = chmem_range(desc, cmd == CMD_MEMORY_ENABLE ? 1 : 0, zone_id);
return rc == 0 ? EXIT_SUCCESS :
rc < 0 ? EXIT_FAILURE : CHMEM_EXIT_SOMEOK;
diff --git a/sys-utils/lsmem.1 b/sys-utils/lsmem.1
index be2862d9476a..e7df50a4ebff 100644
--- a/sys-utils/lsmem.1
+++ b/sys-utils/lsmem.1
@@ -41,12 +41,12 @@ Do not print a header line.
.BR \-o , " \-\-output " \fIlist\fP
Specify which output columns to print. Use \fB\-\-help\fR
to get a list of all supported columns.
+The default list of columns may be extended if \fIlist\fP is
+specified in the format \fB+\fIlist\fP (e.g. \fBlsmem \-o +NODE\fP).
.TP
.BR \-P , " \-\-pairs"
Produce output in the form of key="value" pairs.
All potentially unsafe characters are hex-escaped (\\x<code>).
-The default list of columns may be extended if \fIlist\fP is
-specified in the format \fB+\fIlist\fP (e.g. \fBlsmem \-o +NODE\fP).
.TP
.BR \-r , " \-\-raw"
Produce output in raw format. All potentially unsafe characters are hex-escaped
diff --git a/sys-utils/lsmem.c b/sys-utils/lsmem.c
index aeffd29dd9f8..1d26579fd4c5 100644
--- a/sys-utils/lsmem.c
+++ b/sys-utils/lsmem.c
@@ -42,11 +42,25 @@
#define MEMORY_STATE_GOING_OFFLINE 2
#define MEMORY_STATE_UNKNOWN 3
+enum zone_id {
+ ZONE_DMA = 0,
+ ZONE_DMA32,
+ ZONE_NORMAL,
+ ZONE_HIGHMEM,
+ ZONE_MOVABLE,
+ ZONE_DEVICE,
+ ZONE_NONE,
+ ZONE_UNKNOWN,
+ MAX_NR_ZONES,
+};
+
struct memory_block {
uint64_t index;
uint64_t count;
int state;
int node;
+ int nr_zones;
+ int zones[MAX_NR_ZONES];
unsigned int removable:1;
};
@@ -72,7 +86,9 @@ struct lsmem {
want_state : 1,
want_removable : 1,
want_summary : 1,
- want_table : 1;
+ want_table : 1,
+ want_zones : 1,
+ have_zones : 1;
};
enum {
@@ -82,6 +98,18 @@ enum {
COL_REMOVABLE,
COL_BLOCK,
COL_NODE,
+ COL_ZONES,
+};
+
+static char *zone_names[] = {
+ [ZONE_DMA] = "DMA",
+ [ZONE_DMA32] = "DMA32",
+ [ZONE_NORMAL] = "Normal",
+ [ZONE_HIGHMEM] = "Highmem",
+ [ZONE_MOVABLE] = "Movable",
+ [ZONE_DEVICE] = "Device",
+ [ZONE_NONE] = "None", /* block contains more than one zone, can't be offlined */
+ [ZONE_UNKNOWN] = "Unknown",
};
/* column names */
@@ -102,6 +130,7 @@ static struct coldesc coldescs[] = {
[COL_REMOVABLE] = { "REMOVABLE", 0, SCOLS_FL_RIGHT, N_("memory is removable")},
[COL_BLOCK] = { "BLOCK", 0, SCOLS_FL_RIGHT, N_("memory block number or blocks range")},
[COL_NODE] = { "NODE", 0, SCOLS_FL_RIGHT, N_("numa node of memory")},
+ [COL_ZONES] = { "ZONES", 0, SCOLS_FL_RIGHT, N_("valid zones for the memory range")},
};
/* columns[] array specifies all currently wanted output column. The columns
@@ -120,6 +149,20 @@ static inline size_t err_columns_index(size_t arysz, size_t idx)
return idx;
}
+/*
+ * name must be null-terminated
+ */
+static int zone_name_to_id(const char *name)
+{
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(zone_names); i++) {
+ if (!strcasecmp(name, zone_names[i]))
+ return i;
+ }
+ return ZONE_UNKNOWN;
+}
+
#define add_column(ary, n, id) \
((ary)[ err_columns_index(ARRAY_SIZE(ary), (n)) ] = (id))
@@ -214,6 +257,25 @@ static void add_scols_line(struct lsmem *lsmem, struct memory_block *blk)
else
str = xstrdup("-");
break;
+ case COL_ZONES:
+ if (lsmem->have_zones) {
+ char valid_zones[BUFSIZ];
+ int j, zone_id;
+
+ valid_zones[0] = '\0';
+ for (j = 0; j < blk->nr_zones; j++) {
+ zone_id = blk->zones[j];
+ if (strlen(valid_zones) +
+ strlen(zone_names[zone_id]) > BUFSIZ - 2)
+ break;
+ strcat(valid_zones, zone_names[zone_id]);
+ if (j + 1 < blk->nr_zones)
+ strcat(valid_zones, "/");
+ }
+ str = xstrdup(valid_zones);
+ } else
+ str = xstrdup("-");
+ break;
}
if (str && scols_line_refer_data(line, i, str) != 0)
@@ -272,7 +334,9 @@ static int memory_block_get_node(char *name)
static void memory_block_read_attrs(struct lsmem *lsmem, char *name,
struct memory_block *blk)
{
+ char *token = NULL;
char line[BUFSIZ];
+ int i;
blk->count = 1;
blk->index = strtoumax(name + 6, NULL, 10); /* get <num> of "memory<num>" */
@@ -287,11 +351,26 @@ static void memory_block_read_attrs(struct lsmem *lsmem, char *name,
blk->state = MEMORY_STATE_GOING_OFFLINE;
if (lsmem->have_nodes)
blk->node = memory_block_get_node(name);
+
+ blk->nr_zones = 0;
+ if (lsmem->have_zones) {
+ path_read_str(line, sizeof(line), _PATH_SYS_MEMORY"/%s/%s", name,
+ "valid_zones");
+ token = strtok(line, " ");
+ }
+ for (i = 0; i < MAX_NR_ZONES; i++) {
+ if (token) {
+ blk->zones[i] = zone_name_to_id(token);
+ blk->nr_zones++;
+ token = strtok(NULL, " ");
+ }
+ }
}
static int is_mergeable(struct lsmem *lsmem, struct memory_block *blk)
{
struct memory_block *curr;
+ int i;
if (!lsmem->nblocks)
return 0;
@@ -308,6 +387,15 @@ static int is_mergeable(struct lsmem *lsmem, struct memory_block *blk)
if (curr->node != blk->node)
return 0;
}
+ if (lsmem->want_zones && lsmem->have_zones) {
+ if (curr->nr_zones != blk->nr_zones)
+ return 0;
+ for (i = 0; i < curr->nr_zones; i++) {
+ if (curr->zones[i] == ZONE_UNKNOWN ||
+ curr->zones[i] != blk->zones[i])
+ return 0;
+ }
+ }
return 1;
}
@@ -362,6 +450,12 @@ static void read_basic_info(struct lsmem *lsmem)
if (memory_block_get_node(lsmem->dirs[0]->d_name) != -1)
lsmem->have_nodes = 1;
+
+ /* The valid_zones sysfs attribute was introduced with kernel 3.18 */
+ if (path_exist(_PATH_SYS_MEMORY "/memory0/valid_zones"))
+ lsmem->have_zones = 1;
+ else if (lsmem->want_zones)
+ warnx(_("Cannot read zones, no valid_zones sysfs attribute present"));
}
static void __attribute__((__noreturn__)) usage(void)
@@ -553,6 +647,8 @@ int main(int argc, char **argv)
lsmem->want_node = 1;
if (has_column(COL_REMOVABLE))
lsmem->want_removable = 1;
+ if (has_column(COL_ZONES))
+ lsmem->want_zones = 1;
/*
* Read data and print output
--
2.13.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/3] tests/lsmem: update lsmem test with ZONES column
2017-09-27 17:44 [PATCH 0/3] lsmem/chmem: add memory zone awareness Gerald Schaefer
2017-09-27 17:44 ` [PATCH 1/3] " Gerald Schaefer
@ 2017-09-27 17:44 ` Gerald Schaefer
2017-09-27 17:44 ` [PATCH 3/3] lsmem/chmem: add memory zone awareness to bash-completion Gerald Schaefer
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Gerald Schaefer @ 2017-09-27 17:44 UTC (permalink / raw)
To: util-linux, Karel Zak
Cc: Michal Hocko, linux-mm, Heiko Carstens, Andre Wild, Gerald Schaefer
The existing s390 and x86_64 dumps already contain the valid_zones sysfs
attribute, so just add a new "lsmem -o +ZONES" test command and update
the expected results.
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
---
tests/expected/lsmem/lsmem-s390-zvm-6g | 21 ++++++++++++++++++
tests/expected/lsmem/lsmem-x86_64-16g | 39 ++++++++++++++++++++++++++++++++++
tests/ts/lsmem/lsmem | 1 +
3 files changed, 61 insertions(+)
diff --git a/tests/expected/lsmem/lsmem-s390-zvm-6g b/tests/expected/lsmem/lsmem-s390-zvm-6g
index 05af40d4df9f..9f4c805ad0a6 100644
--- a/tests/expected/lsmem/lsmem-s390-zvm-6g
+++ b/tests/expected/lsmem/lsmem-s390-zvm-6g
@@ -106,3 +106,24 @@ $ lsmem --json --output RANGE,SIZE,STATE,REMOVABLE,BLOCK,NODE
{"range": "0x0000000140000000-0x000000017fffffff", "size": "1G", "state": "offline", "removable": "-", "block": "20-23", "node": "0"}
]
}
+
+---
+
+$ lsmem -o +ZONES
+RANGE SIZE STATE REMOVABLE BLOCK ZONES
+0x0000000000000000-0x000000006fffffff 1.8G online yes 0-6 DMA
+0x0000000070000000-0x000000007fffffff 256M online no 7 DMA/Normal
+0x0000000080000000-0x000000009fffffff 512M online yes 8-9 Normal
+0x00000000a0000000-0x00000000bfffffff 512M online no 10-11 Normal
+0x00000000c0000000-0x00000000dfffffff 512M online yes 12-13 Normal
+0x00000000e0000000-0x00000000efffffff 256M offline - 14 Normal
+0x00000000f0000000-0x00000000ffffffff 256M online yes 15 Normal
+0x0000000100000000-0x000000010fffffff 256M online no 16 Normal
+0x0000000110000000-0x000000011fffffff 256M online no 17 Normal/Movable
+0x0000000120000000-0x000000012fffffff 256M online yes 18 Movable/Normal
+0x0000000130000000-0x000000013fffffff 256M online yes 19 Movable
+0x0000000140000000-0x000000017fffffff 1G offline - 20-23 Movable
+
+Memory block size: 256M
+Total online memory: 4.8G
+Total offline memory: 1.3G
diff --git a/tests/expected/lsmem/lsmem-x86_64-16g b/tests/expected/lsmem/lsmem-x86_64-16g
index 14d7d84f65ca..40316a584518 100644
--- a/tests/expected/lsmem/lsmem-x86_64-16g
+++ b/tests/expected/lsmem/lsmem-x86_64-16g
@@ -269,3 +269,42 @@ $ lsmem --json --output RANGE,SIZE,STATE,REMOVABLE,BLOCK,NODE
{"range": "0x0000000438000000-0x000000043fffffff", "size": "128M", "state": "online", "removable": "no", "block": "135", "node": "0"}
]
}
+
+---
+
+$ lsmem -o +ZONES
+RANGE SIZE STATE REMOVABLE BLOCK ZONES
+0x0000000000000000-0x0000000007ffffff 128M online no 0 None
+0x0000000008000000-0x0000000037ffffff 768M online yes 1-6 DMA32
+0x0000000038000000-0x000000003fffffff 128M online no 7 DMA32
+0x0000000040000000-0x0000000077ffffff 896M online yes 8-14 DMA32
+0x0000000078000000-0x000000007fffffff 128M online no 15 DMA32
+0x0000000080000000-0x00000000afffffff 768M online yes 16-21 DMA32
+0x00000000b0000000-0x00000000bfffffff 256M online no 22-23 DMA32
+0x0000000100000000-0x00000001a7ffffff 2.6G online no 32-52 Normal
+0x00000001a8000000-0x00000001afffffff 128M online yes 53 Normal
+0x00000001b0000000-0x00000001bfffffff 256M online no 54-55 Normal
+0x00000001c0000000-0x00000001ffffffff 1G online yes 56-63 Normal
+0x0000000200000000-0x0000000207ffffff 128M online no 64 Normal
+0x0000000208000000-0x000000021fffffff 384M online yes 65-67 Normal
+0x0000000220000000-0x0000000237ffffff 384M online no 68-70 Normal
+0x0000000238000000-0x0000000277ffffff 1G online yes 71-78 Normal
+0x0000000278000000-0x000000028fffffff 384M online no 79-81 Normal
+0x0000000290000000-0x0000000297ffffff 128M online yes 82 Normal
+0x0000000298000000-0x00000002a7ffffff 256M online no 83-84 Normal
+0x00000002a8000000-0x00000002c7ffffff 512M online yes 85-88 Normal
+0x00000002c8000000-0x00000002dfffffff 384M online no 89-91 Normal
+0x00000002e0000000-0x00000002efffffff 256M online yes 92-93 Normal
+0x00000002f0000000-0x000000034fffffff 1.5G online no 94-105 Normal
+0x0000000350000000-0x0000000357ffffff 128M online yes 106 Normal
+0x0000000358000000-0x000000036fffffff 384M online no 107-109 Normal
+0x0000000370000000-0x0000000377ffffff 128M online yes 110 Normal
+0x0000000378000000-0x00000003c7ffffff 1.3G online no 111-120 Normal
+0x00000003c8000000-0x00000003e7ffffff 512M online yes 121-124 Normal
+0x00000003e8000000-0x000000042fffffff 1.1G online no 125-133 Normal
+0x0000000430000000-0x0000000437ffffff 128M online yes 134 Normal
+0x0000000438000000-0x000000043fffffff 128M online no 135 None
+
+Memory block size: 128M
+Total online memory: 16G
+Total offline memory: 0B
diff --git a/tests/ts/lsmem/lsmem b/tests/ts/lsmem/lsmem
index 79c0523b96a3..b1313773e212 100755
--- a/tests/ts/lsmem/lsmem
+++ b/tests/ts/lsmem/lsmem
@@ -49,6 +49,7 @@ for dump in $(ls $TS_SELF/dumps/*.tar.bz2 | sort); do
do_lsmem --all --output $LSCOLUMNS
do_lsmem --raw --output $LSCOLUMNS
do_lsmem --json --output $LSCOLUMNS
+ do_lsmem -o +ZONES
ts_finalize_subtest
done
--
2.13.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/3] lsmem/chmem: add memory zone awareness to bash-completion
2017-09-27 17:44 [PATCH 0/3] lsmem/chmem: add memory zone awareness Gerald Schaefer
2017-09-27 17:44 ` [PATCH 1/3] " Gerald Schaefer
2017-09-27 17:44 ` [PATCH 2/3] tests/lsmem: update lsmem test with ZONES column Gerald Schaefer
@ 2017-09-27 17:44 ` Gerald Schaefer
2017-10-02 11:12 ` [PATCH 0/3] lsmem/chmem: add memory zone awareness Karel Zak
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Gerald Schaefer @ 2017-09-27 17:44 UTC (permalink / raw)
To: util-linux, Karel Zak
Cc: Michal Hocko, linux-mm, Heiko Carstens, Andre Wild, Gerald Schaefer
From: Andre Wild <wild@linux.vnet.ibm.com>
This patch extends the valid --output values with ZONES for the
lsmem bash-completion, and adds the --zone option for the chmem
bash-completion.
Signed-off-by: Andre Wild <wild@linux.vnet.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
---
bash-completion/chmem | 1 +
bash-completion/lsmem | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/bash-completion/chmem b/bash-completion/chmem
index 00b870dbd90d..3e3af87acaa5 100644
--- a/bash-completion/chmem
+++ b/bash-completion/chmem
@@ -16,6 +16,7 @@ _chmem_module()
--disable
--blocks
--verbose
+ --zone
--help
--version
"
diff --git a/bash-completion/lsmem b/bash-completion/lsmem
index 8f7a46ec30af..9aa124569d53 100644
--- a/bash-completion/lsmem
+++ b/bash-completion/lsmem
@@ -9,7 +9,7 @@ _lsmem_module()
local prefix realcur OUTPUT_ALL OUTPUT
realcur="${cur##*,}"
prefix="${cur%$realcur}"
- OUTPUT_ALL='RANGE SIZE STATE REMOVABLE BLOCK NODE'
+ OUTPUT_ALL='RANGE SIZE STATE REMOVABLE BLOCK NODE ZONES'
for WORD in $OUTPUT_ALL; do
if ! [[ $prefix == *"$WORD"* ]]; then
OUTPUT="$WORD ${OUTPUT:-""}"
--
2.13.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 0/3] lsmem/chmem: add memory zone awareness
2017-09-27 17:44 [PATCH 0/3] lsmem/chmem: add memory zone awareness Gerald Schaefer
` (2 preceding siblings ...)
2017-09-27 17:44 ` [PATCH 3/3] lsmem/chmem: add memory zone awareness to bash-completion Gerald Schaefer
@ 2017-10-02 11:12 ` Karel Zak
2017-10-18 11:40 ` Karel Zak
2017-10-20 10:45 ` Karel Zak
5 siblings, 0 replies; 10+ messages in thread
From: Karel Zak @ 2017-10-02 11:12 UTC (permalink / raw)
To: Gerald Schaefer
Cc: util-linux, Michal Hocko, linux-mm, Heiko Carstens, Andre Wild
On Wed, Sep 27, 2017 at 07:44:43PM +0200, Gerald Schaefer wrote:
> These patches are against lsmem/chmem in util-linux, they add support
> for listing and changing memory zone allocation.
>
> Added Michal Hocko and linux-mm on cc, to raise general awareness for
> the lsmem/chmem tools, and the new memory zone functionality in
> particular. I think this can be quite useful for memory hotplug kernel
> development, and if not, sorry for the noise.
Seems good.
I'll merge it (probably with some minor changes:-) after v2.31
release. Thanks!
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/3] lsmem/chmem: add memory zone awareness
2017-09-27 17:44 [PATCH 0/3] lsmem/chmem: add memory zone awareness Gerald Schaefer
` (3 preceding siblings ...)
2017-10-02 11:12 ` [PATCH 0/3] lsmem/chmem: add memory zone awareness Karel Zak
@ 2017-10-18 11:40 ` Karel Zak
2017-11-02 16:54 ` Gerald Schaefer
2017-10-20 10:45 ` Karel Zak
5 siblings, 1 reply; 10+ messages in thread
From: Karel Zak @ 2017-10-18 11:40 UTC (permalink / raw)
To: Gerald Schaefer
Cc: util-linux, Michal Hocko, linux-mm, Heiko Carstens, Andre Wild
On Wed, Sep 27, 2017 at 07:44:43PM +0200, Gerald Schaefer wrote:
> bash-completion/chmem | 1 +
> bash-completion/lsmem | 2 +-
> sys-utils/chmem.8 | 19 +++++
> sys-utils/chmem.c | 136 +++++++++++++++++++++++++++++++--
> sys-utils/lsmem.1 | 4 +-
> sys-utils/lsmem.c | 98 +++++++++++++++++++++++-
> tests/expected/lsmem/lsmem-s390-zvm-6g | 21 +++++
> tests/expected/lsmem/lsmem-x86_64-16g | 39 ++++++++++
> tests/ts/lsmem/lsmem | 1 +
> 9 files changed, 309 insertions(+), 12 deletions(-)
Merged to my "next" branch (in master we have still feature-freeze).
I have also added a note about the way how lsmem merges blocks to
create the RANGE column. It seems important, because the number of
ranges is affected by ZONES (or REMOVABLE). See:
https://github.com/karelzak/util-linux/commit/ffe5267c91018ca8cac8bedc14b695478c11a5dd
Maybe it's possible to explain it in a better way... (send patch;-)
The another possibility is to *always use* zones and removable
attributes to create the ranges (merge blocks) independently on the
output columns (e.g. -o ZONES). So, the result will be always the same
number of ranges with the same <start>-<end>.
Now (see the first range):
$ lsmem
RANGE SIZE STATE REMOVABLE BLOCK
0x0000000000000000-0x0000000047ffffff 1.1G online no 0-8
0x0000000048000000-0x0000000057ffffff 256M online yes 9-10
0x0000000058000000-0x000000005fffffff 128M online no 11
0x0000000060000000-0x0000000067ffffff 128M online yes 12
0x0000000068000000-0x0000000087ffffff 512M online no 13-16
0x0000000088000000-0x000000008fffffff 128M online yes 17
0x0000000090000000-0x00000000afffffff 512M online no 18-21
0x00000000b0000000-0x00000000bfffffff 256M online yes 22-23
0x0000000100000000-0x000000042fffffff 12.8G online no 32-133
0x0000000430000000-0x0000000437ffffff 128M online yes 134
0x0000000438000000-0x000000043fffffff 128M online no 135
lsmem -o+ZONES
RANGE SIZE STATE REMOVABLE BLOCK ZONES
0x0000000000000000-0x0000000007ffffff 128M online no 0 None
0x0000000008000000-0x0000000047ffffff 1G online no 1-8 DMA32
0x0000000048000000-0x0000000057ffffff 256M online yes 9-10 DMA32
0x0000000058000000-0x000000005fffffff 128M online no 11 DMA32
0x0000000060000000-0x0000000067ffffff 128M online yes 12 DMA32
0x0000000068000000-0x0000000087ffffff 512M online no 13-16 DMA32
0x0000000088000000-0x000000008fffffff 128M online yes 17 DMA32
0x0000000090000000-0x00000000afffffff 512M online no 18-21 DMA32
0x00000000b0000000-0x00000000bfffffff 256M online yes 22-23 DMA32
0x0000000100000000-0x000000042fffffff 12.8G online no 32-133 Normal
0x0000000430000000-0x0000000437ffffff 128M online yes 134 Normal
0x0000000438000000-0x000000043fffffff 128M online no 135 None
lsmem -oRANGE,SIZE
RANGE SIZE
0x0000000000000000-0x00000000bfffffff 3G
0x0000000100000000-0x000000043fffffff 13G
I didn't test it, but the question is how usable is
0x0000000000000000-<end> as option for chmem.
It's also seems difficult to use it in scripts if you want to output only
a RANGE, for example
FOO=$(lsmem -oRANGE -n --summary=never | head -1)
but the range is affected by missing columns.
Comments?
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/3] lsmem/chmem: add memory zone awareness
2017-09-27 17:44 [PATCH 0/3] lsmem/chmem: add memory zone awareness Gerald Schaefer
` (4 preceding siblings ...)
2017-10-18 11:40 ` Karel Zak
@ 2017-10-20 10:45 ` Karel Zak
5 siblings, 0 replies; 10+ messages in thread
From: Karel Zak @ 2017-10-20 10:45 UTC (permalink / raw)
To: Gerald Schaefer
Cc: util-linux, Michal Hocko, linux-mm, Heiko Carstens, Andre Wild
On Wed, Sep 27, 2017 at 07:44:43PM +0200, Gerald Schaefer wrote:
> These patches are against lsmem/chmem in util-linux, they add support
> for listing and changing memory zone allocation.
>
> Added Michal Hocko and linux-mm on cc, to raise general awareness for
> the lsmem/chmem tools, and the new memory zone functionality in
> particular. I think this can be quite useful for memory hotplug kernel
> development, and if not, sorry for the noise.
>
> Andre Wild (1):
> lsmem/chmem: add memory zone awareness to bash-completion
>
> Gerald Schaefer (2):
> lsmem/chmem: add memory zone awareness
> tests/lsmem: update lsmem test with ZONES column
Merged to the master branch.
I have added a new --split=<list> command line option to the lsmem.
It allows to control the way how lsmem merges memory blocks to the
ranges. The default is to use differences in STATE,REMOVABLE,NODE and
ZONES attributes. The ranges are no more affected by --output, it
means commands like
lsmem --output=RANGE
lsmem --output=RANGE,ZONES
returns the same memory ranges. You have to use --split to define your
policy:
lsmem --split=REMOVABLE,STATE
will create the ranges according to REMOVABLE and STATE attributes.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/3] lsmem/chmem: add memory zone awareness
2017-10-18 11:40 ` Karel Zak
@ 2017-11-02 16:54 ` Gerald Schaefer
2017-11-03 10:11 ` Karel Zak
0 siblings, 1 reply; 10+ messages in thread
From: Gerald Schaefer @ 2017-11-02 16:54 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Michal Hocko, linux-mm, Heiko Carstens, Andre Wild
On Wed, 18 Oct 2017 13:40:09 +0200
Karel Zak <kzak@redhat.com> wrote:
> On Wed, Sep 27, 2017 at 07:44:43PM +0200, Gerald Schaefer wrote:
> > bash-completion/chmem | 1 +
> > bash-completion/lsmem | 2 +-
> > sys-utils/chmem.8 | 19 +++++
> > sys-utils/chmem.c | 136 +++++++++++++++++++++++++++++++--
> > sys-utils/lsmem.1 | 4 +-
> > sys-utils/lsmem.c | 98 +++++++++++++++++++++++-
> > tests/expected/lsmem/lsmem-s390-zvm-6g | 21 +++++
> > tests/expected/lsmem/lsmem-x86_64-16g | 39 ++++++++++
> > tests/ts/lsmem/lsmem | 1 +
> > 9 files changed, 309 insertions(+), 12 deletions(-)
>
> Merged to my "next" branch (in master we have still feature-freeze).
>
> I have also added a note about the way how lsmem merges blocks to
> create the RANGE column. It seems important, because the number of
> ranges is affected by ZONES (or REMOVABLE). See:
>
> https://github.com/karelzak/util-linux/commit/ffe5267c91018ca8cac8bedc14b695478c11a5dd
>
> Maybe it's possible to explain it in a better way... (send patch;-)
>
> The another possibility is to *always use* zones and removable
> attributes to create the ranges (merge blocks) independently on the
> output columns (e.g. -o ZONES). So, the result will be always the same
> number of ranges with the same <start>-<end>.
>
> Now (see the first range):
>
> $ lsmem
> RANGE SIZE STATE REMOVABLE BLOCK
> 0x0000000000000000-0x0000000047ffffff 1.1G online no 0-8
> 0x0000000048000000-0x0000000057ffffff 256M online yes 9-10
> 0x0000000058000000-0x000000005fffffff 128M online no 11
> 0x0000000060000000-0x0000000067ffffff 128M online yes 12
> 0x0000000068000000-0x0000000087ffffff 512M online no 13-16
> 0x0000000088000000-0x000000008fffffff 128M online yes 17
> 0x0000000090000000-0x00000000afffffff 512M online no 18-21
> 0x00000000b0000000-0x00000000bfffffff 256M online yes 22-23
> 0x0000000100000000-0x000000042fffffff 12.8G online no 32-133
> 0x0000000430000000-0x0000000437ffffff 128M online yes 134
> 0x0000000438000000-0x000000043fffffff 128M online no 135
>
> lsmem -o+ZONES
> RANGE SIZE STATE REMOVABLE BLOCK ZONES
> 0x0000000000000000-0x0000000007ffffff 128M online no 0 None
> 0x0000000008000000-0x0000000047ffffff 1G online no 1-8 DMA32
> 0x0000000048000000-0x0000000057ffffff 256M online yes 9-10 DMA32
> 0x0000000058000000-0x000000005fffffff 128M online no 11 DMA32
> 0x0000000060000000-0x0000000067ffffff 128M online yes 12 DMA32
> 0x0000000068000000-0x0000000087ffffff 512M online no 13-16 DMA32
> 0x0000000088000000-0x000000008fffffff 128M online yes 17 DMA32
> 0x0000000090000000-0x00000000afffffff 512M online no 18-21 DMA32
> 0x00000000b0000000-0x00000000bfffffff 256M online yes 22-23 DMA32
> 0x0000000100000000-0x000000042fffffff 12.8G online no 32-133 Normal
> 0x0000000430000000-0x0000000437ffffff 128M online yes 134 Normal
> 0x0000000438000000-0x000000043fffffff 128M online no 135 None
>
> lsmem -oRANGE,SIZE
> RANGE SIZE
> 0x0000000000000000-0x00000000bfffffff 3G
> 0x0000000100000000-0x000000043fffffff 13G
>
>
> I didn't test it, but the question is how usable is
> 0x0000000000000000-<end> as option for chmem.
>
> It's also seems difficult to use it in scripts if you want to output only
> a RANGE, for example
>
> FOO=$(lsmem -oRANGE -n --summary=never | head -1)
>
> but the range is affected by missing columns.
>
> Comments?
Sorry for the late answer. I'm not sure if I understand the problem, it
"works as designed" that the range merging is done based on the output
columns, but I see that it was not really described as such. So I do
like the note that you added with the above mentioned commit.
However, regarding the --split option, I think it may be confusing at
least for human users, if an "lsmem -oRANGE" will now print more than
one range, even if this is now based on a "fixed" set of default columns
that are used for merging (but "subject to change" according to the man
page).
Now the user will not see the columns that are used for merging if he
says "lsmem -oRANGE", as opposed to the previous behavior where only the
visible output columns were used for merge decision (and for "lsmem
-oRANGE" that would simply be one big range because there are no other
columns that may differ).
I also do not really see the benefit for script usage, at least if we
define it as "expected behavior" to have the ranges merged based on the
output columns. Maybe I am missing something, but I think the --split
option does not really solve any problem, but rather introduces
potential for future confusion. I would rather only have the behavior
documented in the man pages, as you did in the above mentioned commit
(and which was then removed with the --split patch).
Regards,
Gerald
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/3] lsmem/chmem: add memory zone awareness
2017-11-02 16:54 ` Gerald Schaefer
@ 2017-11-03 10:11 ` Karel Zak
2017-11-03 13:31 ` Gerald Schaefer
0 siblings, 1 reply; 10+ messages in thread
From: Karel Zak @ 2017-11-03 10:11 UTC (permalink / raw)
To: Gerald Schaefer
Cc: util-linux, Michal Hocko, linux-mm, Heiko Carstens, Andre Wild
On Thu, Nov 02, 2017 at 05:54:08PM +0100, Gerald Schaefer wrote:
> Sorry for the late answer. I'm not sure if I understand the problem, it
> "works as designed" that the range merging is done based on the output
> columns, but I see that it was not really described as such. So I do
> like the note that you added with the above mentioned commit.
>
> However, regarding the --split option, I think it may be confusing at
> least for human users, if an "lsmem -oRANGE" will now print more than
> one range, even if this is now based on a "fixed" set of default columns
> that are used for merging (but "subject to change" according to the man
> page).
OK, I think we can support both concepts :-) I have modified lsmem to:
- follow output columns for split policy by default (= your original implementation)
- the --split is optional and may be used to override the default behavior
it means for humans it's probably less concussing and advanced users may
define by --split another way how to generate the ranges.
I think it's good compromise and it's backwardly compatible with
the previous version. OK?
If yes, I need to backport this change to RHEL7.5 :-)
> I also do not really see the benefit for script usage, at least if we
> define it as "expected behavior" to have the ranges merged based on the
We want to keep it user friendly. The "expected behavior" (now
default) forces you to parse lsmem output to filter out unnecessary
columns (if you care about RANGE only).
And in all our utils the --output option really control the output, but
no another behavior.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/3] lsmem/chmem: add memory zone awareness
2017-11-03 10:11 ` Karel Zak
@ 2017-11-03 13:31 ` Gerald Schaefer
0 siblings, 0 replies; 10+ messages in thread
From: Gerald Schaefer @ 2017-11-03 13:31 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Michal Hocko, linux-mm, Heiko Carstens, Andre Wild
On Fri, 3 Nov 2017 11:11:04 +0100
Karel Zak <kzak@redhat.com> wrote:
> On Thu, Nov 02, 2017 at 05:54:08PM +0100, Gerald Schaefer wrote:
> > Sorry for the late answer. I'm not sure if I understand the problem, it
> > "works as designed" that the range merging is done based on the output
> > columns, but I see that it was not really described as such. So I do
> > like the note that you added with the above mentioned commit.
> >
> > However, regarding the --split option, I think it may be confusing at
> > least for human users, if an "lsmem -oRANGE" will now print more than
> > one range, even if this is now based on a "fixed" set of default columns
> > that are used for merging (but "subject to change" according to the man
> > page).
>
> OK, I think we can support both concepts :-) I have modified lsmem to:
>
> - follow output columns for split policy by default (= your original implementation)
> - the --split is optional and may be used to override the default behavior
>
> it means for humans it's probably less concussing and advanced users may
> define by --split another way how to generate the ranges.
>
> I think it's good compromise and it's backwardly compatible with
> the previous version. OK?
Yes, that looks good.
>
> If yes, I need to backport this change to RHEL7.5 :-)
>
Yes, please :-)
> > I also do not really see the benefit for script usage, at least if we
> > define it as "expected behavior" to have the ranges merged based on the
>
> We want to keep it user friendly. The "expected behavior" (now
> default) forces you to parse lsmem output to filter out unnecessary
> columns (if you care about RANGE only).
>
> And in all our utils the --output option really control the output, but
> no another behavior.
OK, that makes sense. I did not have any output selection in the original
implementation, and also no focus on script usage, but as (maybe so far
the only) human user I did get confused by the new range merging.
Regards,
Gerald
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-11-03 13:31 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-27 17:44 [PATCH 0/3] lsmem/chmem: add memory zone awareness Gerald Schaefer
2017-09-27 17:44 ` [PATCH 1/3] " Gerald Schaefer
2017-09-27 17:44 ` [PATCH 2/3] tests/lsmem: update lsmem test with ZONES column Gerald Schaefer
2017-09-27 17:44 ` [PATCH 3/3] lsmem/chmem: add memory zone awareness to bash-completion Gerald Schaefer
2017-10-02 11:12 ` [PATCH 0/3] lsmem/chmem: add memory zone awareness Karel Zak
2017-10-18 11:40 ` Karel Zak
2017-11-02 16:54 ` Gerald Schaefer
2017-11-03 10:11 ` Karel Zak
2017-11-03 13:31 ` Gerald Schaefer
2017-10-20 10:45 ` Karel Zak
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).