Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277356
b: refs/heads/master
c: 41d0d93
h: refs/heads/master
v: v3
  • Loading branch information
Nelson Elhage authored and Arnaldo Carvalho de Melo committed Dec 23, 2011
1 parent a08f2dd commit ed91d39
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 18e6093904abfd51671ff5846c2fdaba9ebbf21b
refs/heads/master: 41d0d933494ce10eb77758a1168b08e317c42e8e
2 changes: 1 addition & 1 deletion trunk/tools/perf/Documentation/perf-record.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ OPTIONS

-m::
--mmap-pages=::
Number of mmap data pages.
Number of mmap data pages. Must be a power of two.

-g::
--call-graph::
Expand Down
3 changes: 3 additions & 0 deletions trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ static void perf_record__open(struct perf_record *rec)
"/proc/sys/kernel/perf_event_mlock_kb,\n"
"or try again with a smaller value of -m/--mmap_pages.\n"
"(current value: %d)\n", opts->mmap_pages);
else if (!is_power_of_2(opts->mmap_pages))
die("--mmap_pages/-m value must be a power of two.");

die("failed to mmap with %d (%s)\n", errno, strerror(errno));
}

Expand Down
2 changes: 2 additions & 0 deletions trunk/tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
/* 512 kiB: default amount of unprivileged mlocked memory */
if (pages == UINT_MAX)
pages = (512 * 1024) / page_size;
else if (!is_power_of_2(pages))
return -EINVAL;

mask = pages * page_size - 1;

Expand Down
11 changes: 11 additions & 0 deletions trunk/tools/perf/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,15 @@ int readn(int fd, void *buf, size_t size);
#define _STR(x) #x
#define STR(x) _STR(x)

/*
* Determine whether some value is a power of two, where zero is
* *not* considered a power of two.
*/

static inline __attribute__((const))
bool is_power_of_2(unsigned long n)
{
return (n != 0 && ((n & (n - 1)) == 0));
}

#endif

0 comments on commit ed91d39

Please sign in to comment.