Received: by 10.223.164.221 with SMTP id h29csp2391060wrb; Mon, 23 Oct 2017 06:41:51 -0700 (PDT) X-Received: by 10.159.218.135 with SMTP id w7mr10537263plp.229.1508766111412; Mon, 23 Oct 2017 06:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508766111; cv=none; d=google.com; s=arc-20160816; b=eA+Layg8sukZF6eDrcBPSHWYpNbTcEHgCpPEZpN94rfORcN38aEgHwEbzrT4d5adE0 kk5PVkI1B0ojwJ8YaivK/o/MiqKYm1l3B61Zmkmdfxp/Oi2M1mfC5KlnIxRSBrzOwN+r syI8UvwnbkepUW6Llx3WAil5XEAOo+nsh1vcA6eynjZWJUT247Vmwgr0xmqDcqbQctWi dIZCM9ICyGvRIL/o4wnleWrXMTrK0ZZIhjr7bNdSRyRZ/KeCwtHxBJTxxRNWsHA8gHYy JNrD7VKZCnv3wDxF1iEOgk8zkdHfOv7p5M7UfRahk0juLeD1xcWb9UbF/gf23sdAN1VI NJNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=guU9gyHdellV3IugMUejnH+MECc0AVdNPumnIg7xC8s=; b=aavH8PAlXfgWkp8gpqITZphMcux7UOR367USJu6YhcBKcIfq82g5Ovit8efxKAK95C M0oM9j/Tfoy/YDT/xMQ5E+eyMSEPNXiRTw57mrvkpLWh0Fj+yG61Waa2hYgOE4/CXLnP 8ueMl5DczfLjv8+aTQE5Jr0nn68VL+ntrxeGiKB9PMq4iTl2tG6lN+zbJJwk4I6UoUfi WyXcdKbHY3C4A8mqNcK1yRCtjgMNkElJh3SvwcogIuTYYvekLJVtnjl4DfsC8kT/cNjm N1ia4sszg3YmR4mNnAbFakeeNyVC1e7ePlYh8EGlP2R/gbsjQuXmx4Gt1uaqMnYzr62G 0QLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EkuYA9eb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w62si5366834pfb.133.2017.10.23.06.41.37; Mon, 23 Oct 2017 06:41:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EkuYA9eb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932282AbdJWNlP (ORCPT + 99 others); Mon, 23 Oct 2017 09:41:15 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:50150 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932188AbdJWNlN (ORCPT ); Mon, 23 Oct 2017 09:41:13 -0400 Received: by mail-lf0-f67.google.com with SMTP id w21so20211647lfc.6; Mon, 23 Oct 2017 06:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=guU9gyHdellV3IugMUejnH+MECc0AVdNPumnIg7xC8s=; b=EkuYA9ebHPFNS2Xo8nO/AdKqSWdozdq0wgSah9mCgxD4ysB4qnTcKUQSHFOyLUPhLh aQW28dHrBzu2lhPfymYz70zGZ5jBEI++jv0xJSrzOhEVlqtLaGMNyXx9oH1T/iweI44G EJY4LD2acZqp9AVAXySRDLvRgXH41unvYMwI1HXqYM97q+c84ICDDn2DjtBl2aiVSlcx 2tBxGh5l3kq54hnFQ1s7XwIMn/tNA4Pffxds/mz5X1x/iIqZ4yzPCGPiJTU1zDtuJvDG WGiV0yIJs4OzD8DxkRs0AP0NASegGcJNlp0wuH+n7jbhKYW35ptlUUdm9yCFUrijYOwO LZqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=guU9gyHdellV3IugMUejnH+MECc0AVdNPumnIg7xC8s=; b=fv+ez673hx4xXrFaOP8X9DdLuVaV/eLlTLqCYvO+6rTtVK35TxIwaMBKPEfXYvYZ4i u11UWy9hHPjFchcbQz/X+dywh6NmhC1jex8zMggAa3Q0dvuG/nOvqeNpOFmuTAd++9ML T0w4jb8z3Tk8ro0eWJwBRqoTknVz3LXpejTW38Dxe60aBO6MDY+M2L5x/kiezy5s2/6J ++OXq2NSmdGZKsUuDO2JF6fnuDdYqEwEojn4nTbrIVkuBSID4pbYsCfi/nFjSx+DuaFv 1hfSvgtBBpdDS0BVthvWkcmxwpx+u2yCQhCltfjNRprM/jQmDzBnSIFpqFDTaP+nC5So G6ug== X-Gm-Message-State: AMCzsaVycJz1YIoj23BhDmjjoZVVxNNqLI6jR52uLRy18tc5NfD97Zsm SO7c+CcxTNCpbrtZiwsLyIS4ALjsCbbVVcd6fuY= X-Google-Smtp-Source: ABhQp+TCBUOzsSAjOMlWpHvYT7Q1CLRHLz7i4CYihThU9oOcXX4ORN6/fwrIg4lSM3fLjxBudGLz0c/Pgs02lqojdtM= X-Received: by 10.25.23.214 with SMTP id 83mr4441855lfx.213.1508766071729; Mon, 23 Oct 2017 06:41:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.167.79 with HTTP; Mon, 23 Oct 2017 06:41:11 -0700 (PDT) In-Reply-To: References: <1507049339-16963-1-git-send-email-pintu.ping@gmail.com> <1507981006-7430-1-git-send-email-pintu.ping@gmail.com> <2c0cf8c1-7f4d-5639-58d3-0fd7595df256@redhat.com> <9fb9b4ee-2834-511b-ff78-d14ea5609728@kernel.org> <53743866-3a76-e499-b49c-5079ad73e3be@osg.samsung.com> From: Pintu Kumar Date: Mon, 23 Oct 2017 19:11:11 +0530 Message-ID: Subject: Re: [PATCHv3 1/1] [tools/selftests]: android/ion: userspace test utility for ion buffer sharing To: Shuah Khan , Pintu Kumar Cc: shuah@kernel.org, Laura Abbott , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Greg Kroah-Hartman , dvhart@infradead.org, Bamvor Zhang Jian Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 21, 2017 at 12:51 AM, Shuah Khan wrote: > On 10/20/2017 09:18 AM, Pintu Kumar wrote: >> On Fri, Oct 20, 2017 at 8:10 PM, Shuah Khan wrote: >>> On 10/18/2017 04:38 AM, Pintu Kumar wrote: >>>> On Wed, Oct 18, 2017 at 2:28 AM, Shuah Khan wrote: >>>>> On 10/17/2017 02:21 PM, Laura Abbott wrote: >>>>>> On 10/14/2017 04:36 AM, Pintu Agarwal wrote: >>>>>>> This is a test utility to verify ION buffer sharing in user space >>>>>>> between 2 independent processes. >>>>>>> It uses unix domain socket (with SCM_RIGHTS) as IPC to transfer an FD to >>>>>>> another process to share the same buffer. >>>>>>> This utility demonstrates how ION buffer sharing can be implemented between >>>>>>> two user space processes, using various heap types. >>>>>>> >>>>>>> This utility is made to be run as part of kselftest framework in kernel. >>>>>>> The utility is verified on Ubuntu-32 bit system with Linux Kernel 4.14, >>>>>>> using ION system heap and CMA heap. >>>>>>> >>>>>>> For more information about the utility please check the README file. >>>>>>> >>>>>>> Signed-off-by: Pintu Agarwal >>>>>>> --- >>>>>>> tools/testing/selftests/Makefile | 3 +- >>>>>>> tools/testing/selftests/android/Makefile | 44 ++++ >>>>>>> tools/testing/selftests/android/ion/.gitignore | 2 + >>>>>>> tools/testing/selftests/android/ion/Makefile | 16 ++ >>>>>>> tools/testing/selftests/android/ion/README | 132 +++++++++++ >>>>>>> tools/testing/selftests/android/ion/config | 3 + >>>>>>> tools/testing/selftests/android/ion/ion_test.sh | 61 +++++ >>>>>>> .../testing/selftests/android/ion/ionapp_export.c | 151 ++++++++++++ >>>>>>> .../testing/selftests/android/ion/ionapp_import.c | 88 +++++++ >>>>>>> tools/testing/selftests/android/ion/ionutils.c | 259 +++++++++++++++++++++ >>>>>>> tools/testing/selftests/android/ion/ionutils.h | 55 +++++ >>>>>>> tools/testing/selftests/android/ion/ipcsocket.c | 227 ++++++++++++++++++ >>>>>>> tools/testing/selftests/android/ion/ipcsocket.h | 35 +++ >>>>>>> tools/testing/selftests/android/run.sh | 3 + >>>>>>> 14 files changed, 1078 insertions(+), 1 deletion(-) >>>>>>> create mode 100644 tools/testing/selftests/android/Makefile >>>>>>> create mode 100644 tools/testing/selftests/android/ion/.gitignore >>>>>>> create mode 100644 tools/testing/selftests/android/ion/Makefile >>>>>>> create mode 100644 tools/testing/selftests/android/ion/README >>>>>>> create mode 100644 tools/testing/selftests/android/ion/config >>>>>>> create mode 100755 tools/testing/selftests/android/ion/ion_test.sh >>>>>>> create mode 100644 tools/testing/selftests/android/ion/ionapp_export.c >>>>>>> create mode 100644 tools/testing/selftests/android/ion/ionapp_import.c >>>>>>> create mode 100644 tools/testing/selftests/android/ion/ionutils.c >>>>>>> create mode 100644 tools/testing/selftests/android/ion/ionutils.h >>>>>>> create mode 100644 tools/testing/selftests/android/ion/ipcsocket.c >>>>>>> create mode 100644 tools/testing/selftests/android/ion/ipcsocket.h >>>>>>> create mode 100755 tools/testing/selftests/android/run.sh >>>>>>> >>>>>>> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile >>>>>>> index ff80564..61bc77b 100644 >>>>>>> --- a/tools/testing/selftests/Makefile >>>>>>> +++ b/tools/testing/selftests/Makefile >>>>>>> @@ -1,4 +1,5 @@ >>>>>>> -TARGETS = bpf >>>>>>> +TARGETS = android >>>>>>> +TARGETS += bpf >>>>>>> TARGETS += breakpoints >>>>>>> TARGETS += capabilities >>>>>>> TARGETS += cpufreq >>>>>>> diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile >>>>>>> new file mode 100644 >>>>>>> index 0000000..ee76446 >>>>>>> --- /dev/null >>>>>>> +++ b/tools/testing/selftests/android/Makefile >>>>>>> @@ -0,0 +1,44 @@ >>>>>>> +SUBDIRS := ion >>>>>>> + >>>>>>> +TEST_PROGS := run.sh >>>>>>> + >>>>>>> +.PHONY: all clean >>>>>>> + >>>>>>> +include ../lib.mk >>>>>>> + >>>>>>> +all: >>>>>>> + @for DIR in $(SUBDIRS); do \ >>>>>>> + BUILD_TARGET=$(OUTPUT)/$$DIR; \ >>>>>>> + mkdir $$BUILD_TARGET -p; \ >>>>>>> + make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ >>>>>>> + if [ -e $$DIR/$(TEST_PROGS) ]; then >>>>>>> + rsync -a $$DIR/$(TEST_PROGS) $$BUILD_TARGET/; >>>>>>> + fi >>>>>>> + done >>>>>>> + >>>>>>> +override define RUN_TESTS >>>>>>> + @cd $(OUTPUT); ./run.sh >>>>>>> +endef >>>>>>> + >>>>>>> +override define INSTALL_RULE >>>>>>> + mkdir -p $(INSTALL_PATH) >>>>>>> + install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) >>>>>>> + >>>>>>> + @for SUBDIR in $(SUBDIRS); do \ >>>>>>> + BUILD_TARGET=$(OUTPUT)/$$SUBDIR; \ >>>>>>> + mkdir $$BUILD_TARGET -p; \ >>>>>>> + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$SUBDIR INSTALL_PATH=$(INSTALL_PATH)/$$SUBDIR install; \ >>>>>>> + done; >>>>>>> +endef >>>>>>> + >>>>>>> +override define EMIT_TESTS >>>>>>> + echo "./run.sh" >>>>>>> +endef >>>>>>> + >>>>>>> +override define CLEAN >>>>>>> + @for DIR in $(SUBDIRS); do \ >>>>>>> + BUILD_TARGET=$(OUTPUT)/$$DIR; \ >>>>>>> + mkdir $$BUILD_TARGET -p; \ >>>>>>> + make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ >>>>>>> + done >>>>>>> +endef >>>>>>> diff --git a/tools/testing/selftests/android/ion/.gitignore b/tools/testing/selftests/android/ion/.gitignore >>>>>>> new file mode 100644 >>>>>>> index 0000000..67e6f39 >>>>>>> --- /dev/null >>>>>>> +++ b/tools/testing/selftests/android/ion/.gitignore >>>>>>> @@ -0,0 +1,2 @@ >>>>>>> +ionapp_export >>>>>>> +ionapp_import >>>>>>> diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile >>>>>>> new file mode 100644 >>>>>>> index 0000000..b84e3b1 >>>>>>> --- /dev/null >>>>>>> +++ b/tools/testing/selftests/android/ion/Makefile >>>>>>> @@ -0,0 +1,16 @@ >>>>>>> + >>>>>>> +INCLUDEDIR := -I../../../../../drivers/staging/android/uapi/ >>>>>>> +CFLAGS := $(INCLUDEDIR) -Wall -O2 -g >>>>>>> + >>>>>>> +TEST_GEN_FILES := ionapp_export ionapp_import >>>>>>> + >>>>>>> +all: $(TEST_GEN_FILES) >>>>>>> + >>>>>>> +$(TEST_GEN_FILES): ipcsocket.c ionutils.c >>>>>>> + >>>>>>> +TEST_PROGS := ion_test.sh >>>>>>> + >>>>>>> +include ../../lib.mk >>>>>>> + >>>>>>> +$(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c >>>>>>> +$(OUTPUT)/ionapp_import: ionapp_import.c ipcsocket.c ionutils.c >>>>>>> diff --git a/tools/testing/selftests/android/ion/README b/tools/testing/selftests/android/ion/README >>>>>>> new file mode 100644 >>>>>>> index 0000000..163e353 >>>>>>> --- /dev/null >>>>>>> +++ b/tools/testing/selftests/android/ion/README >>>>>>> @@ -0,0 +1,132 @@ >>>>>>> +ION BUFFER SHARING UTILITY >>>>>>> +========================== >>>>>>> +File: ion_test.sh : Utility to test ION driver buffer sharing mechanism. >>>>>>> +Author: Pintu Kumar >>>>>>> + >>>>>>> +Introduction: >>>>>>> +------------- >>>>>>> +This is a test utility to verify ION buffer sharing in user space >>>>>>> +between 2 independent processes. >>>>>>> +It uses unix domain socket (with SCM_RIGHTS) as IPC to transfer an FD to >>>>>>> +another process to share the same buffer. >>>>>>> +This utility demonstrates how ION buffer sharing can be implemented between >>>>>>> +two user space processes, using various heap types. >>>>>>> +The following heap types are supported by ION driver. >>>>>>> +ION_HEAP_TYPE_SYSTEM (0) >>>>>>> +ION_HEAP_TYPE_SYSTEM_CONTIG (1) >>>>>>> +ION_HEAP_TYPE_CARVEOUT (2) >>>>>>> +ION_HEAP_TYPE_CHUNK (3) >>>>>>> +ION_HEAP_TYPE_DMA (4) >>>>>>> + >>>>>>> +By default only the SYSTEM and SYSTEM_CONTIG heaps are supported. >>>>>>> +Each heap is associated with the respective heap id. >>>>>>> +This utility is designed in the form of client/server program. >>>>>>> +The server part (ionapp_export) is the exporter of the buffer. >>>>>>> +It is responsible for creating an ION client, allocating the buffer based on >>>>>>> +the heap id, writing some data to this buffer and then exporting the FD >>>>>>> +(associated with this buffer) to another process using socket IPC. >>>>>>> +This FD is called as buffer FD (which is different than the ION client FD). >>>>>>> + >>>>>>> +The client part (ionapp_import) is the importer of the buffer. >>>>>>> +It retrives the FD from the socket data and installs into its address space. >>>>>>> +This new FD internally points to the same kernel buffer. >>>>>>> +So first it reads the data that is stored in this buffer and prints it. >>>>>>> +Then it writes the different size of data (it could be different data) to the >>>>>>> +same buffer. >>>>>>> +Finally the buffer FD must be closed by both the exporter and importer. >>>>>>> +Thus the same kernel buffer is shared among two user space processes using >>>>>>> +ION driver and only one time allocation. >>>>>>> + >>>>>>> +Prerequisite: >>>>>>> +------------- >>>>>>> +This utility works only if /dev/ion interface is present. >>>>>>> +The following configs needs to be enabled in kernel to include ion driver. >>>>>>> +CONFIG_ANDROID=y >>>>>>> +CONFIG_ION=y >>>>>>> +CONFIG_ION_SYSTEM_HEAP=y >>>>>> >>>>>> You also need CONFIG_STAGING right now as well. >>>>> >>>> >>>> Ok, added CONFIG_STAGING under config and README >>>> >>>>> In which case, please make sure the test fails gracefully when the >>>>> these config options are disabled. >>>>> >>>>> What does the test do when all of these options are disabled? >>>>> >>>> I assume that if these configs are not present the /dev/ion will also >>>> not exists. >>>> If that is the case then, I don't proceed with the test. >>>> This is checked under ion_test script using: check_device >>>> >>>>>> >>>>>>> + >>>>>>> +This utility requires to be run as root user. >>>>>>> + >>>>>>> + >>>>>>> +Compile and test: >>>>>>> +----------------- >>>>>>> +This utility is made to be run as part of kselftest framework in kernel. >>>>>>> +To compile and run using kselftest you can simply do the following from the >>>>>>> +kernel top directory. >>>>>>> +linux$ make TARGETS=android kselftest >>>>> >>>>> Please make sure >>>>> >>>>> make O=/tmp/kselftest TARGETS=android kselftest >>>>> >>>>> works. >>>>> >>>> >>>> Ok when I specify O as output directory. It did not work. >>>> ./run.sh: 3: ./run.sh: ./ion_test.sh: not found >>>> ../lib.mk:41: recipe for target 'run_tests' failed >>>> >>>> When I checked /tmp/kselftest/ion/, I see that ion_test.sh is not installed. >>>> Only the executable are installed. >>>> I followed the same Makefile as futex. >>>> Currently I am trying to figure out what could be the problem. >>>> Any hint will be really appreciated. >>> >>> Please see the latest futex Makefile from 4.14. You will see that the >>> TEST_PROGS get copied from its all target for sub-dirs. You just have to >>> add a copy in that path >>> >> >> Yes, I am already using the latest version of futex/Makefile. >> Actually I figured out the problem, but currently I don't know how to fix it. >> In futex case, both in the main dir as well as sub-dir they are using >> the same TEST_PROGS name as . >> So both the scripts are getting installed in /tmp/. >> However in my case, in main dir I am using but in sub-dir I >> am using as TEST_PROGS. > > That should be fine. Let me play with it and let you know. > >> So, the sub-dir TEST_PROGS is not installed. Only the TEST_GEN_FILES >> are installed. > > Right. This is not for install path. This is setting up the O=dir with > the right files for run_tests target. > >> If I change the name to , then it is working fine. >> > Currently I am checking more how to fix this. This could be problem >> with futex as well. > > I don't think that is the problem.' > >> If I could not figure out, I will also change TEST_PROGS to run.sh and push it. > Ok I found the problem and fixed it. Now it is working fine with ion_test.sh script as well. I verified that the same problem is there in futex as well, if I change the name of script inside functional from run.sh to some other name. Now I verified all the various test using kselftest. - make kselftest - ./kselftest_install.sh - make TARGETS=android kselftest - make -C tools/testing/selftests TARGETS=android run_tests - make O=/tmp/kselftest TARGETS=android kselftest And I have verified using root and without root as well. I will push the new patch set soon. Thanks, Pintu > thanks, > -- Shuah > From 1581805679229508776@xxx Fri Oct 20 19:24:09 +0000 2017 X-GM-THRID: 1579656416160844925 X-Gmail-Labels: Inbox,Category Forums