Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6227889rdb; Thu, 14 Dec 2023 11:45:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IEO3V6+frY4SNUqA+kHOELsNSWDSAcb4JsdW7U2bmKRzTfrsMJbdOow2xdncMf13vi3aWAZ X-Received: by 2002:a50:cc49:0:b0:54b:f643:e45b with SMTP id n9-20020a50cc49000000b0054bf643e45bmr2797877edi.37.1702583128998; Thu, 14 Dec 2023 11:45:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702583128; cv=none; d=google.com; s=arc-20160816; b=TvGD/UwUKlhfUWT/UHt/2PH6e6VTp1SqPKeNO2R9x3OpH5YmHyojI2SVvhX7wDPXH3 Ze13YwCg2kGcM19dTvITMFXQYBRqER4t2a7JW+thuvviopcvcHzNndrtq7n9OuVdoUHL sLMH7CApr14qdD0I3f+oCnN7A/m2lDwX2Sn5E7CLybUMFVq19fHsrtjZzlJmaf6NnIFY J3EC+HPAFeko1Es+cplgSGYvOXf1FZxHf7RDayx9a0JlMzmQPFPNL5HsPT3kNMnlvO6a 0rnW19Yv6Cyb/ZPQLw5sfUrOicUOoENuw3/17uM1Xue4xHOYr5GR8hZJZkOeGxv8YVlV GSLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=MpUjOoTdCqNzayaiwbixMLyZUnTZjhFDCaA6n5v3lDM=; fh=yskiR2dCENpbidFU6Qh27J0j4u+idnmkHk1Pb3+Ulyg=; b=Wp+ES2Td+Y1MJACfDBTLgnluqYcvmjEBO3zOIIN22sL3fSKWIGgBNG1wEV24qc5jDW g67EB5Ob/UaUfLFzD8R2bGkmBzNpSnve+jvYvvC2OGJGDXYlniAD/2Z5NBOgKkNAjZRA odf6r4sbdP2vVeqwUCpXSQSnB3MZQBt0FrUndCpTRLSuCyYOXzCfu9KBFvsOnuqqfoWL gG63gt/VGGzv5MQglYU9OzJ0tk5DbnVKyek//qz70UcwQrMEtGP9Oaxa4vBdCVjga+gw WOEN++ZbwbycLWc2GiJMB2bDQpFC4IAlGcWUkAURY1F4g5pj0otDJQC2aTIMqy5EvYmL +A+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=T5cRHmky; spf=pass (google.com: domain of linux-kernel+bounces-24-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h6-20020a056402094600b005527c55ee88si661336edz.375.2023.12.14.11.45.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 11:45:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=T5cRHmky; spf=pass (google.com: domain of linux-kernel+bounces-24-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6FEC51F22080 for ; Thu, 14 Dec 2023 19:45:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94A5E697B4; Thu, 14 Dec 2023 19:45:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="T5cRHmky" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E23568E83 for ; Thu, 14 Dec 2023 19:45:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-551e6b99490so3206249a12.0 for ; Thu, 14 Dec 2023 11:45:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1702583114; x=1703187914; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=MpUjOoTdCqNzayaiwbixMLyZUnTZjhFDCaA6n5v3lDM=; b=T5cRHmkyC1XeP1ByTEbxUxOR7s6Iy7cYdIniNLwsjt7ikJ3h5wWxdHeXZTFssUASur FWgTX9GPLeeaLHOpsnNjVBqqOQsZLLAqAyOHn3RjBFr/+mMTC+Wl7ltvmIE0swwofVRe 0gdUzC7arOg7g/Z8a2y3OuKMlk0wNmlIYCX9E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702583114; x=1703187914; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MpUjOoTdCqNzayaiwbixMLyZUnTZjhFDCaA6n5v3lDM=; b=E/kiVd1waxCjt2ZIzbi/b3+eSqhYmCauM1rDuxLzEKpy3AMttA/zrTCIZAGwFRTHMG Sp2K8y0aqbk6PmhEisO7if8A32QoiP4m4o/Cm05ImJRtHq2XNrLy73IWLTwM+LPUmUPy pZQ3/h7jQ6lwYAeJ76xcA8l31j+7uLGjfZH0UP9yMdnUFAmfW4B6muDXSVcRhBMHXFwf J/rY1dwUF1pb3hloNCv0QJpwspvYxOfLPHxjtYl0a5tJ4PWmCjBgdXCnudSWRlPCaS4r YOrvi05e/hZzI3dh7VxZzDInEuaEJbkd3ZezCQ4vDCnxnljzjPbpFz6EG3y4FqHVRFLn kW6w== X-Gm-Message-State: AOJu0YxziTlTL0OIZx/DhfIZhRQhEHedLb8d0zgtyIMOfW856o0Gy2jP UOQynQ8BKC6DXC8oGJH3pzOzsT/0N0DKp178ola3lw== X-Received: by 2002:a50:ccdb:0:b0:551:d8ea:e67d with SMTP id b27-20020a50ccdb000000b00551d8eae67dmr964179edj.133.1702583114146; Thu, 14 Dec 2023 11:45:14 -0800 (PST) Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com. [209.85.218.46]) by smtp.gmail.com with ESMTPSA id fe1-20020a056402390100b005527c02c1d6sm776402edb.50.2023.12.14.11.45.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Dec 2023 11:45:13 -0800 (PST) Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a1ef2f5ed01so1077026366b.0 for ; Thu, 14 Dec 2023 11:45:12 -0800 (PST) X-Received: by 2002:a17:907:3ac2:b0:a19:d40a:d21f with SMTP id fi2-20020a1709073ac200b00a19d40ad21fmr2222801ejc.235.1702583112429; Thu, 14 Dec 2023 11:45:12 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231213211126.24f8c1dd@gandalf.local.home> <20231213214632.15047c40@gandalf.local.home> <20231214115614.2cf5a40e@gandalf.local.home> In-Reply-To: <20231214115614.2cf5a40e@gandalf.local.home> From: Linus Torvalds Date: Thu, 14 Dec 2023 11:44:55 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] ring-buffer: Remove 32bit timestamp logic To: Steven Rostedt Cc: "linux-arch@vger.kernel.org" , LKML , Linux Trace Kernel , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers Content-Type: text/plain; charset="UTF-8" On Thu, 14 Dec 2023 at 08:55, Steven Rostedt wrote: > > And yes, this does get called in NMI context. Not on an i486-class machine they won't. You don't have a local apic on those, and they won't have any NMI sources under our control (ie NMI does exist, but we're talking purely legacy NMI for "motherboard problems" like RAM parity errors etc) > I had a patch that added: > > + /* ring buffer does cmpxchg, make sure it is safe in NMI context */ > + if (!IS_ENABLED(CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG) && > + (unlikely(in_nmi()))) { > + return NULL; > + } CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG doesn't work on x86 in this context, because the issue is that yes, there's a safe 'cmpxchg', but that's not what you want. You want the save cmpxchg64, which is an entirely different beast. And honestly, I don't think that NMI_SAFE_CMPXCHG covers the double-word case anywhere else either, except purely by luck. In mm/slab.c, we also use a double-wide cmpxchg, and there the rule has literally been that it's conditional on (a) system_has_cmpxchg64() existing as a macro (b) using that macro to then gate - at runtime - whether it actually works or not I think - but didn't check - that we essentially only enable the two-word case on x86 as a result, and fall back to the slow case on all other architectures - and on the i486 case. That said, other architectures *do* have a working double-word cmpxchg, but I wouldn't guarantee it. For example, 32-bit arm does have one using ldrexd/strexd, but that only exists on arm v6+. And guess what? You'll silently get a "disable interrupts, do it as a non-atomic load-store" on arm too for that case. And again, pre-v6 arm is about as relevant as i486 is, but my point is, that double-word cmpxchg you rely on simply DOES NOT EXIST on 32-bit platforms except under special circumstances. So this isn't a "x86 is the odd man out". This is literally generic. > Now back to my original question. Are you OK with me sending this to you > now, or should I send you just the subtle fixes to the 32-bit rb_time_* > code and keep this patch for the merge window? I'm absolutely not taking some untested random "let's do 64-bit cmpxchg that we know is broken on 32-bit using broken conditionals" shit. What *would* work is that slab approach, which is essentially #ifndef system_has_cmpxchg64 #define system_has_cmpxchg64() false #endif ... if (!system_has_cmpxchg64()) return error or slow case do_64bit_cmpxchg_case(); (although the slub case is much more indirect, and uses a __CMPXCHG_DOUBLE flag that only gets set when that define exists etc). But that would literally cut off support for all non-x86 32-bit architectures. So no. You need to forget about the whole "do a 64-bit cmpxchg on 32-bit architectures" as being some kind of solution in the short term. Linus