Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D32EC433DF for ; Fri, 5 Jun 2020 13:18:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4FDD3206DB for ; Fri, 5 Jun 2020 13:18:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dk/0gIRb"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="dsehpjip" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FDD3206DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0057PM4KIfHLFquqGeZtwKDHBOYzp0RFywIhYeCsZEQ=; b=dk/0gIRbTV27EP hUQEZTRUm2OghU9VC+kRm4JJF964G/y/ly9nSz0BY6ryDWBtSWkNwxjsVwGMSskmE4EPj5q73vde4 1okdss4O2CKyOxZrMm0hDOAo2T/Zcg9/uDGlzwKx/UZRRz9M7c5yHuYw0gSV8NFCJ/SHJBG3rGpS1 A2KbMFKmf2U5h2Bm4C3KNVmaYdvh205oErkQGgNC3B5Kx7NlC35qBLTABGU+SjOhiVADseBLAjOlo TEzwjDtJRSeKkkSYOOR+Z1qnK5fQha1vZlBCP4occLarxiMZGFb8FQKr6iyv7RptbK5WPYK4O2rbt d8j8MHs/y19HwTJFwgUQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jhCFB-0001ub-VD; Fri, 05 Jun 2020 13:18:45 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jhCF8-0001tm-0h for linux-arm-kernel@lists.infradead.org; Fri, 05 Jun 2020 13:18:43 +0000 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 230382067B; Fri, 5 Jun 2020 13:18:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591363121; bh=E8zd1k6lBfh5hIPxsN+yGGvhFntauwXqOH2qSc+8OZs=; h=From:To:Cc:Subject:Date:From; b=dsehpjipT9kRadH9vpuX2x9bB2RzPipHtTjY39kJjrKcVGyYdGMD+GicGsXVuDIpT vVOiO9+6anGy9UeKbKG6cVwOQ9RgeATahOztbS7J5L6xWQ+dRJU2+VXKZHq4RqxTMl 9BxBCqdu4W5bvYwdr8sp/N8DyGCdIP3cEVBzza4k= From: Mark Brown To: Will Deacon , Catalin Marinas Subject: [PATCH 0/5] arm64: vdso: getcpu() support Date: Fri, 5 Jun 2020 14:11:26 +0100 Message-Id: <20200605131131.16491-1-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200605_061842_101796_9DE02CE9 X-CRM114-Status: GOOD ( 17.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Brown , Andrei Vagin , Vincenzo Frascino , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some applications, especially tracing ones, benefit from avoiding the syscall overhead for getcpu() so it is common for architectures to have vDSO implementations. Add one for arm64, using TPIDRRO_EL0 to pass a pointer to per-CPU data rather than just store the immediate value in order to allow for future extensibility. It is questionable if something TPIDRRO_EL0 based is worthwhile at all on current kernels, since v4.18 we have had support for restartable sequences which can be used to provide a sched_getcpu() implementation with generally better performance than the vDSO approach on architectures which have that[1]. Work is ongoing to implement this for glibc: https://lore.kernel.org/lkml/20200527185130.5604-3-mathieu.desnoyers@efficios.com/ but is not yet merged and will need similar work for other userspaces. The main advantages for the vDSO implementation are the node parameter (though this is a static mapping to CPU number so could be looked up separately when processing data if it's needed, it shouldn't need to be in the hot path) and ease of implementation for users. This is currently not compatible with KPTI due to what Will suggests is a misunderstanding on my part about the use of TPIDRRO_EL0 by the KPTI trampoline, since this posting is mainly for discussion of the approach as a whole and Will only just mentioned this that's not been addressed here. Since we currently only have a single data page for the vDSO this will also only currently work for lower numbered CPUs, this restriction will be addressed separately. There is some overlap with an in flight patch series from Andrei Vagin supporting time namespaces in the vDSO, there shouldn't be a fundamental issue integrating the two serieses. This builds on work done by Kristina Martsenko some time ago but is a new implementation. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d7822b1e24f2df5df98c76f0e94a5416349ff759 Mark Brown (5): arm64: vdso: Provide a define when building the vDSO arm64: vdso: Add per-CPU data arm64: vdso: Initialise the per-CPU vDSO data arm64: vdso: Add getcpu() implementation selftests: vdso: Support arm64 in getcpu() test arch/arm64/include/asm/processor.h | 12 +---- arch/arm64/include/asm/vdso/datapage.h | 54 +++++++++++++++++++ arch/arm64/kernel/process.c | 26 ++++++++- arch/arm64/kernel/vdso.c | 33 +++++++++++- arch/arm64/kernel/vdso/Makefile | 4 +- arch/arm64/kernel/vdso/vdso.lds.S | 1 + arch/arm64/kernel/vdso/vgetcpu.c | 48 +++++++++++++++++ .../testing/selftests/vDSO/vdso_test_getcpu.c | 10 ++++ 8 files changed, 172 insertions(+), 16 deletions(-) create mode 100644 arch/arm64/include/asm/vdso/datapage.h create mode 100644 arch/arm64/kernel/vdso/vgetcpu.c -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel