Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5079785rwl; Tue, 28 Mar 2023 16:07:27 -0700 (PDT) X-Google-Smtp-Source: AK7set8OSIV77TvUGFJoqe+bTDJWvWkyMbklezsJQuaq1mAC/gFshQpmIEROg5vCbjLvtXM4FzDx X-Received: by 2002:a05:6a20:65a5:b0:d9:71b1:8a9b with SMTP id p37-20020a056a2065a500b000d971b18a9bmr13595098pzh.10.1680044847690; Tue, 28 Mar 2023 16:07:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680044847; cv=none; d=google.com; s=arc-20160816; b=G2PSET9OJF74JVZ4z16Hi0YaKuKHasSA1wCvXLmAEmYYENoAXqK66XKA65ZmzdJcMK xoWhJ6RAJ6Pcsbx1bWpVKzgKy/DWouIXtrewOQJF/q6SzR0vtrktwptvc171UknqeRAb Ml85hye+S2zRW0yv8qil5e1Csi/K6iHdM3Yv0ZodSjJWxvyqlx9N4hQ1mH1+3yrUg/4m DH9CtuqSBTY0goDvHVwbWmUC7g/Q//3Kt4PY4QicGiEXHuhhhBEJJ1GALx6zTLOKu4PV qP71FsGUWvJYsI62OshFjH9pg3ZP0p8YWI3SvNvUn7AptPi1sBQJnytNFqPg1cv2PvHV GkSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=qskuMbf/TQUlVl/XQCSzEK2+S7ntNlCiLvuefA3pamM=; b=zBTFzF/SLmVmaLZtEt8WtBEBvXGFNv2FLyO1RxARtgmPb+nEsPsYDbsMFjdmJ3apKA Ui49aIFVB5E3uuXGR7xJvYi9RJFdXPnR343Bhzf+Pzwg4xmxj70aLvo2XyzU2g8J9tTK IginDy0fqZ7v1Hr43GCC8naXUw0FD9P4HDru9HrmmdwUPaJH7/96NFce4hF/Bq5Bysi2 QdG+VnUj782x3C/qUlTM8kvCbunB5c6EkZipswjLj5U1cVLcrgiIOY3qi49z3Q/EkUgT wuvkB+73rrF/Xzw1op892we6U4HvALhQDvn7EeY9XzdfMAI2g8SZOV9SDNli6ndWkZ9Z M7fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=25yk2ORr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 4-20020a631944000000b004faeaac4dacsi28185798pgz.753.2023.03.28.16.07.13; Tue, 28 Mar 2023 16:07:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=25yk2ORr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229525AbjC1Wxv (ORCPT + 99 others); Tue, 28 Mar 2023 18:53:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbjC1Wxk (ORCPT ); Tue, 28 Mar 2023 18:53:40 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09EF52110 for ; Tue, 28 Mar 2023 15:53:39 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id k37so17869876lfv.0 for ; Tue, 28 Mar 2023 15:53:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; t=1680044017; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qskuMbf/TQUlVl/XQCSzEK2+S7ntNlCiLvuefA3pamM=; b=25yk2ORrLanITla28soBs7miCE+xev3gOhMYTjHwrGodhppl5zmyb5CRsbvTjr70JU ZjO+zCf+xQiNqZfKuR24kdK5V7BHB3Ozhqly3ZCk5gzoQziG5phV7SNdx2yXqFRmLp5U xSrfT+qhWfUOQmnGNm7lNwu3qPo52oIxL+h+lPjgqhZyuvD3bLjWqqVyTTNwU311KZVs y5KgGCVVgnW7N/CBLQay0BwL8p/ZoN7GMg71rJngVtTq5ha1EC2v+ateu0Kmn7g/m2Zt MUMcWrip+u5PEbh/eXSeRl/+NO0lDCzY732wMzRFlJD4+79AHGQQbWm7jTXeby5erbho Gt7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680044017; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qskuMbf/TQUlVl/XQCSzEK2+S7ntNlCiLvuefA3pamM=; b=B3n7PLBiCOWEL1CbHyGBXOtqHk6jB/k2GMV7GOrPYO0M2KWEP0XuNYFZknblvDbaYo vQg6Ud5XYeHs16mpOb3lyfr8XvtigsVhhXyJyLToWXFBateBR1aVOL/NinZLsihdtNRc 59iK/PyIGWLt9KYuEhm6vL5cC00PrzwDw5hq/ePcbof81RaQsmogLGEKVwy8LDyu06w+ 1nx1aloLIInLmOUuCOrYKisQmEp6U0uB+nP/rLzhtsBP+ND2KJSTwmhbpfbneHNUwY/X Rc64dZx2VOwnJErvjmMrpIj4eKHAxItFXejqfnCms4Mb8GNygzO5o5kUkrnZ9mFmM4Qs +irg== X-Gm-Message-State: AAQBX9dM2nhhz0Y48XsH2XxObXm2OGwh/+W8eiM+DvuokP0V3f7z/u1y vgqdblYiWXseTH26gWuoln4/BLTFM8mpTy6sMJvjyw== X-Received: by 2002:a19:a401:0:b0:4d8:1c0e:bfc7 with SMTP id q1-20020a19a401000000b004d81c0ebfc7mr4984994lfc.13.1680044017285; Tue, 28 Mar 2023 15:53:37 -0700 (PDT) MIME-Version: 1.0 References: <20230327163203.2918455-1-evan@rivosinc.com> <8238271.NyiUUSuA9g@diego> In-Reply-To: <8238271.NyiUUSuA9g@diego> From: Evan Green Date: Tue, 28 Mar 2023 15:53:01 -0700 Message-ID: Subject: Re: [PATCH v5 0/6] RISC-V Hardware Probing User Interface To: =?UTF-8?Q?Heiko_St=C3=BCbner?= Cc: Palmer Dabbelt , slewis@rivosinc.com, vineetg@rivosinc.com, Conor Dooley , Albert Ou , Andrew Bresticker , Andrew Jones , Andrew Morton , Anup Patel , Arnd Bergmann , Atish Patra , Bagas Sanjaya , Catalin Marinas , Celeste Liu , Conor Dooley , Dao Lu , Guo Ren , Jann Horn , Jisheng Zhang , Jonathan Corbet , Ley Foon Tan , Mark Brown , Mike Kravetz , Nathan Chancellor , Palmer Dabbelt , Paul Walmsley , Peter Xu , Philipp Tomsich , Randy Dunlap , Samuel Holland , Shuah Khan , Sunil V L , Tobias Klauser , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 28, 2023 at 1:35=E2=80=AFPM Heiko St=C3=BCbner wrote: > > Am Montag, 27. M=C3=A4rz 2023, 18:31:57 CEST schrieb Evan Green: > > > > There's been a bunch of off-list discussions about this, including at > > Plumbers. The original plan was to do something involving providing an > > ISA string to userspace, but ISA strings just aren't sufficient for a > > stable ABI any more: in order to parse an ISA string users need the > > version of the specifications that the string is written to, the versio= n > > of each extension (sometimes at a finer granularity than the RISC-V > > releases/versions encode), and the expected use case for the ISA string > > (ie, is it a U-mode or M-mode string). That's a lot of complexity to > > try and keep ABI compatible and it's probably going to continue to grow= , > > as even if there's no more complexity in the specifications we'll have > > to deal with the various ISA string parsing oddities that end up all > > over userspace. > > > > Instead this patch set takes a very different approach and provides a s= et > > of key/value pairs that encode various bits about the system. The big > > advantage here is that we can clearly define what these mean so we can > > ensure ABI stability, but it also allows us to encode information that'= s > > unlikely to ever appear in an ISA string (see the misaligned access > > performance, for example). The resulting interface looks a lot like > > what arm64 and x86 do, and will hopefully fit well into something like > > ACPI in the future. > > > > The actual user interface is a syscall, with a vDSO function in front o= f > > it. The vDSO function can answer some queries without a syscall at all, > > and falls back to the syscall for cases it doesn't have answers to. > > Currently we prepopulate it with an array of answers for all keys and > > a CPU set of "all CPUs". This can be adjusted as necessary to provide > > fast answers to the most common queries. > > > > An example series in glibc exposing this syscall and using it in an > > ifunc selector for memcpy can be found at [1]. I'm about to send a v2 > > of that series out that incorporates the vDSO function. > > > > I was asked about the performance delta between this and something like > > sysfs. I created a small test program [2] and ran it on a Nezha D1 > > Allwinner board. Doing each operation 100000 times and dividing, these > > operations take the following amount of time: > > - open()+read()+close() of /sys/kernel/cpu_byteorder: 3.8us > > - access("/sys/kernel/cpu_byteorder", R_OK): 1.3us > > - riscv_hwprobe() vDSO and syscall: .0094us > > - riscv_hwprobe() vDSO with no syscall: 0.0091us > > Looks like this series spawned a thread on one of the riscv-lists [0]. > > As auxvals were mentioned in that thread, I was wondering what's the > difference between doing a new syscall vs. putting the keys + values as > architecture auxvec elements [1] ? The auxvec approach would also work. The primary difference is that auxvec bits are actively copied into every new process, forever. If you predict a slow pace of new bits coming in, the auxvec approach probably makes more sense. This series was born out of a prediction that this set of "stuff" was going to be larger than traditional x86/ARM architectures, fiddly (ie bits possibly representing specific versions of various extensions), evolving regularly over time, and heterogeneous between cores. With that sort of rubber band ball in mind, a key/value interface seemed to make more sense. -Evan