public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ANDROID: binder: show high watermark of alloc->pages.
@ 2017-11-13  9:06 Martijn Coenen
  2017-11-13  9:49 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Martijn Coenen @ 2017-11-13  9:06 UTC (permalink / raw)
  To: gregkh, john.stultz, tkjos, arve, amit.pundir
  Cc: linux-kernel, devel, maco, Martijn Coenen

Show the high watermark of the index into the alloc->pages
array, to facilitate sizing the buffer on a per-process
basis.

Signed-off-by: Martijn Coenen <maco@android.com>
---
 drivers/android/binder_alloc.c | 4 ++++
 drivers/android/binder_alloc.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 6f6f745605af..0dba2308125c 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -281,6 +281,9 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
 			goto err_vm_insert_page_failed;
 		}
 
+		if (index + 1 > alloc->pages_high)
+			alloc->pages_high = index + 1;
+
 		trace_binder_alloc_page_end(alloc, index);
 		/* vm_insert_page does not seem to increment the refcount */
 	}
@@ -853,6 +856,7 @@ void binder_alloc_print_pages(struct seq_file *m,
 	}
 	mutex_unlock(&alloc->mutex);
 	seq_printf(m, "  pages: %d:%d:%d\n", active, lru, free);
+	seq_printf(m, "  pages high watermark: %zu\n", alloc->pages_high);
 }
 
 /**
diff --git a/drivers/android/binder_alloc.h b/drivers/android/binder_alloc.h
index 2dd33b6df104..0b145307f1fd 100644
--- a/drivers/android/binder_alloc.h
+++ b/drivers/android/binder_alloc.h
@@ -92,6 +92,7 @@ struct binder_lru_page {
  * @pages:              array of binder_lru_page
  * @buffer_size:        size of address space specified via mmap
  * @pid:                pid for associated binder_proc (invariant after init)
+ * @pages_high:         high watermark of offset in @pages
  *
  * Bookkeeping structure for per-proc address space management for binder
  * buffers. It is normally initialized during binder_init() and binder_mmap()
@@ -112,6 +113,7 @@ struct binder_alloc {
 	size_t buffer_size;
 	uint32_t buffer_free;
 	int pid;
+	size_t pages_high;
 };
 
 #ifdef CONFIG_ANDROID_BINDER_IPC_SELFTEST
-- 
2.15.0.448.gf294e3d99a-goog

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ANDROID: binder: show high watermark of alloc->pages.
  2017-11-13  9:06 [PATCH] ANDROID: binder: show high watermark of alloc->pages Martijn Coenen
@ 2017-11-13  9:49 ` Greg KH
  2017-11-13  9:59   ` Martijn Coenen
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2017-11-13  9:49 UTC (permalink / raw)
  To: Martijn Coenen
  Cc: john.stultz, tkjos, arve, amit.pundir, devel, maco, linux-kernel

On Mon, Nov 13, 2017 at 10:06:56AM +0100, Martijn Coenen wrote:
> Show the high watermark of the index into the alloc->pages
> array, to facilitate sizing the buffer on a per-process
> basis.
> 
> Signed-off-by: Martijn Coenen <maco@android.com>
> ---
>  drivers/android/binder_alloc.c | 4 ++++
>  drivers/android/binder_alloc.h | 2 ++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
> index 6f6f745605af..0dba2308125c 100644
> --- a/drivers/android/binder_alloc.c
> +++ b/drivers/android/binder_alloc.c
> @@ -281,6 +281,9 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
>  			goto err_vm_insert_page_failed;
>  		}
>  
> +		if (index + 1 > alloc->pages_high)
> +			alloc->pages_high = index + 1;
> +
>  		trace_binder_alloc_page_end(alloc, index);
>  		/* vm_insert_page does not seem to increment the refcount */
>  	}
> @@ -853,6 +856,7 @@ void binder_alloc_print_pages(struct seq_file *m,
>  	}
>  	mutex_unlock(&alloc->mutex);
>  	seq_printf(m, "  pages: %d:%d:%d\n", active, lru, free);
> +	seq_printf(m, "  pages high watermark: %zu\n", alloc->pages_high);

Who can use this?  A userspace tool?  Or something else?

This is ok for 4.15-rc1, right?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ANDROID: binder: show high watermark of alloc->pages.
  2017-11-13  9:49 ` Greg KH
@ 2017-11-13  9:59   ` Martijn Coenen
  0 siblings, 0 replies; 3+ messages in thread
From: Martijn Coenen @ 2017-11-13  9:59 UTC (permalink / raw)
  To: Greg KH
  Cc: John Stultz, Todd Kjos, Arve Hjønnevåg, Amit Pundir,
	devel, Martijn Coenen, LKML

On Mon, Nov 13, 2017 at 10:49 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> Who can use this?  A userspace tool?  Or something else?

The output is part of Android bugreports, it's not parsed
automatically but the information is very useful even to manually look
at. Since Treble, we have more processes using binder, and some 32-bit
Android targets run out of vmalloc space because every process using
binder allocates 1MB in vmalloc address space. 1MB is overkill for
many processes, and this helps us find out which processes that are.

> This is ok for 4.15-rc1, right?

Yes.

Thanks,
Martijn

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-13  9:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-13  9:06 [PATCH] ANDROID: binder: show high watermark of alloc->pages Martijn Coenen
2017-11-13  9:49 ` Greg KH
2017-11-13  9:59   ` Martijn Coenen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox