[PATCH 8/8] mmap_cache: add customizable search function
Masatake YAMATO
yamato at redhat.com
Thu Mar 1 05:59:10 UTC 2018
On Tue, 27 Feb 2018 02:27:04 +0300, "Dmitry V. Levin" <ldv at altlinux.org> wrote:
> On Sat, Jan 27, 2018 at 05:36:44AM +0900, Masatake YAMATO wrote:
>> * defs.h (mmap_cache_search_custom): New function.
>> (mmap_cache_search_fn): New type.
>> * mmap_cache.c (mmap_cache_search_custom): New function.
>>
>> Signed-off-by: Masatake YAMATO <yamato at redhat.com>
>> ---
>> defs.h | 3 +++
>> mmap_cache.c | 12 ++++++++++++
>> 2 files changed, 15 insertions(+)
>>
>> diff --git a/defs.h b/defs.h
>> index 881768dd..bae5e4a1 100644
>> --- a/defs.h
>> +++ b/defs.h
>> @@ -748,6 +748,9 @@ extern void mmap_cache_delete(struct tcb *tcp, const char *caller);
>> extern enum mmap_cache_rebuild_result mmap_cache_rebuild_if_invalid(struct tcb *tcp, const char *caller);
>> extern struct mmap_cache_t *mmap_cache_search(struct tcb *tcp, unsigned long ip);
>>
>> +typedef bool (* mmap_cache_search_fn) (struct mmap_cache_t *, void *);
>> +extern struct mmap_cache_t *mmap_cache_search_custom(struct tcb *tcp, mmap_cache_search_fn, void *);
>> +
>> static inline void
>> printstrn(struct tcb *tcp, kernel_ulong_t addr, kernel_ulong_t len)
>> {
>> diff --git a/mmap_cache.c b/mmap_cache.c
>> index 88753071..f14d8942 100644
>> --- a/mmap_cache.c
>> +++ b/mmap_cache.c
>> @@ -237,3 +237,15 @@ mmap_cache_search(struct tcb *tcp, unsigned long ip)
>> }
>> return NULL;
>> }
>> +
>> +struct mmap_cache_t *
>> +mmap_cache_search_custom(struct tcb *tcp, mmap_cache_search_fn search_fn, void *data)
>> +{
>> + int i;
>> +
>> + for (i = 0; i <= (int) tcp->mmap_cache_size; i++) {
>> + if (search_fn (tcp->mmap_cache + i, data))
>> + return tcp->mmap_cache + i;
>> + }
>> + return NULL;
>> +}
>
> Why do you need this function?
> It looks like an iterator rather than a search function.
Thank you for reviewing. I would like to withdraw this change.
The function is useful when decoding mmap area of kvm vcpu.
So this change should be in decoding-mmap-area-of-kvm-vcpu
change set that I would like to submit here after linux-4.16
is released.
The docoder works mostly. However, it needs the change on
kernel side. The kernel side change merged already.
(https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e46b469278a59781f9b25ff608af84892963821b)
The change will be included in 4.16.
Masatake YAMATO
>
> --
> ldv
More information about the Strace-devel
mailing list