Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp220815rdb; Thu, 19 Oct 2023 02:24:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBkb+i1po3GPXbAwDANG2A7iofjgj/J5a2/PhpN3caiw4e/wN9kK0RXtKT8dtPmO30Me7d X-Received: by 2002:a05:6358:5d91:b0:135:4003:7851 with SMTP id s17-20020a0563585d9100b0013540037851mr1552905rwm.19.1697707449422; Thu, 19 Oct 2023 02:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697707449; cv=none; d=google.com; s=arc-20160816; b=RE30em8drC3N5JydHAUy8acBV74g/pvbFlzDlQfkXANBNf12LQ2Qbh/DQ790yg0ozB UlyDUJS/eJ9jsoEzhl89PNWx38Uz3AxKURQO4jIPqOQ/W3eyqtEXiuF+cPWUiRjvPA82 B4fcMBbW1B8ZjbxFT3HDTTSg/SRyp2sifdaWKKVigHQAa+d7Mu4HNOEStDUbjlCDRn4D 4FinlCOV2Fwv1qYAp/pu8ho9fD774OO06n33eGzutUxmarS8EP2lKzCCUh0lpiXDfnwk 5R1gB/T5DROwT/BK1o3gHIX+JBM5vU4lZtoKRpDynjM7k4ozkfXNPE7owhJVQZnG96sl XMYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=dYBmZb8L0tkdmg0cquRQf2b689ZCsR+eJJtSll1Zofc=; fh=LO5d+Cj4LHV40UgYu9cWKfMqQeSUe4QKwYh92NPWG1Y=; b=EIGCGG1oFssxWoORPwjHjplt9fbRV+x66dHLoLXjkqFsBKIHXbSrgs4xDyD9A3vMtO M6/ZSUBedva+OdLmbmTPt3FKyqqUz28xJ2aR4Www/4md6ML2yRGWVe8mbttRPPMNbk0A razvXlI2UcqYPaZpEdz/m9qZJYF0bY32gC6lUFzrdpnU8qDWIV8qu4UqC7ZyY1Od+3OX B0JDmUEu8b6vArmtgZJWQxBxn7bDC35BxBRb7bXoKeuR0GfrROqMrWAIipvkvIp04Zbe viOOIYJMwunkrlg7l2aqj0JXq3qjhmYkR/rD3H4Rry7/JCq15rk2p7Slvedwyeny3w+H O6tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=E5jkXEwb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a5-20020aa79705000000b006b4c1a2085fsi4841613pfg.168.2023.10.19.02.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 02:24:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=E5jkXEwb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E4DB28069F13; Thu, 19 Oct 2023 02:24:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344920AbjJSJYE (ORCPT + 99 others); Thu, 19 Oct 2023 05:24:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235260AbjJSJX6 (ORCPT ); Thu, 19 Oct 2023 05:23:58 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE9CC98 for ; Thu, 19 Oct 2023 02:23:56 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-53df747cfe5so13514241a12.2 for ; Thu, 19 Oct 2023 02:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697707435; x=1698312235; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dYBmZb8L0tkdmg0cquRQf2b689ZCsR+eJJtSll1Zofc=; b=E5jkXEwbYEfrQ+XtM1mDMnYNyRa2A938tavW3Ru91hvJ4b/aq8fdFjyqSpxec+d22+ FHqLJrRwlNAALR5wqGuvUcRbxgccBjQjUWEJACWES/ZpBXQb5jj02hH5zUki6BQFqf/t xyKMMC6hy7um43f2iX+6PBXFhzoObqrndSsmwiXr1eiAg/6k3kTQV46kC6+mmIRewwss Ibp24wA7d+uGHm1kzufOZyWARSGOL9GgnQJJDW0lKDKlx7JI81fNhg0T6FP3DhiJGvH2 BXeTwgPcN2aUhyf/Bnid7TJZtTKNxyzUf/26zC1S2kg4VGu8pfTpQxQotcxVka0FEfb2 EVyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697707435; x=1698312235; h=content-transfer-encoding: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=dYBmZb8L0tkdmg0cquRQf2b689ZCsR+eJJtSll1Zofc=; b=dB6+eya7KDb/8hXL5XuImV0taNhe7p2kSJs/Y6WKC9dcpOK/l33uVvlNbAWy6VqEvo k+tJaRK+dDf/zS6GdRoO7/ZQ9JjEe8D0AUU/oeF5lSuubpJMgeHVIu2Ap5WpGgA4XdYQ HDCmkux35yN1AzHaORDxLoyEYHLObv7vrbHSH40RjHv4WoxIXxx746LBQqCaP/2+6ew8 OKDZiH5sLpQW8SUkM9B6iXmvA4W12Trbp/XOEnXCCzgodl6QleNfUYpVMIf/UTyWn22R SCrUsvr3uV5N6v3GpVlwcCqD0YjK5tZg5Q8PVnJ2KZy2bjAT34OzTZcuXF4LSgQ5LN0T IAUQ== X-Gm-Message-State: AOJu0YzN/SwS2C9U+QoIkARzZYYvcIBHQOniCiRXpkTBXW3scNK99fT1 VMFwNVTYIc3Kd/Dzz0NAHD6E6/g3MB6ffe2gQSw= X-Received: by 2002:a05:6402:42d1:b0:53e:46b0:32be with SMTP id i17-20020a05640242d100b0053e46b032bemr1235054edc.34.1697707435100; Thu, 19 Oct 2023 02:23:55 -0700 (PDT) MIME-Version: 1.0 References: <20231019090733.GR33217@noisy.programming.kicks-ass.net> In-Reply-To: <20231019090733.GR33217@noisy.programming.kicks-ass.net> From: Uros Bizjak Date: Thu, 19 Oct 2023 11:23:43 +0200 Message-ID: Subject: Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr() To: Peter Zijlstra Cc: Linus Torvalds , Nadav Amit , "the arch/x86 maintainers" , Linux Kernel Mailing List , Andy Lutomirski , Brian Gerst , Denys Vlasenko , "H . Peter Anvin" , Thomas Gleixner , Josh Poimboeuf , Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 02:24:08 -0700 (PDT) On Thu, Oct 19, 2023 at 11:09=E2=80=AFAM Peter Zijlstra wrote: > > On Wed, Oct 18, 2023 at 03:40:05PM -0700, Linus Torvalds wrote: > > On Wed, 18 Oct 2023 at 14:40, Uros Bizjak wrote: > > > > > > The ones in "raw" form are not IRQ safe and these are implemented > > > without volatile qualifier. > > > > You are misreading it. > > > > Both *are* irq safe - on x86. > > Stronger, x86 arch code very much relies on them being NMI-safe. Which > makes the generic implementation insufficient. > > They *must* be single RmW instructions on x86. Maybe I should rephrase my quoted claim above: "raw" versions are not needed to be IRQ safe [*]. [*] Memory arguments need to be stable, so IRQ and NMI handlers can not change them outside of the critical section where the "raw" version operates. When memory arguments are stable, the compiler can omit reads (cache) the arguments, or re-reads them (rematerialize) from memory. The atomicity of the operation is irrelevant in the "raw" context, so the implementation of raw_percpu_xchg_op using raw_cpu_read/write is OK in this context. Uros.