This patch will update multithread options to search help info. -f is used for
customizing the zone size. -n is used for specifying the search_value thread
quantity.
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
help.c | 17 +++++++++++++++--
memory.c | 28 +++++++++++++++++++++++++---
2 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/help.c b/help.c
index 56a9d82..add7eeb 100644
--- a/help.c
+++ b/help.c
@@ -3498,7 +3498,7 @@ char *help_search[] = {
"search",
"search memory",
"[-s start] [ -[kKV] | -u | -p | -t | -T ] [-e end | -l length] [-m mask]\n"
-" [-x count] -[cwh] [value | (expression) | symbol | string] ...",
+" [-x | -f | -n count] -[cwh] [value | (expression) | symbol | string]
...",
" This command searches for a given value within a range of user virtual,
kernel",
" virtual, or physical memory space. If no end nor length value is entered,
",
" then the search stops at the end of user virtual, kernel virtual, or
physical",
@@ -3544,7 +3544,20 @@ char *help_search[] = {
" -x count Display the memory contents before and after any found value.
The",
" before and after memory context will consist of \"count\"
memory",
" items of the same size as the \"value\" argument. This
option is",
-" not applicable with the -c option.",
+" not applicable with the -c and -n options.",
+" -f count A search operation is mainly made up by 2 steps: readmem into
some",
+" buffers and find values within the buffers. Value finding can
work",
+" on one zone while readmem can prepare the data of next zone.
A",
+" zone is a batch of pagebufs for readmem and value finding to
work",
+" alternately. The total number of pagebufs of a zone, is
determined",
+" by thread number and a factor, i.e. pagebufs_num_of_a_zone = ",
+" thread_num * (1 << factor). This option will give
\"count\" value",
+" to the factor. If not specified, 0 is given by default.",
+" -n count Create \"count\" threads for value finding. All threads
will",
+" handle different pagebufs concurrently within a zone. This
option",
+" is useful when the value finding is time consumptive, such as
the",
+" -c option for string finding. If not specified, 1 thread is
given",
+" by default.",
" value Search for this hexadecimal long, unless modified by the -c, -w,
",
" or -h options.",
"(expression) Search for the value of this expression; the expression value
must",
diff --git a/memory.c b/memory.c
index 024eccc..51e8327 100644
--- a/memory.c
+++ b/memory.c
@@ -14319,7 +14319,7 @@ cmd_search(void)
{
int i, c, memtype, ranges, context, max;
ulonglong start, end;
- ulong value, mask, len;
+ ulong value, mask, len, thread_num, factor;
ulong uvaddr_start, uvaddr_end;
ulong kvaddr_start, kvaddr_end, range_end;
int sflag, Kflag, Vflag, pflag, Tflag, tflag;
@@ -14337,6 +14337,7 @@ cmd_search(void)
context = max = 0;
start = end = 0;
value = mask = sflag = pflag = Kflag = Vflag = memtype = len = Tflag = tflag = 0;
+ thread_num = factor = 0;
kvaddr_start = kvaddr_end = 0;
uvaddr_start = UNINITIALIZED;
uvaddr_end = COMMON_VADDR_SPACE() ? (ulong)(-1) : machdep->kvbase;
@@ -14373,7 +14374,7 @@ cmd_search(void)
searchinfo.mode = SEARCH_ULONG; /* default search */
- while ((c = getopt(argcnt, args, "Ttl:ukKVps:e:v:m:hwcx:")) != EOF) {
+ while ((c = getopt(argcnt, args, "Ttl:ukKVps:e:v:m:n:hwcx:f:")) != EOF) {
switch(c)
{
case 'u':
@@ -14453,6 +14454,16 @@ cmd_search(void)
mask = htol(optarg, FAULT_ON_ERROR, NULL);
break;
+ case 'n':
+ thread_num = stol(optarg, FAULT_ON_ERROR, NULL);
+ searchinfo.thread_num = thread_num;
+ break;
+
+ case 'f':
+ factor = stol(optarg, FAULT_ON_ERROR, NULL);
+ searchinfo.factor = 1 << factor;
+ break;
+
case 'h':
if (searchinfo.mode != SEARCH_DEFAULT)
error(INFO, "WARNING: overriding previously"
@@ -14670,14 +14681,25 @@ cmd_search(void)
break;
}
+ if (searchinfo.thread_num != 0) {
+ error(INFO, "-x option is not allowed with -n, "
+ "reset -n value to be 1\n\n");
+ }
+ searchinfo.thread_num = searchinfo.page_buf_zone_num = 1;
+
if (context > max)
error(FATAL,
"context value %d is too large: maximum is %d\n",
context, max);
searchinfo.context = context;
+ } else {
+ searchinfo.thread_num = searchinfo.thread_num ?
+ searchinfo.thread_num : 1;
+ searchinfo.page_buf_zone_num = 2;
}
-
+
+ searchinfo.factor = searchinfo.factor ? searchinfo.factor : 1;
searchinfo.vcnt = 0;
searchinfo.val = UNUSED;
--
2.33.1