Re: [PATCH 07/18] perf tools: Limit ordered events queue size

2014-06-30 Thread Jiri Olsa
On Fri, Jun 27, 2014 at 05:11:15PM -0600, David Ahern wrote:
> On 6/18/14, 8:58 AM, Jiri Olsa wrote:
> >@@ -520,7 +522,7 @@ static void queue_event(struct ordered_events_queue *q, 
> >struct ordered_event *ne
> >  static struct ordered_event *alloc_event(struct ordered_events_queue *q)
> >  {
> > struct list_head *cache = >cache;
> >-struct ordered_event *new;
> >+struct ordered_event *new = NULL;
> >
> > if (!list_empty(cache)) {
> > new = list_entry(cache->next, struct ordered_event, list);
> >@@ -529,10 +531,14 @@ static struct ordered_event *alloc_event(struct 
> >ordered_events_queue *q)
> > new = q->buffer + q->buffer_idx;
> > if (++q->buffer_idx == MAX_SAMPLE_BUFFER)
> > q->buffer = NULL;
> >-} else {
> >-q->buffer = malloc(MAX_SAMPLE_BUFFER * sizeof(*new));
> >+} else if (q->cur_alloc_size < q->max_alloc_size) {
> >+size_t size = MAX_SAMPLE_BUFFER * sizeof(*new);
> >+
> >+q->buffer = malloc(size);
> > if (!q->buffer)
> > return NULL;
> >+
> >+q->cur_alloc_size += size;
> > list_add(>buffer->list, >to_free);
> >
> 
> When is cur_alloc_size decremented?

never, it get's incremented untiul we reach the limit,
then it stays and the cache is used for new events..
and it's all released at the end

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 07/18] perf tools: Limit ordered events queue size

2014-06-30 Thread Jiri Olsa
On Fri, Jun 27, 2014 at 05:11:15PM -0600, David Ahern wrote:
 On 6/18/14, 8:58 AM, Jiri Olsa wrote:
 @@ -520,7 +522,7 @@ static void queue_event(struct ordered_events_queue *q, 
 struct ordered_event *ne
   static struct ordered_event *alloc_event(struct ordered_events_queue *q)
   {
  struct list_head *cache = q-cache;
 -struct ordered_event *new;
 +struct ordered_event *new = NULL;
 
  if (!list_empty(cache)) {
  new = list_entry(cache-next, struct ordered_event, list);
 @@ -529,10 +531,14 @@ static struct ordered_event *alloc_event(struct 
 ordered_events_queue *q)
  new = q-buffer + q-buffer_idx;
  if (++q-buffer_idx == MAX_SAMPLE_BUFFER)
  q-buffer = NULL;
 -} else {
 -q-buffer = malloc(MAX_SAMPLE_BUFFER * sizeof(*new));
 +} else if (q-cur_alloc_size  q-max_alloc_size) {
 +size_t size = MAX_SAMPLE_BUFFER * sizeof(*new);
 +
 +q-buffer = malloc(size);
  if (!q-buffer)
  return NULL;
 +
 +q-cur_alloc_size += size;
  list_add(q-buffer-list, q-to_free);
 
 
 When is cur_alloc_size decremented?

never, it get's incremented untiul we reach the limit,
then it stays and the cache is used for new events..
and it's all released at the end

jirka
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 07/18] perf tools: Limit ordered events queue size

2014-06-27 Thread David Ahern

On 6/18/14, 8:58 AM, Jiri Olsa wrote:

@@ -520,7 +522,7 @@ static void queue_event(struct ordered_events_queue *q, 
struct ordered_event *ne
  static struct ordered_event *alloc_event(struct ordered_events_queue *q)
  {
struct list_head *cache = >cache;
-   struct ordered_event *new;
+   struct ordered_event *new = NULL;

if (!list_empty(cache)) {
new = list_entry(cache->next, struct ordered_event, list);
@@ -529,10 +531,14 @@ static struct ordered_event *alloc_event(struct 
ordered_events_queue *q)
new = q->buffer + q->buffer_idx;
if (++q->buffer_idx == MAX_SAMPLE_BUFFER)
q->buffer = NULL;
-   } else {
-   q->buffer = malloc(MAX_SAMPLE_BUFFER * sizeof(*new));
+   } else if (q->cur_alloc_size < q->max_alloc_size) {
+   size_t size = MAX_SAMPLE_BUFFER * sizeof(*new);
+
+   q->buffer = malloc(size);
if (!q->buffer)
return NULL;
+
+   q->cur_alloc_size += size;
list_add(>buffer->list, >to_free);



When is cur_alloc_size decremented?

$ git checkout remotes/jolsa/perf/core_ordered_events

$ egrep -r cur_alloc_size tools/perf/
tools/perf//util/ordered-events.c:	} else if (q->cur_alloc_size < 
q->max_alloc_size) {
tools/perf//util/ordered-events.c:		   q->cur_alloc_size, 
q->max_alloc_size);

tools/perf//util/ordered-events.c:  q->cur_alloc_size += size;
tools/perf//util/ordered-events.c:  q->cur_alloc_size = 0;
tools/perf//util/ordered-events.h:  u64 cur_alloc_size;

Does not appear to ever be decremented.

David

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 07/18] perf tools: Limit ordered events queue size

2014-06-27 Thread David Ahern

On 6/18/14, 8:58 AM, Jiri Olsa wrote:

@@ -520,7 +522,7 @@ static void queue_event(struct ordered_events_queue *q, 
struct ordered_event *ne
  static struct ordered_event *alloc_event(struct ordered_events_queue *q)
  {
struct list_head *cache = q-cache;
-   struct ordered_event *new;
+   struct ordered_event *new = NULL;

if (!list_empty(cache)) {
new = list_entry(cache-next, struct ordered_event, list);
@@ -529,10 +531,14 @@ static struct ordered_event *alloc_event(struct 
ordered_events_queue *q)
new = q-buffer + q-buffer_idx;
if (++q-buffer_idx == MAX_SAMPLE_BUFFER)
q-buffer = NULL;
-   } else {
-   q-buffer = malloc(MAX_SAMPLE_BUFFER * sizeof(*new));
+   } else if (q-cur_alloc_size  q-max_alloc_size) {
+   size_t size = MAX_SAMPLE_BUFFER * sizeof(*new);
+
+   q-buffer = malloc(size);
if (!q-buffer)
return NULL;
+
+   q-cur_alloc_size += size;
list_add(q-buffer-list, q-to_free);



When is cur_alloc_size decremented?

$ git checkout remotes/jolsa/perf/core_ordered_events

$ egrep -r cur_alloc_size tools/perf/
tools/perf//util/ordered-events.c:	} else if (q-cur_alloc_size  
q-max_alloc_size) {
tools/perf//util/ordered-events.c:		   q-cur_alloc_size, 
q-max_alloc_size);

tools/perf//util/ordered-events.c:  q-cur_alloc_size += size;
tools/perf//util/ordered-events.c:  q-cur_alloc_size = 0;
tools/perf//util/ordered-events.h:  u64 cur_alloc_size;

Does not appear to ever be decremented.

David

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/18] perf tools: Limit ordered events queue size

2014-06-18 Thread Jiri Olsa
Add limit to the ordered events queue allocation. This way
we will be able to control the size of the queue buffers.

There's no limit at the moment (it's set to (u64) -1). The config
code will come in following patches.

Cc: Arnaldo Carvalho de Melo 
Cc: Corey Ashford 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jean Pihet 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Signed-off-by: Jiri Olsa 
---
 tools/perf/util/session.c | 12 +---
 tools/perf/util/session.h |  2 ++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index f6991ac..5c00d9b 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -79,6 +79,8 @@ struct perf_session *perf_session__new(struct perf_data_file 
*file,
INIT_LIST_HEAD(>ordered_events.events);
INIT_LIST_HEAD(>ordered_events.cache);
INIT_LIST_HEAD(>ordered_events.to_free);
+   session->ordered_events.max_alloc_size = (u64) -1;
+   session->ordered_events.cur_alloc_size = 0;
machines__init(>machines);
 
if (file) {
@@ -520,7 +522,7 @@ static void queue_event(struct ordered_events_queue *q, 
struct ordered_event *ne
 static struct ordered_event *alloc_event(struct ordered_events_queue *q)
 {
struct list_head *cache = >cache;
-   struct ordered_event *new;
+   struct ordered_event *new = NULL;
 
if (!list_empty(cache)) {
new = list_entry(cache->next, struct ordered_event, list);
@@ -529,10 +531,14 @@ static struct ordered_event *alloc_event(struct 
ordered_events_queue *q)
new = q->buffer + q->buffer_idx;
if (++q->buffer_idx == MAX_SAMPLE_BUFFER)
q->buffer = NULL;
-   } else {
-   q->buffer = malloc(MAX_SAMPLE_BUFFER * sizeof(*new));
+   } else if (q->cur_alloc_size < q->max_alloc_size) {
+   size_t size = MAX_SAMPLE_BUFFER * sizeof(*new);
+
+   q->buffer = malloc(size);
if (!q->buffer)
return NULL;
+
+   q->cur_alloc_size += size;
list_add(>buffer->list, >to_free);
 
/* First entry is abused to maintain the to_free list. */
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 76b897f..9f64ac9 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -20,6 +20,8 @@ struct ordered_events_queue {
u64 last_flush;
u64 next_flush;
u64 max_timestamp;
+   u64 max_alloc_size;
+   u64 cur_alloc_size;
struct list_headevents;
struct list_headcache;
struct list_headto_free;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/18] perf tools: Limit ordered events queue size

2014-06-18 Thread Jiri Olsa
Add limit to the ordered events queue allocation. This way
we will be able to control the size of the queue buffers.

There's no limit at the moment (it's set to (u64) -1). The config
code will come in following patches.

Cc: Arnaldo Carvalho de Melo a...@kernel.org
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jean Pihet jean.pi...@linaro.org
Cc: Namhyung Kim namhy...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Signed-off-by: Jiri Olsa jo...@kernel.org
---
 tools/perf/util/session.c | 12 +---
 tools/perf/util/session.h |  2 ++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index f6991ac..5c00d9b 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -79,6 +79,8 @@ struct perf_session *perf_session__new(struct perf_data_file 
*file,
INIT_LIST_HEAD(session-ordered_events.events);
INIT_LIST_HEAD(session-ordered_events.cache);
INIT_LIST_HEAD(session-ordered_events.to_free);
+   session-ordered_events.max_alloc_size = (u64) -1;
+   session-ordered_events.cur_alloc_size = 0;
machines__init(session-machines);
 
if (file) {
@@ -520,7 +522,7 @@ static void queue_event(struct ordered_events_queue *q, 
struct ordered_event *ne
 static struct ordered_event *alloc_event(struct ordered_events_queue *q)
 {
struct list_head *cache = q-cache;
-   struct ordered_event *new;
+   struct ordered_event *new = NULL;
 
if (!list_empty(cache)) {
new = list_entry(cache-next, struct ordered_event, list);
@@ -529,10 +531,14 @@ static struct ordered_event *alloc_event(struct 
ordered_events_queue *q)
new = q-buffer + q-buffer_idx;
if (++q-buffer_idx == MAX_SAMPLE_BUFFER)
q-buffer = NULL;
-   } else {
-   q-buffer = malloc(MAX_SAMPLE_BUFFER * sizeof(*new));
+   } else if (q-cur_alloc_size  q-max_alloc_size) {
+   size_t size = MAX_SAMPLE_BUFFER * sizeof(*new);
+
+   q-buffer = malloc(size);
if (!q-buffer)
return NULL;
+
+   q-cur_alloc_size += size;
list_add(q-buffer-list, q-to_free);
 
/* First entry is abused to maintain the to_free list. */
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 76b897f..9f64ac9 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -20,6 +20,8 @@ struct ordered_events_queue {
u64 last_flush;
u64 next_flush;
u64 max_timestamp;
+   u64 max_alloc_size;
+   u64 cur_alloc_size;
struct list_headevents;
struct list_headcache;
struct list_headto_free;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/