Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751516AbdIJLsG (ORCPT ); Sun, 10 Sep 2017 07:48:06 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:38565 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751441AbdIJLsF (ORCPT ); Sun, 10 Sep 2017 07:48:05 -0400 X-Google-Smtp-Source: ADKCNb7tBt/wZ/0Orm+0Xw7+yEnx13YQZzwzIuxT2A4hD00EkKIxUF6M/UAPlbMpIV+FRgDLYtyISLFTTLGaoaMj7bg= MIME-Version: 1.0 In-Reply-To: <20170816002559.162668-3-sherryy@android.com> References: <20170816002559.162668-1-sherryy@android.com> <20170816002559.162668-3-sherryy@android.com> From: Geert Uytterhoeven Date: Sun, 10 Sep 2017 13:48:04 +0200 X-Google-Sender-Auth: ThdX4f1kD6jUue4H1M5Z73rzFVs Message-ID: Subject: Re: [PATCH 2/5] android: binder: Add allocator selftest To: Sherry Yang Cc: "linux-kernel@vger.kernel.org" , tkjos@google.com, maco@google.com, Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Riley Andrews , "open list:ANDROID DRIVERS" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3152 Lines: 81 Hi Sherry, On Wed, Aug 16, 2017 at 2:25 AM, Sherry Yang wrote: > binder_alloc_selftest tests that alloc_new_buf handles page allocation and > deallocation properly when allocate and free buffers. The test allocates 5 > buffers of various sizes to cover all possible page alignment cases, and > frees the buffers using a list of exhaustive freeing order. > > Test: boot the device with ANDROID_BINDER_IPC_SELFTEST config option > enabled. Allocator selftest passes. > > Change-Id: I9064f60c85b1e0389c88e927e2b147ec92cae0d1 > Signed-off-by: Sherry Yang > --- > drivers/android/Kconfig | 10 ++ > drivers/android/Makefile | 1 + > drivers/android/binder.c | 2 + > drivers/android/binder_alloc.h | 5 + > drivers/android/binder_alloc_selftest.c | 271 ++++++++++++++++++++++++++++++++ > 5 files changed, 289 insertions(+) > create mode 100644 drivers/android/binder_alloc_selftest.c > > diff --git a/drivers/android/Kconfig b/drivers/android/Kconfig > index 832e885349b1..0f295704abd4 100644 > --- a/drivers/android/Kconfig > +++ b/drivers/android/Kconfig > @@ -44,6 +44,16 @@ config ANDROID_BINDER_IPC_32BIT > > Note that enabling this will break newer Android user-space. > > +config ANDROID_BINDER_IPC_SELFTEST > + bool "Android Binder IPC Driver Selftest" What about making this tristate... > + depends on ANDROID_BINDER_IPC > + ---help--- > + This feature allows binder selftest to run. > + > + Binder selftest checks the allocation and free of binder buffers > + exhaustively with combinations of various buffer sizes and > + alignments. > + > endif # if ANDROID > > endmenu > diff --git a/drivers/android/Makefile b/drivers/android/Makefile > index 4b7c726bb560..a01254c43ee3 100644 > --- a/drivers/android/Makefile > +++ b/drivers/android/Makefile > @@ -1,3 +1,4 @@ > ccflags-y += -I$(src) # needed for trace events > > obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o binder_alloc.o > +obj-$(CONFIG_ANDROID_BINDER_IPC_SELFTEST) += binder_alloc_selftest.o > diff --git a/drivers/android/binder.c b/drivers/android/binder.c > index 9f95d7093f32..b31e64c6f666 100644 > --- a/drivers/android/binder.c > +++ b/drivers/android/binder.c > @@ -4225,6 +4225,8 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) > /*pr_info("binder_ioctl: %d:%d %x %lx\n", > proc->pid, current->pid, cmd, arg);*/ > > + binder_selftest_alloc(&proc->alloc); ... and calling the selftest function from module_init() in drivers/android/binder_alloc_selftest.c? That way the test can either run builtin during starup, or during module load, like most other selftests? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds