Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1250301ybg; Sat, 26 Oct 2019 16:10:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvhudXjErjt6/X02W1lMy3lfStxTeFGnsjSGyyDhHBye2Gjp3N6a2V8OYSAg6HeyBT86Ja X-Received: by 2002:a50:d70c:: with SMTP id t12mr11762680edi.252.1572131415999; Sat, 26 Oct 2019 16:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572131415; cv=none; d=google.com; s=arc-20160816; b=nWERUTf9FdS2BTNO7kN0NmU9I1NcZQeWUu8vgBHignD3f1rIEDmp6wdaS+nu6H68Ay TauAPIHOaS4SVg61miCzuvjTuEobH3DJwPk6VUnXS1ACkt5raHk6M0araSPEFp5KoeaP pw1xe3FglJVWDL0A7RGD6PcvWQtRsvWnphxQdKnqznI/rRZf2kiaMRFvLGj0mPEbnWyD j9xIVk4WQN+KMJN0D0edHdSe/ojLprFemMk/cGJp/jCyjPQE8pi9qtcO/oeMvFxFl60y qzY3hSpy3553iiV8NHlMl02GISI+6D/6J+NN9GUiq4JKLXMLpIRijr058uLcRRg7yRf8 SXfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8zf793uMAURodFat1/30zIiIx2Wqq2/xJmLQDHav1ro=; b=karUoOGkxODdJ+0g9t7h2MgiXDopfGb2+EOAlJZH4CuUjbfJMVlPfre4ByjqpQjlJ3 mpCDd45+GF0tMsundQ+S+3vjuqHWyXaKbeEnwjBH7P0Mm/mvd49y7C8FER5Yc6Q11Yu9 dD7CJcsNZFHhh1hroeJgNaz79QjURa+7Umn0ZzqljKjit8tTGtEZ4Kr/v7OcgiPqs+HU l0s9dI61u3zKSrsXyUWgVhGF9f3GSVL6pw5kzFOF9AhH8IKPG0qaNhqvsDkql8MajCqf A9GuDzfQhdXUlHQabsy2qkL+N9AXngImb44aA1F1TnrgUhST/4bX6Q00HF6fPJirwXSV cQIg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c57si4666030edc.386.2019.10.26.16.09.23; Sat, 26 Oct 2019 16:10:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726541AbfJZXGx (ORCPT + 99 others); Sat, 26 Oct 2019 19:06:53 -0400 Received: from gate.crashing.org ([63.228.1.57]:55397 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726443AbfJZXGx (ORCPT ); Sat, 26 Oct 2019 19:06:53 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x9QN6B4B014950; Sat, 26 Oct 2019 18:06:11 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id x9QN69JB014947; Sat, 26 Oct 2019 18:06:09 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Sat, 26 Oct 2019 18:06:09 -0500 From: Segher Boessenkool To: Thomas Gleixner Cc: Christophe Leroy , linux-kernel@vger.kernel.org, Paul Mackerras , luto@kernel.org, vincenzo.frascino@arm.com, linuxppc-dev@lists.ozlabs.org Subject: Re: [RFC PATCH] powerpc/32: Switch VDSO to C implementation. Message-ID: <20191026230609.GY28442@gate.crashing.org> References: <8ce3582f7f7da9ff0286ced857e5aa2e5ae6746e.1571662378.git.christophe.leroy@c-s.fr> <95bd2367-8edc-29db-faa3-7729661e05f2@c-s.fr> <439bce37-9c2c-2afe-9c9e-2f500472f9f8@c-s.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 26, 2019 at 08:48:27PM +0200, Thomas Gleixner wrote: > On Sat, 26 Oct 2019, Christophe Leroy wrote: > Let's look at the code: > > __cvdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) > { > const struct vdso_data *vd = __arch_get_vdso_data(); > > if (likely(tv != NULL)) { > struct __kernel_timespec ts; > > if (do_hres(&vd[CS_HRES_COARSE], CLOCK_REALTIME, &ts)) > return gettimeofday_fallback(tv, tz); > > tv->tv_sec = ts.tv_sec; > tv->tv_usec = (u32)ts.tv_nsec / NSEC_PER_USEC; > > IIRC PPC did some magic math tricks to avoid that. Could you just for the > fun of it replace this division with > > (u32)ts.tv_nsec >> 10; On this particular CPU (the 885, right?) a division by 1000 is just 9 cycles. On other CPUs it can be more, say 19 cycles like on the 750; not cheap at all, but not hugely expensive either, comparatively. (A 64/32->32 division is expensive on all 32-bit PowerPC: there is no hardware help for it at all, so it's all done in software.) Of course the compiler won't do a division by a constant with a division instruction at all, so it's somewhat cheaper even, 5 or 6 cycles or so. > One thing which might be worth to try as well is to mark all functions in > that file as inline. The speedup by the do_hres() inlining was impressive > on PPC. The hand-optimised asm code will pretty likely win handsomely, whatever you do. Especially on cores like the 885 (no branch prediction, single issue, small caches, etc.: every instruction counts). Is there any reason to replace this hand-optimised code? It was written for exacty this reason? These functions are critical and should be as fast as possible. Segher