* [PATCH 0/2] android: binder: debug message improvements
@ 2018-07-27 0:17 Sherry Yang
2018-07-27 0:17 ` [PATCH 1/2] android: binder: Show extra_buffers_size in trace Sherry Yang
2018-07-27 0:17 ` [PATCH 2/2] android: binder: Rate-limit debug and userspace triggered err msgs Sherry Yang
0 siblings, 2 replies; 4+ messages in thread
From: Sherry Yang @ 2018-07-27 0:17 UTC (permalink / raw)
To: linux-kernel; +Cc: tkjos, maco
This patch set includes extra_buffers_size in trace so that the
total transaction size can be inferred. It also ratelimits debug
messages to avoid excessive log spams reported by sysbot.
android: binder: Show extra_buffers_size in trace
android: binder: Rate-limit debug and userspace triggered err msgs
drivers/android/binder.c | 5 +++--
drivers/android/binder_alloc.c | 41 ++++++++++++++++++--------
drivers/android/binder_trace.h | 7 +++++--
3 files changed, 34 insertions(+), 19 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] android: binder: Show extra_buffers_size in trace
2018-07-27 0:17 [PATCH 0/2] android: binder: debug message improvements Sherry Yang
@ 2018-07-27 0:17 ` Sherry Yang
2018-07-27 0:17 ` [PATCH 2/2] android: binder: Rate-limit debug and userspace triggered err msgs Sherry Yang
1 sibling, 0 replies; 4+ messages in thread
From: Sherry Yang @ 2018-07-27 0:17 UTC (permalink / raw)
To: linux-kernel
Cc: tkjos, maco, Sherry Yang, Greg Kroah-Hartman,
Arve Hjønnevåg, Todd Kjos, Martijn Coenen,
open list:ANDROID DRIVERS
Add extra_buffers_size to the binder_transaction_alloc_buf tracepoint.
Acked-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Sherry Yang <sherryy@android.com>
---
drivers/android/binder_trace.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/android/binder_trace.h b/drivers/android/binder_trace.h
index 76e3b9c8a8a2..588eb3ec3507 100644
--- a/drivers/android/binder_trace.h
+++ b/drivers/android/binder_trace.h
@@ -248,14 +248,17 @@ DECLARE_EVENT_CLASS(binder_buffer_class,
__field(int, debug_id)
__field(size_t, data_size)
__field(size_t, offsets_size)
+ __field(size_t, extra_buffers_size)
),
TP_fast_assign(
__entry->debug_id = buf->debug_id;
__entry->data_size = buf->data_size;
__entry->offsets_size = buf->offsets_size;
+ __entry->extra_buffers_size = buf->extra_buffers_size;
),
- TP_printk("transaction=%d data_size=%zd offsets_size=%zd",
- __entry->debug_id, __entry->data_size, __entry->offsets_size)
+ TP_printk("transaction=%d data_size=%zd offsets_size=%zd extra_buffers_size=%zd",
+ __entry->debug_id, __entry->data_size, __entry->offsets_size,
+ __entry->extra_buffers_size)
);
DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf,
--
2.18.0.345.g5c9ce644c3-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] android: binder: Rate-limit debug and userspace triggered err msgs
2018-07-27 0:17 [PATCH 0/2] android: binder: debug message improvements Sherry Yang
2018-07-27 0:17 ` [PATCH 1/2] android: binder: Show extra_buffers_size in trace Sherry Yang
@ 2018-07-27 0:17 ` Sherry Yang
2018-08-02 8:34 ` Greg Kroah-Hartman
1 sibling, 1 reply; 4+ messages in thread
From: Sherry Yang @ 2018-07-27 0:17 UTC (permalink / raw)
To: linux-kernel
Cc: tkjos, maco, Sherry Yang, Greg Kroah-Hartman,
Arve Hjønnevåg, Todd Kjos, Martijn Coenen,
open list:ANDROID DRIVERS
Use rate-limited debug messages where userspace can trigger
excessive log spams.
Acked-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Sherry Yang <sherryy@android.com>
---
drivers/android/binder.c | 5 +++--
drivers/android/binder_alloc.c | 41 +++++++++++++++++++++-------------
2 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 95283f3bb51c..78cc1190282c 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -71,6 +71,7 @@
#include <linux/pid_namespace.h>
#include <linux/security.h>
#include <linux/spinlock.h>
+#include <linux/ratelimit.h>
#include <uapi/linux/android/binder.h>
#include "binder_alloc.h"
@@ -161,13 +162,13 @@ module_param_call(stop_on_user_error, binder_set_stop_on_user_error,
#define binder_debug(mask, x...) \
do { \
if (binder_debug_mask & mask) \
- pr_info(x); \
+ pr_info_ratelimited(x); \
} while (0)
#define binder_user_error(x...) \
do { \
if (binder_debug_mask & BINDER_DEBUG_USER_ERROR) \
- pr_info(x); \
+ pr_info_ratelimited(x); \
if (binder_stop_on_user_error) \
binder_stop_on_user_error = 2; \
} while (0)
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 2628806c64a2..e16116e9ad1f 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -28,6 +28,7 @@
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/list_lru.h>
+#include <linux/ratelimit.h>
#include "binder_alloc.h"
#include "binder_trace.h"
@@ -36,11 +37,12 @@ struct list_lru binder_alloc_lru;
static DEFINE_MUTEX(binder_alloc_mmap_lock);
enum {
+ BINDER_DEBUG_USER_ERROR = 1U << 0,
BINDER_DEBUG_OPEN_CLOSE = 1U << 1,
BINDER_DEBUG_BUFFER_ALLOC = 1U << 2,
BINDER_DEBUG_BUFFER_ALLOC_ASYNC = 1U << 3,
};
-static uint32_t binder_alloc_debug_mask;
+static uint32_t binder_alloc_debug_mask = BINDER_DEBUG_USER_ERROR;
module_param_named(debug_mask, binder_alloc_debug_mask,
uint, 0644);
@@ -48,7 +50,7 @@ module_param_named(debug_mask, binder_alloc_debug_mask,
#define binder_alloc_debug(mask, x...) \
do { \
if (binder_alloc_debug_mask & mask) \
- pr_info(x); \
+ pr_info_ratelimited(x); \
} while (0)
static struct binder_buffer *binder_buffer_next(struct binder_buffer *buffer)
@@ -152,8 +154,10 @@ static struct binder_buffer *binder_alloc_prepare_to_free_locked(
* free the buffer twice
*/
if (buffer->free_in_progress) {
- pr_err("%d:%d FREE_BUFFER u%016llx user freed buffer twice\n",
- alloc->pid, current->pid, (u64)user_ptr);
+ binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
+ "%d:%d FREE_BUFFER u%016llx user freed buffer twice\n",
+ alloc->pid, current->pid,
+ (u64)user_ptr);
return NULL;
}
buffer->free_in_progress = 1;
@@ -224,8 +228,9 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
}
if (!vma && need_mm) {
- pr_err("%d: binder_alloc_buf failed to map pages in userspace, no vma\n",
- alloc->pid);
+ binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
+ "%d: binder_alloc_buf failed to map pages in userspace, no vma\n",
+ alloc->pid);
goto err_no_vma;
}
@@ -344,8 +349,9 @@ static struct binder_buffer *binder_alloc_new_buf_locked(
int ret;
if (alloc->vma == NULL) {
- pr_err("%d: binder_alloc_buf, no vma\n",
- alloc->pid);
+ binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
+ "%d: binder_alloc_buf, no vma\n",
+ alloc->pid);
return ERR_PTR(-ESRCH);
}
@@ -417,11 +423,14 @@ static struct binder_buffer *binder_alloc_new_buf_locked(
if (buffer_size > largest_free_size)
largest_free_size = buffer_size;
}
- pr_err("%d: binder_alloc_buf size %zd failed, no address space\n",
- alloc->pid, size);
- pr_err("allocated: %zd (num: %zd largest: %zd), free: %zd (num: %zd largest: %zd)\n",
- total_alloc_size, allocated_buffers, largest_alloc_size,
- total_free_size, free_buffers, largest_free_size);
+ binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
+ "%d: binder_alloc_buf size %zd failed, no address space\n",
+ alloc->pid, size);
+ binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
+ "allocated: %zd (num: %zd largest: %zd), free: %zd (num: %zd largest: %zd)\n",
+ total_alloc_size, allocated_buffers,
+ largest_alloc_size, total_free_size,
+ free_buffers, largest_free_size);
return ERR_PTR(-ENOSPC);
}
if (n == NULL) {
@@ -731,8 +740,10 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
err_get_vm_area_failed:
err_already_mapped:
mutex_unlock(&binder_alloc_mmap_lock);
- pr_err("%s: %d %lx-%lx %s failed %d\n", __func__,
- alloc->pid, vma->vm_start, vma->vm_end, failure_string, ret);
+ binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
+ "%s: %d %lx-%lx %s failed %d\n", __func__,
+ alloc->pid, vma->vm_start, vma->vm_end,
+ failure_string, ret);
return ret;
}
--
2.18.0.345.g5c9ce644c3-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] android: binder: Rate-limit debug and userspace triggered err msgs
2018-07-27 0:17 ` [PATCH 2/2] android: binder: Rate-limit debug and userspace triggered err msgs Sherry Yang
@ 2018-08-02 8:34 ` Greg Kroah-Hartman
0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2018-08-02 8:34 UTC (permalink / raw)
To: Sherry Yang
Cc: linux-kernel, tkjos, maco, Arve Hjønnevåg, Todd Kjos,
Martijn Coenen, open list:ANDROID DRIVERS
On Thu, Jul 26, 2018 at 05:17:18PM -0700, Sherry Yang wrote:
> Use rate-limited debug messages where userspace can trigger
> excessive log spams.
>
> Acked-by: Arve Hjønnevåg <arve@android.com>
> Signed-off-by: Sherry Yang <sherryy@android.com>
> ---
> drivers/android/binder.c | 5 +++--
> drivers/android/binder_alloc.c | 41 +++++++++++++++++++++-------------
> 2 files changed, 29 insertions(+), 17 deletions(-)
This patch does not apply to my tree at all. Can you please rebase it
and resend?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-08-02 8:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-27 0:17 [PATCH 0/2] android: binder: debug message improvements Sherry Yang
2018-07-27 0:17 ` [PATCH 1/2] android: binder: Show extra_buffers_size in trace Sherry Yang
2018-07-27 0:17 ` [PATCH 2/2] android: binder: Rate-limit debug and userspace triggered err msgs Sherry Yang
2018-08-02 8:34 ` Greg Kroah-Hartman
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.