Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3291321rdb; Wed, 27 Dec 2023 02:42:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IG75vfuWYQah4ZCU+iZSZghll0CgZ/GccXcOLPoizQp1JoDO6i1+wszRzx1dx1tmor4++dq X-Received: by 2002:a81:dc07:0:b0:5ee:d57e:ee04 with SMTP id h7-20020a81dc07000000b005eed57eee04mr17275ywj.21.1703673751129; Wed, 27 Dec 2023 02:42:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703673751; cv=none; d=google.com; s=arc-20160816; b=r3rh0qP3WLnGn/z6cuapEF5zyLGU/hD1xaJ6wh6ktwJxCTbxnJVMBoWWjmTWeldCL+ 4KIQPo9qLgnmiGkeTF5CFjDXXYGZ0S2X+6gvohq76iGhnsMQF1dsaVnLKx56PsZh3Hl3 YZKuFRmv/GfvR+vY41eystG9T/MEdiuDCVMxMjxHjH85s3Luxpt7P0QDbWQiCWAcbf39 QaobCcpl0rK0GT59PYqr+T4K03cUPRFcbM5GKuqwb18VpuoYZMnHXAOMgr2LI35Wf98r /nny/9qOvW9nbE3Ilkb264AETbxIUatmw6sZGUuVy1hInj1MD7j4LygtgtXOavXD1P0m upIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=e6j6QZK0Llh90ZRxMpYK5nIAk0jiNINKYSRO4ZQNlZA=; fh=O6HoGTYAYP0KHk5JSpiBEXdcUutywyy6Li8/6mUHc3E=; b=bIjAAKTmemag2DnFgZmmsp2GNA25z8VWhbjQFCxnvWoIAIntC+d+wH18Hu8l718Ngf 4v5LvlR1uUitn13eo07fFhhncN5jOFxM2MrMA1UxaQXdEv6pKOvKgdNVy1KxRjJjkJ03 tn49qSdbR2L+ZneQ68unNW6ajKetHufAWq+mNccQhLeXQ2cEAh2RuiQPlrXlY+038p+K Ic8H4+rhXWrGdrCeAfZ2zocTNpUij1aY07+Mtlka+P8jCXiWAkA4fxmFP96sRihF2tX4 LgesEAz+xRAb/Va2JLLhywU96nwKW4bwFhfaxY8NVK2sbeHAM5uIQDaOJDaKqhmWzzmt emPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-11964-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11964-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y15-20020a05622a004f00b004277e25d50esi14155031qtw.393.2023.12.27.02.42.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 02:42:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11964-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-11964-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11964-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8E2281C217D2 for ; Wed, 27 Dec 2023 10:42:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3848144374; Wed, 27 Dec 2023 10:42:23 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F229844362 for ; Wed, 27 Dec 2023 10:42:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aculab.com Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-50-QI0vpALcOICqpEAYQ6T2Mw-1; Wed, 27 Dec 2023 10:42:11 +0000 X-MC-Unique: QI0vpALcOICqpEAYQ6T2Mw-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 27 Dec 2023 10:41:53 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Wed, 27 Dec 2023 10:41:53 +0000 From: David Laight To: 'Jisheng Zhang' , Paul Walmsley , Palmer Dabbelt , Albert Ou CC: "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Eric Biggers , Conor Dooley , "Qingfang DENG" , Charlie Jenkins Subject: RE: [PATCH v4 1/2] riscv: introduce RISCV_EFFICIENT_UNALIGNED_ACCESS Thread-Topic: [PATCH v4 1/2] riscv: introduce RISCV_EFFICIENT_UNALIGNED_ACCESS Thread-Index: AQHaNu5/tgkH4SyC6kWXjxrDsB1U3bC88TvA Date: Wed, 27 Dec 2023 10:41:53 +0000 Message-ID: References: <20231225044207.3821-1-jszhang@kernel.org> <20231225044207.3821-2-jszhang@kernel.org> In-Reply-To: <20231225044207.3821-2-jszhang@kernel.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable From: Jisheng Zhang > Sent: 25 December 2023 04:42 >=20 > Some riscv implementations such as T-HEAD's C906, C908, C910 and C920 > support efficient unaligned access, for performance reason we want > to enable HAVE_EFFICIENT_UNALIGNED_ACCESS on these platforms. To > avoid performance regressions on other non efficient unaligned access > platforms, HAVE_EFFICIENT_UNALIGNED_ACCESS can't be globally selected. How efficient are these EFFICIENT_UNALIGNED_ACCESS ? For single word accesses it doesn't matter much (since they don't fault). But for memcpy() (and similar) if they are slightly slow (eg the same as two aligned accesses) it is likely still worth doing misaligned transfers for both ends and aligned transfers for the middle. For example, on modern x86 it really isn't worth worrying about misaligned transfers of 64bit registers. AFAICT accesses within a cacheline just use byte enables - so are zero cost. Accesses that cross cache line boundaries do get split - but the out-of-order execute, store-buffer and the ability to do two reads in each clock cycle make the overall cost only just measurable. Not sure how the various RISC-V cpu compare though. You might get an extra clock delay a lot more often. So, while mostly you 'don't care' about the alignment, there may still be a few places where it does matter. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)