From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE781C433FE for ; Mon, 17 Oct 2022 08:14:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbiJQIO3 (ORCPT ); Mon, 17 Oct 2022 04:14:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230154AbiJQIOT (ORCPT ); Mon, 17 Oct 2022 04:14:19 -0400 Received: from xry111.site (xry111.site [89.208.246.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7EF65C9E9 for ; Mon, 17 Oct 2022 01:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1665994439; bh=aUH/XHGaJbH5Gior3HdfSfhEBDSg2UQ+BopOfkKJaP8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=CT60EdmAYb4CCgDZrqx+T7ZRav7AUSN35MF5alxZR2b2HlSI4ihvy0zfwhZCEMSGc 3DtqUl/lEABUu5OwyQP06g866G9jB0xi8Ii0zWFJ0R5CxrvUDWK81Dnq/lUA7vSVLR AMIbSF4UI3rufVN1gfk2aDlJtvqZkT71i/dHDoIc= Received: from [IPv6:240e:358:1124:a900:dc73:854d:832e:3] (unknown [IPv6:240e:358:1124:a900:dc73:854d:832e:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 3EF7565A8B; Mon, 17 Oct 2022 04:13:53 -0400 (EDT) Message-ID: <514ccb3b1a2fbd37f238f169eef0f40c89d3e3dd.camel@xry111.site> Subject: Re: [PATCH] LoongArch: Add unaligned access support From: Xi Ruoyao To: Arnd Bergmann , Huacai Chen Cc: Huacai Chen , loongarch@lists.linux.dev, Xuefeng Li , Tiezhu Yang , guoren , WANG Xuerui , Jiaxun Yang , linux-kernel@vger.kernel.org Date: Mon, 17 Oct 2022 16:13:47 +0800 In-Reply-To: References: <20221016133418.2122777-1-chenhuacai@loongson.cn> <506fe4e5-a203-48e6-84a6-f70133be15dd@app.fastmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2022-10-17 at 09:38 +0200, Arnd Bergmann wrote: > > Some unaligned accesses are observed from the kernel network stack, it > > seems related to whether the packet aligns to IP header or MAC header. >=20 > This is usually a bug in the device driver. It's a fairly common bug > since the network driver has to ensure the alignment is correct, but > it's usually fixable, and fixing it results in better performance on > machines that support unaligned access as well. Or, maybe a GCC bug is causing -mstrict-align not implemented correctly. > > And, gcc has a -mstrict-align parameter, if without this, there are > > unaligned instructions. >=20 > Does this default to strict or non-strict mode? Usually gcc does not > allow to turn this off on architectures that have no hardware support > for unaligned access. On LoongArch the unaligned access support is optional. An implementation is allowed to implement it or not. The software can determine if it's supported by a CPUCFG instruction. I think -march=3Dla264 will turn off strict align, but it's not added into GCC yet. The GCC default is -mno-strict-align. I expressed my concern about this decision when I reviewed the GCC port, but at last they just kept the decision. But the kernel already sets -mstrict-align in CFLAGS anyway. --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University