Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7106023ybl; Mon, 23 Dec 2019 18:26:13 -0800 (PST) X-Google-Smtp-Source: APXvYqz8C8S27/z9Rx5CBMxLwsfc18pgnazBuodRsVsJHhVXzuMOGYksrUeW/tC0IL+INnifEOno X-Received: by 2002:a05:6830:18f1:: with SMTP id d17mr29510225otf.298.1577154373608; Mon, 23 Dec 2019 18:26:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577154373; cv=none; d=google.com; s=arc-20160816; b=Wlpr1SMmhTeRlt32hfccOVIclOp8wc0E8mHI4UWLE/jsWeAlHYqUhZquV8wzXej/J3 DsBAZEVPMUQ4Wo6UpY0uUVEUUjV9+Q1tfNn6y4M8cRUP7tQVNKBAvS1VGR4hBYc5r8G0 V/K9X+wMwB6SZs3Q/5p0dRPicB6R7w6QHWOG9FnwtjY90MT/8igKK+cqtugv+W3bEVlV Q4E9VlllvcbIc8dEf433Px4UPiGRwqEIqT2XFPC7tA8oLZ1kXJLAZvruM7GRxkl8f/3I f9tln/UusBEM8uUQqsZAnfZHXPlsueJwTL5lkK9tQ27qVGU9wuguWQWlEX8eS6eiNKvo E2cQ== 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 :in-reply-to:references:mime-version:dkim-signature; bh=RGI+3gvmm6DgwKKfavj8QFDg3y31fRlm37QOf1gGsbs=; b=YTpyT/QoPg+X56egT5abNxx95MQkpGOy7Wmh+FOq4tXC5rnzKG+9IdiTYrEBPkEAg9 +s4zfQU0dnzeK9txgAczDrai/9fxv+NhmiBuXwEgn/G6AxlpH9btxZ1fjfOzHk9CAIGI RNK4Q7OWBREawTlM3pN9EANJw9+muqI0OZ9oBj8pDehAI/CChVGKFtYxP+0YquZilMWn RCYPfHyrtRxxLRFWtRX/1XMM8Px/2xHyXrGMdAGQbT9aIEd58w4BCzk0sQdth4ccWRv4 LioCrxDQ+pqc2ckGPkLsIfcRewIgM16ZTBPX4e+G0ZQcKUZwMB1Q/DFo86TT84lGP3ky ISLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oPvK6VPz; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c17si8264935otp.131.2019.12.23.18.26.01; Mon, 23 Dec 2019 18:26:13 -0800 (PST) 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=@kernel.org header.s=default header.b=oPvK6VPz; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727158AbfLXCYV (ORCPT + 99 others); Mon, 23 Dec 2019 21:24:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:50140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726871AbfLXCYV (ORCPT ); Mon, 23 Dec 2019 21:24:21 -0500 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2E588207FF for ; Tue, 24 Dec 2019 02:24:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577154260; bh=SPQ7Bj4a4eNp21OAcqYrY8SxuFJJaC2a6yGdIeeRS1o=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=oPvK6VPzi1k2yyEjQny+BqytBOGY+Pvm5TAIa+d74eS8hvsJFnqaOLMcPbR1MVHcg TJAbv69cwFBjDUU1LcTUwFGC1sdBHfjcRbhYXPuD/8fDpRJfQhxnnenWDdYNTNMhtK WQtdttyNyw+EIZ8phdY7Uk7eLt21kAD5fLV0wvro= Received: by mail-wr1-f43.google.com with SMTP id z7so18555085wrl.13 for ; Mon, 23 Dec 2019 18:24:20 -0800 (PST) X-Gm-Message-State: APjAAAW1JxiWQjJVAB3U9FfL7rLzxRMp3O//aV7Azd16IzNUzjgyvKmZ McUBvNqxSPbC3ZlVvWP5v0ngoTSxFyaKW68Ijk7kLg== X-Received: by 2002:adf:f491:: with SMTP id l17mr32117348wro.149.1577154258620; Mon, 23 Dec 2019 18:24:18 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Andy Lutomirski Date: Mon, 23 Dec 2019 18:24:05 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v2 02/10] lib: vdso: move call to fallback out of common code. To: Christophe Leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Arnd Bergmann , Thomas Gleixner , Vincenzo Frascino , Andrew Lutomirski , LKML , linuxppc-dev , linux-arm-kernel , "open list:MIPS" , X86 ML 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 Mon, Dec 23, 2019 at 6:31 AM Christophe Leroy wrote: > > On powerpc, VDSO functions and syscalls cannot be implemented in C > because the Linux kernel ABI requires that CR[SO] bit is set in case > of error and cleared when no error. > > As this cannot be done in C, C VDSO functions and syscall'based > fallback need a trampoline in ASM. > > By moving the fallback calls out of the common code, arches like > powerpc can implement both the call to C VDSO and the fallback call > in a single trampoline function. Maybe the issue is that I'm not a powerpc person, but I don't understand this. The common vDSO code is in C. Presumably this means that you need an asm trampoline no matter what to call the C code. Is the improvement that, with this change, you can have the asm trampoline do a single branch, so it's logically: ret = [call the C code]; if (ret == 0) { set success bit; } else { ret = fallback; if (ret == 0) set success bit; else set failure bit; } return ret; instead of: ret = [call the C code, which includes the fallback]; if (ret == 0) set success bit; else set failure bit; It's not obvious to me that the former ought to be faster. > > The two advantages are: > - No need play back and forth with CR[SO] and negative return value. > - No stack frame is required in VDSO C functions for the fallbacks. How is no stack frame required? Do you mean that the presence of the fallback causes worse code generation? Can you improve the fallback instead?