Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4128335rwi; Mon, 17 Oct 2022 01:43:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4cff59n+kUnYohvsO070PnDzBTmrTZkuTnRQV3FaJx2dgDR8c/JPrd/GZ+pmIikG2bYIrh X-Received: by 2002:a17:906:5daa:b0:78d:fa76:f837 with SMTP id n10-20020a1709065daa00b0078dfa76f837mr7547983ejv.239.1665996202328; Mon, 17 Oct 2022 01:43:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665996202; cv=none; d=google.com; s=arc-20160816; b=C732RjGrdtPk6dzrbZFJ9o4LXaECphdCQGO86WCKulIaO/1mTE11PLYhQu3urZLXI+ /VAQeoNNTQa1A7hVGB9+BJXWdfIcQa1WWpqCWLwkPohgCRtPGuPMbg2G5Q3OHzAIe0RJ NavsWp0vohfhXY+ISTwDT0UR5UrR39KLdAnLvXO8Vh6FeIT4dLKLs3iQoCQVr4hEV1Le JeySaRenME91SWzyb5wEDbCBSjJjF0AwJb1ll2TypCI6nBTZZH60j9eRwxJIvHTgbAc+ r7tst0IPNwH1V9uZTHGTqnQWI15hwyLV95u67odqg7++TSXAQnKoY43n7eROqQfRQkm0 nAgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=p7YTOVS1Y3YERIyAiPBsX1peJ6UObo5YR2OSKOL3wDk=; b=TR10OCSPmKgtVQ+Ak7DuH8s6NjPn8VUC4u6bLuWXW49ZtDuS299+V4ZYdg7lTQelZ0 7O8P2wkwdVuLxCFhYOvon6etD5PW5pP541dKcdb1iTDG1AtPFfWjmBWgqPL5G/X/0EOz tLk0eWIXG6aFES04vBBrdoq9LSyImHJfZkmDrKDbPtw6SJCbj6z4UxuWFdz5PIfB0IN+ vhrBpZhx1bvxD14+avMzRsxsOwPuLrGpIFI2EMU/w62Uh8a7dFwCJe62pdfRp9G/DH4X maalQTE2C0WXt0eQN8Tak4WEOwOC6GMbQTZHn55XSQivkfhFc16XIG/F8Us3VeCIfzMS TsMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=CT60EdmA; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a4-20020a05640213c400b00457f9c97f13si8091667edx.581.2022.10.17.01.42.54; Mon, 17 Oct 2022 01:43:22 -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=@xry111.site header.s=default header.b=CT60EdmA; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229850AbiJQIO2 (ORCPT + 99 others); Mon, 17 Oct 2022 04:14:28 -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 X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, PDS_OTHER_BAD_TLD,SPF_HELO_PASS,SPF_PASS autolearn=no 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 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