Skip to content

Commit c6c27e3

Browse files
hmynenimpe
authored andcommitted
selftests/powerpc: Use req_max_processed_len from sysfs NX capabilities
On PowerVM, the hypervisor defines the maximum buffer length for each NX request and the kernel exported this value via sysfs. This patch reads this value if the sysfs entry is available and is used to limit the request length. Signed-off-by: Haren Myneni <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 20ccb00 commit c6c27e3

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
CFLAGS = -O3 -m64 -I./include
1+
CFLAGS = -O3 -m64 -I./include -I../include
22

33
TEST_GEN_FILES := gzfht_test gunz_test
44
TEST_PROGS := nx-gzip-test.sh
55

66
include ../../lib.mk
77

8-
$(TEST_GEN_FILES): gzip_vas.c
8+
$(TEST_GEN_FILES): gzip_vas.c ../utils.c

tools/testing/selftests/powerpc/nx-gzip/gzfht_test.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include <assert.h>
6161
#include <errno.h>
6262
#include <signal.h>
63+
#include "utils.h"
6364
#include "nxu.h"
6465
#include "nx.h"
6566

@@ -70,6 +71,8 @@ FILE *nx_gzip_log;
7071
#define FNAME_MAX 1024
7172
#define FEXT ".nx.gz"
7273

74+
#define SYSFS_MAX_REQ_BUF_PATH "devices/vio/ibm,compression-v1/nx_gzip_caps/req_max_processed_len"
75+
7376
/*
7477
* LZ counts returned in the user supplied nx_gzip_crb_cpb_t structure.
7578
*/
@@ -244,6 +247,7 @@ int compress_file(int argc, char **argv, void *handle)
244247
struct nx_gzip_crb_cpb_t *cmdp;
245248
uint32_t pagelen = 65536;
246249
int fault_tries = NX_MAX_FAULTS;
250+
char buf[32];
247251

248252
cmdp = (void *)(uintptr_t)
249253
aligned_alloc(sizeof(struct nx_gzip_crb_cpb_t),
@@ -263,8 +267,17 @@ int compress_file(int argc, char **argv, void *handle)
263267
assert(NULL != (outbuf = (char *)malloc(outlen)));
264268
nxu_touch_pages(outbuf, outlen, pagelen, 1);
265269

266-
/* Compress piecemeal in smallish chunks */
267-
chunk = 1<<22;
270+
/*
271+
* On PowerVM, the hypervisor defines the maximum request buffer
272+
* size is defined and this value is available via sysfs.
273+
*/
274+
if (!read_sysfs_file(SYSFS_MAX_REQ_BUF_PATH, buf, sizeof(buf))) {
275+
chunk = atoi(buf);
276+
} else {
277+
/* sysfs entry is not available on PowerNV */
278+
/* Compress piecemeal in smallish chunks */
279+
chunk = 1<<22;
280+
}
268281

269282
/* Write the gzip header to the stream */
270283
num_hdr_bytes = gzip_header_blank(outbuf);

0 commit comments

Comments
 (0)