From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Yannick Brosseau <scientist@fb.com>
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
zhu.wen-jie@hp.com, ak@linux.intel.com
Subject: Re: [PATCH] perf: Correctly identify anon_hugepage when generating map
Date: Tue, 13 Oct 2015 11:54:44 -0300 [thread overview]
Message-ID: <20151013145444.GS14409@kernel.org> (raw)
In-Reply-To: <1444264306-3057-1-git-send-email-scientist@fb.com>
Em Wed, Oct 07, 2015 at 05:31:46PM -0700, Yannick Brosseau escreveu:
> When parsing /proc/xxx/maps, the sscanf in perf_event__synthesize_mmap_events
> truncate the map name at the space in "/anon_hugepage (deleted)".
> is_anon_memory then only receive the string "/anon_hugepage" and do not detect it.
> We change is_anon_memory to only compare the first part of the string
> effectively ignoring if the (deleted) part is there or not.
>
> +++ b/tools/perf/util/map.c
> @@ -26,8 +26,8 @@ const char *map_type__name[MAP__NR_TYPES] = {
> static inline int is_anon_memory(const char *filename)
> {
> return !strcmp(filename, "//anon") ||
> - !strcmp(filename, "/dev/zero (deleted)") ||
> - !strcmp(filename, "/anon_hugepage (deleted)");
> + !strncmp(filename, "/dev/zero", sizeof("/dev/zero")) ||
> + !strncmp(filename, "/anon_hugepage", sizeof("/anon_hugepage"));
Have you tested this?
[acme@zoo ~]$ cat strncmp_sizeof.c
#include <string.h>
#include <stdio.h>
int main(void)
{
#define pattern "/anon_hugepage"
size_t sz = sizeof(pattern);
return printf("sizeof=%zd\nstrncmp(sz )=%d\nstrncmp(sz - 1)=%d\n", sz,
strncmp("/anon_hugepage (deleted)", pattern, sz),
strncmp("/anon_hugepage (deleted)", pattern, sz - 1));
}
[acme@zoo ~]$ make strncmp_sizeof
cc strncmp_sizeof.c -o strncmp_sizeof
[acme@zoo ~]$ ./strncmp_sizeof
sizeof=15
strncmp(sz )=32
strncmp(sz - 1)=0
[acme@zoo ~]$
Hint, you're not considering the '\0'.
- Arnaldo
prev parent reply other threads:[~2015-10-13 14:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-08 0:31 [PATCH] perf: Correctly identify anon_hugepage when generating map Yannick Brosseau
2015-10-13 14:54 ` Arnaldo Carvalho de Melo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151013145444.GS14409@kernel.org \
--to=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=scientist@fb.com \
--cc=zhu.wen-jie@hp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.