Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp1157756rwl; Fri, 4 Nov 2022 10:23:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7goDxYUr2jPb8IT1VgkOnk9+hXl/K6AeokFiPvsXaMm8/3ppax9eWQOM7vuiscDLCgPgMG X-Received: by 2002:a05:6a00:c8d:b0:56d:e6d:c427 with SMTP id a13-20020a056a000c8d00b0056d0e6dc427mr35938741pfv.74.1667582613431; Fri, 04 Nov 2022 10:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667582613; cv=none; d=google.com; s=arc-20160816; b=TydVXs7vvBBcImqHTnseS6x0Mzdjy76jk8pP4JT1+6LExLnn5XUcZ68L6tygJXPVHY dZlPH9B8AaFtkm8NPyqVDzfnxFX42b+g83d6ggGcvLxLyTtikjAg6Mvn4kRK1oIn8OLu BwtSEDO54oT1gIUBoG+8QH38XMRtEXnV6828sAyKykVm9zKsVrykQ6YGiMcrBPnkEV3w khUtSYqtTm5KNHL7EBQiLPcdYfpcq+adkwRGKXLZy0KOrmrYRqlNPbaddZyCdJsUQnJq hk4CsEQInNeEKWJ4uozfyZZllGNGyMKgUhTuZyf4M6liR3mR3aQ5INaV0W3f4SZNzBFQ jRrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=3HUn0bx/DAdGh10erDX6/ij0JMTkQvrZRJ0YE9oyOkg=; b=gX3zzrR5pdQsC7mgH1DwaDVE/rrXFnaJvdHl9LI5v5/5FpU35xvxq8zDAbvpuNfBlN i7bv49/Hdq4abHjmXj2nRD2CZmQUN1Gewp/7HZfz+/dHQdW4cTUcPFxfEjn9wdYPbw3/ ql98xwnYRxFdT0xR8/4pesatxvNYHpEKoOA2d/H7PH4RUqnlu6WkGS7j9XHLw6mtvc4b +7NrD/Jp6+dqZaAar5d4Bg0Qogv5HHRIJpS6ZkfgmnupUIOmtjFk3Y31kFDLWqKs2L7r 9E5CDi9T2HHJOQTHSyQETDzq7iwhHpS1FLoHJpUNxSUfl+DAXLTi0hKMUbt0xCzHDHRo DFqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=NRUvfFrD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cj25-20020a056a00299900b005635bfe397bsi5048800pfb.218.2022.11.04.10.23.21; Fri, 04 Nov 2022 10:23:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=NRUvfFrD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231201AbiKDRPd (ORCPT + 96 others); Fri, 4 Nov 2022 13:15:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229964AbiKDRPb (ORCPT ); Fri, 4 Nov 2022 13:15:31 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D082731ED0 for ; Fri, 4 Nov 2022 10:15:27 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id 8so3475800qka.1 for ; Fri, 04 Nov 2022 10:15:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=3HUn0bx/DAdGh10erDX6/ij0JMTkQvrZRJ0YE9oyOkg=; b=NRUvfFrDFHOS0DexelZeJzCweg+FOTiOHPh4mO/e5pN+PvA2OQBrv+Abt7svyOW3sY f2GMbHGcprDFQDdi6ml/VW3skdY1t8KuguOR6TfcMgi4Unm+Sw46QMJL/NVwXnPEYDS5 5sHLJKU0WuCEL0dz78hapCmxnIaZgfpGnVlv4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=3HUn0bx/DAdGh10erDX6/ij0JMTkQvrZRJ0YE9oyOkg=; b=lTVI4AqA5zKFHV03cJcjV28933DIkRE15ld7Jo3gfGbSMqnPLK9S5n4Tg14295QL12 jbv3QQ1F3EcymGZ0d9ihvPr0jlhuOedSXuplw5HTu+mM5IQsOxKCV9O01EyKZ4jtb1eN jbiur/jkpg6va+rMEpOoBmBSMza2YHA+KmUmiWhEYR/nViWcEf54zZfGO/7icKrFaejT JDF+wiCQf7fX7FG9sxcRWpbKMIIsh3TP4LnQIjAqwYC81fGVmQT6nYzEvoKzJJWB0zwm 3ig0c48vEM8ruzhTOct0L6wG318mNqLuHXgKcWhZZvCy/GYOebj2VWTdhagp+hUzyK7p GU1A== X-Gm-Message-State: ACrzQf3pctqkzDeUISLPTtHsC5oi+rI1AsrBvKFNi1BqM7+3Zqf1K1PU Lh8pX3nyaU491SJOH9ckZ4NiD0k49PViOA== X-Received: by 2002:a37:b1c4:0:b0:6fa:996f:2279 with SMTP id a187-20020a37b1c4000000b006fa996f2279mr2013902qkf.607.1667582126499; Fri, 04 Nov 2022 10:15:26 -0700 (PDT) Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com. [209.85.128.170]) by smtp.gmail.com with ESMTPSA id i18-20020a05620a405200b006fa8299b4d5sm2878487qko.100.2022.11.04.10.15.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Nov 2022 10:15:25 -0700 (PDT) Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-3701a0681daso49576087b3.4 for ; Fri, 04 Nov 2022 10:15:25 -0700 (PDT) X-Received: by 2002:a81:114e:0:b0:36a:fc80:fa62 with SMTP id 75-20020a81114e000000b0036afc80fa62mr36113103ywr.58.1667582124813; Fri, 04 Nov 2022 10:15:24 -0700 (PDT) MIME-Version: 1.0 References: <20221022111403.531902164@infradead.org> <20221022114425.168036718@infradead.org> In-Reply-To: From: Linus Torvalds Date: Fri, 4 Nov 2022 10:15:08 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 11/13] x86_64: Remove pointless set_64bit() usage To: Peter Zijlstra Cc: Nathan Chancellor , Uros Bizjak , x86@kernel.org, willy@infradead.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, aarcange@redhat.com, kirill.shutemov@linux.intel.com, jroedel@suse.de Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On Fri, Nov 4, 2022 at 9:01 AM Peter Zijlstra wrote: > > So cmpxchg_double() does a cmpxchg on a double long value and is > currently supported by: i386, x86_64, arm64 and s390. > > On all those, except i386, two longs are u128. > > So how about we introduce u128 and cmpxchg128 -- then it directly > mirrors the u64 and cmpxchg64 usage we already have. It then also > naturally imposses the alignment thing. Ack, except that we might have some "u128" users that do *not* necessarily want any alignment thing. But maybe we could at least start with an u128 type that is marked as being fully aligned, and if some other user comes in down the line that wants relaxed alignment we can call it "u128_unaligned" or something. That would have avoided the pain we have on x86-32 where "u64" in a UAPI structure is differently aligned than it is on actual 64-bit architectures. > Of those slub.c is the only one that cares about 32bit and would need > some 'compat' code to pick between cmpxchg64 / cmpxchg128, but it > already has everything wrapped in helpers so that shouldn't be too big > of a worry. Ack. Special case, and we can call it something very clear, and in fact it would clean up the slab code too if we actually used some explicit type for this. Right now, slab does /* Double-word boundary */ void *freelist; /* first free object */ union { unsigned long counters; struct { where the alignment constraints are just a comment, and then it passes pointers to the two words around manually. But it should be fairly straightforward to make it use an actual properly typed thing, and using an unnamed union member, do something that takes an explicitly aligned "two word" thing instead. IOW, make the 'compat' case *not* use those stupid two separate pointers (that have to be consecutive and aligned), but actually do something like struct cmpxchg_double_long { unsigned long a,b; } __aligned(2*sizeof(long)); and then the slab case can use that union of that and the existing "freelist+word-union" to make this all not just a comment to people, but something the compiler sees too. Linus