From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 4597F332EBD for ; Thu, 21 May 2026 22:13:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779401620; cv=none; b=Zt5ROr4rhnHxvPdlqnqxLhwkfKRplfmKmfcxYCE7B/XbZ4ZcIO4Yd6Bb4/FHRBLS7L9QPXlHkHjbUerz/qRnwcxRXIL2RAp7eSRMTfpXzUElI3TyiIPbu0emuoOmozR+kc33UMkjNKHbjsCcSuSZrWlLN3qYqVGcyjiiB4GDHNs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779401620; c=relaxed/simple; bh=R7WsN4z6EjgmoX/FEiW2LPeLsl6WX2AHzNxJSevq+bQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JD200ZdXeejvbypToT/dZfdqFTZYEDMatr5ZXtqFGysm0yPGY+L4vAFSdVBz41P6QcHWE+oCFg/u+MWOicA76WhlQsm3M6yAljAGNIL9wRn6eJD7dyvvNeUN1b1T9Cg35dtCbnZIefP4dllx/o+KeTEfNgK9ZmyfjorcW3Jk1sA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dPR3/yjM; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dPR3/yjM" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-48a3e9862f0so37782865e9.1 for ; Thu, 21 May 2026 15:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779401618; x=1780006418; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=Apv4BVfh2CBdAgPohTzEnCX66gLKozYK0MvWW1yk0T0=; b=dPR3/yjMjxTSpVslM5s/SdZd1V/ldLwtSN1EXoSfZOxInGn13Rk1btcu4gcmX/GDMg N3eQ2UfwFbHBI3zMqU5KIImtc0B2Z43mSwXUNGGWnwVUY/iYR6ScQz64kkxDPsKgF7X3 pMWOuKG2UNPUKDpaxGaZ3MzSaEp9NfNm6gPDYgzIOVa+z1coWmaxlNLUvveonKiTrVvq 8PeTPxyjgUEYudNbsAulrtCq1U78RMG6XNdMDRbZxcI8ThkzelRVX0n207E3O5S04hZv NK1fCtbKt2k2byHjBUYb1v00ciLMaOCCqn/5rutn1TrO8Q7eirztZnNCmV8CsF2fIqtt Xzcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779401618; x=1780006418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Apv4BVfh2CBdAgPohTzEnCX66gLKozYK0MvWW1yk0T0=; b=R2xkUDgHdb5lwIRAwiUsDTfkOw/AULwYk14ubVyKq4ZZx4FtUToBRAWFDeb9hy4Gbt 0mI+hkChdLOrCMxm6vhMXP5cCg1TQdn+PoUiMNvhGzZmnPA/IADngXpw5fdJSZBg1rjF 2tRi8V3550bzDmIBlH5n0TpLcOQ2TgDJU/WsvWhxYW6LPpNt4mNjkTUkVDBbFXh5Kk2y iax4yEDBDZB/ry+Z2Pc8L1EX26UITH7OvCXAWWg4sVB3qfjsqecqb391tvLGkrfkvZy6 OxlzyhmtUjQaFOcNF1Iu9KkNzHhTGQPnZemv2ix2hOUhkGleQ+xpzrMgX4zAlJbZVPIK /mag== X-Forwarded-Encrypted: i=1; AFNElJ9D/4SrUQ/YCoGCXh8Tn1CJ3AdtM4kGVLY4TgA5hOIj6ttorcFrShf4bVkpeFmQsSC2KoLWCrDrFG2Q3lI=@vger.kernel.org X-Gm-Message-State: AOJu0YxgOQ02HAcAQ7FocUvN8U+J/gTLes7WIWop6xiAuR9TSV/SlWnb gVt2WXeOEe4aPGZuEhnGKKuDsFoPOCQQ7KPDKhC4OOofwZ1i1Ej4MvWA6ZVnPX8sYGg= X-Gm-Gg: Acq92OF0/AXy3ShilPPkjV+oH3Qbhb3XyYkTQPToFDkGJnACr9caOb305UXiURQXOaY HfKmCpNHVB1gQGHWyKwD/D72I5dl9LdALfgzD3Mpt002dJZvPq2VfSKBBWzjdY6zBnk3zDr6j3n +uAGneq7oJ1gNGhoTtv+XJ+GGcoDvAkHWwhkZkZDk6S81M2OQo1RCZfAZfYL0vuHdRi/QNtOyvK B5JIAfm/AalHvWvszQTlGs+abaFhSImnTtR18CV5FWw9NTqSdWJhDhh/6zY7by5w3lA8ygJdXOb mr8RGrjt/EMJZyZGmIYASS2gc6iqRntMIaU8xsB25mUNHQnyxMM3xaLgWtpiIz7U2R0BoA61vbp erzdijXMFhcnr6Yr53AyTepGKONYs762LeNvzeXn1QK9Ljlgo5+ANxinab6XLd/l8OZWzVlr86h iwXuhVgIYjUy4/3bUH3sbw8fTTd+fK+UfRsF5ydJrex3yVlq7GVK1nUG4MQoCoYaHE X-Received: by 2002:a05:600c:1c0b:b0:48a:53cb:8604 with SMTP id 5b1f17b1804b1-490426a495amr7073795e9.14.1779401617652; Thu, 21 May 2026 15:13:37 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490452545a4sm427045e9.4.2026.05.21.15.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 15:13:37 -0700 (PDT) Date: Thu, 21 May 2026 23:13:35 +0100 From: David Laight To: Yang Shi Cc: Heiko Carstens , Alexander Gordeev , Sven Schnelle , Vasily Gorbik , Christian Borntraeger , Juergen Christ , "Christoph Lameter (Ampere)" , Peter Zijlstra , Shrikanth Hegde , linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: Re: [PATCH v3 0/9] s390: Improve this_cpu operations Message-ID: <20260521231335.2fd3f7e3@pumpkin> In-Reply-To: References: <20260520092243.264847-1-hca@linux.ibm.com> <9d503c6f-5641-4b28-998e-01e38b3622a9@os.amperecomputing.com> <20260520233409.0683f595@pumpkin> <20260521111744.6e58bfd6@pumpkin> <592ea7fb-b836-4c47-a0cb-248a185cbaa8@os.amperecomputing.com> <20260521185532.002541c6@pumpkin> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 21 May 2026 13:46:25 -0700 Yang Shi wrote: > On 5/21/26 10:55 AM, David Laight wrote: ... > > The 'trick' here will work for reading/writing values if you don't > > care that the value read is stale (or might have been written to > > the memory for a different cpu). > > If you don't care the stale value, you can just call __this_cpu_read(). You can get an impossible value. The generated code might be like this: this_cpu_data = xxx; preempt_disable_count = this_cpu_data->preempt_disable_count; If the count was non-zero at the start you'll read the value from the current cpu and all is fine. But if the count is zero you can get preempted between the instructions, the process now running on your 'old' cpu can increment the value and you then read the new non-zero value. That won't be good at all. You can only use __this_cpu_read() for things that don't change. The big problem with using per-cpu page tables is there will be absolutely nothing stopping code taking the wrong address of a per-cpu variable and saving it somewhere. At the moment you have to use the helper so always get the global address. -- David > > Thanks, > Yang