From patchwork Tue Jun 14 23:08:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9177163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5FAF960772 for ; Tue, 14 Jun 2016 23:10:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42D642832A for ; Tue, 14 Jun 2016 23:10:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 356E92833B; Tue, 14 Jun 2016 23:10:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C67652832A for ; Tue, 14 Jun 2016 23:10:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCxSI-0006uO-1n; Tue, 14 Jun 2016 23:09:10 +0000 Received: from mail-bn1bon0079.outbound.protection.outlook.com ([157.56.111.79] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCxSF-0006qJ-0e for linux-arm-kernel@lists.infradead.org; Tue, 14 Jun 2016 23:09:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-caviumnetworks-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=9vZwWg+62UKORh1QdL18rRh/wMcdTAxXzVY69Sx/VZ0=; b=uj3Mevr1JigG5Py2Bi756LzCSm3EEQcy9JShsj3otinq0rx4fg1V4tNviUINIA4ItmJyeJ2Nm4pzBk3WUMFnBs35EQCJxcL6+TLHdS2UvGk6iHaJ/fkZ0kA0XBK7UfQuaHLvFnCs4vviihTi9AqXKmxFeg0vJE0Qy8tgEhZpkVo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (50.233.148.158) by SN1PR07MB2256.namprd07.prod.outlook.com (10.164.47.150) with Microsoft SMTP Server (TLS) id 15.1.517.8; Tue, 14 Jun 2016 23:08:43 +0000 Date: Wed, 15 Jun 2016 02:08:38 +0300 From: Yury Norov To: Catalin Marinas Subject: Re: [PATCH 01/23] all: syscall wrappers: add documentation Message-ID: <20160614230838.GA15130@yury-N73SV> References: <6293194.tGy03QJ9ME@wuerfel> <20160525.135039.244098606649448826.davem@davemloft.net> <6407614.fdv5XFSBue@wuerfel> <20160525.142821.1719403997976778673.davem@davemloft.net> <20160526204819.GA10274@yury-N73SV> <20160526222943.GA16729@MBP.local> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160526222943.GA16729@MBP.local> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [50.233.148.158] X-ClientProxiedBy: BLUPR18CA0010.namprd18.prod.outlook.com (10.162.230.20) To SN1PR07MB2256.namprd07.prod.outlook.com (10.164.47.150) X-MS-Office365-Filtering-Correlation-Id: 435beb35-3417-4a87-ea1d-08d394a8d52c X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2256; 2:EmGvA1DkE+QNA56ZLDzzShsw8H25vh3cuURscpR+pam922OsTX2Ns/1EbgXGkRvq3mCeFWXzIVhaiOrOkRlYItY/r9DL/PxISM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QnorsrN2fNpUjs603sp5evz1AlIwv+/dBz1rgl7tub/OPvpT9R3Vhts83gpLtcbD87xGHH8nN1nTIkqHO95654niH0kWk6KRKFVhfk5eeEEqQZtiBLhhO1Uu78I2l56L0HlR9bJc X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2256; 20:fVtcmbvp7BrIibsTHXs63FxPVYY8bLJ0+zftOqtD1y8Hc5xAYF9Y8TOo4S9x3Hm1jRQY9+iNeTk7dCH6kVJ2WMf6x5QKyz6Xr1CLOoIqkIBW0lOUE389PM0WxL55d30v24+HnBl7/VHYM123CEZWZyMKN2hcPwo8PJJUHQNBpMTXl6jbecTiRX8cmNJAhPrrqYScCB1tXaXGmZz2X8rz+O9hflWtzywBhABFg7XH/Jfv/Ys9fa6liQ59BEqELnxJOLTGKNMWaH4VycNkwKJgrTdJCzfdvAZEfLs3NvQUjZyM9sTQtet2waGcprxuD14z+0eIMCYf+2RimFzNC5+4K2kYXUikVx3qWFkqEfELWMj3KJy4jBaJj50g+8XKWVvDOmXK6bUUbCT0vYfRDpfUY7N1lCwGlTOGYltdd8qZBcxqB64bisgkxppKO5zL7BXe4DbGwBek+aYbDv+HroO5SjacRnZLnzjhBV1jJYhv00j/8KgojFcjbRb9BN/+UvHB42Y+S7MUO/VR693oajuDMCgRslpDZ4nL0rJ+oHNFFyAxcmmQEBeWaYnTKODGob85Beg3uTuV+/9KCAF9HtWQyqR3lcAg1ppzWf4DnPK7ivg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(166708455590820); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:SN1PR07MB2256; BCL:0; PCL:0; RULEID:; SRVR:SN1PR07MB2256; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2256; 4:eUhR9H619bSAWTRgGqD3VdLA4P05UpUHn5a8zo1wK9PJ4tD0U7D3/rM6cX7IFNaXNAHXVMggbzUz0v5zxqG4NeNB5lxz0w/NqjiY1gp9yKMADBCpjF4UscANzJFX8niqo4Nm9cF2RZW/ElE1TqLXEBC+xR94g0VIJBlC33EOeWdJJFtNBk0TK81XSFxkFUSvU3078cOVtnLiTq+SnrOvuGXTnSRh9deav1Z8wF3TAmtP+PsaZmfPr5gFyttFjT4eKWPSGspC2wDqLD2TAwSKTQHG22GbyznabU+xw+BTivkQaVmuBkUEKxDmuIth4dhxH5D52FEwvGWvn63RrZjHQIly+/MGdciYjDzhSwsgPwzIhJ9kXPoFcAleq3v2tdjb5seg6ps0BWeBHqppmuy8Wb8xJVOBgcoMwnt92kSv/bA= X-Forefront-PRVS: 09730BD177 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(199003)(189002)(76506005)(47776003)(42186005)(4326007)(50466002)(66066001)(97756001)(2906002)(105586002)(586003)(106356001)(23726003)(3846002)(1076002)(6116002)(83506001)(9686002)(8676002)(5004730100002)(77096005)(76176999)(54356999)(19580395003)(2950100001)(189998001)(15975445007)(33656002)(93886004)(101416001)(5008740100001)(92566002)(81166006)(81156014)(33716001)(50986999)(97736004)(46406003)(110136002)(68736007)(4001350100001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB2256; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; CAT:NONE; LANG:en; CAT:NONE; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR07MB2256; 23:ZTkQKJ7SyP1VOeVqSZAsFxnHgG2PWl7YIu+r66jRe?= =?us-ascii?Q?iD0TxiZXPZ9QyMGhfyhRKhXWPkZ/B8eM9RoxdP4pGpBq+oKabpqwgV5z2TqS?= =?us-ascii?Q?vy/ldXrL3iTZx9ml3FPS85oNdHs2kSJlTDLOl1A8D0VoRGkDTHJaK/gRxPoj?= =?us-ascii?Q?XFyQGuuV5WoZkfDN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= =?us-ascii?Q?mERVB4IKsSjmD2mQsopKrm5heFK77Vey3w279/sxk7CaEn0WcgR/27JGHZ2+?= =?us-ascii?Q?5vUkg+74iyl1XaNWp1EnuuLOT864VU07wGGFmoOmK8GqpGX1EjaIQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2256; 6:Os4kf5bNcvLoEHuJgefU7/LOFkWIm1u1cCjihEYp/9Zpb3lK1YyqjRb+jAU8KrzhIHqIAlhYTD9IPS/K4VnmF/rTxmNVlRsOz6+MECm2vjp+SAJEmlNkyJkAdvL7D6Du5KQV3RKauxoKGKQ4HSBlekXxdsul7u5a2+C3UKylD+GjaYY/HW3S+Fqzq04ELet0yj4ZdV154ppzQhw4wYv+/iV2B/6zpAkpQN61oG3QvlGkmm3n8AHsGJeFf4+ooIu3Y0bFyHF1iBFInrJQnlGkNQ==; 5:NQAj0TNNUW/yoMiqDDtYsBrmeu7jB7161tvVkKLHvh0DnQMj70B2FE3K6h8VCD75Pmsd0X6eJgd55DJLqoG7edCLE0codWEHpuMG3/SjWvrEFYNjKa6wP+AYj4d14IM9xtDVMfvMAc2Yr5sNuoZn2A==; 24:Z9ShiJVbnGkwXVOcnsOOung76Imm2Ohl6KU+xlZR3XZmPYr/8o8JO/Z1IU0zBYxLKteNYqTRAHD6x/GD9rvNXtOJWpCTDT6gm4QWYlsJgEo=; 7:5VhhrG/ZpoeJyBYGXQXtY0HaQ+Uvr2n7ed1ydH/pknn2a/ApBPK8xq0l2xUx2JHClD6f6DJZy/xlUjlhmCQHljzE/hU3Fo0Gy0EoZlvwuDa1VV+kR+ZqAQtE8Ux9ymfS/yPiTC9Yx0vGJ4L6e+NG93f06yuARWFk0+RLIZSKj90Nfr5ncZqfTTzyjE9FFWjjSxGz5B4uWwtZmSo1cJcDSw== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2016 23:08:43.8857 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2256 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160614_160907_315182_7333F3AE X-CRM114-Status: GOOD ( 13.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-doc@vger.kernel.org, szabolcs.nagy@arm.com, heiko.carstens@de.ibm.com, philipp.tomsich@theobroma-systems.com, joseph@codesourcery.com, linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Prasun.Kapoor@caviumnetworks.com, agraf@suse.de, geert@linux-m68k.org, kilobyte@angband.pl, arnd@arndb.de, pinskia@gmail.com, klimov.linux@gmail.com, broonie@kernel.org, bamvor.zhangjian@huawei.com, linux-arm-kernel@lists.infradead.org, libc-alpha@sourceware.org, Nathan_Lynch@mentor.com, linux-kernel@vger.kernel.org, schwidefsky@de.ibm.com, David Miller , christoph.muellner@theobroma-systems.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Catalin, David, all > COMPAT_SYSCALL_WRAP2(creat, ...): > mov w0, w0 > b > > > > Cost wise, this seems like it all cancels out in the end, but what > > > do I know? > > > > I think you know something, and I also think Heiko and other s390 guys > > know something as well. So I'd like to listen their arguments here. > > > > For me spark64 way is looking reasonable only because it's really simple > > and takes less coding. I'll try it on some branch and share here what happened. > > The kernel code will definitely look simpler ;). It would be good to see > if there actually is any performance impact. Even with 16 more cycles on > syscall entry, would they be lost in the noise? You don't need a full > implementation, just some dummy mov x0, x0 on the entry path. > > -- > Catalin I wrote a simple test: struct timeval start, end; unsigned long long ut; int main() { gettimeofday(&start, NULL); for (int i = 1000000; i; i--) syscall(__NR_getrusage, 100 /* EINVAL */, NULL); gettimeofday(&end, NULL); ut = (end.tv_sec - start.tv_sec) * 1000000ULL + end.tv_usec - start.tv_usec; printf("%lld\n", ut); exit(EXIT_SUCCESS); } In kernel there's minimal overhead: return -EINVAL; On QEMU: With MOVs: W/O MOVs: 832015 814564 840639 803165 830482 813116 832895 802928 832083 832658 834461 802993 829405 812465 846677 822651 828409 803393 836845 821470 828716 801044 831620 821301 825423 800278 829946 821476 We have 83 mS vs 81 mS, ~2.6% of performance degradation. And I can show bigger numbers if I'll use asm svc instead of syscall() wrapper which increases time as well. It's definitely more than 0, but not so big anyway. For syscalls with heavy payload it will be non-measurable. So the choice is still there. Should we use wrappers and save 2.5% of syscall performance. Or clear top-halves unconditionally and win in simplicity? If QEMU is looking non-representative, I can run test on real hardware, but it takes a time, and I think will end up with similar results. Latest kernel with wrappers and library are here: https://github.com/norov/linux/commits/ilp32 https://github.com/norov/glibc/commits/ilp32-dev BTW, notice the change in ABI: syscalls that take stat and statfs structures now routed to (wrapped) native handlers, after switching userspace to use 64-bit off_t, ino_t, blkcnt_t, fsblkcnt_t and fsfilcnt_t types. Yury. diff --git a/kernel/sys.c b/kernel/sys.c index 89d5be4..003d5ad 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1634,6 +1634,17 @@ COMPAT_SYSCALL_DEFINE2(getrusage, int, who, struct compat_rusage __user *, ru) { struct rusage r; + asm volatile ( + " mov w0, w0 \n" + " mov w1, w1 \n" + " mov w2, w2 \n" + " mov w3, w3 \n" + " mov w4, w4 \n" + " mov w5, w5 \n" + " mov w6, w6 \n" + " mov w7, w7 \n" + ); + if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN && who != RUSAGE_THREAD)