Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp151579rdb; Mon, 18 Sep 2023 10:41:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+CLWmXNoYLqG5I1tZsOCc4sMSkM1bRoUV8hjjZB9by6TBkg1FRZhD0YlfCtQVlEVibIoD X-Received: by 2002:a17:90b:1e11:b0:274:638d:da9a with SMTP id pg17-20020a17090b1e1100b00274638dda9amr8627343pjb.34.1695058906419; Mon, 18 Sep 2023 10:41:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695058906; cv=none; d=google.com; s=arc-20160816; b=PCDhlgCLrh4N1f9VJ/rDbjCbSKKqsNlWFraVtIR9V8QVbmosj46wNv5XdTdGYZljW0 dH4YtynBNPY1MQEoel0R5ZJwujjJSYnRGS1m0+FdjIonWiqRRNbi7hgfOGMGS4c6bEi2 YyruCeUsxKEg6p71vM9xPKRvZqlGclUv4XQxid03YASosrBHHoHOsBRMsxbyKQURrF/j kMEt97OKYesozaQM67oCI5aP4fj++nRSNUO2CEFE2HeJCgGyq+Q+pqqROFvQSVHqjMta 8RE5wHwN8wggENzSewmkk3tVJEbLVO8PoWgfach5az0Hr90MmduhFa6rIkET22LVymLG QmNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=l+QC3uvRAP/qwqfmL2VbNl9H9w4JnwrITUvS9mJuYN4=; fh=ZUqSVuvO8ZYalw+VfDP8U0T2OmYYxfp+ySbaqvJY8+Q=; b=DkhrnEzEej2yyprNNBCbsB+YmzuEpZabkq0Ql6/vNpz9n62WgxKGbvX7GXQNDOLvrJ /e+0TBaeRtJeSZLESuzbq6AzaFlVK457OTYfi/hZFOG3jLBlTDfUpvzVff5TxJ4WQRVl BqVAAsHh1v61q7TEZmMvJjYFw3FN3yYO7RTe0Eg5CaVod4C8HvGznfoDWw6y7t4O3gh0 yGuuI+sEs6XMhAj8Usk5IQBRVQMHE2K9x2WDd65fFS07TQE4jSdwC4h28q/scfLDTT4t 0dYjlDcFHrJe+pUsuJNlrRhEFkZLSDt360+I/0zsbKpLwm8XpcQCwgPerPOM0ilo4UG+ aZVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=coQE0q1Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id d9-20020a17090ab30900b00263bfa6e205si10551900pjr.50.2023.09.18.10.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 10:41:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=coQE0q1Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1A4A8802A02C; Mon, 18 Sep 2023 01:38:45 -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 S238531AbjIRIiI (ORCPT + 99 others); Mon, 18 Sep 2023 04:38:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240837AbjIRIhr (ORCPT ); Mon, 18 Sep 2023 04:37:47 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12425EA for ; Mon, 18 Sep 2023 01:37:33 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-503178a0d7fso82564e87.1 for ; Mon, 18 Sep 2023 01:37:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1695026251; x=1695631051; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=l+QC3uvRAP/qwqfmL2VbNl9H9w4JnwrITUvS9mJuYN4=; b=coQE0q1QXizI6/zxln70piCSkLCmAJJE7+aXzVoZtmc43KOeEcMmz4fEFKBJOm0eA/ NHvwlVBZNf1YW67Kq0DotflHJLW7AYAWK19beTuDXN0+JFQmjVyRUXf5LGD8nUmZ2r6r rhGLsVXcAO8PV+86QEwlLjdXz42Umn5WIAtfSY/B/IElMQG8Qp+dX3yHZkoa57CnrksN qrOqkf1iQXSdJlBN8KO0MfRBgDqAEq0sYK1vc3zNy6ebyPmOrpyeWm5jYq9UMhhKmP6D gCgxFVmGcYA3uRlcFmwbS/h3orRN2Ezo1bo5njba/rrRucimQ3yG8UpoWv3VBizAd2FT lvbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695026251; x=1695631051; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=l+QC3uvRAP/qwqfmL2VbNl9H9w4JnwrITUvS9mJuYN4=; b=TJVSLPeDfWWGcp2aWIix94MRpCBKWWuAi270LPSWezqJbzCSg7a62Pujks482j6Sgq dsB2WoUaZxcNNwDrtLqim2utLtpJrSKC8xD7zLS9FKMjYJFmHkePFLbCr7hqQk0TFVrX vAFtDmcZ5SQOfQ9wgOf6hhLAJTrBVhhY3eOUfBgnpr6Rd15p1dOgoKMyFy4M65cjAtnL cei5dhrDN4pS1G6YRJcgZdYk6KPIBT5yE1TKz9YJxLJWzI4Jozi0YqXlXFQlRPo0iLkd qIoHqZtuUzuBnSZxjcAU+hsyqN6ISsvdzqS+X2iaYhvrcTbfcglEfJD1iIuAEyNbSRFl kf0g== X-Gm-Message-State: AOJu0Yzg/hJ9JtfWxtoQiRP0RudTxnz7Ja04y/qxmQrvQPdzXcF9EMYp CeNPux6bIt4RFnEy+PZPVX5HMQ== X-Received: by 2002:a19:ca04:0:b0:503:46c:5577 with SMTP id a4-20020a19ca04000000b00503046c5577mr3420792lfg.3.1695026251229; Mon, 18 Sep 2023 01:37:31 -0700 (PDT) Received: from ?IPV6:2a01:e0a:999:a3a0:3e7c:f127:3270:503e? ([2a01:e0a:999:a3a0:3e7c:f127:3270:503e]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031fb91f23e9sm11992220wrx.43.2023.09.18.01.37.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Sep 2023 01:37:30 -0700 (PDT) Message-ID: <086307ce-2d0d-4cf7-98c8-66a00ddec2aa@rivosinc.com> Date: Mon, 18 Sep 2023 10:37:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] tracing/user_events: align uaddr on unsigned long alignment Content-Language: en-US To: David Laight , Steven Rostedt , Masami Hiramatsu , "linux-kernel@vger.kernel.org" , "linux-trace-kernel@vger.kernel.org" Cc: Beau Belgrave References: <20230914131102.179100-1-cleger@rivosinc.com> <94183afa1fca44d18459da3d12a155d3@AcuMS.aculab.com> From: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= In-Reply-To: <94183afa1fca44d18459da3d12a155d3@AcuMS.aculab.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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: 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]); Mon, 18 Sep 2023 01:38:45 -0700 (PDT) On 17/09/2023 23:09, David Laight wrote: > From: Clément Léger >> Sent: 14 September 2023 14:11 >> >> enabler->uaddr can be aligned on 32 or 64 bits. If aligned on 32 bits, >> this will result in a misaligned access on 64 bits architectures since >> set_bit()/clear_bit() are expecting an unsigned long (aligned) pointer. >> On architecture that do not support misaligned access, this will crash >> the kernel. Align uaddr on unsigned long size to avoid such behavior. >> This bug was found while running kselftests on RISC-V. > > You don't want to do it on x86-64 either. > A locked accesses that crosses a cache line boundary is horrid. > So horrid that recent cpu's can be made to fault. Hi David, Thanks for the additional information. > > I'd also doubt that other cpu that can do misaligned transfers > can even do locked ones. > > For x86 (and LE) the long[] bitmap can be treated as char[] > avoiding all the problems. > > Perhaps there ought to be bit a bit-array based on char[] > (not long[]) that would be endianness independent and > use byte-sized atomics. That would work for a few architectures but I don't think all of them have byte "grain" atomics. So I guess Masami solution (long aligned set/clear_bit()) remains the best out there. Clément > (IIRC that is still an issue on sparc32...) > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales)