From owner-freebsd-arm@freebsd.org Mon Feb 22 19:20:46 2021 Return-Path: Delivered-To: freebsd-arm@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8528A54BE02 for ; Mon, 22 Feb 2021 19:20:46 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DksTn2Z7Rz4d38 for ; Mon, 22 Feb 2021 19:20:45 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-lf1-x131.google.com with SMTP id e7so7615817lft.2 for ; Mon, 22 Feb 2021 11:20:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=+oUTB1/OmgqMO8WT5szpeXI9o/m1qMmFjBmpoFsaYAk=; b=IAJdV4I2rrQfjs+MvRpaBU+NfLN4MzAH5DCC/xBogCPPFMAHRwqKhP6nxpV/21VjLr Z7PWWVdUfQ/bG+scxR+8Yp0e1KZDh+0hvTYchNhEPvuoykXRtQz7dw/dvmtjupAbsR/M msvsSJyPa6Vw56/FGqFxIQMAn3JoLfZwkUoWmDl+FZ/Qyfl8aY9OBoOGnWsUpufChx+w 8rLChd+TgFv7vPvRWyA8GjhlwhO0UVssnJePI3uXRWnssa0LCQ959ZfWUP/oMNr5Tyn6 xwtZBOP7Pde7fWhfin6paMnVxNSqSJRaWHLscFOTqdRW5suj93ve8PUB/rIng1zAqu+n n06A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=+oUTB1/OmgqMO8WT5szpeXI9o/m1qMmFjBmpoFsaYAk=; b=MyiETbop8rNrXUiGPk4ZRi/lO+w7PbBkzfkxMNiPoYIoWiZuFcsOZYUUQkqoWVgrr/ 4GVT2Bnp0WF7TsYQ1bsXO4ZAz99oQoLVGZC7g88/VPReNqCaLmKpxlODGzVCOL78K6bu wzp551h3r1i/QFCpjeU/KCl8h9HRjydYu/av2kK76WBQactk4vQeVOsksihxHfe8iujJ gI40Y6+jM0mMe4oVfTsB8BR88cSVdDbg60I436WgBnsVciVFKV2Dra7nKGo1JQlE7bSS RJ8kenGGpuPk5N4q7CpqNAidAxeV6fnTi42yh+UyTos+l0zbcBiRTjSt/eWidNz44mlQ sRVg== X-Gm-Message-State: AOAM532Gxe3AHlqwZaM/ZOpEj2bg8ivB14bhth6Cn47TQJcBxoJ7xmMi 0E9qF50EStOVP87t6gsO4kijzB1kP1cE5mYquGoiStzzlH8= X-Google-Smtp-Source: ABdhPJysKQ1k7zGghk0dmNNKJIjpmrwxnJPcbv8SaUyoCIkVdtI0CQu2FBucrJNQk0LxshcpxNousWfMTh8D3wtKjag= X-Received: by 2002:ac2:4144:: with SMTP id c4mr14003116lfi.549.1614021643736; Mon, 22 Feb 2021 11:20:43 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a2e:958d:0:0:0:0:0 with HTTP; Mon, 22 Feb 2021 11:20:43 -0800 (PST) From: Mateusz Guzik Date: Mon, 22 Feb 2021 20:20:43 +0100 Message-ID: Subject: state of kernel core primitives in aarch64 To: freebsd-arm@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4DksTn2Z7Rz4d38 X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=IAJdV4I2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2a00:1450:4864:20::131 as permitted sender) smtp.mailfrom=mjguzik@gmail.com X-Spamd-Result: default: False [-4.00 / 15.00]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_NONE(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::131:from]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-arm@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::131:from:127.0.2.255]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::131:from]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-arm] X-Mailman-Approved-At: Mon, 22 Feb 2021 21:20:18 +0000 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Porting FreeBSD to ARM processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Feb 2021 19:20:46 -0000 I made a quick trip and it looks like there is performance left on the table. Similar remarks are probably applicable to userspace. First some clean up: bzero, bcmp and bcopy are all defined as builtins to memset, memcmp and memmove, but the kernel still provides them. Arguably both bzero and bcmp can be a little bit faster than memset (for knowing upfront the target is to be zeroed out) and memmcp (for only having to note the difference instead of computing what it is). If such optimizations are of significance of arm, builtins should be changed at least on that arch. So happens clang provides __builtin_bzero which do resort to calling relevant routines if necessary. Regardless of the above, all routines seem to be slower than they need to, at least when I compare them to non-simd code in https://github.com/ARM-software/optimized-routines/tree/master/string/aarch64 As a simple test I ran a simple test calling access(2) in a loop over /usr/obj/usr/src/amd64.amd64/sys/GENERIC/vnode_if.c, running on ARM Neoverse-N1 r3p1. This copies the string from userspace using copyinstr and compares each component (usr, obj and so on) using memcmp. According to dtrace[1] both copying and comparing are top of the profile. You can prod me on irc regarding hardware and benchmark code. [1] dtrace seems to return a bogus result where sampling on instructions reports return address instead and the conclusion was made with that in mind -- Mateusz Guzik