From patchwork Fri Mar 3 19:58:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13159455 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 679B9C7EE2F for ; Fri, 3 Mar 2023 20:00:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2517E6B0083; Fri, 3 Mar 2023 15:00:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 202576B0085; Fri, 3 Mar 2023 15:00:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A2136B0087; Fri, 3 Mar 2023 15:00:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E84B66B0083 for ; Fri, 3 Mar 2023 15:00:49 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9E443A11F4 for ; Fri, 3 Mar 2023 20:00:49 +0000 (UTC) X-FDA: 80528655018.13.0082024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 960004002B for ; Fri, 3 Mar 2023 20:00:47 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=f62vylpe; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677873647; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:references:dkim-signature; bh=iUvNynje4NLXuVViJqGVXz34mfwfY1r+EmC29iXiBlQ=; b=gWbzos1L0Izl2KERZrEp6VjO/nGSOKZAjHGWQqyH+eoPDXE+xd47TU7JzwpfE3E90zzQdj agvKom8TmwwnIHVzrOo06kmbasEYUwNrYcmiMdGO9JWcvJmUsqeqMN3wY4WwMpM7nTfh18 maL+7QJunnCueOJq9rdUhUdVAR1yMmc= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=f62vylpe; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677873647; a=rsa-sha256; cv=none; b=VtSqqcNCau1gAvFtlXK812ZIZgqpFMh+FnxxKf1sqZTnWHbRE6eivxJkT+igBVO8eR+hJj y+1DG/eBPh5rJ7fC+wVeqB0JixPYjxDPdN2ZIfTKL5Adq5SCVy7xhXEdvXHoqdNV2Ln+7t WVeP73ESgb0W055TMbjgbgfnt+m+Ksg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677873647; 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=f62vylpeWNxgtjpTfSbiwr/3W/trGHqneILbNo6ilEB6KxSj8Saq89rkz11c/YKTxXl8zf grK75wTUkiOYZeVHW38i72bs55rRSVjnCALJ7/TXyvqvLBoi5oaLBVKUNIGTTGljVuAC3t aisU3E8okPFAczIVm07mPThWayQXPIo= 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-516-PxqYS3KjPXirwMt8cwawRQ-1; Fri, 03 Mar 2023 15:00:30 -0500 X-MC-Unique: PxqYS3KjPXirwMt8cwawRQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 53E9A85C70B; Fri, 3 Mar 2023 20:00:30 +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 1E0FB40C6EC4; Fri, 3 Mar 2023 20:00:30 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 8C9F04291962B; Fri, 3 Mar 2023 17:00:12 -0300 (-03) Message-ID: <20230303195908.800742864@redhat.com> User-Agent: quilt/0.67 Date: Fri, 03 Mar 2023 16:58:43 -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, Marcelo Tosatti Subject: [PATCH v3 02/11] this_cpu_cmpxchg: ARM64: switch this_cpu_cmpxchg to locked, add _local function References: <20230303195841.310844446@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Queue-Id: 960004002B X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: gfq6m9ggunassz68u7irodstqd6umbb5 X-HE-Tag: 1677873647-316399 X-HE-Meta: U2FsdGVkX1+7eP6w8YFSuuaStbV0pCY/zQlATRwJ5rHInfhVuqKaVh3eVf5uqMJ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qtBdCAXT1R7Lq499jlciDd3Yplg2WMrBy3N+g5U0G8Dg+Ke51MiDTNpODLQamd84yZEakAh1xJl4NFsyyXRu1LOBqrkYDtVCXPVZceUU/hS1pMbA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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);