Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4087335rwi; Mon, 17 Oct 2022 00:57:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7piDoyDROfS2aMp2019Hwlhh312j5V+olVaunWSXA9xm+MKoRA1166lJeYYK3J7KQxaQ8Q X-Received: by 2002:a05:6402:34c7:b0:45c:c02c:e256 with SMTP id w7-20020a05640234c700b0045cc02ce256mr9447376edc.198.1665993444888; Mon, 17 Oct 2022 00:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665993444; cv=none; d=google.com; s=arc-20160816; b=cYSr3HViFuZML2ZqkIV4H+SvGCBNIPwgD+ZV++FcxPzi4je+3cHSqKCP5VSBAHF85i k25Cd1sBBrgJYFiepYJUPd32UQeqTXtDMLMgtEIQS624GWCBWpw2ImKXvLSA1hZPj7kD Qgy2cM+PCOWytf9uh4n9MAmUK4A+hgWu8hfAiFH+3IgifPUAvJFAYUaoopvjwxoJs7j3 o2hZ7eVgtIByYoox3wAy5MAlfVr70ZD+iryQe/VcE79CSS2TCzE56k7Obn2N9uf7SaMs lQ3HdQOIaingJzIM3zxm81inH4BW52TxACCZyZjsl2hzAYRJAg01W6IuR3KaOT73N4e+ zJuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=zbjFXoy9ahNSpk7XfIRFOe6vIEM/swg042Zyz7dwIhc=; b=Zo6gxw2pAMWppJFFJHLffbbVa9nnP4HlhYHpnvUwLDsF8fALQgNJKQFRIg3W4dZ6I9 Qirr4wmohGHD3lxK+e89IrEXeYxS40Se9sY3cUC24/klYwUtpPPu3UVa56t9NKIXeLYV ITHHDr9vZfZ6KkOPiLC4dY6qdqBsWkT5jpp2d2NoEWvJdU9coTuF8fZffzD0a5y9oWeG tKydLgz9/j+6vhTAANvR1CaNXNFvps8r7WEGr9uX2l1eGTmBgbeIX6Nrw0HZgFsjQ/Et pakPnYUI6OuQbIo6fCxxKRfM6t/vgXO9NkWzKX+Ytg9wJZl5CFr3HKDpeVb5WV8NtRZ7 +7jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=STyWlc5p; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=Qd6SvW9z; 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 hr22-20020a1709073f9600b0073da4a0f01csi8229116ejc.743.2022.10.17.00.56.58; Mon, 17 Oct 2022 00:57:24 -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=@arndb.de header.s=fm2 header.b=STyWlc5p; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=Qd6SvW9z; 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 S229944AbiJQHiv (ORCPT + 99 others); Mon, 17 Oct 2022 03:38:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229898AbiJQHiu (ORCPT ); Mon, 17 Oct 2022 03:38:50 -0400 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 210215A3EE for ; Mon, 17 Oct 2022 00:38:49 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 0BC38320090B; Mon, 17 Oct 2022 03:38:47 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute3.internal (MEProxy); Mon, 17 Oct 2022 03:38:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1665992327; x=1666078727; bh=zbjFXoy9ah NSpk7XfIRFOe6vIEM/swg042Zyz7dwIhc=; b=STyWlc5pFOLM4Fqu7Qsbcu8XpO J3iw3DP6idXN3jEIXxRbe2lS2MhA0LHDX7HzN404PTmEYKnnW5YSQ+itreGF6msA H9zX+uSuDrTS7BuwStw52gcIQ1aOg0Zsxn0yqTndNey7OMTFgg65uC2BH/huMNpE DgiTfEa6T8NKAiLejxDmVx6EOW5GkweiJbbf6oOPJfJnTZgZaBAOLq6Myu+6rjeE MXVFnhOawO/WLvWNd3Df1U6FNkMwNymB8grdyj42ywWvkRA64dYTl3zkkxBczGSq k7F8AZFfNLLyCPHFPbxEpK+1h/fByXivj1thkhwY5WAgFcPh5JuFkTGL58Ug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1665992327; x=1666078727; bh=zbjFXoy9ahNSpk7XfIRFOe6vIEM/ swg042Zyz7dwIhc=; b=Qd6SvW9zmWEnD4/tbkg1fmUUJbeyZ0+wxvnl7RFFJRu0 sP/AEYdF9tHwSpnjtSj/gyHmGfPMnJxWlZDlkVCRp4ZDw2MR/ldfG9P7+RMK96Of pL8Kg0ApG2Sr9PdNLI1kvFYzOU0iyAKpzS/oSTvwc97Ss+9RsJP9hbnxm42GBS3c U4Cnb/mhjTkthnKQ4f6YvQ0VkRqCN54SjhiSeObeLftGVAbqJH2kGUeNeDQ2Hbsa YWGpxKCyjbjQEuJSWIJ1hVEtO8L1csy28O1+u4D5Prg36O4fsmLHGyvzLZJ5tX5b wbpviAYIXyLU/xISPCuthPIGjlFGimzY7oarEg5Aqw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekkedguddvvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdet rhhnugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrg htthgvrhhnpeffheeugeetiefhgeethfejgfdtuefggeejleehjeeutefhfeeggefhkedt keetffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grrhhnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id B9A7DB60086; Mon, 17 Oct 2022 03:38:46 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1047-g9e4af4ada4-fm-20221005.001-g9e4af4ad Mime-Version: 1.0 Message-Id: In-Reply-To: References: <20221016133418.2122777-1-chenhuacai@loongson.cn> <506fe4e5-a203-48e6-84a6-f70133be15dd@app.fastmail.com> Date: Mon, 17 Oct 2022 09:38:26 +0200 From: "Arnd Bergmann" To: "Huacai Chen" Cc: "Huacai Chen" , loongarch@lists.linux.dev, "Xuefeng Li" , "Tiezhu Yang" , guoren , "WANG Xuerui" , "Jiaxun Yang" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] LoongArch: Add unaligned access support Content-Type: text/plain X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham 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, Oct 17, 2022, at 9:31 AM, Huacai Chen wrote: > Hi, Arnd, > > On Mon, Oct 17, 2022 at 3:12 PM Arnd Bergmann wrote: >> >> On Sun, Oct 16, 2022, at 3:34 PM, Huacai Chen wrote: >> > Loongson-2 series (Loongson-2K500, Loongson-2K1000) don't support >> > unaligned access in hardware, while Loongson-3 series (Loongson-3A5000, >> > Loongson-3C5000) are configurable whether support unaligned access in >> > hardware. This patch add unaligned access emulation for those LoongArch >> > processors without hardware support. >> > >> > Signed-off-by: Huacai Chen >> >> What does the Loongarch ELF ABI say about this? On most architectures, >> C compilers are not allowed to produce unaligned accesses for standard >> compliant source code, the only way you'd get this is when casting >> a an unaligned (e.g. char*) pointer to another type with higher alignment >> requirement. > Some unaligned accesses are observed from the kernel network stack, it > seems related to whether the packet aligns to IP header or MAC header. 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. Which driver did you observe this with? > And, gcc has a -mstrict-align parameter, if without this, there are > unaligned instructions. 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. >> > +/* sysctl hooks */ >> > +int unaligned_enabled __read_mostly = 1; /* Enabled by default */ >> > +int no_unaligned_warning __read_mostly = 1; /* Only 1 warning by default */ >> >> The comment says 'sysctl', the implementation has a debugfs interface. > Originally "enabled", "warning" and "counters" are all debugfs > interfaces, then you told me to use sysctl. Now in this version > "enabled" and "warning" are converted to sysctl, but there are no > existing "counters" sysctl. I don't see the sysctl interface in the patch, what am I missing? Arnd