From patchwork Mon Mar 13 16:25:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 68932 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1291847wrd; Mon, 13 Mar 2023 09:49:57 -0700 (PDT) X-Google-Smtp-Source: AK7set942IAoywv7kApmQ2P9ItICOe+AEveIPXD5qH6Diq+tmWIjE9HY5hc3tW1j3bHWvf1MWDad X-Received: by 2002:a17:902:6a83:b0:19e:866c:3547 with SMTP id n3-20020a1709026a8300b0019e866c3547mr30543583plk.65.1678726196944; Mon, 13 Mar 2023 09:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678726196; cv=none; d=google.com; s=arc-20160816; b=U2WRMEeQcO86gPr4IvE8Lxb1cM2LGmA/Riyztyrf9GV64HXsG6Ld+yxniTmouu6rXi WNq2v8is10lFMJoQDWtKAOYwDVMh+i7r/nvNBrFeTCbQxY65s4/zrx/Ip3UVDQZ7aJLV myJLL4BGxfXqOar6Mk7dIPJzAJqoQtMWJ+InaCVfR19i309pHAoFKic7GR1SA9v8QElo q2zVFjTIgDBP8bJ2HVeGrSoCwsHk4XxBVeasY6u+XU71IRw9ySKdmPxuqyB9QkTA9UjL P84StaSgGDv6HU3OIuoQBNRSvLT+v17XULgPx5dlMDVaxiu8qOizzZ8CFeImg6Utr+Yr 44FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=iUvNynje4NLXuVViJqGVXz34mfwfY1r+EmC29iXiBlQ=; b=va55qAuIa5y+M6AgkgfnOGBIMsQU+r+OqeCFn0u3m7A7mgpN98MFrTGr25riAT26I9 GISSKH/mBQu6yPRhq4eWI8hwCY0GDtuKcG3gwMg26+zvCugbL6dHK9PxQjzie2+9/wHd Sa86iBkPf3pJm6z4eNSCbHS6mRBa3jsuws/KWJRIltbDDIpXzyKQsfMNSoxe/kdNx3QU fyq3ZBKF8mvF6UqKQqYFl25B+zGvMrez7cm6GxZeNugH+wAJWomR6krVaL20Lqft+cNE 7Qo/BRxDf8p1oqVryQPlTDAU3HAhewpFmM+LIgvssyUdE+0LnoznPk/8f5lM1ShN3L9w iymA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R9glNPjQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ky4-20020a170902f98400b0019e6a5cf724si177520plb.203.2023.03.13.09.49.44; Mon, 13 Mar 2023 09:49:56 -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=@redhat.com header.s=mimecast20190719 header.b=R9glNPjQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231374AbjCMQaD (ORCPT + 99 others); Mon, 13 Mar 2023 12:30:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbjCMQ3H (ORCPT ); Mon, 13 Mar 2023 12:29:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11BC47A91E for ; Mon, 13 Mar 2023 09:27:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678724867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=iUvNynje4NLXuVViJqGVXz34mfwfY1r+EmC29iXiBlQ=; b=R9glNPjQ9JH41ZUUhZm78C36m6D7U/izmO00owo2Xjm/m6eHJapvMEmTvr7RTjHBlhfW8t anaNQC4wC79oXfRssqtONlYHzYmI93UG72fyYBcaoflIG61SKF7qsuD5RrPVUE8pkaawRt cY1gHCzGHxrYsg2LMxtiI46QmzaDhI0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-256-_i-nT0qoM-Wt4M1D21UMfQ-1; Mon, 13 Mar 2023 12:27:40 -0400 X-MC-Unique: _i-nT0qoM-Wt4M1D21UMfQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 32BC618E0044; Mon, 13 Mar 2023 16:27:40 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E93CA1121318; Mon, 13 Mar 2023 16:27:39 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 11E84401344A4; Mon, 13 Mar 2023 13:26:44 -0300 (-03) Message-ID: <20230313162634.283504192@redhat.com> User-Agent: quilt/0.67 Date: Mon, 13 Mar 2023 13:25:08 -0300 From: Marcelo Tosatti To: Christoph Lameter Cc: Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Russell King , Huacai Chen , Heiko Carstens , x86@kernel.org, Vlastimil Babka , Marcelo Tosatti Subject: [PATCH v5 01/12] this_cpu_cmpxchg: ARM64: switch this_cpu_cmpxchg to locked, add _local function References: <20230313162507.032200398@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760272000936380595?= X-GMAIL-MSGID: =?utf-8?q?1760272000936380595?= Goal is to have vmstat_shepherd to transfer from per-CPU counters to global counters remotely. For this, an atomic this_cpu_cmpxchg is necessary. Following the kernel convention for cmpxchg/cmpxchg_local, change ARM's this_cpu_cmpxchg_ helpers to be atomic, and add this_cpu_cmpxchg_local_ helpers which are not atomic. Signed-off-by: Marcelo Tosatti Index: linux-vmstat-remote/arch/arm64/include/asm/percpu.h =================================================================== --- linux-vmstat-remote.orig/arch/arm64/include/asm/percpu.h +++ linux-vmstat-remote/arch/arm64/include/asm/percpu.h @@ -232,13 +232,23 @@ PERCPU_RET_OP(add, add, ldadd) _pcp_protect_return(xchg_relaxed, pcp, val) #define this_cpu_cmpxchg_1(pcp, o, n) \ - _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) + _pcp_protect_return(cmpxchg, pcp, o, n) #define this_cpu_cmpxchg_2(pcp, o, n) \ - _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) + _pcp_protect_return(cmpxchg, pcp, o, n) #define this_cpu_cmpxchg_4(pcp, o, n) \ - _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) + _pcp_protect_return(cmpxchg, pcp, o, n) #define this_cpu_cmpxchg_8(pcp, o, n) \ + _pcp_protect_return(cmpxchg, pcp, o, n) + +#define this_cpu_cmpxchg_local_1(pcp, o, n) \ _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) +#define this_cpu_cmpxchg_local_2(pcp, o, n) \ + _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) +#define this_cpu_cmpxchg_local_4(pcp, o, n) \ + _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) +#define this_cpu_cmpxchg_local_8(pcp, o, n) \ + _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) + #ifdef __KVM_NVHE_HYPERVISOR__ extern unsigned long __hyp_per_cpu_offset(unsigned int cpu);