Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2185506pxb; Fri, 25 Mar 2022 12:36:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgDK5TbE+iGbbnAvD8vIB4HHFAruIE7PUUq9BaSgQ6UgCNs9/HJQ7WTuaumFcwEBDosrG6 X-Received: by 2002:a05:6a00:98e:b0:4fb:1162:b2a5 with SMTP id u14-20020a056a00098e00b004fb1162b2a5mr4645269pfg.12.1648237018448; Fri, 25 Mar 2022 12:36:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648237018; cv=none; d=google.com; s=arc-20160816; b=nxA3YRTcIXpwaUpGus+g5qWbP1HAByz49l1NeN0uMB5nWgX2+U5u5ZcbiwGUs/lVUn k7AT0Bi9EzDqwERCYSxFR0cc+/Ce6Th3xy29bMJiKQ57/GIRx3w3/VZeJmq4SWSIBUz4 DJR6UKgvFolxRS3V/LewNmtbWhL2RmqF7+HzBnH9EkmFIP48Hd2Rc8M5+bqyXCmCvf0X AzHhFzlEuLkW/WR21ixU9wGE49IBCxMTLJJ4O9g69TRLuBtBpXlTOG3wgdQn1CU+qoXt gXPBkMOX67tsRqWg2RyQpO9FyBWaIb+BoVODKFZ9sIE/euAwhu/swZer5KGFqEbuEoIc BVIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=Yt6RjQL7+8uCUwnFlP+GHK79ld0XaeD3LIiPog555q8=; b=w5CuRQIp+p7NXvxkPs8MsvJO7F9HoBnDNx/1knat9+4C3dhbYwtOQ5Cvo+o6/PiEDH Q0thcOVP1sdrHG3anAWBa6q2EQmvKsUqOmSUPAF0dI0h0NWwF1VDHxPp3dd5tZNDVXlk 8BAy45+m+FHjCGovrOwogDgphDl45IXXJBoSYQuxvjLJLprTDYbGJYo0aknXfBxibfm0 Pv3ba3iDTTa2dnf0e4N+yMNDWC59/PyuViUECCKH5d7+ihYyFikTZ7T61eyuG/TAhJ84 yNCcQmZm1uG2DQ8AOOhlOyFXqoQBlXp9PN/5p3Qup8ZkBb607K69Twq7qJQhDAfsOgX1 nXNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bxjpBRoq; dkim=neutral (no key) header.i=@linutronix.de; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id m9-20020a1709026bc900b00153b2d1660esi3019594plt.534.2022.03.25.12.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:36:58 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bxjpBRoq; dkim=neutral (no key) header.i=@linutronix.de; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D743E177D39; Fri, 25 Mar 2022 11:27:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352304AbiCXRlM (ORCPT + 99 others); Thu, 24 Mar 2022 13:41:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239345AbiCXRlL (ORCPT ); Thu, 24 Mar 2022 13:41:11 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDA4775E5B for ; Thu, 24 Mar 2022 10:39:39 -0700 (PDT) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1648143578; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yt6RjQL7+8uCUwnFlP+GHK79ld0XaeD3LIiPog555q8=; b=bxjpBRoqXsCOLpylQDPNICcchH+GaINGX7NUSPQT5DIFaVy/UxU18HEGj3qkU3kIgolv5N xaPYDJGB8VIDagNwtS81RDnRdFtS5XUM6tMlf/6r6EXlwfCfog+im2fkHja36IF3deWv3y 6yFXzAuJtU+MM/nNhNIQyxFisAPE2764zrzQlDwl1xLK1sip9qoTsfCEvr63rRto656oNH ZIuqE7aAYxjfe0nBp+cCDDGQSLYtRk4ghwluQxkLT4Vp50MkzbELYuNnqpfAVw/ZEHHm6X wmjUINZKAykK2al7LwnLxmCMdn45s6yQwLTGQhBM621XtL5skN4hRL/KjuaMnA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1648143578; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yt6RjQL7+8uCUwnFlP+GHK79ld0XaeD3LIiPog555q8=; b=GuCaIz4L+sC5pGzb7fZ/lADakGrKq7QSy1LQiRw6TlKYUBIgYiRHk3teyzF7xH96PAKod0 OqlamYvXmO823dDg== To: torvalds@linux-foundation.org Cc: akpm@linux-foundation.org, bigeasy@linutronix.de, boqun.feng@gmail.com, bp@alien8.de, linux-kernel@vger.kernel.org, longman@redhat.com, mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de, will@kernel.org, Dennis Zhou , Tejun Heo , Christoph Lameter Subject: [PATCH 0/3] Remove volatile from arch_raw_cpu_ptr() and revert the hacks. Date: Thu, 24 Mar 2022 18:39:24 +0100 Message-Id: <20220324173927.2230447-1-bigeasy@linutronix.de> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 2022-03-23 10:17:08 [-0700], Linus Torvalds wrote: > I get the feeling that the real problem is that on x86, we have this: >=20 > #define arch_raw_cpu_ptr(ptr) \ > ({ \ > unsigned long tcp_ptr__; \ > asm volatile("add " __percpu_arg(1) ", %0" \ > : "=3Dr" (tcp_ptr__) \ > : "m" (this_cpu_off), "0" (ptr)); \ > (typeof(*(ptr)) __kernel __force *)tcp_ptr__; \ > }) >=20 > and that "volatile" is just *WRONG*. >=20 > That volatile is what literally tells the compiler "you can't remove > this if it isn't used". It is indeed just x86. After double checking arm/mips removes that code properly. > But there's no point to that. >=20 > So how about we >=20 > (a) just revert commit 9983a9d577db4 >=20 > (b) remove that bogus 'volatile' >=20 > Doesn't that fix the problem? The following series does that. The assembly code looks okay. In a few simple test cases the this_cpu_ptr() usage is always created and is not moved passed preempt_enable() statement. The resulting vmlinux shrunk a bit. The test config lost ~2KiB: text data bss dec hex filename 22533901 10722831 13963496 47220228 2d08604 vmlinux.volatile 22531589 10722831 13971688 47226108 2d09cfc vmlinux.patched after looking at it it was sometimes due avoiding this_cpu_ptr(), sometimes it looked that the compiler made other decisions at the earlier resulting to be more beneficial later on. Sebastian