Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2687473pxu; Mon, 14 Dec 2020 08:32:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzs88P3F9mKUl2NSSA6BPJI9RZRLwDl1StpoW98IOYxQGwtiFQixk7BEb5Zxz+Z8d16KXzo X-Received: by 2002:a50:e791:: with SMTP id b17mr25338564edn.388.1607963557342; Mon, 14 Dec 2020 08:32:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607963557; cv=none; d=google.com; s=arc-20160816; b=eq3wu5aJ3S2848Z+G3IIoRvsYDlFh6G/OTwgiCTunM1GWPCzekx0CIud2tX3McpbR8 asBUAr0LJweOnOAS/3JUmyLhvl2Gnw9z4+tr6I9e/ae0D3ESQh89FUvEK6Wyb4j05Kw3 NxdNdMPcV5SKd0j9YgRrH06rXF+Ztuwhlh3k1K+PPlrWA1dYAJ+De139UGFYIZqxC/xa d36KUOInEJdV4CpfzNy8outolp+kI++pKYt0+2t/pICDQ482uB2STpjeosG2Pl8SvlnY 0cbi1Mg+LqquPY5HdVJGzAAIHJ0iaUWFXGQgsO6Q1kGC4tlDpIF1nf+a4aihIUXSLojc MyNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=UZAsiTg8tdKZPKYTd1UHs7/008Sibvq5mWqIFP/SVRo=; b=UdCvI8UeoJXrFByJJJmkfu5l2cc8P5LOCwtz+rtmdgL3S05CHG3ifWCX8MeaJ8pmIc NApnZWY9KHmMIqfgxIzRI0Pb1sBjCi7Tt+Fc49/kixclTNh16mNjisr+/YCSi9TSbMW2 V05OZemwgi/vSr+FZkq88vkkHNYXsRYpl2TSjVqFK/+FEHHgC684UeO/qflPkARtkSGI bLLn4NKDHZ+RVvns8CFQF9lSJBO9iv4Q4Y3FgeVXxLb/tew0nV3nGZGMW2U6pehMQuW9 +S4SYSk65BwzBkDceL67TaNYkYmpPj2BzRlEEfOxfWBkIQuY/fibkrq6UlJhZldMOc3K ph9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ck16si1649668edb.36.2020.12.14.08.32.13; Mon, 14 Dec 2020 08:32:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440247AbgLNQ1U (ORCPT + 99 others); Mon, 14 Dec 2020 11:27:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:34346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440242AbgLNQ1M (ORCPT ); Mon, 14 Dec 2020 11:27:12 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 95526227C3; Mon, 14 Dec 2020 16:26:31 +0000 (UTC) Date: Mon, 14 Dec 2020 11:26:29 -0500 From: Steven Rostedt To: Anatoly Pugachev Cc: Linux Kernel list , Sparc kernel list , Ingo Molnar Subject: Re: [sparc64] ftrace: kernel startup-tests unaligned access Message-ID: <20201214112629.3cf6f240@gandalf.local.home> In-Reply-To: <20201214111512.415717ac@gandalf.local.home> References: <20201214111512.415717ac@gandalf.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 14 Dec 2020 11:15:12 -0500 Steven Rostedt wrote: > Does sparc64 require 8 byte alignment for 8 byte words? > In other words, does this patch fix anything? -- Steve diff --git a/arch/Kconfig b/arch/Kconfig index 56b6ccc0e32d..fa716994f77e 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -143,6 +143,22 @@ config UPROBES managed by the kernel and kept transparent to the probed application. ) +config HAVE_64BIT_ALIGNED_ACCESS + def_bool 64BIT && !HAVE_EFFICIENT_UNALIGNED_ACCESS + help + Some architectures require 64 bit accesses to be 64 bit + aligned, which also requires structs containing 64 bit values + to be 64 bit aligned too. This includes some 32 bit + architectures which can do 64 bit accesses, as well as 64 bit + architectures without unaligned access. + + This symbol should be selected by an architecture if 64 bit + accesses are required to be 64 bit aligned in this way even + though it is not a 64 bit architecture. + + See Documentation/unaligned-memory-access.txt for more + information on the topic of unaligned memory accesses. + config HAVE_EFFICIENT_UNALIGNED_ACCESS bool help diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index f09d3f5911cb..623657f84b72 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -130,7 +130,16 @@ int ring_buffer_print_entry_header(struct trace_seq *s) #define RB_ALIGNMENT 4U #define RB_MAX_SMALL_DATA (RB_ALIGNMENT * RINGBUF_TYPE_DATA_TYPE_LEN_MAX) #define RB_EVNT_MIN_SIZE 8U /* two 32bit words */ -#define RB_ALIGN_DATA __aligned(RB_ALIGNMENT) + +#ifndef CONFIG_HAVE_64BIT_ALIGNED_ACCESS +# define RB_FORCE_8BYTE_ALIGNMENT 0 +# define RB_ARCH_ALIGNMENT RB_ALIGNMENT +#else +# define RB_FORCE_8BYTE_ALIGNMENT 1 +# define RB_ARCH_ALIGNMENT 8U +#endif + +#define RB_ALIGN_DATA __aligned(RB_ARCH_ALIGNMENT) /* define RINGBUF_TYPE_DATA for 'case RINGBUF_TYPE_DATA:' */ #define RINGBUF_TYPE_DATA 0 ... RINGBUF_TYPE_DATA_TYPE_LEN_MAX @@ -2717,7 +2726,7 @@ rb_update_event(struct ring_buffer_per_cpu *cpu_buffer, event->time_delta = delta; length -= RB_EVNT_HDR_SIZE; - if (length > RB_MAX_SMALL_DATA) { + if (length > RB_MAX_SMALL_DATA || RB_FORCE_8BYTE_ALIGNMENT) { event->type_len = 0; event->array[0] = length; } else @@ -2732,11 +2741,11 @@ static unsigned rb_calculate_event_length(unsigned length) if (!length) length++; - if (length > RB_MAX_SMALL_DATA) + if (length > RB_MAX_SMALL_DATA || RB_FORCE_8BYTE_ALIGNMENT) length += sizeof(event.array[0]); length += RB_EVNT_HDR_SIZE; - length = ALIGN(length, RB_ALIGNMENT); + length = ALIGN(length, RB_ARCH_ALIGNMENT); /* * In case the time delta is larger than the 27 bits for it