Message ID | 20231005190451.175568-2-adrian.hunter@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp508521vqb; Thu, 5 Oct 2023 12:06:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0nVkharwr+WeV7Uc9dc0pZ0caiNMDlUqYTW/6yA3QHstlMaJvGJpIdzs7l5AN49McFgmB X-Received: by 2002:a05:6a20:1607:b0:163:61c:9275 with SMTP id l7-20020a056a20160700b00163061c9275mr6861378pzj.41.1696532815173; Thu, 05 Oct 2023 12:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696532815; cv=none; d=google.com; s=arc-20160816; b=AlXKItNXcO/QWOPEdviTVVF0a/IsHy13FrVwFlrSgLyXX2qXeRWpvJVEZErzC5Tx6K 5xrvz7wDxXAFSnZVpemUJepVWy02LLpHbvmWNp/fkeBqX5FKpbJfs9HSzrSNRNQ6Hjsn dZuH7otmj66XGLBhFECN+6E4R37JY4bMKpXlUIMLwkhsKpFEIIMfJYgBjXl/V3E7QaKT Tnfc9a+zfHftm+PlVHmYE+pjkyQoEKs02VvYqq/FnWp3Ns2jyomkSE2HR9Uu9pqHK0T6 pHQ/EPYAIZT0aZr26UmfHbr8wWSjiBAHH4ApRD3BmO2y4YeFi6QFGQgRZYslXYhnwzoE br0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5Rq+PUNdhPPKOn/goOo0uLhrEzdjJllAkQ6WWkpMj+U=; fh=7ueK1huCq2Lf3LMjc8i3Ob70zhQl+8ZRdqYzG6swRYY=; b=s456uUf8LlO/vdiW9miV9txyE8ygtLTOhedEnPZ2eayl9jlRWA+cQvaIgdIjaLRsFG /i8TKf9cfbN55LcNcNqMBPMzh76z77SK37MxzbY4h5aBtvgDXf8328FQPVUTWfIViKGr m7OrZut3II7DkljLwqneBjl4UZgiB8rk7cRKOFf14l1v+WXCurfKRvAKmLZyHc9qLjLT fP1ceXbB7p66V31w5IJr/k9eyVqqUomohgAkNExmvxATF8YvNnGJ62cFmUhwURnUWgPU njsvH3t+Fmzi/P0dJUhmu9eVtFiT41T0p7FuJNfW9jDe/NvDMJh/i6FdDSfcQh4sApNF RQuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GcXzKhMs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id g21-20020a056a0023d500b0068fee0e95c5si1959655pfc.89.2023.10.05.12.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 12:06:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GcXzKhMs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7747883CDFEB; Thu, 5 Oct 2023 12:06:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229959AbjJETGh (ORCPT <rfc822;ezelljr.billy@gmail.com> + 18 others); Thu, 5 Oct 2023 15:06:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229939AbjJETGf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 5 Oct 2023 15:06:35 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B644FEA; Thu, 5 Oct 2023 12:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696532794; x=1728068794; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dx4bgn3zzTZ9xOLzFW1eBj7lM2vIsla8X5xiYClbPKg=; b=GcXzKhMsdO3FDl35O3GpDpY1GlBXi2Bl2Rl1Mh9wUIB9hAsgBxOJbRHi 0nRfqICQ/fOKoxdu4iwEQFfe6dQ0CY9pM9xSZSqANgUsamLIuFhrT2mbv LsPvTb3PngKBOMLxKhuSDPbIGVQC+gQBIIVlOBBRa7JOf3i6DV1jdKpf0 VmUfeBbtb+sagL+uwE66C/FfmUI+jVNIzfGEmWP1s1Cjz+5OIqETm8XDg 5WXGt1uYDYxc8kK3sS9CvwEuF/1+kxUbCIY9pBgFcnXZwUTj20RRZDGYG pqqnwl/IZmA6JpjQyPF3LwWQ70tnbBL9t6paqFGP3RkQqIBntMzUqlT86 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="383488228" X-IronPort-AV: E=Sophos;i="6.03,203,1694761200"; d="scan'208";a="383488228" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2023 12:05:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="999055088" X-IronPort-AV: E=Sophos;i="6.03,203,1694761200"; d="scan'208";a="999055088" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.249.35.8]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2023 12:05:10 -0700 From: Adrian Hunter <adrian.hunter@intel.com> To: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH 1/5] perf tools: Add get_unaligned_leNN() Date: Thu, 5 Oct 2023 22:04:47 +0300 Message-Id: <20231005190451.175568-2-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005190451.175568-1-adrian.hunter@intel.com> References: <20231005190451.175568-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 05 Oct 2023 12:06:50 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778943592910275208 X-GMAIL-MSGID: 1778943592910275208 |
Series |
perf intel-pt: Use of get_unaligned_le16() etc
|
|
Commit Message
Adrian Hunter
Oct. 5, 2023, 7:04 p.m. UTC
Add get_unaligned_le16(), get_unaligned_le32 and get_unaligned_le64, same
as include/asm-generic/unaligned.h.
Use diagnostic pragmas to ignore -Wpacked used by perf build.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/include/asm-generic/unaligned.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
Comments
Em Thu, Oct 05, 2023 at 10:04:47PM +0300, Adrian Hunter escreveu: > Add get_unaligned_le16(), get_unaligned_le32 and get_unaligned_le64, same > as include/asm-generic/unaligned.h. > > Use diagnostic pragmas to ignore -Wpacked used by perf build. Can we get the tools copy of include/asm-generic/unaligned.h closer and have it in check-headers.sh? - Arnaldo > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> > --- > tools/include/asm-generic/unaligned.h | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/tools/include/asm-generic/unaligned.h b/tools/include/asm-generic/unaligned.h > index 47387c607035..9140bb4e16c6 100644 > --- a/tools/include/asm-generic/unaligned.h > +++ b/tools/include/asm-generic/unaligned.h > @@ -6,6 +6,9 @@ > #ifndef __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H > #define __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H > > +#pragma GCC diagnostic push > +#pragma GCC diagnostic ignored "-Wpacked" > + > #define __get_unaligned_t(type, ptr) ({ \ > const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > __pptr->x; \ > @@ -19,5 +22,22 @@ > #define get_unaligned(ptr) __get_unaligned_t(typeof(*(ptr)), (ptr)) > #define put_unaligned(val, ptr) __put_unaligned_t(typeof(*(ptr)), (val), (ptr)) > > +static inline u16 get_unaligned_le16(const void *p) > +{ > + return le16_to_cpu(__get_unaligned_t(__le16, p)); > +} > + > +static inline u32 get_unaligned_le32(const void *p) > +{ > + return le32_to_cpu(__get_unaligned_t(__le32, p)); > +} > + > +static inline u64 get_unaligned_le64(const void *p) > +{ > + return le64_to_cpu(__get_unaligned_t(__le64, p)); > +} > + > +#pragma GCC diagnostic pop > + > #endif /* __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H */ > > -- > 2.34.1 >
On 5/10/23 22:38, Arnaldo Carvalho de Melo wrote: > Em Thu, Oct 05, 2023 at 10:04:47PM +0300, Adrian Hunter escreveu: >> Add get_unaligned_le16(), get_unaligned_le32 and get_unaligned_le64, same >> as include/asm-generic/unaligned.h. >> >> Use diagnostic pragmas to ignore -Wpacked used by perf build. > > Can we get the tools copy of include/asm-generic/unaligned.h closer and > have it in check-headers.sh? I sent another patch for that
Em Thu, Oct 05, 2023 at 04:38:05PM -0300, Arnaldo Carvalho de Melo escreveu: > Em Thu, Oct 05, 2023 at 10:04:47PM +0300, Adrian Hunter escreveu: > > Add get_unaligned_le16(), get_unaligned_le32 and get_unaligned_le64, same > > as include/asm-generic/unaligned.h. > > > > Use diagnostic pragmas to ignore -Wpacked used by perf build. > > Can we get the tools copy of include/asm-generic/unaligned.h closer and > have it in check-headers.sh? And this is not building when cross building to mips, mips64 and mipsel on debian:experimental: In file included from util/intel-pt-decoder/intel-pt-pkt-decoder.c:10: /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h: In function 'get_unaligned_le16': /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:13:29: error: packed attribute causes inefficient alignment for 'x' [-Werror=attributes] 13 | const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ | ^ /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:27:28: note: in expansion of macro '__get_unaligned_t' 27 | return le16_to_cpu(__get_unaligned_t(__le16, p)); | ^~~~~~~~~~~~~~~~~ /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h: In function 'get_unaligned_le32': /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:13:29: error: packed attribute causes inefficient alignment for 'x' [-Werror=attributes] 13 | const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ | ^ /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:32:28: note: in expansion of macro '__get_unaligned_t' 32 | return le32_to_cpu(__get_unaligned_t(__le32, p)); | ^~~~~~~~~~~~~~~~~ Ditto for some other distros when cross building on ubuntu:18.04 MKDIR /tmp/build/perf/util/perf-regs-arch/ In file included from /usr/sparc64-linux-gnu/include/bits/byteswap.h:34:0, from /usr/sparc64-linux-gnu/include/endian.h:60, from util/intel-pt-decoder/intel-pt-pkt-decoder.c:9: /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h: In function 'get_unaligned_le16': /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:13:22: error: packed attribute causes inefficient alignment for 'x' [-Werror=attributes] const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ ^ /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:27:21: note: in expansion of macro '__get_unaligned_t' return le16_to_cpu(__get_unaligned_t(__le16, p)); ^~~~~~~~~~~~~~~~~ 37 14.17 ubuntu:18.04-x-arm : FAIL gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 38 13.56 ubuntu:18.04-x-arm64 : FAIL gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 42 12.70 ubuntu:18.04-x-riscv64 : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 44 13.95 ubuntu:18.04-x-sh4 : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 45 13.08 ubuntu:18.04-x-sparc64 : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) > - Arnaldo > > > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> > > --- > > tools/include/asm-generic/unaligned.h | 20 ++++++++++++++++++++ > > 1 file changed, 20 insertions(+) > > > > diff --git a/tools/include/asm-generic/unaligned.h b/tools/include/asm-generic/unaligned.h > > index 47387c607035..9140bb4e16c6 100644 > > --- a/tools/include/asm-generic/unaligned.h > > +++ b/tools/include/asm-generic/unaligned.h > > @@ -6,6 +6,9 @@ > > #ifndef __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H > > #define __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H > > > > +#pragma GCC diagnostic push > > +#pragma GCC diagnostic ignored "-Wpacked" > > + > > #define __get_unaligned_t(type, ptr) ({ \ > > const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > > __pptr->x; \ > > @@ -19,5 +22,22 @@ > > #define get_unaligned(ptr) __get_unaligned_t(typeof(*(ptr)), (ptr)) > > #define put_unaligned(val, ptr) __put_unaligned_t(typeof(*(ptr)), (val), (ptr)) > > > > +static inline u16 get_unaligned_le16(const void *p) > > +{ > > + return le16_to_cpu(__get_unaligned_t(__le16, p)); > > +} > > + > > +static inline u32 get_unaligned_le32(const void *p) > > +{ > > + return le32_to_cpu(__get_unaligned_t(__le32, p)); > > +} > > + > > +static inline u64 get_unaligned_le64(const void *p) > > +{ > > + return le64_to_cpu(__get_unaligned_t(__le64, p)); > > +} > > + > > +#pragma GCC diagnostic pop > > + > > #endif /* __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H */ > > > > -- > > 2.34.1 > > > > -- > > - Arnaldo
On 26/10/23 16:44, Arnaldo Carvalho de Melo wrote: > Em Thu, Oct 05, 2023 at 04:38:05PM -0300, Arnaldo Carvalho de Melo escreveu: >> Em Thu, Oct 05, 2023 at 10:04:47PM +0300, Adrian Hunter escreveu: >>> Add get_unaligned_le16(), get_unaligned_le32 and get_unaligned_le64, same >>> as include/asm-generic/unaligned.h. >>> >>> Use diagnostic pragmas to ignore -Wpacked used by perf build. >> >> Can we get the tools copy of include/asm-generic/unaligned.h closer and >> have it in check-headers.sh? > > And this is not building when cross building to mips, mips64 and mipsel > on debian:experimental: > > In file included from util/intel-pt-decoder/intel-pt-pkt-decoder.c:10: > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h: In function 'get_unaligned_le16': > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:13:29: error: packed attribute causes inefficient alignment for 'x' [-Werror=attributes] So I guess another diagnostic pragma is needed, perhaps the following works? #pragma GCC diagnostic ignored "-Wattributes" > 13 | const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > | ^ > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:27:28: note: in expansion of macro '__get_unaligned_t' > 27 | return le16_to_cpu(__get_unaligned_t(__le16, p)); > | ^~~~~~~~~~~~~~~~~ > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h: In function 'get_unaligned_le32': > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:13:29: error: packed attribute causes inefficient alignment for 'x' [-Werror=attributes] > 13 | const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > | ^ > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:32:28: note: in expansion of macro '__get_unaligned_t' > 32 | return le32_to_cpu(__get_unaligned_t(__le32, p)); > | ^~~~~~~~~~~~~~~~~ > > > Ditto for some other distros when cross building on ubuntu:18.04 > > MKDIR /tmp/build/perf/util/perf-regs-arch/ > In file included from /usr/sparc64-linux-gnu/include/bits/byteswap.h:34:0, > from /usr/sparc64-linux-gnu/include/endian.h:60, > from util/intel-pt-decoder/intel-pt-pkt-decoder.c:9: > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h: In function 'get_unaligned_le16': > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:13:22: error: packed attribute causes inefficient alignment for 'x' [-Werror=attributes] > const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > ^ > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:27:21: note: in expansion of macro '__get_unaligned_t' > return le16_to_cpu(__get_unaligned_t(__le16, p)); > ^~~~~~~~~~~~~~~~~ > > 37 14.17 ubuntu:18.04-x-arm : FAIL gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) > 38 13.56 ubuntu:18.04-x-arm64 : FAIL gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) > 42 12.70 ubuntu:18.04-x-riscv64 : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) > 44 13.95 ubuntu:18.04-x-sh4 : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) > 45 13.08 ubuntu:18.04-x-sparc64 : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) > >> - Arnaldo >> >>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> >>> --- >>> tools/include/asm-generic/unaligned.h | 20 ++++++++++++++++++++ >>> 1 file changed, 20 insertions(+) >>> >>> diff --git a/tools/include/asm-generic/unaligned.h b/tools/include/asm-generic/unaligned.h >>> index 47387c607035..9140bb4e16c6 100644 >>> --- a/tools/include/asm-generic/unaligned.h >>> +++ b/tools/include/asm-generic/unaligned.h >>> @@ -6,6 +6,9 @@ >>> #ifndef __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H >>> #define __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H >>> >>> +#pragma GCC diagnostic push >>> +#pragma GCC diagnostic ignored "-Wpacked" >>> + >>> #define __get_unaligned_t(type, ptr) ({ \ >>> const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ >>> __pptr->x; \ >>> @@ -19,5 +22,22 @@ >>> #define get_unaligned(ptr) __get_unaligned_t(typeof(*(ptr)), (ptr)) >>> #define put_unaligned(val, ptr) __put_unaligned_t(typeof(*(ptr)), (val), (ptr)) >>> >>> +static inline u16 get_unaligned_le16(const void *p) >>> +{ >>> + return le16_to_cpu(__get_unaligned_t(__le16, p)); >>> +} >>> + >>> +static inline u32 get_unaligned_le32(const void *p) >>> +{ >>> + return le32_to_cpu(__get_unaligned_t(__le32, p)); >>> +} >>> + >>> +static inline u64 get_unaligned_le64(const void *p) >>> +{ >>> + return le64_to_cpu(__get_unaligned_t(__le64, p)); >>> +} >>> + >>> +#pragma GCC diagnostic pop >>> + >>> #endif /* __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H */ >>> >>> -- >>> 2.34.1 >>> >> >> -- >> >> - Arnaldo >
Em Thu, Oct 26, 2023 at 07:09:26PM +0300, Adrian Hunter escreveu: > On 26/10/23 16:44, Arnaldo Carvalho de Melo wrote: > > Em Thu, Oct 05, 2023 at 04:38:05PM -0300, Arnaldo Carvalho de Melo escreveu: > >> Em Thu, Oct 05, 2023 at 10:04:47PM +0300, Adrian Hunter escreveu: > >>> Add get_unaligned_le16(), get_unaligned_le32 and get_unaligned_le64, same > >>> as include/asm-generic/unaligned.h. > >>> > >>> Use diagnostic pragmas to ignore -Wpacked used by perf build. > >> > >> Can we get the tools copy of include/asm-generic/unaligned.h closer and > >> have it in check-headers.sh? > > > > And this is not building when cross building to mips, mips64 and mipsel > > on debian:experimental: > > > > In file included from util/intel-pt-decoder/intel-pt-pkt-decoder.c:10: > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h: In function 'get_unaligned_le16': > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:13:29: error: packed attribute causes inefficient alignment for 'x' [-Werror=attributes] > > So I guess another diagnostic pragma is needed, perhaps the following works? > > #pragma GCC diagnostic ignored "-Wattributes" I'll try it. - Arnaldo > > > 13 | const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > > | ^ > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:27:28: note: in expansion of macro '__get_unaligned_t' > > 27 | return le16_to_cpu(__get_unaligned_t(__le16, p)); > > | ^~~~~~~~~~~~~~~~~ > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h: In function 'get_unaligned_le32': > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:13:29: error: packed attribute causes inefficient alignment for 'x' [-Werror=attributes] > > 13 | const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > > | ^ > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:32:28: note: in expansion of macro '__get_unaligned_t' > > 32 | return le32_to_cpu(__get_unaligned_t(__le32, p)); > > | ^~~~~~~~~~~~~~~~~ > > > > > > Ditto for some other distros when cross building on ubuntu:18.04 > > > > MKDIR /tmp/build/perf/util/perf-regs-arch/ > > In file included from /usr/sparc64-linux-gnu/include/bits/byteswap.h:34:0, > > from /usr/sparc64-linux-gnu/include/endian.h:60, > > from util/intel-pt-decoder/intel-pt-pkt-decoder.c:9: > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h: In function 'get_unaligned_le16': > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:13:22: error: packed attribute causes inefficient alignment for 'x' [-Werror=attributes] > > const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > > ^ > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:27:21: note: in expansion of macro '__get_unaligned_t' > > return le16_to_cpu(__get_unaligned_t(__le16, p)); > > ^~~~~~~~~~~~~~~~~ > > > > 37 14.17 ubuntu:18.04-x-arm : FAIL gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) > > 38 13.56 ubuntu:18.04-x-arm64 : FAIL gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) > > 42 12.70 ubuntu:18.04-x-riscv64 : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) > > 44 13.95 ubuntu:18.04-x-sh4 : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) > > 45 13.08 ubuntu:18.04-x-sparc64 : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) > > > >> - Arnaldo > >> > >>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> > >>> --- > >>> tools/include/asm-generic/unaligned.h | 20 ++++++++++++++++++++ > >>> 1 file changed, 20 insertions(+) > >>> > >>> diff --git a/tools/include/asm-generic/unaligned.h b/tools/include/asm-generic/unaligned.h > >>> index 47387c607035..9140bb4e16c6 100644 > >>> --- a/tools/include/asm-generic/unaligned.h > >>> +++ b/tools/include/asm-generic/unaligned.h > >>> @@ -6,6 +6,9 @@ > >>> #ifndef __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H > >>> #define __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H > >>> > >>> +#pragma GCC diagnostic push > >>> +#pragma GCC diagnostic ignored "-Wpacked" > >>> + > >>> #define __get_unaligned_t(type, ptr) ({ \ > >>> const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > >>> __pptr->x; \ > >>> @@ -19,5 +22,22 @@ > >>> #define get_unaligned(ptr) __get_unaligned_t(typeof(*(ptr)), (ptr)) > >>> #define put_unaligned(val, ptr) __put_unaligned_t(typeof(*(ptr)), (val), (ptr)) > >>> > >>> +static inline u16 get_unaligned_le16(const void *p) > >>> +{ > >>> + return le16_to_cpu(__get_unaligned_t(__le16, p)); > >>> +} > >>> + > >>> +static inline u32 get_unaligned_le32(const void *p) > >>> +{ > >>> + return le32_to_cpu(__get_unaligned_t(__le32, p)); > >>> +} > >>> + > >>> +static inline u64 get_unaligned_le64(const void *p) > >>> +{ > >>> + return le64_to_cpu(__get_unaligned_t(__le64, p)); > >>> +} > >>> + > >>> +#pragma GCC diagnostic pop > >>> + > >>> #endif /* __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H */ > >>> > >>> -- > >>> 2.34.1 > >>> > >> > >> -- > >> > >> - Arnaldo > > >
Em Thu, Oct 26, 2023 at 07:09:26PM +0300, Adrian Hunter escreveu: > On 26/10/23 16:44, Arnaldo Carvalho de Melo wrote: > > Em Thu, Oct 05, 2023 at 04:38:05PM -0300, Arnaldo Carvalho de Melo escreveu: > >> Em Thu, Oct 05, 2023 at 10:04:47PM +0300, Adrian Hunter escreveu: > >>> Add get_unaligned_le16(), get_unaligned_le32 and get_unaligned_le64, same > >>> as include/asm-generic/unaligned.h. > >>> > >>> Use diagnostic pragmas to ignore -Wpacked used by perf build. > >> > >> Can we get the tools copy of include/asm-generic/unaligned.h closer and > >> have it in check-headers.sh? > > > > And this is not building when cross building to mips, mips64 and mipsel > > on debian:experimental: > > > > In file included from util/intel-pt-decoder/intel-pt-pkt-decoder.c:10: > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h: In function 'get_unaligned_le16': > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:13:29: error: packed attribute causes inefficient alignment for 'x' [-Werror=attributes] > > So I guess another diagnostic pragma is needed, perhaps the following works? > > #pragma GCC diagnostic ignored "-Wattributes" Yeah, I tested with this and it works, I'll add a patch with your Suggested-by, ok? - Arnaldo > > > 13 | const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > > | ^ > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:27:28: note: in expansion of macro '__get_unaligned_t' > > 27 | return le16_to_cpu(__get_unaligned_t(__le16, p)); > > | ^~~~~~~~~~~~~~~~~ > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h: In function 'get_unaligned_le32': > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:13:29: error: packed attribute causes inefficient alignment for 'x' [-Werror=attributes] > > 13 | const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > > | ^ > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:32:28: note: in expansion of macro '__get_unaligned_t' > > 32 | return le32_to_cpu(__get_unaligned_t(__le32, p)); > > | ^~~~~~~~~~~~~~~~~ > > > > > > Ditto for some other distros when cross building on ubuntu:18.04 > > > > MKDIR /tmp/build/perf/util/perf-regs-arch/ > > In file included from /usr/sparc64-linux-gnu/include/bits/byteswap.h:34:0, > > from /usr/sparc64-linux-gnu/include/endian.h:60, > > from util/intel-pt-decoder/intel-pt-pkt-decoder.c:9: > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h: In function 'get_unaligned_le16': > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:13:22: error: packed attribute causes inefficient alignment for 'x' [-Werror=attributes] > > const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > > ^ > > /git/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:27:21: note: in expansion of macro '__get_unaligned_t' > > return le16_to_cpu(__get_unaligned_t(__le16, p)); > > ^~~~~~~~~~~~~~~~~ > > > > 37 14.17 ubuntu:18.04-x-arm : FAIL gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) > > 38 13.56 ubuntu:18.04-x-arm64 : FAIL gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) > > 42 12.70 ubuntu:18.04-x-riscv64 : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) > > 44 13.95 ubuntu:18.04-x-sh4 : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) > > 45 13.08 ubuntu:18.04-x-sparc64 : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) > > > >> - Arnaldo > >> > >>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> > >>> --- > >>> tools/include/asm-generic/unaligned.h | 20 ++++++++++++++++++++ > >>> 1 file changed, 20 insertions(+) > >>> > >>> diff --git a/tools/include/asm-generic/unaligned.h b/tools/include/asm-generic/unaligned.h > >>> index 47387c607035..9140bb4e16c6 100644 > >>> --- a/tools/include/asm-generic/unaligned.h > >>> +++ b/tools/include/asm-generic/unaligned.h > >>> @@ -6,6 +6,9 @@ > >>> #ifndef __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H > >>> #define __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H > >>> > >>> +#pragma GCC diagnostic push > >>> +#pragma GCC diagnostic ignored "-Wpacked" > >>> + > >>> #define __get_unaligned_t(type, ptr) ({ \ > >>> const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > >>> __pptr->x; \ > >>> @@ -19,5 +22,22 @@ > >>> #define get_unaligned(ptr) __get_unaligned_t(typeof(*(ptr)), (ptr)) > >>> #define put_unaligned(val, ptr) __put_unaligned_t(typeof(*(ptr)), (val), (ptr)) > >>> > >>> +static inline u16 get_unaligned_le16(const void *p) > >>> +{ > >>> + return le16_to_cpu(__get_unaligned_t(__le16, p)); > >>> +} > >>> + > >>> +static inline u32 get_unaligned_le32(const void *p) > >>> +{ > >>> + return le32_to_cpu(__get_unaligned_t(__le32, p)); > >>> +} > >>> + > >>> +static inline u64 get_unaligned_le64(const void *p) > >>> +{ > >>> + return le64_to_cpu(__get_unaligned_t(__le64, p)); > >>> +} > >>> + > >>> +#pragma GCC diagnostic pop > >>> + > >>> #endif /* __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H */ > >>> > >>> -- > >>> 2.34.1 > >>> > >> > >> -- > >> > >> - Arnaldo > > >
diff --git a/tools/include/asm-generic/unaligned.h b/tools/include/asm-generic/unaligned.h index 47387c607035..9140bb4e16c6 100644 --- a/tools/include/asm-generic/unaligned.h +++ b/tools/include/asm-generic/unaligned.h @@ -6,6 +6,9 @@ #ifndef __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H #define __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpacked" + #define __get_unaligned_t(type, ptr) ({ \ const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ __pptr->x; \ @@ -19,5 +22,22 @@ #define get_unaligned(ptr) __get_unaligned_t(typeof(*(ptr)), (ptr)) #define put_unaligned(val, ptr) __put_unaligned_t(typeof(*(ptr)), (val), (ptr)) +static inline u16 get_unaligned_le16(const void *p) +{ + return le16_to_cpu(__get_unaligned_t(__le16, p)); +} + +static inline u32 get_unaligned_le32(const void *p) +{ + return le32_to_cpu(__get_unaligned_t(__le32, p)); +} + +static inline u64 get_unaligned_le64(const void *p) +{ + return le64_to_cpu(__get_unaligned_t(__le64, p)); +} + +#pragma GCC diagnostic pop + #endif /* __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H */